ferret 0.11.6 → 0.11.8.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. data/README +10 -22
  2. data/RELEASE_CHANGES +137 -0
  3. data/RELEASE_NOTES +60 -0
  4. data/Rakefile +379 -274
  5. data/TODO +100 -8
  6. data/bin/ferret-browser +0 -0
  7. data/ext/BZLIB_blocksort.c +1094 -0
  8. data/ext/BZLIB_bzlib.c +1578 -0
  9. data/ext/BZLIB_compress.c +672 -0
  10. data/ext/BZLIB_crctable.c +104 -0
  11. data/ext/BZLIB_decompress.c +626 -0
  12. data/ext/BZLIB_huffman.c +205 -0
  13. data/ext/BZLIB_randtable.c +84 -0
  14. data/ext/{api.c → STEMMER_api.c} +7 -10
  15. data/ext/{libstemmer.c → STEMMER_libstemmer.c} +3 -2
  16. data/ext/{stem_ISO_8859_1_danish.c → STEMMER_stem_ISO_8859_1_danish.c} +123 -124
  17. data/ext/{stem_ISO_8859_1_dutch.c → STEMMER_stem_ISO_8859_1_dutch.c} +177 -188
  18. data/ext/STEMMER_stem_ISO_8859_1_english.c +1117 -0
  19. data/ext/{stem_ISO_8859_1_finnish.c → STEMMER_stem_ISO_8859_1_finnish.c} +276 -306
  20. data/ext/STEMMER_stem_ISO_8859_1_french.c +1246 -0
  21. data/ext/{stem_ISO_8859_1_german.c → STEMMER_stem_ISO_8859_1_german.c} +161 -170
  22. data/ext/STEMMER_stem_ISO_8859_1_hungarian.c +1230 -0
  23. data/ext/STEMMER_stem_ISO_8859_1_italian.c +1065 -0
  24. data/ext/STEMMER_stem_ISO_8859_1_norwegian.c +297 -0
  25. data/ext/{stem_ISO_8859_1_porter.c → STEMMER_stem_ISO_8859_1_porter.c} +263 -290
  26. data/ext/{stem_ISO_8859_1_portuguese.c → STEMMER_stem_ISO_8859_1_portuguese.c} +362 -380
  27. data/ext/STEMMER_stem_ISO_8859_1_spanish.c +1093 -0
  28. data/ext/STEMMER_stem_ISO_8859_1_swedish.c +307 -0
  29. data/ext/STEMMER_stem_ISO_8859_2_romanian.c +998 -0
  30. data/ext/{stem_KOI8_R_russian.c → STEMMER_stem_KOI8_R_russian.c} +244 -245
  31. data/ext/STEMMER_stem_UTF_8_danish.c +339 -0
  32. data/ext/{stem_UTF_8_dutch.c → STEMMER_stem_UTF_8_dutch.c} +192 -211
  33. data/ext/STEMMER_stem_UTF_8_english.c +1125 -0
  34. data/ext/{stem_UTF_8_finnish.c → STEMMER_stem_UTF_8_finnish.c} +284 -324
  35. data/ext/STEMMER_stem_UTF_8_french.c +1256 -0
  36. data/ext/{stem_UTF_8_german.c → STEMMER_stem_UTF_8_german.c} +170 -187
  37. data/ext/STEMMER_stem_UTF_8_hungarian.c +1234 -0
  38. data/ext/STEMMER_stem_UTF_8_italian.c +1073 -0
  39. data/ext/STEMMER_stem_UTF_8_norwegian.c +299 -0
  40. data/ext/{stem_UTF_8_porter.c → STEMMER_stem_UTF_8_porter.c} +271 -310
  41. data/ext/STEMMER_stem_UTF_8_portuguese.c +1023 -0
  42. data/ext/STEMMER_stem_UTF_8_romanian.c +1004 -0
  43. data/ext/STEMMER_stem_UTF_8_russian.c +694 -0
  44. data/ext/STEMMER_stem_UTF_8_spanish.c +1097 -0
  45. data/ext/STEMMER_stem_UTF_8_swedish.c +309 -0
  46. data/ext/STEMMER_stem_UTF_8_turkish.c +2205 -0
  47. data/ext/{utilities.c → STEMMER_utilities.c} +100 -68
  48. data/ext/analysis.c +276 -121
  49. data/ext/analysis.h +190 -143
  50. data/ext/api.h +3 -4
  51. data/ext/array.c +5 -3
  52. data/ext/array.h +52 -43
  53. data/ext/bitvector.c +38 -482
  54. data/ext/bitvector.h +446 -124
  55. data/ext/bzlib.h +282 -0
  56. data/ext/bzlib_private.h +503 -0
  57. data/ext/compound_io.c +23 -22
  58. data/ext/config.h +21 -11
  59. data/ext/document.c +43 -40
  60. data/ext/document.h +31 -21
  61. data/ext/except.c +20 -38
  62. data/ext/except.h +89 -76
  63. data/ext/extconf.rb +3 -2
  64. data/ext/ferret.c +49 -35
  65. data/ext/ferret.h +14 -11
  66. data/ext/field_index.c +262 -0
  67. data/ext/field_index.h +52 -0
  68. data/ext/filter.c +11 -10
  69. data/ext/fs_store.c +65 -47
  70. data/ext/global.c +245 -165
  71. data/ext/global.h +252 -54
  72. data/ext/hash.c +200 -243
  73. data/ext/hash.h +205 -163
  74. data/ext/hashset.c +118 -96
  75. data/ext/hashset.h +110 -82
  76. data/ext/header.h +19 -19
  77. data/ext/helper.c +11 -10
  78. data/ext/helper.h +14 -6
  79. data/ext/index.c +745 -366
  80. data/ext/index.h +503 -529
  81. data/ext/internal.h +1020 -0
  82. data/ext/lang.c +10 -0
  83. data/ext/lang.h +35 -15
  84. data/ext/mempool.c +5 -4
  85. data/ext/mempool.h +30 -22
  86. data/ext/modules.h +35 -7
  87. data/ext/multimapper.c +43 -2
  88. data/ext/multimapper.h +32 -23
  89. data/ext/posh.c +0 -0
  90. data/ext/posh.h +4 -38
  91. data/ext/priorityqueue.c +10 -12
  92. data/ext/priorityqueue.h +33 -21
  93. data/ext/q_boolean.c +22 -9
  94. data/ext/q_const_score.c +3 -2
  95. data/ext/q_filtered_query.c +15 -12
  96. data/ext/q_fuzzy.c +147 -135
  97. data/ext/q_match_all.c +3 -2
  98. data/ext/q_multi_term.c +28 -32
  99. data/ext/q_parser.c +451 -173
  100. data/ext/q_phrase.c +158 -79
  101. data/ext/q_prefix.c +16 -18
  102. data/ext/q_range.c +363 -31
  103. data/ext/q_span.c +130 -141
  104. data/ext/q_term.c +21 -21
  105. data/ext/q_wildcard.c +19 -23
  106. data/ext/r_analysis.c +369 -242
  107. data/ext/r_index.c +421 -434
  108. data/ext/r_qparser.c +142 -92
  109. data/ext/r_search.c +790 -407
  110. data/ext/r_store.c +44 -44
  111. data/ext/r_utils.c +264 -96
  112. data/ext/ram_store.c +29 -23
  113. data/ext/scanner.c +895 -0
  114. data/ext/scanner.h +36 -0
  115. data/ext/scanner_mb.c +6701 -0
  116. data/ext/scanner_utf8.c +4415 -0
  117. data/ext/search.c +210 -87
  118. data/ext/search.h +556 -488
  119. data/ext/similarity.c +17 -16
  120. data/ext/similarity.h +51 -44
  121. data/ext/sort.c +157 -354
  122. data/ext/stem_ISO_8859_1_hungarian.h +16 -0
  123. data/ext/stem_ISO_8859_2_romanian.h +16 -0
  124. data/ext/stem_UTF_8_hungarian.h +16 -0
  125. data/ext/stem_UTF_8_romanian.h +16 -0
  126. data/ext/stem_UTF_8_turkish.h +16 -0
  127. data/ext/stopwords.c +287 -278
  128. data/ext/store.c +57 -51
  129. data/ext/store.h +308 -286
  130. data/ext/symbol.c +10 -0
  131. data/ext/symbol.h +23 -0
  132. data/ext/term_vectors.c +14 -293
  133. data/ext/threading.h +22 -22
  134. data/ext/win32.h +12 -4
  135. data/lib/ferret.rb +2 -1
  136. data/lib/ferret/browser.rb +1 -1
  137. data/lib/ferret/field_symbol.rb +94 -0
  138. data/lib/ferret/index.rb +221 -34
  139. data/lib/ferret/number_tools.rb +6 -6
  140. data/lib/ferret/version.rb +3 -0
  141. data/test/{unit → long_running}/largefile/tc_largefile.rb +1 -1
  142. data/test/test_helper.rb +7 -2
  143. data/test/test_installed.rb +1 -0
  144. data/test/threading/thread_safety_index_test.rb +10 -1
  145. data/test/threading/thread_safety_read_write_test.rb +4 -7
  146. data/test/threading/thread_safety_test.rb +0 -0
  147. data/test/unit/analysis/tc_analyzer.rb +29 -27
  148. data/test/unit/analysis/tc_token_stream.rb +23 -16
  149. data/test/unit/index/tc_index.rb +116 -11
  150. data/test/unit/index/tc_index_reader.rb +27 -27
  151. data/test/unit/index/tc_index_writer.rb +10 -0
  152. data/test/unit/index/th_doc.rb +38 -21
  153. data/test/unit/search/tc_filter.rb +31 -10
  154. data/test/unit/search/tc_index_searcher.rb +6 -0
  155. data/test/unit/search/tm_searcher.rb +53 -1
  156. data/test/unit/store/tc_fs_store.rb +40 -2
  157. data/test/unit/store/tc_ram_store.rb +0 -0
  158. data/test/unit/store/tm_store.rb +0 -0
  159. data/test/unit/store/tm_store_lock.rb +7 -6
  160. data/test/unit/tc_field_symbol.rb +26 -0
  161. data/test/unit/ts_analysis.rb +0 -0
  162. data/test/unit/ts_index.rb +0 -0
  163. data/test/unit/ts_store.rb +0 -0
  164. data/test/unit/ts_utils.rb +0 -0
  165. data/test/unit/utils/tc_number_tools.rb +0 -0
  166. data/test/utils/content_generator.rb +226 -0
  167. metadata +262 -221
  168. data/ext/inc/lang.h +0 -48
  169. data/ext/inc/threading.h +0 -31
  170. data/ext/stem_ISO_8859_1_english.c +0 -1156
  171. data/ext/stem_ISO_8859_1_french.c +0 -1276
  172. data/ext/stem_ISO_8859_1_italian.c +0 -1091
  173. data/ext/stem_ISO_8859_1_norwegian.c +0 -296
  174. data/ext/stem_ISO_8859_1_spanish.c +0 -1119
  175. data/ext/stem_ISO_8859_1_swedish.c +0 -307
  176. data/ext/stem_UTF_8_danish.c +0 -344
  177. data/ext/stem_UTF_8_english.c +0 -1176
  178. data/ext/stem_UTF_8_french.c +0 -1296
  179. data/ext/stem_UTF_8_italian.c +0 -1113
  180. data/ext/stem_UTF_8_norwegian.c +0 -302
  181. data/ext/stem_UTF_8_portuguese.c +0 -1055
  182. data/ext/stem_UTF_8_russian.c +0 -709
  183. data/ext/stem_UTF_8_spanish.c +0 -1137
  184. data/ext/stem_UTF_8_swedish.c +0 -313
  185. data/lib/ferret_version.rb +0 -3
@@ -1,6 +1,10 @@
1
1
  #ifndef FRT_INDEX_H
2
2
  #define FRT_INDEX_H
3
3
 
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+
4
8
  #include "global.h"
5
9
  #include "document.h"
6
10
  #include "analysis.h"
@@ -12,17 +16,19 @@
12
16
  #include "bitvector.h"
13
17
  #include "priorityqueue.h"
14
18
 
15
- typedef struct IndexReader IndexReader;
16
- typedef struct MultiReader MultiReader;
17
- typedef struct Deleter Deleter;
19
+ typedef struct FrtIndexReader FrtIndexReader;
20
+ typedef struct FrtMultiReader FrtMultiReader;
21
+ typedef struct FrtDeleter FrtDeleter;
22
+
23
+ extern bool frt_file_name_filter_is_index_file(const char *file_name, bool include_locks);
18
24
 
19
25
  /****************************************************************************
20
26
  *
21
- * Config
27
+ * FrtConfig
22
28
  *
23
29
  ****************************************************************************/
24
30
 
25
- typedef struct Config
31
+ typedef struct FrtConfig
26
32
  {
27
33
  int chunk_size;
28
34
  int max_buffer_memory;
@@ -33,205 +39,209 @@ typedef struct Config
33
39
  int max_merge_docs;
34
40
  int max_field_length;
35
41
  bool use_compound_file;
36
- } Config;
42
+ } FrtConfig;
37
43
 
38
- extern const Config default_config;
44
+ extern const FrtConfig frt_default_config;
39
45
 
40
46
  /***************************************************************************
41
47
  *
42
- * CacheObject
48
+ * FrtCacheObject
43
49
  *
44
50
  ***************************************************************************/
45
51
 
46
- typedef struct CacheObject {
47
- HashTable *ref_tab1;
48
- HashTable *ref_tab2;
52
+ typedef struct FrtCacheObject {
53
+ FrtHash *ref_tab1;
54
+ FrtHash *ref_tab2;
49
55
  void *ref1;
50
56
  void *ref2;
51
57
  void *obj;
52
58
  void (*destroy)(void *p);
53
- } CacheObject;
59
+ } FrtCacheObject;
54
60
 
55
- extern void cache_destroy(CacheObject *co);
56
- extern CacheObject *co_create(HashTable *ref_tab1, HashTable *ref_tab2,
57
- void *ref1, void *ref2, void (*destroy)(void *p), void *obj);
58
- extern HashTable *co_hash_create();
61
+ extern void frt_cache_destroy(FrtCacheObject *co);
62
+ extern FrtCacheObject *frt_co_create(FrtHash *ref_tab1,
63
+ FrtHash *ref_tab2,
64
+ void *ref1, void *ref2, frt_free_ft destroy, void *obj);
65
+ extern FrtHash *frt_co_hash_create();
59
66
 
60
67
  /****************************************************************************
61
68
  *
62
- * FieldInfo
69
+ * FrtFieldInfo
63
70
  *
64
71
  ****************************************************************************/
65
72
 
66
- enum StoreValues
73
+ typedef enum
67
74
  {
68
- STORE_NO = 0,
69
- STORE_YES = 1,
70
- STORE_COMPRESS = 2
71
- };
75
+ FRT_STORE_NO = 0,
76
+ FRT_STORE_YES = 1,
77
+ FRT_STORE_COMPRESS = 2
78
+ } FrtStoreValue;
72
79
 
73
- enum IndexValues
80
+ typedef enum
74
81
  {
75
- INDEX_NO = 0,
76
- INDEX_UNTOKENIZED = 1,
77
- INDEX_YES = 3,
78
- INDEX_UNTOKENIZED_OMIT_NORMS = 5,
79
- INDEX_YES_OMIT_NORMS = 7
80
- };
82
+ FRT_INDEX_NO = 0,
83
+ FRT_INDEX_UNTOKENIZED = 1,
84
+ FRT_INDEX_YES = 3,
85
+ FRT_INDEX_UNTOKENIZED_OMIT_NORMS = 5,
86
+ FRT_INDEX_YES_OMIT_NORMS = 7
87
+ } FrtIndexValue;
81
88
 
82
- enum TermVectorValues
89
+ typedef enum
83
90
  {
84
- TERM_VECTOR_NO = 0,
85
- TERM_VECTOR_YES = 1,
86
- TERM_VECTOR_WITH_POSITIONS = 3,
87
- TERM_VECTOR_WITH_OFFSETS = 5,
88
- TERM_VECTOR_WITH_POSITIONS_OFFSETS = 7
89
- };
91
+ FRT_TERM_VECTOR_NO = 0,
92
+ FRT_TERM_VECTOR_YES = 1,
93
+ FRT_TERM_VECTOR_WITH_POSITIONS = 3,
94
+ FRT_TERM_VECTOR_WITH_OFFSETS = 5,
95
+ FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS = 7
96
+ } FrtTermVectorValue;
90
97
 
91
- #define FI_IS_STORED_BM 0x001
92
- #define FI_IS_COMPRESSED_BM 0x002
93
- #define FI_IS_INDEXED_BM 0x004
94
- #define FI_IS_TOKENIZED_BM 0x008
95
- #define FI_OMIT_NORMS_BM 0x010
96
- #define FI_STORE_TERM_VECTOR_BM 0x020
97
- #define FI_STORE_POSITIONS_BM 0x040
98
- #define FI_STORE_OFFSETS_BM 0x080
98
+ #define FRT_FI_IS_STORED_BM 0x001
99
+ #define FRT_FI_IS_COMPRESSED_BM 0x002
100
+ #define FRT_FI_IS_INDEXED_BM 0x004
101
+ #define FRT_FI_IS_TOKENIZED_BM 0x008
102
+ #define FRT_FI_OMIT_NORMS_BM 0x010
103
+ #define FRT_FI_STORE_TERM_VECTOR_BM 0x020
104
+ #define FRT_FI_STORE_POSITIONS_BM 0x040
105
+ #define FRT_FI_STORE_OFFSETS_BM 0x080
99
106
 
100
- typedef struct FieldInfo
107
+ typedef struct FrtFieldInfo
101
108
  {
102
- char *name;
109
+ FrtSymbol name;
103
110
  float boost;
104
111
  unsigned int bits;
105
112
  int number;
106
113
  int ref_cnt;
107
- } FieldInfo;
108
-
109
- extern FieldInfo *fi_new(const char *name,
110
- enum StoreValues store,
111
- enum IndexValues index,
112
- enum TermVectorValues term_vector);
113
- extern char *fi_to_s(FieldInfo *fi);
114
- extern void fi_deref(FieldInfo *fi);
115
-
116
- #define fi_is_stored(fi) (((fi)->bits & FI_IS_STORED_BM) != 0)
117
- #define fi_is_compressed(fi) (((fi)->bits & FI_IS_COMPRESSED_BM) != 0)
118
- #define fi_is_indexed(fi) (((fi)->bits & FI_IS_INDEXED_BM) != 0)
119
- #define fi_is_tokenized(fi) (((fi)->bits & FI_IS_TOKENIZED_BM) != 0)
120
- #define fi_omit_norms(fi) (((fi)->bits & FI_OMIT_NORMS_BM) != 0)
121
- #define fi_store_term_vector(fi) (((fi)->bits & FI_STORE_TERM_VECTOR_BM) != 0)
122
- #define fi_store_positions(fi) (((fi)->bits & FI_STORE_POSITIONS_BM) != 0)
123
- #define fi_store_offsets(fi) (((fi)->bits & FI_STORE_OFFSETS_BM) != 0)
114
+ } FrtFieldInfo;
115
+
116
+ extern FrtFieldInfo *frt_fi_new(FrtSymbol name,
117
+ FrtStoreValue store,
118
+ FrtIndexValue index,
119
+ FrtTermVectorValue term_vector);
120
+ extern char *frt_fi_to_s(FrtFieldInfo *fi);
121
+ extern void frt_fi_deref(FrtFieldInfo *fi);
122
+
123
+ #define fi_is_stored(fi) (((fi)->bits & FRT_FI_IS_STORED_BM) != 0)
124
+ #define fi_is_compressed(fi) (((fi)->bits & FRT_FI_IS_COMPRESSED_BM) != 0)
125
+ #define fi_is_indexed(fi) (((fi)->bits & FRT_FI_IS_INDEXED_BM) != 0)
126
+ #define fi_is_tokenized(fi) (((fi)->bits & FRT_FI_IS_TOKENIZED_BM) != 0)
127
+ #define fi_omit_norms(fi) (((fi)->bits & FRT_FI_OMIT_NORMS_BM) != 0)
128
+ #define fi_store_term_vector(fi) (((fi)->bits & FRT_FI_STORE_TERM_VECTOR_BM) != 0)
129
+ #define fi_store_positions(fi) (((fi)->bits & FRT_FI_STORE_POSITIONS_BM) != 0)
130
+ #define fi_store_offsets(fi) (((fi)->bits & FRT_FI_STORE_OFFSETS_BM) != 0)
124
131
  #define fi_has_norms(fi)\
125
- (((fi)->bits & (FI_OMIT_NORMS_BM|FI_IS_INDEXED_BM)) == FI_IS_INDEXED_BM)
132
+ (((fi)->bits & (FRT_FI_OMIT_NORMS_BM|FRT_FI_IS_INDEXED_BM)) == FRT_FI_IS_INDEXED_BM)
126
133
 
127
134
  /****************************************************************************
128
135
  *
129
- * FieldInfos
136
+ * FrtFieldInfos
130
137
  *
131
138
  ****************************************************************************/
132
139
 
133
140
  #define FIELD_INFOS_INIT_CAPA 4
134
141
  /* carry changes over to dummy_fis in test/test_segments.c */
135
- typedef struct FieldInfos
142
+ typedef struct FrtFieldInfos
136
143
  {
137
- int store;
138
- int index;
139
- int term_vector;
144
+ FrtStoreValue store;
145
+ FrtIndexValue index;
146
+ FrtTermVectorValue term_vector;
140
147
  int size;
141
148
  int capa;
142
- FieldInfo **fields;
143
- HashTable *field_dict;
149
+ FrtFieldInfo **fields;
150
+ FrtHash *field_dict;
144
151
  int ref_cnt;
145
- } FieldInfos;
146
-
147
- extern FieldInfos *fis_new(int store, int index, int term_vector);
148
- extern FieldInfo *fis_add_field(FieldInfos *fis, FieldInfo *fi);
149
- extern FieldInfo *fis_get_field(FieldInfos *fis, const char *name);
150
- extern int fis_get_field_num(FieldInfos *fis, const char *name);
151
- extern FieldInfo *fis_get_or_add_field(FieldInfos *fis, const char *name);
152
- extern void fis_write(FieldInfos *fis, OutStream *os);
153
- extern FieldInfos *fis_read(InStream *is);
154
- extern char *fis_to_s(FieldInfos *fis);
155
- extern void fis_deref(FieldInfos *fis);
152
+ } FrtFieldInfos;
153
+
154
+ FrtFieldInfos *frt_fis_new(FrtStoreValue store, FrtIndexValue index,
155
+ FrtTermVectorValue term_vector);
156
+ extern FrtFieldInfo *frt_fis_add_field(FrtFieldInfos *fis, FrtFieldInfo *fi);
157
+ extern FrtFieldInfo *frt_fis_get_field(FrtFieldInfos *fis, FrtSymbol name);
158
+ extern int frt_fis_get_field_num(FrtFieldInfos *fis, FrtSymbol name);
159
+ extern FrtFieldInfo *frt_fis_by_number(FrtFieldInfos *fis, int num);
160
+ extern FrtFieldInfo *frt_fis_get_or_add_field(FrtFieldInfos *fis,
161
+ FrtSymbol name);
162
+ extern void frt_fis_write(FrtFieldInfos *fis, FrtOutStream *os);
163
+ extern FrtFieldInfos *frt_fis_read(FrtInStream *is);
164
+ extern char *frt_fis_to_s(FrtFieldInfos *fis);
165
+ extern void frt_fis_deref(FrtFieldInfos *fis);
156
166
 
157
167
  /****************************************************************************
158
168
  *
159
- * SegmentInfo
169
+ * FrtSegmentInfo
160
170
  *
161
171
  ****************************************************************************/
162
172
 
163
- #define SEGMENT_NAME_MAX_LENGTH 100
164
- #define SEGMENTS_FILE_NAME "segments"
173
+ #define FRT_SEGMENT_NAME_MAX_LENGTH 100
174
+ #define FRT_SEGMENTS_FILE_NAME "segments"
165
175
 
166
- typedef struct SegmentInfo
176
+ typedef struct FrtSegmentInfo
167
177
  {
168
178
  int ref_cnt;
169
179
  char *name;
170
- Store *store;
180
+ FrtStore *store;
171
181
  int doc_cnt;
172
182
  int del_gen;
173
183
  int *norm_gens;
174
184
  int norm_gens_size;
175
185
  bool use_compound_file;
176
- } SegmentInfo;
186
+ } FrtSegmentInfo;
177
187
 
178
- extern SegmentInfo *si_new(char *name, int doc_cnt, Store *store);
179
- extern void si_deref(SegmentInfo *si);
180
- extern bool si_has_deletions(SegmentInfo *si);
181
- extern bool si_uses_compound_file(SegmentInfo *si);
182
- extern bool si_has_separate_norms(SegmentInfo *si);
183
- extern void si_advance_norm_gen(SegmentInfo *si, int field_num);
188
+ extern FrtSegmentInfo *frt_si_new(char *name, int doc_cnt, FrtStore *store);
189
+ extern void frt_si_deref(FrtSegmentInfo *si);
190
+ extern bool frt_si_has_deletions(FrtSegmentInfo *si);
191
+ extern bool frt_si_uses_compound_file(FrtSegmentInfo *si);
192
+ extern bool frt_si_has_separate_norms(FrtSegmentInfo *si);
193
+ extern void frt_si_advance_norm_gen(FrtSegmentInfo *si, int field_num);
184
194
 
185
195
  /****************************************************************************
186
196
  *
187
- * SegmentInfos
197
+ * FrtSegmentInfos
188
198
  *
189
199
  ****************************************************************************/
190
200
 
191
- typedef struct SegmentInfos
201
+ typedef struct FrtSegmentInfos
192
202
  {
193
- FieldInfos *fis;
194
- f_u64 counter;
195
- f_u64 version;
196
- f_i64 generation;
197
- f_i32 format;
198
- Store *store;
199
- SegmentInfo **segs;
203
+ FrtFieldInfos *fis;
204
+ frt_u64 counter;
205
+ frt_u64 version;
206
+ frt_i64 generation;
207
+ frt_i32 format;
208
+ FrtStore *store;
209
+ FrtSegmentInfo **segs;
200
210
  int size;
201
211
  int capa;
202
- } SegmentInfos;
203
-
204
- extern char *fn_for_generation(char *buf, char *base, char *ext, f_i64 gen);
205
-
206
- extern SegmentInfos *sis_new(FieldInfos *fis);
207
- extern SegmentInfo *sis_new_segment(SegmentInfos *sis, int dcnt, Store *store);
208
- extern SegmentInfo *sis_add_si(SegmentInfos *sis, SegmentInfo *si);
209
- extern void sis_del_at(SegmentInfos *sis, int at);
210
- extern void sis_del_from_to(SegmentInfos *sis, int from, int to);
211
- extern void sis_clear(SegmentInfos *sis);
212
- extern SegmentInfos *sis_read(Store *store);
213
- extern void sis_write(SegmentInfos *sis, Store *store, Deleter *deleter);
214
- extern f_u64 sis_read_current_version(Store *store);
215
- extern void sis_destroy(SegmentInfos *sis);
216
- extern f_i64 sis_current_segment_generation(Store *store);
217
- extern char *sis_curr_seg_file_name(char *buf, Store *store);
218
- extern void sis_put(SegmentInfos *sis, FILE *stream);
212
+ } FrtSegmentInfos;
213
+
214
+ extern char *frt_fn_for_generation(char *buf, char *base, char *ext, frt_i64 gen);
215
+
216
+ extern FrtSegmentInfos *frt_sis_new(FrtFieldInfos *fis);
217
+ extern FrtSegmentInfo *frt_sis_new_segment(FrtSegmentInfos *sis, int dcnt, FrtStore *store);
218
+ extern FrtSegmentInfo *frt_sis_add_si(FrtSegmentInfos *sis, FrtSegmentInfo *si);
219
+ extern void frt_sis_del_at(FrtSegmentInfos *sis, int at);
220
+ extern void frt_sis_del_from_to(FrtSegmentInfos *sis, int from, int to);
221
+ extern void frt_sis_clear(FrtSegmentInfos *sis);
222
+ extern FrtSegmentInfos *frt_sis_read(FrtStore *store);
223
+ extern void frt_sis_write(FrtSegmentInfos *sis, FrtStore *store, FrtDeleter *deleter);
224
+ extern frt_u64 frt_sis_read_current_version(FrtStore *store);
225
+ extern void frt_sis_destroy(FrtSegmentInfos *sis);
226
+ extern frt_i64 frt_sis_current_segment_generation(FrtStore *store);
227
+ extern char *frt_sis_curr_seg_file_name(char *buf, FrtStore *store);
228
+ extern void frt_sis_put(FrtSegmentInfos *sis, FILE *stream);
219
229
 
220
230
  /****************************************************************************
221
231
  *
222
- * TermInfo
232
+ * FrtTermInfo
223
233
  *
224
234
  ****************************************************************************/
225
235
 
226
- typedef struct TermInfo
236
+ typedef struct FrtTermInfo
227
237
  {
228
238
  int doc_freq;
229
239
  off_t frq_ptr;
230
240
  off_t prx_ptr;
231
241
  off_t skip_offset;
232
- } TermInfo;
242
+ } FrtTermInfo;
233
243
 
234
- #define ti_set(ti, mdf, mfp, mpp, mso) do {\
244
+ #define frt_ti_set(ti, mdf, mfp, mpp, mso) do {\
235
245
  (ti).doc_freq = mdf;\
236
246
  (ti).frq_ptr = mfp;\
237
247
  (ti).prx_ptr = mpp;\
@@ -240,183 +250,183 @@ typedef struct TermInfo
240
250
 
241
251
  /****************************************************************************
242
252
  *
243
- * TermEnum
253
+ * FrtTermEnum
244
254
  *
245
255
  ****************************************************************************/
246
256
 
247
- typedef struct TermEnum TermEnum;
257
+ typedef struct FrtTermEnum FrtTermEnum;
248
258
 
249
- struct TermEnum
259
+ struct FrtTermEnum
250
260
  {
251
- char curr_term[MAX_WORD_SIZE];
252
- char prev_term[MAX_WORD_SIZE];
253
- TermInfo curr_ti;
261
+ char curr_term[FRT_MAX_WORD_SIZE];
262
+ char prev_term[FRT_MAX_WORD_SIZE];
263
+ FrtTermInfo curr_ti;
254
264
  int curr_term_len;
255
265
  int field_num;
256
- TermEnum *(*set_field)(TermEnum *te, int field_num);
257
- char *(*next)(TermEnum *te);
258
- char *(*skip_to)(TermEnum *te, const char *term);
259
- void (*close)(TermEnum *te);
260
- TermEnum *(*clone)(TermEnum *te);
266
+ FrtTermEnum *(*set_field)(FrtTermEnum *te, int field_num);
267
+ char *(*next)(FrtTermEnum *te);
268
+ char *(*skip_to)(FrtTermEnum *te, const char *term);
269
+ void (*close)(FrtTermEnum *te);
270
+ FrtTermEnum *(*clone)(FrtTermEnum *te);
261
271
  };
262
272
 
263
- char *te_get_term(struct TermEnum *te);
264
- TermInfo *te_get_ti(struct TermEnum *te);
273
+ char *frt_te_get_term(struct FrtTermEnum *te);
274
+ FrtTermInfo *frt_te_get_ti(struct FrtTermEnum *te);
265
275
 
266
276
  /****************************************************************************
267
277
  *
268
- * SegmentTermEnum
278
+ * FrtSegmentTermEnum
269
279
  *
270
280
  ****************************************************************************/
271
281
 
272
- /* * SegmentTermIndex * */
282
+ /* * FrtSegmentTermIndex * */
273
283
 
274
- typedef struct SegmentTermIndex
284
+ typedef struct FrtSegmentTermIndex
275
285
  {
276
286
  off_t index_ptr;
277
287
  off_t ptr;
278
- int index_size;
288
+ int index_cnt;
279
289
  int size;
280
290
  char **index_terms;
281
291
  int *index_term_lens;
282
- TermInfo *index_term_infos;
292
+ FrtTermInfo *index_term_infos;
283
293
  off_t *index_ptrs;
284
- } SegmentTermIndex;
294
+ } FrtSegmentTermIndex;
285
295
 
286
- /* * SegmentFieldIndex * */
296
+ /* * FrtSegmentFieldIndex * */
287
297
 
288
- typedef struct SegmentTermEnum SegmentTermEnum;
298
+ typedef struct FrtSegmentTermEnum FrtSegmentTermEnum;
289
299
 
290
- typedef struct SegmentFieldIndex
300
+ typedef struct FrtSegmentFieldIndex
291
301
  {
292
- mutex_t mutex;
302
+ frt_mutex_t mutex;
293
303
  int skip_interval;
294
304
  int index_interval;
295
305
  off_t index_ptr;
296
- TermEnum *index_te;
297
- HashTable *field_dict;
298
- } SegmentFieldIndex;
306
+ FrtTermEnum *index_te;
307
+ FrtHash *field_dict;
308
+ } FrtSegmentFieldIndex;
299
309
 
300
- extern SegmentFieldIndex *sfi_open(Store *store, const char *segment);
301
- extern void sfi_close(SegmentFieldIndex *sfi);
310
+ extern FrtSegmentFieldIndex *frt_sfi_open(FrtStore *store, const char *segment);
311
+ extern void frt_sfi_close(FrtSegmentFieldIndex *sfi);
302
312
 
303
313
 
304
- /* * SegmentTermEnum * */
305
- struct SegmentTermEnum
314
+ /* * FrtSegmentTermEnum * */
315
+ struct FrtSegmentTermEnum
306
316
  {
307
- TermEnum te;
308
- InStream *is;
317
+ FrtTermEnum te;
318
+ FrtInStream *is;
309
319
  int size;
310
320
  int pos;
311
321
  int skip_interval;
312
- SegmentFieldIndex *sfi;
322
+ FrtSegmentFieldIndex *sfi;
313
323
  };
314
324
 
315
- extern void ste_close(TermEnum *te);
316
- extern TermEnum *ste_clone(TermEnum *te);
317
- extern TermEnum *ste_new(InStream *is, SegmentFieldIndex *sfi);
325
+ extern void frt_ste_close(FrtTermEnum *te);
326
+ extern FrtTermEnum *frt_ste_clone(FrtTermEnum *te);
327
+ extern FrtTermEnum *frt_ste_new(FrtInStream *is, FrtSegmentFieldIndex *sfi);
318
328
 
319
329
  /* * MultiTermEnum * */
320
330
 
321
- extern TermEnum *mte_new(MultiReader *mr, int field_num, const char *term);
331
+ extern FrtTermEnum *frt_mte_new(FrtMultiReader *mr, int field_num, const char *term);
322
332
 
323
333
  /****************************************************************************
324
334
  *
325
- * TermInfosReader
335
+ * FrtTermInfosReader
326
336
  *
327
337
  ****************************************************************************/
328
338
 
329
- #define TE_BUCKET_INIT_CAPA 1
339
+ #define FRT_TE_BUCKET_INIT_CAPA 1
330
340
 
331
- typedef struct TermInfosReader
341
+ typedef struct FrtTermInfosReader
332
342
  {
333
- thread_key_t thread_te;
343
+ frt_thread_key_t thread_te;
334
344
  void **te_bucket;
335
- TermEnum *orig_te;
345
+ FrtTermEnum *orig_te;
336
346
  int field_num;
337
- } TermInfosReader;
347
+ } FrtTermInfosReader;
338
348
 
339
- extern TermInfosReader *tir_open(Store *store,
340
- SegmentFieldIndex *sfi,
349
+ extern FrtTermInfosReader *frt_tir_open(FrtStore *store,
350
+ FrtSegmentFieldIndex *sfi,
341
351
  const char *segment);
342
- extern TermInfosReader *tir_set_field(TermInfosReader *tir, int field_num);
343
- extern TermInfo *tir_get_ti(TermInfosReader *tir, const char *term);
344
- extern char *tir_get_term(TermInfosReader *tir, int pos);
345
- extern void tir_close(TermInfosReader *tir);
352
+ extern FrtTermInfosReader *frt_tir_set_field(FrtTermInfosReader *tir, int field_num);
353
+ extern FrtTermInfo *frt_tir_get_ti(FrtTermInfosReader *tir, const char *term);
354
+ extern char *frt_tir_get_term(FrtTermInfosReader *tir, int pos);
355
+ extern void frt_tir_close(FrtTermInfosReader *tir);
346
356
 
347
357
  /****************************************************************************
348
358
  *
349
- * TermInfosWriter
359
+ * FrtTermInfosWriter
350
360
  *
351
361
  ****************************************************************************/
352
362
 
353
- #define INDEX_INTERVAL 128
354
- #define SKIP_INTERVAL 16
363
+ #define FRT_INDEX_INTERVAL 128
364
+ #define FRT_SKIP_INTERVAL 16
355
365
 
356
- typedef struct TermWriter
366
+ typedef struct FrtTermWriter
357
367
  {
358
368
  int counter;
359
369
  const char *last_term;
360
- TermInfo last_term_info;
361
- OutStream *os;
362
- } TermWriter;
370
+ FrtTermInfo last_term_info;
371
+ FrtOutStream *os;
372
+ } FrtTermWriter;
363
373
 
364
- typedef struct TermInfosWriter
374
+ typedef struct FrtTermInfosWriter
365
375
  {
366
376
  int field_count;
367
377
  int index_interval;
368
378
  int skip_interval;
369
379
  off_t last_index_ptr;
370
- OutStream *tfx_out;
371
- TermWriter *tix_writer;
372
- TermWriter *tis_writer;
373
- } TermInfosWriter;
380
+ FrtOutStream *tfx_out;
381
+ FrtTermWriter *tix_writer;
382
+ FrtTermWriter *tis_writer;
383
+ } FrtTermInfosWriter;
374
384
 
375
- extern TermInfosWriter *tiw_open(Store *store,
385
+ extern FrtTermInfosWriter *frt_tiw_open(FrtStore *store,
376
386
  const char *segment,
377
387
  int index_interval,
378
388
  int skip_interval);
379
- extern void tiw_start_field(TermInfosWriter *tiw, int field_num);
380
- extern void tiw_add(TermInfosWriter *tiw,
389
+ extern void frt_tiw_start_field(FrtTermInfosWriter *tiw, int field_num);
390
+ extern void frt_tiw_add(FrtTermInfosWriter *tiw,
381
391
  const char *term,
382
392
  int t_len,
383
- TermInfo *ti);
384
- extern void tiw_close(TermInfosWriter *tiw);
393
+ FrtTermInfo *ti);
394
+ extern void frt_tiw_close(FrtTermInfosWriter *tiw);
385
395
 
386
396
  /****************************************************************************
387
397
  *
388
- * TermDocEnum
398
+ * FrtTermDocEnum
389
399
  *
390
400
  ****************************************************************************/
391
401
 
392
- typedef struct TermDocEnum TermDocEnum;
393
- struct TermDocEnum
394
- {
395
- void (*seek)(TermDocEnum *tde, int field_num, const char *term);
396
- void (*seek_te)(TermDocEnum *tde, TermEnum *te);
397
- void (*seek_ti)(TermDocEnum *tde, TermInfo *ti);
398
- int (*doc_num)(TermDocEnum *tde);
399
- int (*freq)(TermDocEnum *tde);
400
- bool (*next)(TermDocEnum *tde);
401
- int (*read)(TermDocEnum *tde, int *docs, int *freqs, int req_num);
402
- bool (*skip_to)(TermDocEnum *tde, int target);
403
- int (*next_position)(TermDocEnum *tde);
404
- void (*close)(TermDocEnum *tde);
402
+ typedef struct FrtTermDocEnum FrtTermDocEnum;
403
+ struct FrtTermDocEnum
404
+ {
405
+ void (*seek)(FrtTermDocEnum *tde, int field_num, const char *term);
406
+ void (*seek_te)(FrtTermDocEnum *tde, FrtTermEnum *te);
407
+ void (*seek_ti)(FrtTermDocEnum *tde, FrtTermInfo *ti);
408
+ int (*doc_num)(FrtTermDocEnum *tde);
409
+ int (*freq)(FrtTermDocEnum *tde);
410
+ bool (*next)(FrtTermDocEnum *tde);
411
+ int (*read)(FrtTermDocEnum *tde, int *docs, int *freqs, int req_num);
412
+ bool (*skip_to)(FrtTermDocEnum *tde, int target);
413
+ int (*next_position)(FrtTermDocEnum *tde);
414
+ void (*close)(FrtTermDocEnum *tde);
405
415
  };
406
416
 
407
- /* * SegmentTermDocEnum * */
417
+ /* * FrtSegmentTermDocEnum * */
408
418
 
409
- typedef struct SegmentTermDocEnum SegmentTermDocEnum;
410
- struct SegmentTermDocEnum
419
+ typedef struct FrtSegmentTermDocEnum FrtSegmentTermDocEnum;
420
+ struct FrtSegmentTermDocEnum
411
421
  {
412
- TermDocEnum tde;
413
- void (*seek_prox)(SegmentTermDocEnum *stde, off_t prx_ptr);
414
- void (*skip_prox)(SegmentTermDocEnum *stde);
415
- TermInfosReader *tir;
416
- InStream *frq_in;
417
- InStream *prx_in;
418
- InStream *skip_in;
419
- BitVector *deleted_docs;
422
+ FrtTermDocEnum tde;
423
+ void (*seek_prox)(FrtSegmentTermDocEnum *stde, off_t prx_ptr);
424
+ void (*skip_prox)(FrtSegmentTermDocEnum *stde);
425
+ FrtTermInfosReader *tir;
426
+ FrtInStream *frq_in;
427
+ FrtInStream *prx_in;
428
+ FrtInStream *skip_in;
429
+ FrtBitVector *deleted_docs;
420
430
  int count; /* number of docs for this term skipped */
421
431
  int doc_freq; /* number of doc this term appears in */
422
432
  int doc_num;
@@ -433,451 +443,404 @@ struct SegmentTermDocEnum
433
443
  bool have_skipped : 1;
434
444
  };
435
445
 
436
- extern TermDocEnum *stde_new(TermInfosReader *tir, InStream *frq_in,
437
- BitVector *deleted_docs, int skip_interval);
446
+ extern FrtTermDocEnum *frt_stde_new(FrtTermInfosReader *tir, FrtInStream *frq_in,
447
+ FrtBitVector *deleted_docs, int skip_interval);
438
448
 
439
- /* * SegmentTermDocEnum * */
440
- extern TermDocEnum *stpe_new(TermInfosReader *tir, InStream *frq_in,
441
- InStream *prx_in, BitVector *deleted_docs,
449
+ /* * FrtSegmentTermDocEnum * */
450
+ extern FrtTermDocEnum *frt_stpe_new(FrtTermInfosReader *tir, FrtInStream *frq_in,
451
+ FrtInStream *prx_in, FrtBitVector *deleted_docs,
442
452
  int skip_interval);
443
453
 
444
454
  /****************************************************************************
445
455
  * MultipleTermDocPosEnum
446
456
  ****************************************************************************/
447
457
 
448
- extern TermDocEnum *mtdpe_new(IndexReader *ir, int field_num, char **terms,
458
+ extern FrtTermDocEnum *frt_mtdpe_new(FrtIndexReader *ir, int field_num, char **terms,
449
459
  int t_cnt);
450
460
 
451
461
  /****************************************************************************
452
462
  *
453
- * Offset
463
+ * FrtOffset
454
464
  *
455
465
  ****************************************************************************/
456
466
 
457
- typedef struct Offset
467
+ typedef struct FrtOffset
458
468
  {
459
469
  off_t start;
460
470
  off_t end;
461
- } Offset;
471
+ } FrtOffset;
462
472
 
463
- extern Offset *offset_new(off_t start, off_t end);
473
+ extern FrtOffset *frt_offset_new(off_t start, off_t end);
464
474
 
465
475
  /****************************************************************************
466
476
  *
467
- * Occurence
477
+ * FrtOccurence
468
478
  *
469
479
  ****************************************************************************/
470
480
 
471
- typedef struct Occurence
481
+ typedef struct FrtOccurence
472
482
  {
473
- struct Occurence *next;
483
+ struct FrtOccurence *next;
474
484
  int pos;
475
- } Occurence;
485
+ } FrtOccurence;
476
486
 
477
487
  /****************************************************************************
478
488
  *
479
- * Posting
489
+ * FrtPosting
480
490
  *
481
491
  ****************************************************************************/
482
492
 
483
- typedef struct Posting
493
+ typedef struct FrtPosting
484
494
  {
485
495
  int freq;
486
496
  int doc_num;
487
- Occurence *first_occ;
488
- struct Posting *next;
489
- } Posting;
497
+ FrtOccurence *first_occ;
498
+ struct FrtPosting *next;
499
+ } FrtPosting;
490
500
 
491
- extern Posting *p_new(MemoryPool *mp, int doc_num, int pos);
501
+ extern FrtPosting *frt_p_new(FrtMemoryPool *mp, int doc_num, int pos);
492
502
 
493
503
  /****************************************************************************
494
504
  *
495
- * PostingList
505
+ * FrtPostingList
496
506
  *
497
507
  ****************************************************************************/
498
508
 
499
- typedef struct PostingList
509
+ typedef struct FrtPostingList
500
510
  {
501
511
  const char *term;
502
512
  int term_len;
503
- Posting *first;
504
- Posting *last;
505
- Occurence *last_occ;
506
- } PostingList;
513
+ FrtPosting *first;
514
+ FrtPosting *last;
515
+ FrtOccurence *last_occ;
516
+ } FrtPostingList;
507
517
 
508
- extern PostingList *pl_new(MemoryPool *mp, const char *term,
509
- int term_len, Posting *p);
510
- extern void pl_add_occ(MemoryPool *mp, PostingList *pl, int pos);
518
+ extern FrtPostingList *frt_pl_new(FrtMemoryPool *mp, const char *term,
519
+ int term_len, FrtPosting *p);
520
+ extern void frt_pl_add_occ(FrtMemoryPool *mp, FrtPostingList *pl, int pos);
521
+ extern int frt_pl_cmp(const FrtPostingList **pl1, const FrtPostingList **pl2);
511
522
 
512
523
  /****************************************************************************
513
524
  *
514
- * TVField
525
+ * FrtTVField
515
526
  *
516
527
  ****************************************************************************/
517
528
 
518
- typedef struct TVField
529
+ typedef struct FrtTVField
519
530
  {
520
531
  int field_num;
521
532
  int size;
522
- } TVField;
533
+ } FrtTVField;
523
534
 
524
535
  /****************************************************************************
525
536
  *
526
- * TVTerm
537
+ * FrtTVTerm
527
538
  *
528
539
  ****************************************************************************/
529
540
 
530
- typedef struct TVTerm
541
+ typedef struct FrtTVTerm
531
542
  {
532
543
  char *text;
533
544
  int freq;
534
545
  int *positions;
535
- } TVTerm;
546
+ } FrtTVTerm;
536
547
 
537
548
  /****************************************************************************
538
549
  *
539
- * TermVector
550
+ * FrtTermVector
540
551
  *
541
552
  ****************************************************************************/
542
553
 
543
- typedef struct TermVector
554
+ #define FRT_TV_FIELD_INIT_CAPA 8
555
+ typedef struct FrtTermVector
544
556
  {
545
- int field_num;
546
- char *field;
547
- int term_cnt;
548
- TVTerm *terms;
549
- int offset_cnt;
550
- Offset *offsets;
551
- } TermVector;
557
+ int field_num;
558
+ FrtSymbol field;
559
+ int term_cnt;
560
+ FrtTVTerm *terms;
561
+ int offset_cnt;
562
+ FrtOffset *offsets;
563
+ } FrtTermVector;
552
564
 
553
- extern void tv_destroy(TermVector *tv);
554
- extern int tv_get_tv_term_index(TermVector *tv, const char *term);
555
- extern TVTerm *tv_get_tv_term(TermVector *tv, const char *term);
565
+ extern void frt_tv_destroy(FrtTermVector *tv);
566
+ extern int frt_tv_get_term_index(FrtTermVector *tv, const char *term);
567
+ extern int frt_tv_scan_to_term_index(FrtTermVector *tv, const char *term);
568
+ extern FrtTVTerm *frt_tv_get_tv_term(FrtTermVector *tv, const char *term);
556
569
 
557
570
  /****************************************************************************
558
571
  *
559
- * TermVectorsWriter
572
+ * FrtLazyDoc
560
573
  *
561
574
  ****************************************************************************/
562
575
 
563
- #define TV_FIELD_INIT_CAPA 8
564
-
565
- typedef struct TermVectorsWriter
566
- {
567
- OutStream *tvx_out;
568
- OutStream *tvd_out;
569
- FieldInfos *fis;
570
- TVField *fields;
571
- off_t tvd_ptr;
572
- } TermVectorsWriter;
573
-
574
- extern TermVectorsWriter *tvw_open(Store *store,
575
- const char *segment,
576
- FieldInfos *fis);
577
- extern void tvw_open_doc(TermVectorsWriter *tvw);
578
- extern void tvw_close_doc(TermVectorsWriter *tvw);
579
- extern void tvw_add_postings(TermVectorsWriter *tvw,
580
- int field_num,
581
- PostingList **plists,
582
- int posting_count,
583
- Offset *offsets,
584
- int offset_count);
585
- extern void tvw_close(TermVectorsWriter *tvw);
586
-
587
- /****************************************************************************
588
- *
589
- * TermVectorsReader
590
- *
591
- ****************************************************************************/
592
-
593
- typedef struct TermVectorsReader
594
- {
595
- int size;
596
- InStream *tvx_in;
597
- InStream *tvd_in;
598
- FieldInfos *fis;
599
- } TermVectorsReader;
600
-
601
- extern TermVectorsReader *tvr_open(Store *store,
602
- const char *segment,
603
- FieldInfos *fis);
604
- extern TermVectorsReader *tvr_clone(TermVectorsReader *orig);
605
- extern void tvr_close(TermVectorsReader *tvr);
606
- extern HashTable *tvr_get_tv(TermVectorsReader *tvr, int doc_num);
607
- extern TermVector *tvr_get_field_tv(TermVectorsReader *tvr,
608
- int doc_num,
609
- int field_num);
610
-
611
- /****************************************************************************
612
- *
613
- * LazyDoc
614
- *
615
- ****************************************************************************/
616
-
617
- /* * * LazyDocField * * */
618
- typedef struct LazyDocFieldData
576
+ /* * * FrtLazyDocField * * */
577
+ typedef struct FrtLazyDocFieldData
619
578
  {
620
579
  off_t start;
621
580
  int length;
622
581
  char *text;
623
- } LazyDocFieldData;
582
+ } FrtLazyDocFieldData;
624
583
 
625
- typedef struct LazyDoc LazyDoc;
626
- typedef struct LazyDocField
584
+ typedef struct FrtLazyDoc FrtLazyDoc;
585
+ typedef struct FrtLazyDocField
627
586
  {
628
- char *name;
629
- int size; /* number of data elements */
630
- LazyDocFieldData *data;
631
- int len; /* length of data elements concatenated */
632
- LazyDoc *doc;
633
- } LazyDocField;
587
+ FrtSymbol name;
588
+ FrtLazyDocFieldData *data;
589
+ FrtLazyDoc *doc;
590
+ int size; /* number of data elements */
591
+ int len; /* length of data elements concatenated */
592
+ bool is_compressed : 2; /* set to 2 after all data is loaded */
593
+ } FrtLazyDocField;
634
594
 
635
- extern char *lazy_df_get_data(LazyDocField *self, int i);
636
- extern void lazy_df_get_bytes(LazyDocField *self, char *buf,
595
+ extern char *frt_lazy_df_get_data(FrtLazyDocField *self, int i);
596
+ extern void frt_lazy_df_get_bytes(FrtLazyDocField *self, char *buf,
637
597
  int start, int len);
638
598
 
639
- /* * * LazyDoc * * */
640
- struct LazyDoc
599
+ /* * * FrtLazyDoc * * */
600
+ struct FrtLazyDoc
641
601
  {
642
- HashTable *field_dict;
602
+ FrtHash *field_dictionary;
643
603
  int size;
644
- LazyDocField **fields;
645
- InStream *fields_in;
604
+ FrtLazyDocField **fields;
605
+ FrtInStream *fields_in;
646
606
  };
647
607
 
648
- extern void lazy_doc_close(LazyDoc *self);
608
+ extern void frt_lazy_doc_close(FrtLazyDoc *self);
609
+ extern FrtLazyDocField *frt_lazy_doc_get(FrtLazyDoc *self, FrtSymbol field);
649
610
 
650
611
  /****************************************************************************
651
612
  *
652
- * FieldsReader
613
+ * FrtFieldsReader
653
614
  *
654
615
  ****************************************************************************/
655
616
 
656
- typedef struct FieldsReader
617
+ typedef struct FrtFieldsReader
657
618
  {
658
- int size;
659
- FieldInfos *fis;
660
- Store *store;
661
- InStream *fdx_in;
662
- InStream *fdt_in;
663
- } FieldsReader;
664
-
665
- extern FieldsReader *fr_open(Store *store,
666
- const char *segment, FieldInfos *fis);
667
- extern FieldsReader *fr_clone(FieldsReader *orig);
668
- extern void fr_close(FieldsReader *fr);
669
- extern Document *fr_get_doc(FieldsReader *fr, int doc_num);
670
- extern LazyDoc *fr_get_lazy_doc(FieldsReader *fr, int doc_num);
671
- extern HashTable *fr_get_tv(FieldsReader *fr, int doc_num);
672
- extern TermVector *fr_get_field_tv(FieldsReader *fr, int doc_num,
673
- int field_num);
619
+ int size;
620
+ FrtFieldInfos *fis;
621
+ FrtStore *store;
622
+ FrtInStream *fdx_in;
623
+ FrtInStream *fdt_in;
624
+ } FrtFieldsReader;
625
+
626
+ extern FrtFieldsReader *frt_fr_open(FrtStore *store,
627
+ const char *segment, FrtFieldInfos *fis);
628
+ extern FrtFieldsReader *frt_fr_clone(FrtFieldsReader *orig);
629
+ extern void frt_fr_close(FrtFieldsReader *fr);
630
+ extern FrtDocument *frt_fr_get_doc(FrtFieldsReader *fr, int doc_num);
631
+ extern FrtLazyDoc *frt_fr_get_lazy_doc(FrtFieldsReader *fr, int doc_num);
632
+ extern FrtHash *frt_fr_get_tv(FrtFieldsReader *fr, int doc_num);
633
+ extern FrtTermVector *frt_fr_get_field_tv(FrtFieldsReader *fr, int doc_num,
634
+ int field_num);
674
635
 
675
636
  /****************************************************************************
676
637
  *
677
- * FieldsWriter
638
+ * FrtFieldsWriter
678
639
  *
679
640
  ****************************************************************************/
680
641
 
681
- typedef struct FieldsWriter
642
+ typedef struct FrtFieldsWriter
682
643
  {
683
- FieldInfos *fis;
684
- OutStream *fdt_out;
685
- OutStream *fdx_out;
686
- TVField *tv_fields;
644
+ FrtFieldInfos *fis;
645
+ FrtOutStream *fdt_out;
646
+ FrtOutStream *fdx_out;
647
+ FrtOutStream *buffer;
648
+ FrtTVField *tv_fields;
687
649
  off_t start_ptr;
688
- } FieldsWriter;
650
+ } FrtFieldsWriter;
689
651
 
690
- extern FieldsWriter *fw_open(Store *store,
691
- const char *segment, FieldInfos *fis);
692
- extern void fw_close(FieldsWriter *fw);
693
- extern void fw_add_doc(FieldsWriter *fw, Document *doc);
694
- extern void fw_add_postings(FieldsWriter *fw,
652
+ extern FrtFieldsWriter *frt_fw_open(FrtStore *store,
653
+ const char *segment, FrtFieldInfos *fis);
654
+ extern void frt_fw_close(FrtFieldsWriter *fw);
655
+ extern void frt_fw_add_doc(FrtFieldsWriter *fw, FrtDocument *doc);
656
+ extern void frt_fw_add_postings(FrtFieldsWriter *fw,
695
657
  int field_num,
696
- PostingList **plists,
658
+ FrtPostingList **plists,
697
659
  int posting_count,
698
- Offset *offsets,
660
+ FrtOffset *offsets,
699
661
  int offset_count);
700
- extern void fw_write_tv_index(FieldsWriter *fw);
662
+ extern void frt_fw_write_tv_index(FrtFieldsWriter *fw);
701
663
 
702
664
  /****************************************************************************
703
665
  *
704
- * Deleter
666
+ * FrtDeleter
705
667
  *
706
- * A utility class (used by both IndexReader and IndexWriter) to keep track of
668
+ * A utility class (used by both FrtIndexReader and FrtIndexWriter) to keep track of
707
669
  * files that need to be deleted because they are no longer referenced by the
708
670
  * index.
709
671
  *
710
672
  ****************************************************************************/
711
673
 
712
- struct Deleter
674
+ struct FrtDeleter
713
675
  {
714
- Store *store;
715
- SegmentInfos *sis;
716
- HashSet *pending;
676
+ FrtStore *store;
677
+ FrtSegmentInfos *sis;
678
+ FrtHashSet *pending;
717
679
  };
718
680
 
719
- extern Deleter *deleter_new(SegmentInfos *sis, Store *store);
720
- extern void deleter_destroy(Deleter *dlr);
721
- extern void deleter_clear_pending_files(Deleter *dlr);
722
- extern void deleter_delete_file(Deleter *dlr, char *file_name);
723
- extern void deleter_find_deletable_files(Deleter *dlr);
724
- extern void deleter_commit_pending_files(Deleter *dlr);
725
- extern void deleter_delete_files(Deleter *dlr, char **files, int file_cnt);
681
+ extern FrtDeleter *frt_deleter_new(FrtSegmentInfos *sis, FrtStore *store);
682
+ extern void frt_deleter_destroy(FrtDeleter *dlr);
683
+ extern void frt_deleter_clear_pending_files(FrtDeleter *dlr);
684
+ extern void frt_deleter_delete_file(FrtDeleter *dlr, char *file_name);
685
+ extern void frt_deleter_find_deletable_files(FrtDeleter *dlr);
686
+ extern void frt_deleter_commit_pending_files(FrtDeleter *dlr);
687
+ extern void frt_deleter_delete_files(FrtDeleter *dlr, char **files, int file_cnt);
726
688
 
727
689
  /****************************************************************************
728
690
  *
729
- * IndexReader
691
+ * FrtIndexReader
730
692
  *
731
693
  ****************************************************************************/
732
694
 
733
- #define WRITE_LOCK_NAME "write"
734
- #define COMMIT_LOCK_NAME "commit"
735
-
736
- struct IndexReader
737
- {
738
- int (*num_docs)(IndexReader *ir);
739
- int (*max_doc)(IndexReader *ir);
740
- Document *(*get_doc)(IndexReader *ir, int doc_num);
741
- LazyDoc *(*get_lazy_doc)(IndexReader *ir, int doc_num);
742
- uchar *(*get_norms)(IndexReader *ir, int field_num);
743
- uchar *(*get_norms_into)(IndexReader *ir, int field_num,
744
- uchar *buf);
745
- TermEnum *(*terms)(IndexReader *ir, int field_num);
746
- TermEnum *(*terms_from)(IndexReader *ir, int field_num,
747
- const char *term);
748
- int (*doc_freq)(IndexReader *ir, int field_num,
749
- const char *term);
750
- TermDocEnum *(*term_docs)(IndexReader *ir);
751
- TermDocEnum *(*term_positions)(IndexReader *ir);
752
- TermVector *(*term_vector)(IndexReader *ir, int doc_num,
753
- const char *field);
754
- HashTable *(*term_vectors)(IndexReader *ir, int doc_num);
755
- bool (*is_deleted)(IndexReader *ir, int doc_num);
756
- bool (*has_deletions)(IndexReader *ir);
757
- void (*acquire_write_lock)(IndexReader *ir);
758
- void (*set_norm_i)(IndexReader *ir, int doc_num, int field_num,
759
- uchar val);
760
- void (*delete_doc_i)(IndexReader *ir, int doc_num);
761
- void (*undelete_all_i)(IndexReader *ir);
762
- void (*set_deleter_i)(IndexReader *ir, Deleter *dlr);
763
- bool (*is_latest_i)(IndexReader *ir);
764
- void (*commit_i)(IndexReader *ir);
765
- void (*close_i)(IndexReader *ir);
766
- int ref_cnt;
767
- Deleter *deleter;
768
- Store *store;
769
- Lock *write_lock;
770
- SegmentInfos *sis;
771
- FieldInfos *fis;
772
- HashTable *cache;
773
- HashTable *sort_cache;
774
- uchar *fake_norms;
775
- mutex_t mutex;
776
- bool has_changes : 1;
777
- bool is_stale : 1;
778
- bool is_owner : 1;
695
+ #define FRT_WRITE_LOCK_NAME "write"
696
+ #define FRT_COMMIT_LOCK_NAME "commit"
697
+
698
+ struct FrtIndexReader
699
+ {
700
+ int (*num_docs)(FrtIndexReader *ir);
701
+ int (*max_doc)(FrtIndexReader *ir);
702
+ FrtDocument *(*get_doc)(FrtIndexReader *ir, int doc_num);
703
+ FrtLazyDoc *(*get_lazy_doc)(FrtIndexReader *ir, int doc_num);
704
+ frt_uchar *(*get_norms)(FrtIndexReader *ir, int field_num);
705
+ frt_uchar *(*get_norms_into)(FrtIndexReader *ir, int field_num,
706
+ frt_uchar *buf);
707
+ FrtTermEnum *(*terms)(FrtIndexReader *ir, int field_num);
708
+ FrtTermEnum *(*terms_from)(FrtIndexReader *ir, int field_num,
709
+ const char *term);
710
+ int (*doc_freq)(FrtIndexReader *ir, int field_num,
711
+ const char *term);
712
+ FrtTermDocEnum *(*term_docs)(FrtIndexReader *ir);
713
+ FrtTermDocEnum *(*term_positions)(FrtIndexReader *ir);
714
+ FrtTermVector *(*term_vector)(FrtIndexReader *ir, int doc_num,
715
+ FrtSymbol field);
716
+ FrtHash *(*term_vectors)(FrtIndexReader *ir, int doc_num);
717
+ bool (*is_deleted)(FrtIndexReader *ir, int doc_num);
718
+ bool (*has_deletions)(FrtIndexReader *ir);
719
+ void (*acquire_write_lock)(FrtIndexReader *ir);
720
+ void (*set_norm_i)(FrtIndexReader *ir, int doc_num,
721
+ int field_num, frt_uchar val);
722
+ void (*delete_doc_i)(FrtIndexReader *ir, int doc_num);
723
+ void (*undelete_all_i)(FrtIndexReader *ir);
724
+ void (*set_deleter_i)(FrtIndexReader *ir, FrtDeleter *dlr);
725
+ bool (*is_latest_i)(FrtIndexReader *ir);
726
+ void (*commit_i)(FrtIndexReader *ir);
727
+ void (*close_i)(FrtIndexReader *ir);
728
+ int ref_cnt;
729
+ FrtDeleter *deleter;
730
+ FrtStore *store;
731
+ FrtLock *write_lock;
732
+ FrtSegmentInfos *sis;
733
+ FrtFieldInfos *fis;
734
+ FrtHash *cache;
735
+ FrtHash *field_index_cache;
736
+ frt_mutex_t field_index_mutex;
737
+ frt_uchar *fake_norms;
738
+ frt_mutex_t mutex;
739
+ bool has_changes : 1;
740
+ bool is_stale : 1;
741
+ bool is_owner : 1;
779
742
  };
780
743
 
781
- extern IndexReader *ir_create(Store *store, SegmentInfos *sis, int is_owner);
782
- extern IndexReader *ir_open(Store *store);
783
- extern int ir_get_field_num(IndexReader *ir, const char *field);
784
- extern bool ir_index_exists(Store *store);
785
- extern void ir_close(IndexReader *ir);
786
- extern void ir_commit(IndexReader *ir);
787
- extern void ir_delete_doc(IndexReader *ir, int doc_num);
788
- extern void ir_undelete_all(IndexReader *ir);
789
- extern int ir_doc_freq(IndexReader *ir, const char *field, const char *term);
790
- extern void ir_set_norm(IndexReader *ir, int doc_num, const char *field,
791
- uchar val);
792
- extern uchar *ir_get_norms_i(IndexReader *ir, int field_num);
793
- extern uchar *ir_get_norms(IndexReader *ir, const char *field);
794
- extern uchar *ir_get_norms_into(IndexReader *ir, const char *field, uchar *buf);
795
- extern void ir_destroy(IndexReader *self);
796
- extern Document *ir_get_doc_with_term(IndexReader *ir, const char *field,
744
+ extern FrtIndexReader *frt_ir_create(FrtStore *store, FrtSegmentInfos *sis, int is_owner);
745
+ extern FrtIndexReader *frt_ir_open(FrtStore *store);
746
+ extern int frt_ir_get_field_num(FrtIndexReader *ir, FrtSymbol field);
747
+ extern bool frt_ir_index_exists(FrtStore *store);
748
+ extern void frt_ir_close(FrtIndexReader *ir);
749
+ extern void frt_ir_commit(FrtIndexReader *ir);
750
+ extern void frt_ir_delete_doc(FrtIndexReader *ir, int doc_num);
751
+ extern void frt_ir_undelete_all(FrtIndexReader *ir);
752
+ extern int frt_ir_doc_freq(FrtIndexReader *ir, FrtSymbol field, const char *term);
753
+ extern void frt_ir_set_norm(FrtIndexReader *ir, int doc_num, FrtSymbol field,
754
+ frt_uchar val);
755
+ extern frt_uchar *frt_ir_get_norms_i(FrtIndexReader *ir, int field_num);
756
+ extern frt_uchar *frt_ir_get_norms(FrtIndexReader *ir, FrtSymbol field);
757
+ extern frt_uchar *frt_ir_get_norms_into(FrtIndexReader *ir, FrtSymbol field, frt_uchar *buf);
758
+ extern void frt_ir_destroy(FrtIndexReader *self);
759
+ extern FrtDocument *frt_ir_get_doc_with_term(FrtIndexReader *ir, FrtSymbol field,
797
760
  const char *term);
798
- extern TermEnum *ir_terms(IndexReader *ir, const char *field);
799
- extern TermEnum *ir_terms_from(IndexReader *ir, const char *field,
761
+ extern FrtTermEnum *frt_ir_terms(FrtIndexReader *ir, FrtSymbol field);
762
+ extern FrtTermEnum *frt_ir_terms_from(FrtIndexReader *ir, FrtSymbol field,
800
763
  const char *t);
801
- extern TermDocEnum *ir_term_docs_for(IndexReader *ir, const char *field,
764
+ extern FrtTermDocEnum *frt_ir_term_docs_for(FrtIndexReader *ir, FrtSymbol field,
802
765
  const char *term);
803
- extern TermDocEnum *ir_term_positions_for(IndexReader *ir, const char *fld,
804
- const char *t);
805
- extern void ir_add_cache(IndexReader *ir);
806
- extern bool ir_is_latest(IndexReader *ir);
766
+ extern FrtTermDocEnum *frt_ir_term_positions_for(FrtIndexReader *ir,
767
+ FrtSymbol field,
768
+ const char *t);
769
+ extern void frt_ir_add_cache(FrtIndexReader *ir);
770
+ extern bool frt_ir_is_latest(FrtIndexReader *ir);
807
771
 
808
772
  /****************************************************************************
809
- * MultiReader
773
+ * FrtMultiReader
810
774
  ****************************************************************************/
811
775
 
812
- struct MultiReader {
813
- IndexReader ir;
776
+ struct FrtMultiReader {
777
+ FrtIndexReader ir;
814
778
  int max_doc;
815
779
  int num_docs_cache;
816
780
  int r_cnt;
817
781
  int *starts;
818
- IndexReader **sub_readers;
819
- HashTable *norms_cache;
782
+ FrtIndexReader **sub_readers;
783
+ FrtHash *norms_cache;
820
784
  bool has_deletions : 1;
821
785
  int **field_num_map;
822
786
  };
823
787
 
824
- extern int mr_get_field_num(MultiReader *mr, int ir_num, int f_num);
825
- extern IndexReader *mr_open(IndexReader **sub_readers, const int r_cnt);
788
+ extern int frt_mr_get_field_num(FrtMultiReader *mr, int ir_num, int f_num);
789
+ extern FrtIndexReader *frt_mr_open(FrtIndexReader **sub_readers, const int r_cnt);
826
790
 
827
791
 
828
792
  /****************************************************************************
829
793
  *
830
- * Boost
794
+ * FrtBoost
831
795
  *
832
796
  ****************************************************************************/
833
797
 
834
- typedef struct Boost
798
+ typedef struct FrtBoost
835
799
  {
836
800
  float val;
837
801
  int doc_num;
838
- struct Boost *next;
839
- } Boost;
802
+ struct FrtBoost *next;
803
+ } FrtBoost;
840
804
 
841
805
  /****************************************************************************
842
806
  *
843
- * FieldInverter
807
+ * FrtFieldInverter
844
808
  *
845
809
  ****************************************************************************/
846
810
 
847
- typedef struct FieldInverter
811
+ typedef struct FrtFieldInverter
848
812
  {
849
- HashTable *plists;
850
- uchar *norms;
851
- FieldInfo *fi;
813
+ FrtHash *plists;
814
+ frt_uchar *norms;
815
+ FrtFieldInfo *fi;
852
816
  int length;
853
817
  bool is_tokenized : 1;
854
818
  bool store_term_vector : 1;
855
819
  bool store_offsets : 1;
856
820
  bool has_norms : 1;
857
- } FieldInverter;
821
+ } FrtFieldInverter;
858
822
 
859
823
  /****************************************************************************
860
824
  *
861
- * DocWriter
825
+ * FrtDocWriter
862
826
  *
863
827
  ****************************************************************************/
864
828
 
865
829
  #define DW_OFFSET_INIT_CAPA 512
866
- typedef struct IndexWriter IndexWriter;
867
-
868
- typedef struct DocWriter
869
- {
870
- Store *store;
871
- SegmentInfo *si;
872
- FieldInfos *fis;
873
- TermVectorsWriter *tvw;
874
- FieldsWriter *fw;
875
- MemoryPool *mp;
876
- Analyzer *analyzer;
877
- HashTable *curr_plists;
878
- HashTable *fields;
879
- Similarity *similarity;
880
- Offset *offsets;
830
+ typedef struct FrtIndexWriter FrtIndexWriter;
831
+
832
+ typedef struct FrtDocWriter
833
+ {
834
+ FrtStore *store;
835
+ FrtSegmentInfo *si;
836
+ FrtFieldInfos *fis;
837
+ FrtFieldsWriter *fw;
838
+ FrtMemoryPool *mp;
839
+ FrtAnalyzer *analyzer;
840
+ FrtHash *curr_plists;
841
+ FrtHash *fields;
842
+ FrtSimilarity *similarity;
843
+ FrtOffset *offsets;
881
844
  int offsets_size;
882
845
  int offsets_capa;
883
846
  int doc_num;
@@ -885,77 +848,88 @@ typedef struct DocWriter
885
848
  int skip_interval;
886
849
  int max_field_length;
887
850
  int max_buffered_docs;
888
- } DocWriter;
851
+ } FrtDocWriter;
889
852
 
890
- extern DocWriter *dw_open(IndexWriter *is, SegmentInfo *si);
891
- extern void dw_close(DocWriter *dw);
892
- extern void dw_add_doc(DocWriter *dw, Document *doc);
893
- extern void dw_new_segment(DocWriter *dw, SegmentInfo *si);
853
+ extern FrtDocWriter *frt_dw_open(FrtIndexWriter *is, FrtSegmentInfo *si);
854
+ extern void frt_dw_close(FrtDocWriter *dw);
855
+ extern void frt_dw_add_doc(FrtDocWriter *dw, FrtDocument *doc);
856
+ extern void frt_dw_new_segment(FrtDocWriter *dw, FrtSegmentInfo *si);
857
+ /* For testing. need to remove somehow. FIXME */
858
+ extern FrtHash *frt_dw_invert_field(FrtDocWriter *dw,
859
+ FrtFieldInverter *fld_inv,
860
+ FrtDocField *df);
861
+ extern FrtFieldInverter *frt_dw_get_fld_inv(FrtDocWriter *dw, FrtFieldInfo *fi);
862
+ extern void frt_dw_reset_postings(FrtHash *postings);
894
863
 
895
864
  /****************************************************************************
896
865
  *
897
- * IndexWriter
866
+ * FrtIndexWriter
898
867
  *
899
868
  ****************************************************************************/
900
869
 
901
- typedef struct DelTerm
870
+ typedef struct FrtDelTerm
902
871
  {
903
872
  int field_num;
904
873
  char *term;
905
- } DelTerm;
906
-
907
- struct IndexWriter
908
- {
909
- Config config;
910
- mutex_t mutex;
911
- Store *store;
912
- Analyzer *analyzer;
913
- SegmentInfos *sis;
914
- FieldInfos *fis;
915
- DocWriter *dw;
916
- Similarity *similarity;
917
- Lock *write_lock;
918
- Deleter *deleter;
874
+ } FrtDelTerm;
875
+
876
+ struct FrtIndexWriter
877
+ {
878
+ FrtConfig config;
879
+ frt_mutex_t mutex;
880
+ FrtStore *store;
881
+ FrtAnalyzer *analyzer;
882
+ FrtSegmentInfos *sis;
883
+ FrtFieldInfos *fis;
884
+ FrtDocWriter *dw;
885
+ FrtSimilarity *similarity;
886
+ FrtLock *write_lock;
887
+ FrtDeleter *deleter;
919
888
  };
920
889
 
921
- extern void index_create(Store *store, FieldInfos *fis);
922
- extern bool index_is_locked(Store *store);
923
- extern IndexWriter *iw_open(Store *store, volatile Analyzer *analyzer,
924
- const Config *config);
925
- extern void iw_delete_term(IndexWriter *iw, const char *field,
890
+ extern void frt_index_create(FrtStore *store, FrtFieldInfos *fis);
891
+ extern bool frt_index_is_locked(FrtStore *store);
892
+ extern FrtIndexWriter *frt_iw_open(FrtStore *store, FrtAnalyzer *analyzer,
893
+ const FrtConfig *config);
894
+ extern void frt_iw_delete_term(FrtIndexWriter *iw, FrtSymbol field,
926
895
  const char *term);
927
- extern void iw_close(IndexWriter *iw);
928
- extern void iw_add_doc(IndexWriter *iw, Document *doc);
929
- extern int iw_doc_count(IndexWriter *iw);
930
- extern void iw_commit(IndexWriter *iw);
931
- extern void iw_optimize(IndexWriter *iw);
932
- extern void iw_add_readers(IndexWriter *iw, IndexReader **readers,
896
+ extern void frt_iw_delete_terms(FrtIndexWriter *iw, FrtSymbol field,
897
+ char **terms, const int term_cnt);
898
+ extern void frt_iw_close(FrtIndexWriter *iw);
899
+ extern void frt_iw_add_doc(FrtIndexWriter *iw, FrtDocument *doc);
900
+ extern int frt_iw_doc_count(FrtIndexWriter *iw);
901
+ extern void frt_iw_commit(FrtIndexWriter *iw);
902
+ extern void frt_iw_optimize(FrtIndexWriter *iw);
903
+ extern void frt_iw_add_readers(FrtIndexWriter *iw, FrtIndexReader **readers,
933
904
  const int r_cnt);
934
905
 
935
906
  /****************************************************************************
936
907
  *
937
- * CompoundWriter
908
+ * FrtCompoundWriter
938
909
  *
939
910
  ****************************************************************************/
940
911
 
941
- #define CW_INIT_CAPA 16
942
- typedef struct CWFileEntry
912
+ #define FRT_CW_INIT_CAPA 16
913
+ typedef struct FrtCWFileEntry
943
914
  {
944
915
  char *name;
945
916
  off_t dir_offset;
946
917
  off_t data_offset;
947
- } CWFileEntry;
918
+ } FrtCWFileEntry;
948
919
 
949
- typedef struct CompoundWriter {
950
- Store *store;
920
+ typedef struct FrtCompoundWriter {
921
+ FrtStore *store;
951
922
  const char *name;
952
- HashSet *ids;
953
- CWFileEntry *file_entries;
954
- } CompoundWriter;
923
+ FrtHashSet *ids;
924
+ FrtCWFileEntry *file_entries;
925
+ } FrtCompoundWriter;
955
926
 
956
- extern CompoundWriter *open_cw(Store *store, char *name);
957
- extern void cw_add_file(CompoundWriter *cw, char *id);
958
- extern void cw_close(CompoundWriter *cw);
927
+ extern FrtCompoundWriter *frt_open_cw(FrtStore *store, char *name);
928
+ extern void frt_cw_add_file(FrtCompoundWriter *cw, char *id);
929
+ extern void frt_cw_close(FrtCompoundWriter *cw);
959
930
 
931
+ #ifdef __cplusplus
932
+ } // extern "C"
933
+ #endif
960
934
 
961
935
  #endif