Search Postgresql Archives

Gist Index: Problem getting data in GiST Support Functions "penalty".

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I have a user defined data type and a GiST index on this type. My GiST index is not working because I am not getting data in one of the GiST Support Functions "penalty". 


Here is the simplified example my type "MY_TYPE"

1- User Defined Data Type

typedef struct 
{
  long     id;              
  long     x;               
  long     y;               
.......
  BYTEA    mydata[1];       
} MY_TYPE;


typedef struct
{
	long     mnx;
	long     mny;
	long     mxx;
	long     mxy;
	long     m1;
	long     m2;
} MY_SUB_TYPE; 


Create TYPE my_data_type (INPUT = MY_Type_In, OUTPUT = MY_Type_Out,
INTERNALLENGTH=VARIABLE, analyze = my_type_analyze, STORAGE = MAIN);

Create TYPE my_sub_data_type (INPUT=MY_Sub_Type_In, OUTPUT=MY_Sub_Type_Out, INTERNALLENGTH=24);


CREATE OPERATOR CLASS my_type_data_ops
        DEFAULT FOR TYPE my_data_type USING gist AS 
        OPERATOR        1        =<< ,
............
        FUNCTION        1        my_type_gist_consistent (internal, my_data_type, int4),
        FUNCTION        2        my_type_gist_union (internal, internal),
        FUNCTION        3        my_type_gist_compress (internal),
        FUNCTION        4        my_type_gist_decompress (internal),
        FUNCTION        5        my_type_gist_penalty (internal, internal, internal),
        FUNCTION        6        my_type_gist_picksplit(internal, internal),
        FUNCTION        7        my_type_gist_equal(my_sub_data_type, my_sub_data_type, internal);


2- Problem

Create GiST index not returning expected values.

CREATE INDEX my_test_spx ON my_test USING gist (b);
.......
NOTICE:  In my_type_gist_penalty: origentry : ENV <minx= 0, miny = 0, maxx = 0, maxy = 0: m1 = 0 m2 = 0 >


However, when I remove 'm1' and 'm2' from my type "MY_SUB_TYPE", I am getting expected results.

typedef struct
{
	long     mnx;
	long     mny;
	long     mxx;
	long     mxy;
} MY_SUB_TYPE; 

Create TYPE stt_envelope (INPUT=STT_ENVELOPE_In, OUTPUT=STT_ENVELOPE_Out, INTERNALLENGTH=16);

Expected results:

CREATE INDEX my_test_spx ON my_test USING gist (b);
......
NOTICE:  In my_type_gist_penalty: origentry : ENV <minx= 6234067, miny = 2034619, maxx = 6341951, maxy = 2044797 >
CREATE INDEX


3- GiST Function "penalty".

Datum my_type_gist_penalty(PG_FUNCTION_ARGS)
{
	GISTENTRY  *origentry = (GISTENTRY *) PG_GETARG_POINTER(0);
	GISTENTRY  *newentry = (GISTENTRY *) PG_GETARG_POINTER(1);
	float	              *result = (float *) PG_GETARG_POINTER(2);
	Datum		   ud;
	

	if (DatumGetPointer(origentry->key) == NULL && DatumGetPointer(newentry->key) == NULL)
		*result = 0;
	else
	{
                   S_print("In my_type_gist_penalty: origentry " , (MY_SUB_TYPE *) PointerGetDatum(origentry->key)); 
                  ud = DirectFunctionCall2(my_type_union, origentry->key, newentry->key);	
                    ..................
	}
	PG_RETURN_POINTER(result);
}



Can anyone explain why I am seeing this difference? Is there any limitation of GiST Support Functions "penalty"?

I can provide more information if needed.

Thanks.

Ale Raza.


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux