diff options
| author | Teodor Sigaev | 2003-07-21 10:27:44 +0000 |
|---|---|---|
| committer | Teodor Sigaev | 2003-07-21 10:27:44 +0000 |
| commit | b88605337ea37ce1080a696937540cf8b48338d1 (patch) | |
| tree | ed26ee96ed8ca176fca8a956e938b3cc7adcb1f3 /contrib/tsearch2/tsvector.h | |
| parent | a6053826703e288ccc7bd2a9a86a278cef6bc7ed (diff) | |
tsearch2 module
Diffstat (limited to 'contrib/tsearch2/tsvector.h')
| -rw-r--r-- | contrib/tsearch2/tsvector.h | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/contrib/tsearch2/tsvector.h b/contrib/tsearch2/tsvector.h new file mode 100644 index 00000000000..31e6a4b02c9 --- /dev/null +++ b/contrib/tsearch2/tsvector.h @@ -0,0 +1,71 @@ +#ifndef __TXTIDX_H__ +#define __TXTIDX_H__ + +/* +#define TXTIDX_DEBUG +*/ + +#include "postgres.h" + +#include "access/gist.h" +#include "access/itup.h" +#include "utils/elog.h" +#include "utils/palloc.h" +#include "utils/builtins.h" +#include "storage/bufpage.h" + +typedef struct { + uint32 + haspos:1, + len:11, /* MAX 2Kb */ + pos:20; /* MAX 1Mb */ +} WordEntry; +#define MAXSTRLEN ( 1<<11 ) +#define MAXSTRPOS ( 1<<20 ) + +typedef struct { + uint16 + weight:2, + pos:14; +} WordEntryPos; +#define MAXENTRYPOS (1<<14) +#define MAXNUMPOS 256 +#define LIMITPOS(x) ( ( (x) >= MAXENTRYPOS ) ? (MAXENTRYPOS-1) : (x) ) + +typedef struct +{ + int4 len; + int4 size; + char data[1]; +} tsvector; + +#define DATAHDRSIZE (sizeof(int4)*2) +#define CALCDATASIZE(x, lenstr) ( x * sizeof(WordEntry) + DATAHDRSIZE + lenstr ) +#define ARRPTR(x) ( (WordEntry*) ( (char*)x + DATAHDRSIZE ) ) +#define STRPTR(x) ( (char*)x + DATAHDRSIZE + ( sizeof(WordEntry) * ((tsvector*)x)->size ) ) +#define STRSIZE(x) ( ((tsvector*)x)->len - DATAHDRSIZE - ( sizeof(WordEntry) * ((tsvector*)x)->size ) ) +#define _POSDATAPTR(x,e) (STRPTR(x)+((WordEntry*)(e))->pos+SHORTALIGN(((WordEntry*)(e))->len)) +#define POSDATALEN(x,e) ( ( ((WordEntry*)(e))->haspos ) ? (*(uint16*)_POSDATAPTR(x,e)) : 0 ) +#define POSDATAPTR(x,e) ( (WordEntryPos*)( _POSDATAPTR(x,e)+sizeof(uint16) ) ) + + +typedef struct { + WordEntry entry; + WordEntryPos *pos; +} WordEntryIN; + +typedef struct +{ + char *prsbuf; + char *word; + char *curpos; + int4 len; + int4 state; + int4 alen; + WordEntryPos *pos; + bool oprisdelim; +} TI_IN_STATE; + +int4 gettoken_tsvector(TI_IN_STATE * state); + +#endif |
