2001-10-13 07:19:09 +08:00
|
|
|
#ifndef __GISTIDX_H__
|
|
|
|
#define __GISTIDX_H__
|
|
|
|
|
|
|
|
/*
|
|
|
|
#define GISTIDX_DEBUG
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* signature defines
|
|
|
|
*/
|
|
|
|
#define BITBYTE 8
|
2001-10-25 13:50:21 +08:00
|
|
|
#define SIGLENINT 64 /* >121 => key will toast, so it will not
|
|
|
|
* work !!! */
|
2001-10-13 07:19:09 +08:00
|
|
|
#define SIGLEN ( sizeof(int4)*SIGLENINT )
|
|
|
|
#define SIGLENBIT (SIGLEN*BITBYTE)
|
|
|
|
|
|
|
|
typedef char BITVEC[SIGLEN];
|
|
|
|
typedef char *BITVECP;
|
|
|
|
|
|
|
|
#define LOOPBYTE(a) \
|
|
|
|
for(i=0;i<SIGLEN;i++) {\
|
|
|
|
a;\
|
|
|
|
}
|
|
|
|
#define LOOPBIT(a) \
|
2001-10-25 13:50:21 +08:00
|
|
|
for(i=0;i<SIGLENBIT;i++) {\
|
|
|
|
a;\
|
|
|
|
}
|
2001-10-13 07:19:09 +08:00
|
|
|
|
|
|
|
#define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) )
|
2005-05-26 05:40:43 +08:00
|
|
|
#define GETBITBYTE(x,i) ( ((char)(x)) >> (i) & 0x01 )
|
2001-10-13 07:19:09 +08:00
|
|
|
#define CLRBIT(x,i) GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITBYTE ) )
|
|
|
|
#define SETBIT(x,i) GETBYTE(x,i) |= ( 0x01 << ( (i) % BITBYTE ) )
|
|
|
|
#define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITBYTE )) & 0x01 )
|
|
|
|
|
|
|
|
#define HASHVAL(val) (((unsigned int)(val)) % SIGLENBIT)
|
|
|
|
#define HASH(sign, val) SETBIT((sign), HASHVAL(val))
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2001-10-25 13:50:21 +08:00
|
|
|
* type of index key
|
2001-10-13 07:19:09 +08:00
|
|
|
*/
|
2001-10-25 13:50:21 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int4 len;
|
|
|
|
int4 flag;
|
|
|
|
char data[1];
|
2001-11-06 01:46:40 +08:00
|
|
|
} GISTTYPE;
|
2001-10-13 07:19:09 +08:00
|
|
|
|
2001-10-25 13:50:21 +08:00
|
|
|
#define ARRKEY 0x01
|
|
|
|
#define SIGNKEY 0x02
|
|
|
|
#define ALLISTRUE 0x04
|
2001-10-13 07:19:09 +08:00
|
|
|
|
2005-05-26 05:40:43 +08:00
|
|
|
#define ISARRKEY(x) ( ((GISTTYPE*)(x))->flag & ARRKEY )
|
|
|
|
#define ISSIGNKEY(x) ( ((GISTTYPE*)(x))->flag & SIGNKEY )
|
|
|
|
#define ISALLTRUE(x) ( ((GISTTYPE*)(x))->flag & ALLISTRUE )
|
2001-10-13 07:19:09 +08:00
|
|
|
|
2005-05-26 05:40:43 +08:00
|
|
|
#define GTHDRSIZE ( sizeof(int4)* 2 )
|
2001-10-13 07:19:09 +08:00
|
|
|
#define CALCGTSIZE(flag, len) ( GTHDRSIZE + ( ( (flag) & ARRKEY ) ? ((len)*sizeof(int4)) : (((flag) & ALLISTRUE) ? 0 : SIGLEN) ) )
|
|
|
|
|
2005-05-26 05:40:43 +08:00
|
|
|
#define GETSIGN(x) ( (BITVECP)( (char*)(x) + GTHDRSIZE ) )
|
|
|
|
#define GETARR(x) ( (int4*)( (char*)(x) + GTHDRSIZE ) )
|
|
|
|
#define ARRNELEM(x) ( ( ((GISTTYPE*)(x))->len - GTHDRSIZE ) / sizeof(int4) )
|
2001-10-28 14:26:15 +08:00
|
|
|
|
2001-10-13 07:19:09 +08:00
|
|
|
#endif
|