~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to contrib/tsearch2/gistidx.h

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef __GISTIDX_H__
 
2
#define __GISTIDX_H__
 
3
 
 
4
/*
 
5
#define GISTIDX_DEBUG
 
6
*/
 
7
 
 
8
/*
 
9
 * signature defines
 
10
 */
 
11
 
 
12
#define BITBYTE 8
 
13
#define SIGLENINT  63                   /* >121 => key will toast, so it will not
 
14
                                                                 * work !!! */
 
15
#define SIGLEN  ( sizeof(int4)*SIGLENINT )
 
16
#define SIGLENBIT (SIGLEN*BITBYTE)
 
17
 
 
18
typedef char BITVEC[SIGLEN];
 
19
typedef char *BITVECP;
 
20
 
 
21
#define LOOPBYTE(a) \
 
22
                for(i=0;i<SIGLEN;i++) {\
 
23
                                a;\
 
24
                }
 
25
#define LOOPBIT(a) \
 
26
                                for(i=0;i<SIGLENBIT;i++) {\
 
27
                                                                a;\
 
28
                                }
 
29
 
 
30
#define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) )
 
31
#define GETBITBYTE(x,i) ( ((char)(x)) >> i & 0x01 )
 
32
#define CLRBIT(x,i)   GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITBYTE ) )
 
33
#define SETBIT(x,i)   GETBYTE(x,i) |=  ( 0x01 << ( (i) % BITBYTE ) )
 
34
#define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITBYTE )) & 0x01 )
 
35
 
 
36
#define HASHVAL(val) (((unsigned int)(val)) % SIGLENBIT)
 
37
#define HASH(sign, val) SETBIT((sign), HASHVAL(val))
 
38
 
 
39
 
 
40
/*
 
41
 * type of index key
 
42
 */
 
43
typedef struct
 
44
{
 
45
        int4            len;
 
46
        int4            flag;
 
47
        char            data[1];
 
48
}       GISTTYPE;
 
49
 
 
50
#define ARRKEY          0x01
 
51
#define SIGNKEY         0x02
 
52
#define ALLISTRUE       0x04
 
53
 
 
54
#define ISARRKEY(x) ( ((GISTTYPE*)x)->flag & ARRKEY )
 
55
#define ISSIGNKEY(x)    ( ((GISTTYPE*)x)->flag & SIGNKEY )
 
56
#define ISALLTRUE(x)    ( ((GISTTYPE*)x)->flag & ALLISTRUE )
 
57
 
 
58
#define GTHDRSIZE       ( sizeof(int4)*2  )
 
59
#define CALCGTSIZE(flag, len) ( GTHDRSIZE + ( ( (flag) & ARRKEY ) ? ((len)*sizeof(int4)) : (((flag) & ALLISTRUE) ? 0 : SIGLEN) ) )
 
60
 
 
61
#define GETSIGN(x)      ( (BITVECP)( (char*)x+GTHDRSIZE ) )
 
62
#define GETARR(x)       ( (int4*)( (char*)x+GTHDRSIZE ) )
 
63
#define ARRNELEM(x) ( ( ((GISTTYPE*)x)->len - GTHDRSIZE )/sizeof(int4) )
 
64
 
 
65
#endif