mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +03:00
Use postgres-wide macros BITS_PER_BYTE instead self-definenig macros, also use it for calculating bit length of TPQTGist
This commit is contained in:
@ -9,11 +9,10 @@
|
|||||||
* signature defines
|
* signature defines
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define BITBYTE 8
|
|
||||||
#define SIGLENINT 63 /* >121 => key will toast, so it will not work
|
#define SIGLENINT 63 /* >121 => key will toast, so it will not work
|
||||||
* !!! */
|
* !!! */
|
||||||
#define SIGLEN ( sizeof(int4) * SIGLENINT )
|
#define SIGLEN ( sizeof(int4) * SIGLENINT )
|
||||||
#define SIGLENBIT (SIGLEN * BITBYTE)
|
#define SIGLENBIT (SIGLEN * BITS_PER_BYTE)
|
||||||
|
|
||||||
typedef char BITVEC[SIGLEN];
|
typedef char BITVEC[SIGLEN];
|
||||||
typedef char *BITVECP;
|
typedef char *BITVECP;
|
||||||
@ -27,11 +26,11 @@ typedef char *BITVECP;
|
|||||||
a;\
|
a;\
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) )
|
#define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITS_PER_BYTE ) ) )
|
||||||
#define GETBITBYTE(x,i) ( ((char)(x)) >> (i) & 0x01 )
|
#define GETBITBYTE(x,i) ( ((char)(x)) >> (i) & 0x01 )
|
||||||
#define CLRBIT(x,i) GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITBYTE ) )
|
#define CLRBIT(x,i) GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITS_PER_BYTE ) )
|
||||||
#define SETBIT(x,i) GETBYTE(x,i) |= ( 0x01 << ( (i) % BITBYTE ) )
|
#define SETBIT(x,i) GETBYTE(x,i) |= ( 0x01 << ( (i) % BITS_PER_BYTE ) )
|
||||||
#define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITBYTE )) & 0x01 )
|
#define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITS_PER_BYTE )) & 0x01 )
|
||||||
|
|
||||||
#define HASHVAL(val) (((unsigned int)(val)) % SIGLENBIT)
|
#define HASHVAL(val) (((unsigned int)(val)) % SIGLENBIT)
|
||||||
#define HASH(sign, val) SETBIT((sign), HASHVAL(val))
|
#define HASH(sign, val) SETBIT((sign), HASHVAL(val))
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#include "query.h"
|
#include "query.h"
|
||||||
|
|
||||||
typedef uint64 TPQTGist;
|
typedef uint64 TPQTGist;
|
||||||
|
#define SIGLEN (sizeof(TPQTGist)*BITS_PER_BYTE)
|
||||||
|
|
||||||
|
|
||||||
#define GETENTRY(vec,pos) ((TPQTGist *) DatumGetPointer((vec)->vector[(pos)].key))
|
#define GETENTRY(vec,pos) ((TPQTGist *) DatumGetPointer((vec)->vector[(pos)].key))
|
||||||
|
|
||||||
@ -24,7 +26,7 @@ makesign(QUERYTYPE* a) {
|
|||||||
|
|
||||||
for (i = 0; i < a->size; i++) {
|
for (i = 0; i < a->size; i++) {
|
||||||
if ( ptr->type == VAL )
|
if ( ptr->type == VAL )
|
||||||
sign |= 1 << (ptr->val % 64);
|
sign |= 1 << (ptr->val % SIGLEN);
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +200,7 @@ static int
|
|||||||
sizebitvec(TPQTGist sign) {
|
sizebitvec(TPQTGist sign) {
|
||||||
int size=0,i;
|
int size=0,i;
|
||||||
|
|
||||||
for(i=0;i<64;i++)
|
for(i=0;i<SIGLEN;i++)
|
||||||
size += 0x01 & (sign>>i);
|
size += 0x01 & (sign>>i);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
|
Reference in New Issue
Block a user