2003-07-21 18:27:44 +08:00
|
|
|
#ifndef __TXTIDX_H__
|
|
|
|
#define __TXTIDX_H__
|
|
|
|
|
|
|
|
/*
|
|
|
|
#define TXTIDX_DEBUG
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "postgres.h"
|
|
|
|
|
|
|
|
#include "access/gist.h"
|
|
|
|
#include "access/itup.h"
|
|
|
|
#include "utils/builtins.h"
|
|
|
|
#include "storage/bufpage.h"
|
|
|
|
|
2003-08-04 08:43:34 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
2003-07-21 18:27:44 +08:00
|
|
|
uint32
|
2003-08-04 08:43:34 +08:00
|
|
|
haspos:1,
|
|
|
|
len:11, /* MAX 2Kb */
|
|
|
|
pos:20; /* MAX 1Mb */
|
2003-07-21 18:27:44 +08:00
|
|
|
} WordEntry;
|
2003-08-04 08:43:34 +08:00
|
|
|
|
2003-07-21 18:27:44 +08:00
|
|
|
#define MAXSTRLEN ( 1<<11 )
|
|
|
|
#define MAXSTRPOS ( 1<<20 )
|
|
|
|
|
2005-01-25 20:36:25 +08:00
|
|
|
/*
|
2005-10-15 10:49:52 +08:00
|
|
|
Equivalent to
|
2003-08-04 08:43:34 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
2005-10-15 10:49:52 +08:00
|
|
|
uint16
|
|
|
|
weight:2,
|
|
|
|
pos:14;
|
|
|
|
} WordEntryPos;
|
2005-01-25 20:36:25 +08:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef uint16 WordEntryPos;
|
|
|
|
|
|
|
|
#define WEP_GETWEIGHT(x) ( (x) >> 14 )
|
2005-05-26 05:40:43 +08:00
|
|
|
#define WEP_GETPOS(x) ( (x) & 0x3fff )
|
2005-01-25 20:36:25 +08:00
|
|
|
|
2005-10-15 10:49:52 +08:00
|
|
|
#define WEP_SETWEIGHT(x,v) (x) = ( (v) << 14 ) | ( (x) & 0x3fff )
|
|
|
|
#define WEP_SETPOS(x,v) (x) = ( (x) & 0xc000 ) | ( (v) & 0x3fff )
|
2005-01-25 20:36:25 +08:00
|
|
|
|
2003-08-04 08:43:34 +08:00
|
|
|
|
|
|
|
#define MAXENTRYPOS (1<<14)
|
2003-07-21 18:27:44 +08:00
|
|
|
#define MAXNUMPOS 256
|
2003-08-04 08:43:34 +08:00
|
|
|
#define LIMITPOS(x) ( ( (x) >= MAXENTRYPOS ) ? (MAXENTRYPOS-1) : (x) )
|
2003-07-21 18:27:44 +08:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int4 len;
|
|
|
|
int4 size;
|
|
|
|
char data[1];
|
|
|
|
} tsvector;
|
|
|
|
|
2005-05-26 05:40:43 +08:00
|
|
|
#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 ) )
|
2003-07-21 18:27:44 +08:00
|
|
|
#define _POSDATAPTR(x,e) (STRPTR(x)+((WordEntry*)(e))->pos+SHORTALIGN(((WordEntry*)(e))->len))
|
2003-08-04 08:43:34 +08:00
|
|
|
#define POSDATALEN(x,e) ( ( ((WordEntry*)(e))->haspos ) ? (*(uint16*)_POSDATAPTR(x,e)) : 0 )
|
|
|
|
#define POSDATAPTR(x,e) ( (WordEntryPos*)( _POSDATAPTR(x,e)+sizeof(uint16) ) )
|
2003-07-21 18:27:44 +08:00
|
|
|
|
|
|
|
|
2003-08-04 08:43:34 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
WordEntry entry;
|
|
|
|
WordEntryPos *pos;
|
2003-07-21 18:27:44 +08:00
|
|
|
} WordEntryIN;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char *prsbuf;
|
|
|
|
char *word;
|
|
|
|
char *curpos;
|
|
|
|
int4 len;
|
|
|
|
int4 state;
|
|
|
|
int4 alen;
|
2003-08-04 08:43:34 +08:00
|
|
|
WordEntryPos *pos;
|
2003-07-21 18:27:44 +08:00
|
|
|
bool oprisdelim;
|
|
|
|
} TI_IN_STATE;
|
|
|
|
|
|
|
|
int4 gettoken_tsvector(TI_IN_STATE * state);
|
|
|
|
|
|
|
|
#endif
|