On Tue, Feb 07, 2012 at 05:56:52AM -0800, David Fetter wrote:
> On Mon, Feb 06, 2012 at 06:25:33PM -0500, Jay Levitt wrote:
> > I have a rough proof-of-concept for getting nearest-neighbor
> > searches working with cubes.
>
> Please attach such patches to the email when posting them :)
And here's a cleaned-up version of the patch that at least passes
"make check."
Cheers,
David.
--
David Fetter <[email protected]> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: [email protected]
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics
Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate
*** a/contrib/cube/cube.c
--- b/contrib/cube/cube.c
***************
*** 73,78 **** PG_FUNCTION_INFO_V1(g_cube_penalty);
--- 73,79 ----
PG_FUNCTION_INFO_V1(g_cube_picksplit);
PG_FUNCTION_INFO_V1(g_cube_union);
PG_FUNCTION_INFO_V1(g_cube_same);
+ PG_FUNCTION_INFO_V1(g_cube_distance);
Datum g_cube_consistent(PG_FUNCTION_ARGS);
Datum g_cube_compress(PG_FUNCTION_ARGS);
***************
*** 81,86 **** Datum g_cube_penalty(PG_FUNCTION_ARGS);
--- 82,88 ----
Datum g_cube_picksplit(PG_FUNCTION_ARGS);
Datum g_cube_union(PG_FUNCTION_ARGS);
Datum g_cube_same(PG_FUNCTION_ARGS);
+ Datum g_cube_distance(PG_FUNCTION_ARGS);
/*
** B-tree support functions
***************
*** 649,654 **** g_cube_same(PG_FUNCTION_ARGS)
--- 651,671 ----
}
/*
+ ** Distance method
+ */
+ Datum
+ g_cube_distance(PG_FUNCTION_ARGS)
+ {
+ GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
+ NDBOX *query = PG_GETARG_NDBOX(1);
+ double distance;
+
+ distance = DatumGetFloat8(DirectFunctionCall2(cube_distance,
entry->key, PointerGetDatum(query)));
+
+ PG_RETURN_FLOAT8(distance);
+ }
+
+ /*
** SUPPORT ROUTINES
*/
bool
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers