/[MITgcm]/mitgcm.org/devel/buildweb/pkg/swish-e/src/db.h
ViewVC logotype

Annotation of /mitgcm.org/devel/buildweb/pkg/swish-e/src/db.h

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Fri Sep 20 19:47:29 2002 UTC (22 years, 10 months ago) by adcroft
Branch point for: Import, MAIN
File MIME type: text/plain
Initial revision

1 adcroft 1.1 /*
2     **
3     ** This program and library is free software; you can redistribute it and/or
4     ** modify it under the terms of the GNU (Library) General Public License
5     ** as published by the Free Software Foundation; either version 2
6     ** of the License, or any later version.
7     **
8     ** This program is distributed in the hope that it will be useful,
9     ** but WITHOUT ANY WARRANTY; without even the implied warranty of
10     ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11     ** GNU (Library) General Public License for more details.
12     **
13     ** You should have received a copy of the GNU (Library) General Public License
14     ** along with this program; if not, write to the Free Software
15     ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16     **
17     **
18     **
19     ** 2001-01 jose initial coding
20     **
21     */
22    
23     #ifndef __HasSeenModule_DB
24     #define __HasSeenModule_DB 1
25    
26     /* Possible Open File modes */
27     typedef enum {
28     DB_CREATE,
29     DB_READ,
30     DB_READWRITE
31     }
32     DB_OPEN_MODE;
33    
34     void initModule_DB (SWISH *);
35     void freeModule_DB (SWISH *);
36     int configModule_DB (SWISH *sw, StringList *sl);
37    
38     void write_header(SWISH *, INDEXDATAHEADER *, void *, char *, int, int, int);
39     void update_header(SWISH *, void *, int, int );
40     void write_index(SWISH *, IndexFILE *);
41     void write_word(SWISH *, ENTRY *, IndexFILE *);
42     #ifdef USE_BTREE
43     void update_wordID(SWISH *, ENTRY *, IndexFILE *);
44     void delete_worddata(SWISH *, long, IndexFILE *);
45     #endif
46     void build_worddata(SWISH *, ENTRY *, IndexFILE *);
47     void write_worddata(SWISH *, ENTRY *, IndexFILE *);
48     long read_worddata(SWISH * sw, ENTRY * ep, IndexFILE * indexf, unsigned char **bufer, int *sz_buffer);
49     void add_worddata(SWISH *sw, ENTRY *epi, IndexFILE *indexf, unsigned char *buffer, int sz_buffer);
50     int write_words_to_header(SWISH *, int header_ID, struct swline **hash, void *DB);
51     void write_pathlookuptable_to_header(SWISH *, int id, INDEXDATAHEADER *header, void *DB);
52     void write_MetaNames (SWISH *, int id, INDEXDATAHEADER *header, void *DB);
53     int write_integer_table_to_header(SWISH *, int id, int table[], int table_size, void *DB);
54    
55     void read_header(SWISH *, INDEXDATAHEADER *header, void *DB);
56    
57     void parse_MetaNames_from_buffer(INDEXDATAHEADER *header, char *buffer);
58     void parse_stopwords_from_buffer(INDEXDATAHEADER *header, char *buffer);
59     void parse_buzzwords_from_buffer(INDEXDATAHEADER *header, char *buffer);
60     void parse_pathlookuptable_from_buffer(INDEXDATAHEADER *header, char *buffer);
61     void parse_integer_table_from_buffer(int table[], int table_size, char *buffer);
62     char *getfilewords(SWISH *sw, int, IndexFILE *);
63     void setTotalWordsPerFile(SWISH *, IndexFILE *,int ,int );
64     void getTotalWordsPerFile(SWISH *, IndexFILE *, int ,int *);
65    
66    
67    
68     /* Common DB api */
69     void *DB_Create (SWISH *sw, char *dbname);
70     void *DB_Open (SWISH *sw, char *dbname, int mode);
71     void DB_Close(SWISH *sw, void *DB);
72     void DB_Remove(SWISH *sw, void *DB);
73    
74     int DB_InitWriteHeader(SWISH *sw, void *DB);
75     int DB_EndWriteHeader(SWISH *sw, void *DB);
76     int DB_WriteHeaderData(SWISH *sw, int id, unsigned char *s, int len, void *DB);
77    
78     int DB_InitReadHeader(SWISH *sw, void *DB);
79     int DB_ReadHeaderData(SWISH *sw, int *id, unsigned char **s, int *len, void *DB);
80     int DB_EndReadHeader(SWISH *sw, void *DB);
81    
82     int DB_InitWriteWords(SWISH *sw, void *DB);
83     long DB_GetWordID(SWISH *sw, void *DB);
84     int DB_WriteWord(SWISH *sw, char *word, long wordID, void *DB);
85     #ifdef USE_BTREE
86     int DB_UpdateWordID(SWISH *sw, char *word, long wordID, void *DB);
87     int DB_DeleteWordData(SWISH *sw,long wordID, void *DB);
88     #endif
89     int DB_WriteWordHash(SWISH *sw, char *word, long wordID, void *DB);
90     long DB_WriteWordData(SWISH *sw, long wordID, unsigned char *worddata, int lendata, void *DB);
91     int DB_EndWriteWords(SWISH *sw, void *DB);
92    
93     int DB_InitReadWords(SWISH *sw, void *DB);
94     int DB_ReadWordHash(SWISH *sw, char *word, long *wordID, void *DB);
95     int DB_ReadFirstWordInvertedIndex(SWISH *sw, char *word, char **resultword, long *wordID, void *DB);
96     int DB_ReadNextWordInvertedIndex(SWISH *sw, char *word, char **resultword, long *wordID, void *DB);
97     long DB_ReadWordData(SWISH *sw, long wordID, unsigned char **worddata, int *lendata, void *DB);
98     int DB_EndReadWords(SWISH *sw, void *DB);
99    
100    
101     #ifdef USE_BTREE
102     int DB_InitWriteSortedIndex(SWISH *sw, void *DB, int n_props );
103     #else
104     int DB_InitWriteSortedIndex(SWISH *sw, void *DB );
105     #endif
106     int DB_WriteSortedIndex(SWISH *sw, int propID, unsigned char *data, int sz_data,void *DB);
107     int DB_EndWriteSortedIndex(SWISH *sw, void *DB);
108    
109     int DB_InitReadSortedIndex(SWISH *sw, void *DB);
110     int DB_ReadSortedIndex(SWISH *sw, int propID, unsigned char **data, int *sz_data,void *DB);
111     int DB_ReadSortedData(SWISH *sw, int *data,int index, int *value, void *DB);
112     int DB_EndReadSortedIndex(SWISH *sw, void *DB);
113    
114    
115     int DB_InitWriteFiles(SWISH *sw, void *DB);
116     int DB_WriteFile(SWISH *sw, int filenum, unsigned char *filedata,int sz_filedata, void *DB);
117     int DB_EndWriteFiles(SWISH *sw, void *DB);
118    
119     int DB_InitReadFiles(SWISH *sw, void *DB);
120     int DB_ReadFile(SWISH *sw, int filenum, unsigned char **filedata,int *sz_filedata, void *DB);
121     int DB_EndReadFiles(SWISH *sw, void *DB);
122    
123     void DB_WriteProperty( SWISH *sw, IndexFILE *indexf, FileRec *fi, int propID, char *buffer, int buf_len, int uncompressed_len, void *db);
124     void DB_WritePropPositions(SWISH *sw, IndexFILE *indexf, FileRec *fi, void *db);
125     void DB_ReadPropPositions(SWISH *sw, IndexFILE *indexf, FileRec *fi, void *db);
126     char *DB_ReadProperty(SWISH *sw, IndexFILE *indexf, FileRec *fi, int propID, int *buf_len, int *uncompressed_len, void *db);
127     void DB_Reopen_PropertiesForRead(SWISH *sw, void *DB);
128    
129     #ifdef USE_BTREE
130     int DB_WriteTotalWordsPerFile(SWISH *sw, int idx, int wordcount, void *DB);
131     int DB_ReadTotalWordsPerFile(SWISH *sw, int idx, int *wordcount, void *DB);
132     #endif
133    
134    
135     struct MOD_DB
136     {
137     char *DB_name; /* short name for data source */
138    
139     void * (*DB_Create) (SWISH *sw, char *dbname);
140     void * (*DB_Open) (SWISH *sw, char *dbname, int mode);
141     void (*DB_Close) (void *DB);
142     void (*DB_Remove) (void *DB);
143    
144     int (*DB_InitWriteHeader) (void *DB);
145     int (*DB_WriteHeaderData) (int id, unsigned char *s, int len, void *DB);
146     int (*DB_EndWriteHeader) (void *DB);
147    
148     int (*DB_InitReadHeader) (void *DB);
149     int (*DB_ReadHeaderData) (int *id, unsigned char **s, int *len, void *DB);
150     int (*DB_EndReadHeader) (void *DB);
151    
152     int (*DB_InitWriteWords) (void *DB);
153     long (*DB_GetWordID) (void *DB);
154     int (*DB_WriteWord) (char *word, long wordID, void *DB);
155     #ifdef USE_BTREE
156     int (*DB_UpdateWordID)(char *word, long new_wordID, void *DB);
157     int (*DB_DeleteWordData)(long wordID, void *DB);
158     #endif
159     int (*DB_WriteWordHash) (char *word, long wordID, void *DB);
160     long (*DB_WriteWordData) (long wordID, unsigned char *worddata, int lendata, void *DB);
161     int (*DB_EndWriteWords) (void *DB);
162    
163     int (*DB_InitReadWords) (void *DB);
164     int (*DB_ReadWordHash) (char *word, long *wordID, void *DB);
165     int (*DB_ReadFirstWordInvertedIndex) (char *word, char **resultword, long *wordID, void *DB);
166     int (*DB_ReadNextWordInvertedIndex) (char *word, char **resultword, long *wordID, void *DB);
167     long (*DB_ReadWordData) (long wordID, unsigned char **worddata, int *lendata, void *DB);
168     int (*DB_EndReadWords) (void *DB);
169    
170    
171     int (*DB_InitWriteFiles) (void *DB);
172     int (*DB_WriteFile) (int filenum, unsigned char *filedata,int sz_filedata, void *DB);
173     int (*DB_EndWriteFiles) (void *DB);
174    
175     int (*DB_InitReadFiles) (void *DB);
176     int (*DB_ReadFile) (int filenum, unsigned char **filedata,int *sz_filedata, void *DB);
177     int (*DB_EndReadFiles) (void *DB);
178    
179     #ifdef USE_BTREE
180     int (*DB_InitWriteSortedIndex) (void *DB, int n_props);
181     #else
182     int (*DB_InitWriteSortedIndex) (void *DB);
183     #endif
184     int (*DB_WriteSortedIndex) (int propID, unsigned char *data, int sz_data,void *DB);
185     int (*DB_EndWriteSortedIndex) (void *DB);
186    
187     int (*DB_InitReadSortedIndex) (void *DB);
188     int (*DB_ReadSortedIndex) (int propID, unsigned char **data, int *sz_data,void *DB);
189     int (*DB_ReadSortedData) (int *data,int index, int *value, void *DB);
190     int (*DB_EndReadSortedIndex) (void *DB);
191    
192     void (*DB_WriteProperty)( IndexFILE *indexf, FileRec *fi, int propID, char *buffer, int buf_len, int uncompressed_len, void *db);
193     void (*DB_WritePropPositions)(IndexFILE *indexf, FileRec *fi, void *db);
194     void (*DB_ReadPropPositions)(IndexFILE *indexf, FileRec *fi, void *db);
195     char *(*DB_ReadProperty)(IndexFILE *indexf, FileRec *fi, int propID, int *buf_len, int *uncompressed_len, void *db);
196     void (*DB_Reopen_PropertiesForRead)(void *DB);
197     #ifdef USE_BTREE
198     int (*DB_WriteTotalWordsPerFile)(SWISH *sw, int idx, int wordcount, void *DB);
199     int (*DB_ReadTotalWordsPerFile)(SWISH *sw, int idx, int *wordcount, void *DB);
200     #endif
201     };
202    
203    
204     #endif

  ViewVC Help
Powered by ViewVC 1.1.22