I'm trying to get my geometric type to spatially index. I tried RTrees,
but they dont like objects that are bigger than 8k.
I'm now trying to get a GiST index to index based on the bounding box
thats contained inside the geometry. So the index is on a GEOMETRY
type, but the index is only acting on the GEOMETRY->bvolume (which is a
BOX3D).
So far, it doesnt work. Only one of my GiST support functions is called
(the compress function), after that I get the error message:
# create index qq on tp3 using gist (the_geom gist_geometry_ops) with
(islossy);
ERROR: index_formtuple: data takes 8424504 bytes, max is 8191
I simplified the all the geometry in the test (tp3) table so they
contain only one point - each object is only a few hundred bytes, and
there's only 100 rows.
I'm obviously doing something very wrong.
My compress function looks like:
GISTENTRY *ggeometry_compress(GISTENTRY *entry)
{ BOX3D *tmp; GISTENTRY *retval;
if (entry->leafkey) { tmp = (BOX3D *) palloc(sizeof(BOX3D)); memcpy((char *) tmp, (char *) &(((GEOMETRY
*)(entry->pred))->bvol),
sizeof(BOX3D));
retval = palloc(sizeof(GISTENTRY)); gistentryinit(*retval, (char *)tmp, entry->rel, entry->page,
entry->offset, sizeof(BOX3D),FALSE); return(retval); } else return(entry);
}
On its first (and only) call, the geometry ("entry->pred") really is the
first row in the tp3 table.
Does anyone have any ideas where to start tracking this problem down?
Am I writing code for a very old version of GiST?
I've tried to find other examples of GiST using compression, but none of
them work. "contrib/intarray" in the standard distribution just spins
(cpu 100%) when you try to build an index, and
"http://s2k-ftp.cs.berkeley.edu:8000/gist/pggist/" has an example using
the standard built-in polygon type (I based my code on it) - but its
really really old and I spent a few hours trying to get it to compile,
then gave up.
Any ideas or examples?
dave
ps. I'm using postgresql 7.1.1 with the gist.c 7.1 patch. I get the
exact result with out-of-the-box-7.1.1.
pps. My code is available at
ftp://ftp.refractions.net/pub/refractions/postgis.c ftp://ftp.refractions.net/pub/refractions/postgis.h
andthe sql definitions are at
ftp://ftp.refractions.net/pub/refractions/def.sql and a dump of the tp3 table is at
ftp://ftp.refractions.net/pub/refractions/tp3.sql