~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to contrib/tsearch2/tsvector.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 __TXTIDX_H__
 
2
#define __TXTIDX_H__
 
3
 
 
4
/*
 
5
#define TXTIDX_DEBUG
 
6
*/
 
7
 
 
8
#include "postgres.h"
 
9
 
 
10
#include "access/gist.h"
 
11
#include "access/itup.h"
 
12
#include "utils/builtins.h"
 
13
#include "storage/bufpage.h"
 
14
 
 
15
typedef struct
 
16
{
 
17
        uint32
 
18
                                haspos:1,
 
19
                                len:11,                 /* MAX 2Kb */
 
20
                                pos:20;                 /* MAX 1Mb */
 
21
}       WordEntry;
 
22
 
 
23
#define MAXSTRLEN ( 1<<11 )
 
24
#define MAXSTRPOS ( 1<<20 )
 
25
 
 
26
typedef struct
 
27
{
 
28
        uint16
 
29
                                weight:2,
 
30
                                pos:14;
 
31
}       WordEntryPos;
 
32
 
 
33
#define MAXENTRYPOS (1<<14)
 
34
#define MAXNUMPOS       256
 
35
#define LIMITPOS(x) ( ( (x) >= MAXENTRYPOS ) ? (MAXENTRYPOS-1) : (x) )
 
36
 
 
37
typedef struct
 
38
{
 
39
        int4            len;
 
40
        int4            size;
 
41
        char            data[1];
 
42
}       tsvector;
 
43
 
 
44
#define DATAHDRSIZE (sizeof(int4)*2)
 
45
#define CALCDATASIZE(x, lenstr) ( x * sizeof(WordEntry) + DATAHDRSIZE + lenstr )
 
46
#define ARRPTR(x)       ( (WordEntry*) ( (char*)x + DATAHDRSIZE ) )
 
47
#define STRPTR(x)       ( (char*)x + DATAHDRSIZE + ( sizeof(WordEntry) * ((tsvector*)x)->size ) )
 
48
#define STRSIZE(x)      ( ((tsvector*)x)->len - DATAHDRSIZE - ( sizeof(WordEntry) * ((tsvector*)x)->size ) )
 
49
#define _POSDATAPTR(x,e)        (STRPTR(x)+((WordEntry*)(e))->pos+SHORTALIGN(((WordEntry*)(e))->len))
 
50
#define POSDATALEN(x,e) ( ( ((WordEntry*)(e))->haspos ) ? (*(uint16*)_POSDATAPTR(x,e)) : 0 )
 
51
#define POSDATAPTR(x,e) ( (WordEntryPos*)( _POSDATAPTR(x,e)+sizeof(uint16) ) )
 
52
 
 
53
 
 
54
typedef struct
 
55
{
 
56
        WordEntry       entry;
 
57
        WordEntryPos *pos;
 
58
}       WordEntryIN;
 
59
 
 
60
typedef struct
 
61
{
 
62
        char       *prsbuf;
 
63
        char       *word;
 
64
        char       *curpos;
 
65
        int4            len;
 
66
        int4            state;
 
67
        int4            alen;
 
68
        WordEntryPos *pos;
 
69
        bool            oprisdelim;
 
70
}       TI_IN_STATE;
 
71
 
 
72
int4            gettoken_tsvector(TI_IN_STATE * state);
 
73
 
 
74
#endif