isomorfeus-ferret 0.13.8 → 0.13.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/isomorfeus_ferret_ext/bm_store.c +3 -3
- data/ext/isomorfeus_ferret_ext/bzlib.h +83 -82
- data/ext/isomorfeus_ferret_ext/frb_index.c +17 -23
- data/ext/isomorfeus_ferret_ext/frb_search.c +1 -4
- data/ext/isomorfeus_ferret_ext/frb_store.c +32 -34
- data/ext/isomorfeus_ferret_ext/frt_analysis.c +4 -4
- data/ext/isomorfeus_ferret_ext/frt_analysis.h +9 -9
- data/ext/isomorfeus_ferret_ext/frt_bitvector.c +1 -1
- data/ext/isomorfeus_ferret_ext/frt_bitvector.h +1 -1
- data/ext/isomorfeus_ferret_ext/frt_compound_io.c +41 -66
- data/ext/isomorfeus_ferret_ext/frt_config.h +8 -0
- data/ext/isomorfeus_ferret_ext/frt_except.c +1 -0
- data/ext/isomorfeus_ferret_ext/frt_filter.c +2 -4
- data/ext/isomorfeus_ferret_ext/frt_fs_store.c +24 -19
- data/ext/isomorfeus_ferret_ext/frt_global.c +6 -4
- data/ext/isomorfeus_ferret_ext/frt_global.h +1 -1
- data/ext/isomorfeus_ferret_ext/frt_hash.c +40 -48
- data/ext/isomorfeus_ferret_ext/frt_hash.h +14 -16
- data/ext/isomorfeus_ferret_ext/frt_hashset.c +5 -5
- data/ext/isomorfeus_ferret_ext/frt_ind.c +2 -3
- data/ext/isomorfeus_ferret_ext/frt_index.c +148 -219
- data/ext/isomorfeus_ferret_ext/frt_index.h +31 -31
- data/ext/isomorfeus_ferret_ext/frt_lang.c +1 -4
- data/ext/isomorfeus_ferret_ext/frt_multimapper.c +8 -9
- data/ext/isomorfeus_ferret_ext/frt_multimapper.h +1 -1
- data/ext/isomorfeus_ferret_ext/frt_q_boolean.c +6 -6
- data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +8 -3
- data/ext/isomorfeus_ferret_ext/frt_q_parser.c +1743 -1742
- data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +1 -2
- data/ext/isomorfeus_ferret_ext/frt_q_span.c +11 -10
- data/ext/isomorfeus_ferret_ext/frt_ram_store.c +24 -40
- data/ext/isomorfeus_ferret_ext/frt_search.c +29 -28
- data/ext/isomorfeus_ferret_ext/frt_search.h +18 -19
- data/ext/isomorfeus_ferret_ext/frt_store.c +47 -40
- data/ext/isomorfeus_ferret_ext/frt_store.h +46 -48
- data/ext/isomorfeus_ferret_ext/frt_threading.h +12 -5
- data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +4 -3
- data/ext/isomorfeus_ferret_ext/test_1710.c +1 -2
- data/ext/isomorfeus_ferret_ext/test_compound_io.c +8 -8
- data/ext/isomorfeus_ferret_ext/test_fields.c +7 -7
- data/ext/isomorfeus_ferret_ext/test_file_deleter.c +1 -1
- data/ext/isomorfeus_ferret_ext/test_filter.c +4 -3
- data/ext/isomorfeus_ferret_ext/test_fs_store.c +1 -1
- data/ext/isomorfeus_ferret_ext/test_highlighter.c +3 -1
- data/ext/isomorfeus_ferret_ext/test_index.c +61 -61
- data/ext/isomorfeus_ferret_ext/test_q_const_score.c +2 -1
- data/ext/isomorfeus_ferret_ext/test_q_filtered.c +3 -2
- data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +3 -1
- data/ext/isomorfeus_ferret_ext/test_q_span.c +8 -1
- data/ext/isomorfeus_ferret_ext/test_ram_store.c +4 -4
- data/ext/isomorfeus_ferret_ext/test_search.c +9 -4
- data/ext/isomorfeus_ferret_ext/test_segments.c +4 -3
- data/ext/isomorfeus_ferret_ext/test_sort.c +17 -9
- data/ext/isomorfeus_ferret_ext/test_term.c +4 -2
- data/ext/isomorfeus_ferret_ext/test_term_vectors.c +2 -2
- data/ext/isomorfeus_ferret_ext/test_threading.c +5 -4
- data/lib/isomorfeus/ferret/index/index.rb +8 -3
- data/lib/isomorfeus/ferret/version.rb +1 -1
- metadata +16 -2
@@ -27,7 +27,6 @@ static int phrase_pos_cmp(const void *p1, const void *p2) {
|
|
27
27
|
return strcmp(((FrtPhrasePosition *)p1)->terms[0], ((FrtPhrasePosition *)p2)->terms[0]);
|
28
28
|
}
|
29
29
|
|
30
|
-
|
31
30
|
/***************************************************************************
|
32
31
|
*
|
33
32
|
* PhraseScorer
|
@@ -1061,7 +1060,7 @@ static FrtQuery *phq_rewrite(FrtQuery *self, FrtIndexReader *ir)
|
|
1061
1060
|
return q;
|
1062
1061
|
}
|
1063
1062
|
} else {
|
1064
|
-
self
|
1063
|
+
FRT_REF(self);
|
1065
1064
|
return self;
|
1066
1065
|
}
|
1067
1066
|
}
|
@@ -66,11 +66,11 @@ static FrtMatchVector *mv_to_term_mv(FrtMatchVector *term_mv, FrtMatchVector *fu
|
|
66
66
|
typedef struct TVTermDocEnum
|
67
67
|
{
|
68
68
|
FrtTermDocEnum super;
|
69
|
-
int
|
70
|
-
int
|
71
|
-
int
|
72
|
-
int
|
73
|
-
FrtTermVector
|
69
|
+
int doc;
|
70
|
+
int index;
|
71
|
+
int freq;
|
72
|
+
int *positions;
|
73
|
+
FrtTermVector *tv;
|
74
74
|
} TVTermDocEnum;
|
75
75
|
|
76
76
|
static void tv_tde_seek(FrtTermDocEnum *tde, int field_num, const char *term)
|
@@ -131,7 +131,7 @@ static int tv_tde_doc_num(FrtTermDocEnum *tde)
|
|
131
131
|
static FrtTermDocEnum *spanq_ir_term_positions(FrtIndexReader *ir)
|
132
132
|
{
|
133
133
|
TVTermDocEnum *tv_tde = FRT_ALLOC(TVTermDocEnum);
|
134
|
-
FrtTermDocEnum *tde
|
134
|
+
FrtTermDocEnum *tde = (FrtTermDocEnum *)tv_tde;
|
135
135
|
tv_tde->tv = (FrtTermVector *)ir->store;
|
136
136
|
tde->seek = &tv_tde_seek;
|
137
137
|
tde->doc_num = &tv_tde_doc_num;
|
@@ -154,6 +154,7 @@ static FrtMatchVector *spanq_get_matchv_i(FrtQuery *self, FrtMatchVector *mv, Fr
|
|
154
154
|
ir->fis = frt_fis_new(FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_NO, FRT_TERM_VECTOR_NO);
|
155
155
|
frt_fis_add_field(ir->fis, frt_fi_new(tv->field, FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_NO, FRT_TERM_VECTOR_NO));
|
156
156
|
ir->store = (FrtStore *)tv;
|
157
|
+
FRT_REF((FrtStore *)tv);
|
157
158
|
ir->term_positions = &spanq_ir_term_positions;
|
158
159
|
sp_enum = SpQ(self)->get_spans(self, ir);
|
159
160
|
while (sp_enum->next(sp_enum)) {
|
@@ -1727,7 +1728,7 @@ static FrtQuery *spanfq_rewrite(FrtQuery *self, FrtIndexReader *ir) {
|
|
1727
1728
|
frt_q_deref(q);
|
1728
1729
|
SpFQ(self)->match = rq;
|
1729
1730
|
|
1730
|
-
self
|
1731
|
+
FRT_REF(self);
|
1731
1732
|
return self; /* no clauses rewrote */
|
1732
1733
|
}
|
1733
1734
|
|
@@ -1864,7 +1865,7 @@ static FrtQuery *spanoq_rewrite(FrtQuery *self, FrtIndexReader *ir) {
|
|
1864
1865
|
soq->clauses[i] = rewritten;
|
1865
1866
|
}
|
1866
1867
|
|
1867
|
-
self
|
1868
|
+
FRT_REF(self);
|
1868
1869
|
return self;
|
1869
1870
|
}
|
1870
1871
|
|
@@ -2050,7 +2051,7 @@ static FrtQuery *spannq_rewrite(FrtQuery *self, FrtIndexReader *ir)
|
|
2050
2051
|
snq->clauses[i] = rewritten;
|
2051
2052
|
}
|
2052
2053
|
|
2053
|
-
self
|
2054
|
+
FRT_REF(self);
|
2054
2055
|
return self;
|
2055
2056
|
}
|
2056
2057
|
|
@@ -2207,7 +2208,7 @@ static FrtQuery *spanxq_rewrite(FrtQuery *self, FrtIndexReader *ir) {
|
|
2207
2208
|
frt_q_deref(q);
|
2208
2209
|
sxq->exc = rq;
|
2209
2210
|
|
2210
|
-
self
|
2211
|
+
FRT_REF(self);
|
2211
2212
|
return self;
|
2212
2213
|
}
|
2213
2214
|
|
@@ -20,17 +20,16 @@ static void rf_extend_if_necessary(FrtRAMFile *rf, int buf_num) {
|
|
20
20
|
}
|
21
21
|
|
22
22
|
static void rf_close(void *p) {
|
23
|
-
int i;
|
24
23
|
FrtRAMFile *rf = (FrtRAMFile *)p;
|
25
|
-
if (rf
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
if (FRT_DEREF(rf) == 0) {
|
25
|
+
int i;
|
26
|
+
free(rf->name);
|
27
|
+
for (i = 0; i < rf->bufcnt; i++) {
|
28
|
+
free(rf->buffers[i]);
|
29
|
+
}
|
30
|
+
free(rf->buffers);
|
31
|
+
free(rf);
|
31
32
|
}
|
32
|
-
free(rf->buffers);
|
33
|
-
free(rf);
|
34
33
|
}
|
35
34
|
|
36
35
|
static void ram_touch(FrtStore *store, const char *filename) {
|
@@ -50,7 +49,6 @@ static int ram_exists(FrtStore *store, const char *filename) {
|
|
50
49
|
static int ram_remove(FrtStore *store, const char *filename) {
|
51
50
|
FrtRAMFile *rf = (FrtRAMFile *)frt_h_rem(store->dir.ht, filename, false);
|
52
51
|
if (rf != NULL) {
|
53
|
-
FRT_DEREF(rf);
|
54
52
|
rf_close(rf);
|
55
53
|
return true;
|
56
54
|
} else {
|
@@ -74,7 +72,7 @@ static void ram_rename(FrtStore *store, const char *from, const char *to) {
|
|
74
72
|
/* clean up the file we are overwriting */
|
75
73
|
tmp = (FrtRAMFile *)frt_h_get(store->dir.ht, to);
|
76
74
|
if (tmp != NULL) {
|
77
|
-
|
75
|
+
frt_h_del(store->dir.ht, to);
|
78
76
|
}
|
79
77
|
|
80
78
|
frt_h_set(store->dir.ht, rf->name, rf);
|
@@ -99,16 +97,7 @@ static void ram_each(FrtStore *store, void (*func)(const char *fname, void *arg)
|
|
99
97
|
}
|
100
98
|
|
101
99
|
static void ram_close_i(FrtStore *store) {
|
102
|
-
FrtHash *ht = store->dir.ht;
|
103
|
-
int i;
|
104
|
-
for (i = 0; i <= ht->mask; i++) {
|
105
|
-
FrtRAMFile *rf = (FrtRAMFile *)ht->table[i].value;
|
106
|
-
if (rf) {
|
107
|
-
FRT_DEREF(rf);
|
108
|
-
}
|
109
|
-
}
|
110
100
|
frt_h_destroy(store->dir.ht);
|
111
|
-
frt_store_destroy(store);
|
112
101
|
}
|
113
102
|
|
114
103
|
/*
|
@@ -120,7 +109,6 @@ static void ram_clear(FrtStore *store) {
|
|
120
109
|
for (i = 0; i <= ht->mask; i++) {
|
121
110
|
FrtRAMFile *rf = (FrtRAMFile *)ht->table[i].value;
|
122
111
|
if (rf && !frt_file_is_lock(rf->name)) {
|
123
|
-
FRT_DEREF(rf);
|
124
112
|
frt_h_del(ht, rf->name);
|
125
113
|
}
|
126
114
|
}
|
@@ -132,7 +120,6 @@ static void ram_clear_locks(FrtStore *store) {
|
|
132
120
|
for (i = 0; i <= ht->mask; i++) {
|
133
121
|
FrtRAMFile *rf = (FrtRAMFile *)ht->table[i].value;
|
134
122
|
if (rf && frt_file_is_lock(rf->name)) {
|
135
|
-
FRT_DEREF(rf);
|
136
123
|
frt_h_del(ht, rf->name);
|
137
124
|
}
|
138
125
|
}
|
@@ -144,13 +131,12 @@ static void ram_clear_all(FrtStore *store) {
|
|
144
131
|
for (i = 0; i <= ht->mask; i++) {
|
145
132
|
FrtRAMFile *rf = (FrtRAMFile *)ht->table[i].value;
|
146
133
|
if (rf) {
|
147
|
-
FRT_DEREF(rf);
|
148
134
|
frt_h_del(ht, rf->name);
|
149
135
|
}
|
150
136
|
}
|
151
137
|
}
|
152
138
|
|
153
|
-
static
|
139
|
+
static frt_off_t ram_length(FrtStore *store, const char *filename) {
|
154
140
|
FrtRAMFile *rf = (FrtRAMFile *)frt_h_get(store->dir.ht, filename);
|
155
141
|
if (rf != NULL) {
|
156
142
|
return rf->len;
|
@@ -165,7 +151,7 @@ static void ramo_flush_i(FrtOutStream *os, const frt_uchar *src, int len) {
|
|
165
151
|
FrtRAMFile *rf = os->file.rf;
|
166
152
|
int buffer_number, buffer_offset, bytes_in_buffer, bytes_to_copy;
|
167
153
|
int src_offset;
|
168
|
-
|
154
|
+
frt_off_t pointer = os->pointer;
|
169
155
|
|
170
156
|
buffer_number = (int)(pointer / FRT_BUFFER_SIZE);
|
171
157
|
buffer_offset = pointer % FRT_BUFFER_SIZE;
|
@@ -193,7 +179,7 @@ static void ramo_flush_i(FrtOutStream *os, const frt_uchar *src, int len) {
|
|
193
179
|
}
|
194
180
|
}
|
195
181
|
|
196
|
-
static void ramo_seek_i(FrtOutStream *os,
|
182
|
+
static void ramo_seek_i(FrtOutStream *os, frt_off_t pos) {
|
197
183
|
os->pointer = pos;
|
198
184
|
}
|
199
185
|
|
@@ -203,9 +189,7 @@ void frt_ramo_reset(FrtOutStream *os) {
|
|
203
189
|
}
|
204
190
|
|
205
191
|
static void ramo_close_i(FrtOutStream *os) {
|
206
|
-
|
207
|
-
FRT_DEREF(rf);
|
208
|
-
rf_close(rf);
|
192
|
+
rf_close(os->file.rf);
|
209
193
|
}
|
210
194
|
|
211
195
|
void frt_ramo_write_to(FrtOutStream *os, FrtOutStream *other_o) {
|
@@ -232,8 +216,6 @@ static const struct FrtOutStreamMethods RAM_OUT_STREAM_METHODS = {
|
|
232
216
|
FrtOutStream *frt_ram_new_buffer(void) {
|
233
217
|
FrtRAMFile *rf = rf_new("");
|
234
218
|
FrtOutStream *os = frt_os_new();
|
235
|
-
|
236
|
-
FRT_DEREF(rf);
|
237
219
|
os->file.rf = rf;
|
238
220
|
os->pointer = 0;
|
239
221
|
os->m = &RAM_OUT_STREAM_METHODS;
|
@@ -261,12 +243,12 @@ static FrtOutStream *ram_new_output(FrtStore *store, const char *filename) {
|
|
261
243
|
}
|
262
244
|
|
263
245
|
static void rami_read_i(FrtInStream *is, frt_uchar *b, int len) {
|
264
|
-
FrtRAMFile *rf = is->file.rf;
|
246
|
+
FrtRAMFile *rf = is->f->file.rf;
|
265
247
|
|
266
248
|
int offset = 0;
|
267
249
|
int buffer_number, buffer_offset, bytes_in_buffer, bytes_to_copy;
|
268
250
|
int remainder = len;
|
269
|
-
|
251
|
+
frt_off_t start = is->d.pointer;
|
270
252
|
frt_uchar *buffer;
|
271
253
|
|
272
254
|
while (remainder > 0) {
|
@@ -289,17 +271,16 @@ static void rami_read_i(FrtInStream *is, frt_uchar *b, int len) {
|
|
289
271
|
is->d.pointer += len;
|
290
272
|
}
|
291
273
|
|
292
|
-
static
|
293
|
-
return is->file.rf->len;
|
274
|
+
static frt_off_t rami_length_i(FrtInStream *is) {
|
275
|
+
return is->f->file.rf->len;
|
294
276
|
}
|
295
277
|
|
296
|
-
static void rami_seek_i(FrtInStream *is,
|
278
|
+
static void rami_seek_i(FrtInStream *is, frt_off_t pos) {
|
297
279
|
is->d.pointer = pos;
|
298
280
|
}
|
299
281
|
|
300
282
|
static void rami_close_i(FrtInStream *is) {
|
301
|
-
FrtRAMFile *rf = is->file.rf;
|
302
|
-
FRT_DEREF(rf);
|
283
|
+
FrtRAMFile *rf = is->f->file.rf;
|
303
284
|
rf_close(rf);
|
304
285
|
}
|
305
286
|
|
@@ -319,7 +300,8 @@ static FrtInStream *ram_open_input(FrtStore *store, const char *filename) {
|
|
319
300
|
}
|
320
301
|
FRT_REF(rf);
|
321
302
|
is = frt_is_new();
|
322
|
-
is->file.rf = rf;
|
303
|
+
is->f->file.rf = rf;
|
304
|
+
is->f->ref_cnt = 1;
|
323
305
|
is->d.pointer = 0;
|
324
306
|
is->m = &RAM_IN_STREAM_METHODS;
|
325
307
|
|
@@ -351,6 +333,7 @@ static FrtLock *ram_open_lock_i(FrtStore *store, const char *lockname) {
|
|
351
333
|
snprintf(lname, 100, "%s%s.lck", FRT_LOCK_PREFIX, lockname);
|
352
334
|
lock->name = frt_estrdup(lname);
|
353
335
|
lock->store = store;
|
336
|
+
FRT_REF(store);
|
354
337
|
lock->obtain = &ram_lock_obtain;
|
355
338
|
lock->release = &ram_lock_release;
|
356
339
|
lock->is_locked = &ram_lock_is_locked;
|
@@ -359,6 +342,7 @@ static FrtLock *ram_open_lock_i(FrtStore *store, const char *lockname) {
|
|
359
342
|
}
|
360
343
|
|
361
344
|
static void ram_close_lock_i(FrtLock *lock) {
|
345
|
+
FRT_DEREF(lock->store);
|
362
346
|
free(lock->name);
|
363
347
|
free(lock);
|
364
348
|
}
|
@@ -415,7 +399,7 @@ FrtStore *frt_open_ram_store_and_copy(FrtStore *store, FrtStore *from_store, boo
|
|
415
399
|
from_store->each(from_store, ©_files, &cfa);
|
416
400
|
|
417
401
|
if (close_dir) {
|
418
|
-
|
402
|
+
frt_store_close(from_store);
|
419
403
|
}
|
420
404
|
|
421
405
|
return store;
|
@@ -303,7 +303,7 @@ const char *frt_q_get_query_name(FrtQueryType type) {
|
|
303
303
|
static FrtQuery *q_rewrite(FrtQuery *self, FrtIndexReader *ir)
|
304
304
|
{
|
305
305
|
(void)ir;
|
306
|
-
self
|
306
|
+
FRT_REF(self);
|
307
307
|
return self;
|
308
308
|
}
|
309
309
|
|
@@ -318,13 +318,12 @@ FrtSimilarity *frt_q_get_similarity_i(FrtQuery *self, FrtSearcher *searcher) {
|
|
318
318
|
return searcher->get_similarity(searcher);
|
319
319
|
}
|
320
320
|
|
321
|
-
void frt_q_destroy_i(FrtQuery *
|
322
|
-
free(
|
321
|
+
void frt_q_destroy_i(FrtQuery *q) {
|
322
|
+
free(q);
|
323
323
|
}
|
324
324
|
|
325
|
-
void frt_q_deref(FrtQuery *
|
326
|
-
if (
|
327
|
-
self->destroy_i(self);
|
325
|
+
void frt_q_deref(FrtQuery *q) {
|
326
|
+
if (FRT_DEREF(q) == 0) q->destroy_i(q);
|
328
327
|
}
|
329
328
|
|
330
329
|
FrtWeight *frt_q_create_weight_unsup(FrtQuery *self, FrtSearcher *searcher) {
|
@@ -1180,11 +1179,13 @@ static FrtTermVector *isea_get_term_vector(FrtSearcher *self, const int doc_num,
|
|
1180
1179
|
return ir->term_vector(ir, doc_num, field);
|
1181
1180
|
}
|
1182
1181
|
|
1183
|
-
static void isea_close(FrtSearcher *
|
1184
|
-
if (
|
1185
|
-
|
1182
|
+
static void isea_close(FrtSearcher *isea) {
|
1183
|
+
if (FRT_DEREF(isea) == 0) {
|
1184
|
+
if (ISEA(isea)->ir) {
|
1185
|
+
frt_ir_close(ISEA(isea)->ir);
|
1186
|
+
}
|
1187
|
+
free(isea);
|
1186
1188
|
}
|
1187
|
-
free(self);
|
1188
1189
|
}
|
1189
1190
|
|
1190
1191
|
FrtSearcher *frt_isea_alloc(void) {
|
@@ -1193,8 +1194,8 @@ FrtSearcher *frt_isea_alloc(void) {
|
|
1193
1194
|
|
1194
1195
|
FrtSearcher *frt_isea_init(FrtSearcher *self, FrtIndexReader *ir) {
|
1195
1196
|
ISEA(self)->ir = ir;
|
1196
|
-
|
1197
|
-
|
1197
|
+
FRT_REF(ir);
|
1198
|
+
self->ref_cnt = 1;
|
1198
1199
|
self->similarity = frt_sim_create_default();
|
1199
1200
|
self->doc_freq = &frt_isea_doc_freq;
|
1200
1201
|
self->get_doc = &isea_get_doc;
|
@@ -1304,7 +1305,7 @@ static void cdfsea_search_each_w(FrtSearcher *self, FrtWeight *w, FrtFilter *fil
|
|
1304
1305
|
static FrtQuery *cdfsea_rewrite(FrtSearcher *self, FrtQuery *original)
|
1305
1306
|
{
|
1306
1307
|
(void)self;
|
1307
|
-
original
|
1308
|
+
FRT_REF(original);
|
1308
1309
|
return original;
|
1309
1310
|
}
|
1310
1311
|
|
@@ -1721,31 +1722,32 @@ static FrtSimilarity *msea_get_similarity(FrtSearcher *self) {
|
|
1721
1722
|
return self->similarity;
|
1722
1723
|
}
|
1723
1724
|
|
1724
|
-
static void msea_close(FrtSearcher *
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
for (i = 0; i <
|
1730
|
-
s =
|
1725
|
+
static void msea_close(FrtSearcher *msea) {
|
1726
|
+
if (FRT_DEREF(msea) == 0) {
|
1727
|
+
FrtMultiSearcher *rmsea = MSEA(msea);
|
1728
|
+
FrtSearcher *s;
|
1729
|
+
int i;
|
1730
|
+
for (i = 0; i < rmsea->s_cnt; i++) {
|
1731
|
+
s = rmsea->searchers[i];
|
1731
1732
|
s->close(s);
|
1732
1733
|
}
|
1734
|
+
free(rmsea->searchers);
|
1735
|
+
free(rmsea->starts);
|
1736
|
+
free(msea);
|
1733
1737
|
}
|
1734
|
-
free(msea->searchers);
|
1735
|
-
free(msea->starts);
|
1736
|
-
free(self);
|
1737
1738
|
}
|
1738
1739
|
|
1739
1740
|
FrtSearcher *frt_msea_alloc(void) {
|
1740
1741
|
return (FrtSearcher *)FRT_ALLOC(FrtMultiSearcher);
|
1741
1742
|
}
|
1742
1743
|
|
1743
|
-
FrtSearcher *frt_msea_init(FrtSearcher *self, FrtSearcher **searchers, int s_cnt
|
1744
|
+
FrtSearcher *frt_msea_init(FrtSearcher *self, FrtSearcher **searchers, int s_cnt) {
|
1744
1745
|
int i, max_doc = 0;
|
1745
1746
|
int *starts = FRT_ALLOC_N(int, s_cnt + 1);
|
1746
1747
|
for (i = 0; i < s_cnt; i++) {
|
1747
1748
|
starts[i] = max_doc;
|
1748
1749
|
max_doc += searchers[i]->max_doc(searchers[i]);
|
1750
|
+
FRT_REF(searchers[i]);
|
1749
1751
|
}
|
1750
1752
|
starts[i] = max_doc;
|
1751
1753
|
|
@@ -1753,8 +1755,7 @@ FrtSearcher *frt_msea_init(FrtSearcher *self, FrtSearcher **searchers, int s_cnt
|
|
1753
1755
|
MSEA(self)->searchers = searchers;
|
1754
1756
|
MSEA(self)->starts = starts;
|
1755
1757
|
MSEA(self)->max_doc = max_doc;
|
1756
|
-
|
1757
|
-
|
1758
|
+
self->ref_cnt = 1;
|
1758
1759
|
self->similarity = frt_sim_create_default();
|
1759
1760
|
self->doc_freq = &msea_doc_freq;
|
1760
1761
|
self->get_doc = &msea_get_doc;
|
@@ -1777,7 +1778,7 @@ FrtSearcher *frt_msea_init(FrtSearcher *self, FrtSearcher **searchers, int s_cnt
|
|
1777
1778
|
return self;
|
1778
1779
|
}
|
1779
1780
|
|
1780
|
-
FrtSearcher *frt_msea_new(FrtSearcher **searchers, int s_cnt
|
1781
|
+
FrtSearcher *frt_msea_new(FrtSearcher **searchers, int s_cnt) {
|
1781
1782
|
FrtSearcher *self = frt_msea_alloc();
|
1782
|
-
return frt_msea_init(self, searchers, s_cnt
|
1783
|
+
return frt_msea_init(self, searchers, s_cnt);
|
1783
1784
|
}
|
@@ -103,7 +103,7 @@ typedef struct FrtFilter {
|
|
103
103
|
unsigned long long (*hash)(struct FrtFilter *self);
|
104
104
|
int (*eq)(struct FrtFilter *self, struct FrtFilter *o);
|
105
105
|
void (*destroy_i)(struct FrtFilter *self);
|
106
|
-
int
|
106
|
+
_Atomic unsigned int ref_cnt;
|
107
107
|
VALUE rfilter;
|
108
108
|
} FrtFilter;
|
109
109
|
|
@@ -228,7 +228,7 @@ typedef enum {
|
|
228
228
|
} FrtQueryType;
|
229
229
|
|
230
230
|
struct FrtQuery {
|
231
|
-
int
|
231
|
+
_Atomic unsigned int ref_cnt;
|
232
232
|
float boost;
|
233
233
|
FrtWeight *weight;
|
234
234
|
FrtQuery *(*rewrite)(FrtQuery *self, FrtIndexReader *ir);
|
@@ -264,7 +264,7 @@ extern FrtQuery *frt_q_create(size_t size);
|
|
264
264
|
|
265
265
|
typedef struct FrtTermQuery {
|
266
266
|
FrtQuery super;
|
267
|
-
ID
|
267
|
+
ID field;
|
268
268
|
char *term;
|
269
269
|
} FrtTermQuery;
|
270
270
|
|
@@ -283,12 +283,12 @@ typedef enum {
|
|
283
283
|
} FrtBCType;
|
284
284
|
|
285
285
|
typedef struct FrtBooleanClause {
|
286
|
-
int
|
287
|
-
FrtQuery
|
288
|
-
FrtBCType
|
289
|
-
bool
|
290
|
-
bool
|
291
|
-
VALUE
|
286
|
+
_Atomic unsigned int ref_cnt;
|
287
|
+
FrtQuery *query;
|
288
|
+
FrtBCType occur;
|
289
|
+
bool is_prohibited : 1;
|
290
|
+
bool is_required : 1;
|
291
|
+
VALUE rbc;
|
292
292
|
} FrtBooleanClause;
|
293
293
|
|
294
294
|
extern FrtBooleanClause *frt_bc_alloc(void);
|
@@ -330,7 +330,7 @@ extern FrtBooleanClause *frt_bq_add_clause_nr(FrtQuery *self, FrtBooleanClause *
|
|
330
330
|
typedef struct FrtPhraseQuery {
|
331
331
|
FrtQuery super;
|
332
332
|
int slop;
|
333
|
-
ID
|
333
|
+
ID field;
|
334
334
|
FrtPhrasePosition *positions;
|
335
335
|
int pos_cnt;
|
336
336
|
int pos_capa;
|
@@ -351,7 +351,7 @@ extern void frt_phq_set_slop(FrtQuery *self, int slop);
|
|
351
351
|
#define MULTI_TERM_QUERY_MAX_TERMS 256
|
352
352
|
typedef struct FrtMultiTermQuery {
|
353
353
|
FrtQuery super;
|
354
|
-
ID
|
354
|
+
ID field;
|
355
355
|
FrtPriorityQueue *boosted_terms;
|
356
356
|
float min_boost;
|
357
357
|
} FrtMultiTermQuery;
|
@@ -377,7 +377,7 @@ typedef struct FrtMTQSubQuery {
|
|
377
377
|
|
378
378
|
typedef struct FrtPrefixQuery {
|
379
379
|
FrtMTQSubQuery super;
|
380
|
-
ID
|
380
|
+
ID field;
|
381
381
|
char *prefix;
|
382
382
|
} FrtPrefixQuery;
|
383
383
|
|
@@ -395,7 +395,7 @@ extern FrtQuery *frt_prefixq_new(ID field, const char *prefix);
|
|
395
395
|
|
396
396
|
typedef struct FrtWildCardQuery {
|
397
397
|
FrtMTQSubQuery super;
|
398
|
-
ID
|
398
|
+
ID field;
|
399
399
|
char *pattern;
|
400
400
|
} FrtWildCardQuery;
|
401
401
|
|
@@ -415,7 +415,7 @@ extern bool frt_wc_match(const char *pattern, const char *text);
|
|
415
415
|
|
416
416
|
typedef struct FrtFuzzyQuery {
|
417
417
|
FrtMTQSubQuery super;
|
418
|
-
ID
|
418
|
+
ID field;
|
419
419
|
char *term;
|
420
420
|
const char *text; /* term text after prefix */
|
421
421
|
int text_len;
|
@@ -514,7 +514,7 @@ struct FrtSpanEnum {
|
|
514
514
|
/* ** FrtSpanQuery ** */
|
515
515
|
typedef struct FrtSpanQuery {
|
516
516
|
FrtQuery super;
|
517
|
-
ID
|
517
|
+
ID field;
|
518
518
|
FrtSpanEnum *(*get_spans)(FrtQuery *self, FrtIndexReader *ir);
|
519
519
|
FrtHashSet *(*get_terms)(FrtQuery *self);
|
520
520
|
} FrtSpanQuery;
|
@@ -790,6 +790,7 @@ typedef struct FrtPostFilter {
|
|
790
790
|
} FrtPostFilter;
|
791
791
|
|
792
792
|
struct FrtSearcher {
|
793
|
+
_Atomic unsigned int ref_cnt;
|
793
794
|
FrtSimilarity *similarity;
|
794
795
|
int (*doc_freq)(FrtSearcher *self, ID field, const char *term);
|
795
796
|
FrtDocument *(*get_doc)(FrtSearcher *self, int doc_num);
|
@@ -849,7 +850,6 @@ extern char **frt_searcher_highlight(FrtSearcher *self,
|
|
849
850
|
typedef struct FrtIndexSearcher {
|
850
851
|
FrtSearcher super;
|
851
852
|
FrtIndexReader *ir;
|
852
|
-
bool close_ir : 1;
|
853
853
|
} FrtIndexSearcher;
|
854
854
|
|
855
855
|
extern FrtSearcher *frt_isea_alloc(void);
|
@@ -869,12 +869,11 @@ typedef struct FrtMultiSearcher {
|
|
869
869
|
FrtSearcher **searchers;
|
870
870
|
int *starts;
|
871
871
|
int max_doc;
|
872
|
-
bool close_subs : 1;
|
873
872
|
} FrtMultiSearcher;
|
874
873
|
|
875
874
|
extern FrtSearcher *frt_msea_alloc(void);
|
876
|
-
extern FrtSearcher *frt_msea_init(FrtSearcher *self, FrtSearcher **searchers, int s_cnt
|
877
|
-
extern FrtSearcher *frt_msea_new(FrtSearcher **searchers, int s_cnt
|
875
|
+
extern FrtSearcher *frt_msea_init(FrtSearcher *self, FrtSearcher **searchers, int s_cnt);
|
876
|
+
extern FrtSearcher *frt_msea_new(FrtSearcher **searchers, int s_cnt);
|
878
877
|
|
879
878
|
/***************************************************************************
|
880
879
|
*
|