isomorfeus-ferret 0.17.2 → 0.17.3
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/benchmark.c +9 -20
- data/ext/isomorfeus_ferret_ext/benchmarks_all.h +1 -2
- data/ext/isomorfeus_ferret_ext/bm_hash.c +1 -2
- data/ext/isomorfeus_ferret_ext/brotli_dec_decode.c +4 -2
- data/ext/isomorfeus_ferret_ext/brotli_enc_encode.c +3 -2
- data/ext/isomorfeus_ferret_ext/frb_analysis.c +4 -5
- data/ext/isomorfeus_ferret_ext/frb_field_info.c +3 -4
- data/ext/isomorfeus_ferret_ext/frb_index.c +118 -125
- data/ext/isomorfeus_ferret_ext/frb_lazy_doc.c +14 -16
- data/ext/isomorfeus_ferret_ext/frb_search.c +31 -23
- data/ext/isomorfeus_ferret_ext/frb_store.c +27 -13
- data/ext/isomorfeus_ferret_ext/frb_utils.c +3 -6
- data/ext/isomorfeus_ferret_ext/frt_analysis.c +39 -46
- data/ext/isomorfeus_ferret_ext/frt_analysis.h +9 -9
- data/ext/isomorfeus_ferret_ext/frt_array.c +11 -22
- data/ext/isomorfeus_ferret_ext/frt_bitvector.h +3 -6
- data/ext/isomorfeus_ferret_ext/frt_doc_field.c +87 -0
- data/ext/isomorfeus_ferret_ext/frt_doc_field.h +26 -0
- data/ext/isomorfeus_ferret_ext/frt_document.c +4 -97
- data/ext/isomorfeus_ferret_ext/frt_document.h +2 -27
- data/ext/isomorfeus_ferret_ext/frt_except.c +8 -6
- data/ext/isomorfeus_ferret_ext/frt_except.h +1 -2
- data/ext/isomorfeus_ferret_ext/frt_field_index.c +13 -32
- data/ext/isomorfeus_ferret_ext/frt_field_index.h +0 -6
- data/ext/isomorfeus_ferret_ext/frt_field_info.c +69 -0
- data/ext/isomorfeus_ferret_ext/frt_field_info.h +49 -0
- data/ext/isomorfeus_ferret_ext/frt_field_infos.c +196 -0
- data/ext/isomorfeus_ferret_ext/frt_field_infos.h +35 -0
- data/ext/isomorfeus_ferret_ext/frt_global.c +10 -4
- data/ext/isomorfeus_ferret_ext/frt_global.h +11 -15
- data/ext/isomorfeus_ferret_ext/frt_hash.c +8 -8
- data/ext/isomorfeus_ferret_ext/frt_hash.h +1 -2
- data/ext/isomorfeus_ferret_ext/frt_hashset.c +20 -40
- data/ext/isomorfeus_ferret_ext/frt_hashset.h +1 -2
- data/ext/isomorfeus_ferret_ext/frt_helper.c +7 -15
- data/ext/isomorfeus_ferret_ext/frt_in_stream.c +35 -45
- data/ext/isomorfeus_ferret_ext/frt_in_stream.h +3 -2
- data/ext/isomorfeus_ferret_ext/frt_ind.c +20 -38
- data/ext/isomorfeus_ferret_ext/frt_index.c +292 -790
- data/ext/isomorfeus_ferret_ext/frt_index.h +1 -102
- data/ext/isomorfeus_ferret_ext/frt_lang.c +5 -10
- data/ext/isomorfeus_ferret_ext/frt_lazy_doc.c +3 -3
- data/ext/isomorfeus_ferret_ext/frt_lazy_doc.h +1 -1
- data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.c +18 -25
- data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.h +5 -5
- data/ext/isomorfeus_ferret_ext/frt_mdbx_store.c +102 -70
- data/ext/isomorfeus_ferret_ext/frt_mempool.c +8 -16
- data/ext/isomorfeus_ferret_ext/frt_multimapper.c +23 -46
- data/ext/isomorfeus_ferret_ext/frt_multimapper.h +4 -8
- data/ext/isomorfeus_ferret_ext/frt_out_stream.c +31 -43
- data/ext/isomorfeus_ferret_ext/frt_out_stream.h +2 -2
- data/ext/isomorfeus_ferret_ext/frt_posh.c +6 -819
- data/ext/isomorfeus_ferret_ext/frt_posh.h +0 -57
- data/ext/isomorfeus_ferret_ext/frt_priorityqueue.c +11 -22
- data/ext/isomorfeus_ferret_ext/frt_priorityqueue.h +1 -2
- data/ext/isomorfeus_ferret_ext/frt_q_boolean.c +85 -171
- data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +8 -16
- data/ext/isomorfeus_ferret_ext/frt_q_multi_term.c +1 -2
- data/ext/isomorfeus_ferret_ext/frt_q_parser.c +49 -98
- data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +52 -104
- data/ext/isomorfeus_ferret_ext/frt_q_range.c +6 -12
- data/ext/isomorfeus_ferret_ext/frt_q_span.c +113 -226
- data/ext/isomorfeus_ferret_ext/frt_q_wildcard.c +1 -2
- data/ext/isomorfeus_ferret_ext/frt_ram_store.c +134 -85
- data/ext/isomorfeus_ferret_ext/frt_search.c +82 -164
- data/ext/isomorfeus_ferret_ext/frt_similarity.c +11 -22
- data/ext/isomorfeus_ferret_ext/frt_similarity.h +1 -2
- data/ext/isomorfeus_ferret_ext/frt_store.c +13 -25
- data/ext/isomorfeus_ferret_ext/frt_store.h +86 -52
- data/ext/isomorfeus_ferret_ext/frt_term_vectors.c +8 -16
- data/ext/isomorfeus_ferret_ext/frt_win32.h +5 -10
- data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +12 -11
- data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.h +11 -13
- data/ext/isomorfeus_ferret_ext/lz4.c +422 -195
- data/ext/isomorfeus_ferret_ext/lz4.h +114 -46
- data/ext/isomorfeus_ferret_ext/lz4frame.c +421 -242
- data/ext/isomorfeus_ferret_ext/lz4frame.h +122 -53
- data/ext/isomorfeus_ferret_ext/lz4hc.c +127 -111
- data/ext/isomorfeus_ferret_ext/lz4hc.h +14 -14
- data/ext/isomorfeus_ferret_ext/lz4xxhash.h +1 -1
- data/ext/isomorfeus_ferret_ext/mdbx.c +3762 -2526
- data/ext/isomorfeus_ferret_ext/mdbx.h +115 -70
- data/ext/isomorfeus_ferret_ext/test.c +40 -87
- data/ext/isomorfeus_ferret_ext/test.h +3 -6
- data/ext/isomorfeus_ferret_ext/test_1710.c +11 -13
- data/ext/isomorfeus_ferret_ext/test_analysis.c +32 -64
- data/ext/isomorfeus_ferret_ext/test_array.c +6 -12
- data/ext/isomorfeus_ferret_ext/test_bitvector.c +12 -24
- data/ext/isomorfeus_ferret_ext/test_document.c +23 -33
- data/ext/isomorfeus_ferret_ext/test_except.c +10 -21
- data/ext/isomorfeus_ferret_ext/test_fields.c +62 -68
- data/ext/isomorfeus_ferret_ext/test_file_deleter.c +15 -23
- data/ext/isomorfeus_ferret_ext/test_filter.c +17 -27
- data/ext/isomorfeus_ferret_ext/test_global.c +14 -29
- data/ext/isomorfeus_ferret_ext/test_hash.c +19 -38
- data/ext/isomorfeus_ferret_ext/test_hashset.c +8 -16
- data/ext/isomorfeus_ferret_ext/test_helper.c +4 -8
- data/ext/isomorfeus_ferret_ext/test_highlighter.c +16 -28
- data/ext/isomorfeus_ferret_ext/test_index.c +277 -487
- data/ext/isomorfeus_ferret_ext/test_lang.c +7 -14
- data/ext/isomorfeus_ferret_ext/test_mdbx_store.c +2 -5
- data/ext/isomorfeus_ferret_ext/test_mempool.c +5 -10
- data/ext/isomorfeus_ferret_ext/test_multimapper.c +3 -6
- data/ext/isomorfeus_ferret_ext/test_priorityqueue.c +9 -18
- data/ext/isomorfeus_ferret_ext/test_q_const_score.c +4 -6
- data/ext/isomorfeus_ferret_ext/test_q_filtered.c +3 -4
- data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +9 -15
- data/ext/isomorfeus_ferret_ext/test_q_parser.c +8 -16
- data/ext/isomorfeus_ferret_ext/test_q_span.c +19 -35
- data/ext/isomorfeus_ferret_ext/test_ram_store.c +14 -13
- data/ext/isomorfeus_ferret_ext/test_search.c +60 -109
- data/ext/isomorfeus_ferret_ext/test_segments.c +8 -13
- data/ext/isomorfeus_ferret_ext/test_similarity.c +2 -4
- data/ext/isomorfeus_ferret_ext/test_sort.c +14 -24
- data/ext/isomorfeus_ferret_ext/test_store.c +96 -115
- data/ext/isomorfeus_ferret_ext/test_term.c +9 -15
- data/ext/isomorfeus_ferret_ext/test_term_vectors.c +9 -14
- data/ext/isomorfeus_ferret_ext/test_test.c +4 -8
- data/ext/isomorfeus_ferret_ext/test_threading.c +14 -20
- data/ext/isomorfeus_ferret_ext/testhelper.c +11 -21
- data/ext/isomorfeus_ferret_ext/testhelper.h +1 -1
- data/ext/isomorfeus_ferret_ext/tests_all.h +1 -2
- data/lib/isomorfeus/ferret/index/index.rb +1 -1
- data/lib/isomorfeus/ferret/version.rb +1 -1
- metadata +24 -4
@@ -89,8 +89,7 @@ static bool dssc_advance_after_current(FrtScorer *self) {
|
|
89
89
|
while (true) {
|
90
90
|
if (top->next(top)) {
|
91
91
|
frt_pq_down(scorer_queue);
|
92
|
-
}
|
93
|
-
else {
|
92
|
+
} else {
|
94
93
|
frt_pq_pop(scorer_queue);
|
95
94
|
if (scorer_queue->size
|
96
95
|
< (dssc->min_num_matches - dssc->num_matches)) {
|
@@ -107,8 +106,7 @@ static bool dssc_advance_after_current(FrtScorer *self) {
|
|
107
106
|
if (top->doc != self->doc) {
|
108
107
|
/* All remaining subscorers are after self->doc */
|
109
108
|
break;
|
110
|
-
}
|
111
|
-
else {
|
109
|
+
} else {
|
112
110
|
dssc->cum_score += top->score(top);
|
113
111
|
dssc->num_matches++;
|
114
112
|
}
|
@@ -116,8 +114,7 @@ static bool dssc_advance_after_current(FrtScorer *self) {
|
|
116
114
|
|
117
115
|
if (dssc->num_matches >= dssc->min_num_matches) {
|
118
116
|
return true;
|
119
|
-
}
|
120
|
-
else if (scorer_queue->size < dssc->min_num_matches) {
|
117
|
+
} else if (scorer_queue->size < dssc->min_num_matches) {
|
121
118
|
return false;
|
122
119
|
}
|
123
120
|
}
|
@@ -130,8 +127,7 @@ static bool dssc_next(FrtScorer *self) {
|
|
130
127
|
|
131
128
|
if (DSSc(self)->scorer_queue->size < DSSc(self)->min_num_matches) {
|
132
129
|
return false;
|
133
|
-
}
|
134
|
-
else {
|
130
|
+
} else {
|
135
131
|
return dssc_advance_after_current(self);
|
136
132
|
}
|
137
133
|
}
|
@@ -155,11 +151,9 @@ static bool dssc_skip_to(FrtScorer *self, int doc_num) {
|
|
155
151
|
FrtScorer *top = (FrtScorer *)frt_pq_top(scorer_queue);
|
156
152
|
if (top->doc >= doc_num) {
|
157
153
|
return dssc_advance_after_current(self);
|
158
|
-
}
|
159
|
-
else if (top->skip_to(top, doc_num)) {
|
154
|
+
} else if (top->skip_to(top, doc_num)) {
|
160
155
|
frt_pq_down(scorer_queue);
|
161
|
-
}
|
162
|
-
else {
|
156
|
+
} else {
|
163
157
|
frt_pq_pop(scorer_queue);
|
164
158
|
if (scorer_queue->size < dssc->min_num_matches) {
|
165
159
|
return false;
|
@@ -168,8 +162,7 @@ static bool dssc_skip_to(FrtScorer *self, int doc_num) {
|
|
168
162
|
}
|
169
163
|
}
|
170
164
|
|
171
|
-
static FrtExplanation *dssc_explain(FrtScorer *self, int doc_num)
|
172
|
-
{
|
165
|
+
static FrtExplanation *dssc_explain(FrtScorer *self, int doc_num) {
|
173
166
|
int i;
|
174
167
|
DisjunctionSumScorer *dssc = DSSc(self);
|
175
168
|
FrtScorer *sub_scorer;
|
@@ -182,8 +175,7 @@ static FrtExplanation *dssc_explain(FrtScorer *self, int doc_num)
|
|
182
175
|
return e;
|
183
176
|
}
|
184
177
|
|
185
|
-
static void dssc_destroy(FrtScorer *self)
|
186
|
-
{
|
178
|
+
static void dssc_destroy(FrtScorer *self) {
|
187
179
|
DisjunctionSumScorer *dssc = DSSc(self);
|
188
180
|
int i;
|
189
181
|
for (i = 0; i < dssc->ss_cnt; i++) {
|
@@ -196,8 +188,7 @@ static void dssc_destroy(FrtScorer *self)
|
|
196
188
|
}
|
197
189
|
|
198
190
|
static FrtScorer *disjunction_sum_scorer_new(FrtScorer **sub_scorers, int ss_cnt,
|
199
|
-
int min_num_matches)
|
200
|
-
{
|
191
|
+
int min_num_matches) {
|
201
192
|
FrtScorer *self = frt_scorer_new(DisjunctionSumScorer, NULL);
|
202
193
|
DSSc(self)->ss_cnt = ss_cnt;
|
203
194
|
|
@@ -233,16 +224,14 @@ static FrtScorer *disjunction_sum_scorer_new(FrtScorer **sub_scorers, int ss_cnt
|
|
233
224
|
return self;
|
234
225
|
}
|
235
226
|
|
236
|
-
static float cdssc_score(FrtScorer *self)
|
237
|
-
{
|
227
|
+
static float cdssc_score(FrtScorer *self) {
|
238
228
|
DSSc(self)->coordinator->num_matches += DSSc(self)->num_matches;
|
239
229
|
return DSSc(self)->cum_score;
|
240
230
|
}
|
241
231
|
|
242
232
|
static FrtScorer *counting_disjunction_sum_scorer_new(
|
243
233
|
Coordinator *coordinator, FrtScorer **sub_scorers, int ss_cnt,
|
244
|
-
int min_num_matches)
|
245
|
-
{
|
234
|
+
int min_num_matches) {
|
246
235
|
FrtScorer *self = disjunction_sum_scorer_new(sub_scorers, ss_cnt,
|
247
236
|
min_num_matches);
|
248
237
|
DSSc(self)->coordinator = coordinator;
|
@@ -256,8 +245,7 @@ static FrtScorer *counting_disjunction_sum_scorer_new(
|
|
256
245
|
|
257
246
|
#define CSc(scorer) ((ConjunctionScorer *)(scorer))
|
258
247
|
|
259
|
-
typedef struct ConjunctionScorer
|
260
|
-
{
|
248
|
+
typedef struct ConjunctionScorer {
|
261
249
|
FrtScorer super;
|
262
250
|
bool first_time : 1;
|
263
251
|
bool more : 1;
|
@@ -269,8 +257,7 @@ typedef struct ConjunctionScorer
|
|
269
257
|
int last_scored_doc;
|
270
258
|
} ConjunctionScorer;
|
271
259
|
|
272
|
-
static void csc_sort_scorers(ConjunctionScorer *csc)
|
273
|
-
{
|
260
|
+
static void csc_sort_scorers(ConjunctionScorer *csc) {
|
274
261
|
int i;
|
275
262
|
FrtScorer *current = csc->sub_scorers[0], *previous;
|
276
263
|
for (i = 1; i < csc->ss_cnt; i++) {
|
@@ -287,8 +274,7 @@ static void csc_sort_scorers(ConjunctionScorer *csc)
|
|
287
274
|
csc->first_idx = 0;
|
288
275
|
}
|
289
276
|
|
290
|
-
static void csc_init(FrtScorer *self, bool init_scorers)
|
291
|
-
{
|
277
|
+
static void csc_init(FrtScorer *self, bool init_scorers) {
|
292
278
|
ConjunctionScorer *csc = CSc(self);
|
293
279
|
const int sub_sc_cnt = csc->ss_cnt;
|
294
280
|
|
@@ -315,8 +301,7 @@ static void csc_init(FrtScorer *self, bool init_scorers)
|
|
315
301
|
csc->first_time = false;
|
316
302
|
}
|
317
303
|
|
318
|
-
static float csc_score(FrtScorer *self)
|
319
|
-
{
|
304
|
+
static float csc_score(FrtScorer *self) {
|
320
305
|
ConjunctionScorer *csc = CSc(self);
|
321
306
|
const int sub_sc_cnt = csc->ss_cnt;
|
322
307
|
float score = 0.0f; /* sum scores */
|
@@ -329,8 +314,7 @@ static float csc_score(FrtScorer *self)
|
|
329
314
|
return score;
|
330
315
|
}
|
331
316
|
|
332
|
-
static bool csc_do_next(FrtScorer *self)
|
333
|
-
{
|
317
|
+
static bool csc_do_next(FrtScorer *self) {
|
334
318
|
ConjunctionScorer *csc = CSc(self);
|
335
319
|
const int sub_sc_cnt = csc->ss_cnt;
|
336
320
|
int first_idx = csc->first_idx;
|
@@ -351,13 +335,11 @@ static bool csc_do_next(FrtScorer *self)
|
|
351
335
|
return csc->more;
|
352
336
|
}
|
353
337
|
|
354
|
-
static bool csc_next(FrtScorer *self)
|
355
|
-
{
|
338
|
+
static bool csc_next(FrtScorer *self) {
|
356
339
|
ConjunctionScorer *csc = CSc(self);
|
357
340
|
if (csc->first_time) {
|
358
341
|
csc_init(self, true);
|
359
|
-
}
|
360
|
-
else if (csc->more) {
|
342
|
+
} else if (csc->more) {
|
361
343
|
/* trigger further scanning */
|
362
344
|
const int last_idx = FRT_PREV_NUM(csc->first_idx, csc->ss_cnt);
|
363
345
|
FrtScorer *sub_scorer = csc->sub_scorers[last_idx];
|
@@ -366,8 +348,7 @@ static bool csc_next(FrtScorer *self)
|
|
366
348
|
return csc_do_next(self);
|
367
349
|
}
|
368
350
|
|
369
|
-
static bool csc_skip_to(FrtScorer *self, int doc_num)
|
370
|
-
{
|
351
|
+
static bool csc_skip_to(FrtScorer *self, int doc_num) {
|
371
352
|
ConjunctionScorer *csc = CSc(self);
|
372
353
|
const int sub_sc_cnt = csc->ss_cnt;
|
373
354
|
int i;
|
@@ -380,8 +361,7 @@ static bool csc_skip_to(FrtScorer *self, int doc_num)
|
|
380
361
|
for (i = 0; i < sub_sc_cnt; i++) {
|
381
362
|
if (!more) {
|
382
363
|
break;
|
383
|
-
}
|
384
|
-
else {
|
364
|
+
} else {
|
385
365
|
FrtScorer *sub_scorer = csc->sub_scorers[i];
|
386
366
|
more = sub_scorer->skip_to(sub_scorer, doc_num);
|
387
367
|
}
|
@@ -395,8 +375,7 @@ static bool csc_skip_to(FrtScorer *self, int doc_num)
|
|
395
375
|
return csc_do_next(self);
|
396
376
|
}
|
397
377
|
|
398
|
-
static void csc_destroy(FrtScorer *self)
|
399
|
-
{
|
378
|
+
static void csc_destroy(FrtScorer *self) {
|
400
379
|
ConjunctionScorer *csc = CSc(self);
|
401
380
|
const int sub_sc_cnt = csc->ss_cnt;
|
402
381
|
int i;
|
@@ -407,8 +386,7 @@ static void csc_destroy(FrtScorer *self)
|
|
407
386
|
frt_scorer_destroy_i(self);
|
408
387
|
}
|
409
388
|
|
410
|
-
static FrtScorer *conjunction_scorer_new(FrtSimilarity *similarity)
|
411
|
-
{
|
389
|
+
static FrtScorer *conjunction_scorer_new(FrtSimilarity *similarity) {
|
412
390
|
FrtScorer *self = frt_scorer_new(ConjunctionScorer, similarity);
|
413
391
|
|
414
392
|
CSc(self)->first_time = true;
|
@@ -423,8 +401,7 @@ static FrtScorer *conjunction_scorer_new(FrtSimilarity *similarity)
|
|
423
401
|
return self;
|
424
402
|
}
|
425
403
|
|
426
|
-
static float ccsc_score(FrtScorer *self)
|
427
|
-
{
|
404
|
+
static float ccsc_score(FrtScorer *self) {
|
428
405
|
ConjunctionScorer *csc = CSc(self);
|
429
406
|
|
430
407
|
int doc;
|
@@ -437,8 +414,7 @@ static float ccsc_score(FrtScorer *self)
|
|
437
414
|
}
|
438
415
|
|
439
416
|
static FrtScorer *counting_conjunction_sum_scorer_new(
|
440
|
-
Coordinator *coordinator, FrtScorer **sub_scorers, int ss_cnt)
|
441
|
-
{
|
417
|
+
Coordinator *coordinator, FrtScorer **sub_scorers, int ss_cnt) {
|
442
418
|
FrtScorer *self = conjunction_scorer_new(frt_sim_create_default());
|
443
419
|
ConjunctionScorer *csc = CSc(self);
|
444
420
|
csc->coordinator = coordinator;
|
@@ -458,22 +434,19 @@ static FrtScorer *counting_conjunction_sum_scorer_new(
|
|
458
434
|
|
459
435
|
#define SMSc(scorer) ((SingleMatchScorer *)(scorer))
|
460
436
|
|
461
|
-
typedef struct SingleMatchScorer
|
462
|
-
{
|
437
|
+
typedef struct SingleMatchScorer {
|
463
438
|
FrtScorer super;
|
464
439
|
Coordinator *coordinator;
|
465
440
|
FrtScorer *scorer;
|
466
441
|
} SingleMatchScorer;
|
467
442
|
|
468
443
|
|
469
|
-
static float smsc_score(FrtScorer *self)
|
470
|
-
{
|
444
|
+
static float smsc_score(FrtScorer *self) {
|
471
445
|
SMSc(self)->coordinator->num_matches++;
|
472
446
|
return SMSc(self)->scorer->score(SMSc(self)->scorer);
|
473
447
|
}
|
474
448
|
|
475
|
-
static bool smsc_next(FrtScorer *self)
|
476
|
-
{
|
449
|
+
static bool smsc_next(FrtScorer *self) {
|
477
450
|
FrtScorer *scorer = SMSc(self)->scorer;
|
478
451
|
if (scorer->next(scorer)) {
|
479
452
|
self->doc = scorer->doc;
|
@@ -482,8 +455,7 @@ static bool smsc_next(FrtScorer *self)
|
|
482
455
|
return false;
|
483
456
|
}
|
484
457
|
|
485
|
-
static bool smsc_skip_to(FrtScorer *self, int doc_num)
|
486
|
-
{
|
458
|
+
static bool smsc_skip_to(FrtScorer *self, int doc_num) {
|
487
459
|
FrtScorer *scorer = SMSc(self)->scorer;
|
488
460
|
if (scorer->skip_to(scorer, doc_num)) {
|
489
461
|
self->doc = scorer->doc;
|
@@ -492,22 +464,18 @@ static bool smsc_skip_to(FrtScorer *self, int doc_num)
|
|
492
464
|
return false;
|
493
465
|
}
|
494
466
|
|
495
|
-
static FrtExplanation *smsc_explain(FrtScorer *self, int doc_num)
|
496
|
-
{
|
467
|
+
static FrtExplanation *smsc_explain(FrtScorer *self, int doc_num) {
|
497
468
|
FrtScorer *scorer = SMSc(self)->scorer;
|
498
469
|
return scorer->explain(scorer, doc_num);
|
499
470
|
}
|
500
471
|
|
501
|
-
static void smsc_destroy(FrtScorer *self)
|
502
|
-
{
|
472
|
+
static void smsc_destroy(FrtScorer *self) {
|
503
473
|
FrtScorer *scorer = SMSc(self)->scorer;
|
504
474
|
scorer->destroy(scorer);
|
505
475
|
frt_scorer_destroy_i(self);
|
506
476
|
}
|
507
477
|
|
508
|
-
static FrtScorer *single_match_scorer_new(Coordinator *coordinator,
|
509
|
-
FrtScorer *scorer)
|
510
|
-
{
|
478
|
+
static FrtScorer *single_match_scorer_new(Coordinator *coordinator, FrtScorer *scorer) {
|
511
479
|
FrtScorer *self = frt_scorer_new(SingleMatchScorer, scorer->similarity);
|
512
480
|
SMSc(self)->coordinator = coordinator;
|
513
481
|
SMSc(self)->scorer = scorer;
|
@@ -526,16 +494,14 @@ static FrtScorer *single_match_scorer_new(Coordinator *coordinator,
|
|
526
494
|
|
527
495
|
#define ROSSc(scorer) ((ReqOptSumScorer *)(scorer))
|
528
496
|
|
529
|
-
typedef struct ReqOptSumScorer
|
530
|
-
{
|
497
|
+
typedef struct ReqOptSumScorer {
|
531
498
|
FrtScorer super;
|
532
499
|
FrtScorer *req_scorer;
|
533
500
|
FrtScorer *opt_scorer;
|
534
501
|
bool first_time_opt;
|
535
502
|
} ReqOptSumScorer;
|
536
503
|
|
537
|
-
static float rossc_score(FrtScorer *self)
|
538
|
-
{
|
504
|
+
static float rossc_score(FrtScorer *self) {
|
539
505
|
ReqOptSumScorer *rossc = ROSSc(self);
|
540
506
|
FrtScorer *req_scorer = rossc->req_scorer;
|
541
507
|
FrtScorer *opt_scorer = rossc->opt_scorer;
|
@@ -548,11 +514,9 @@ static float rossc_score(FrtScorer *self)
|
|
548
514
|
FRT_SCORER_NULLIFY(rossc->opt_scorer);
|
549
515
|
return req_score;
|
550
516
|
}
|
551
|
-
}
|
552
|
-
else if (opt_scorer == NULL) {
|
517
|
+
} else if (opt_scorer == NULL) {
|
553
518
|
return req_score;
|
554
|
-
}
|
555
|
-
else if ((opt_scorer->doc < cur_doc)
|
519
|
+
} else if ((opt_scorer->doc < cur_doc)
|
556
520
|
&& ! opt_scorer->skip_to(opt_scorer, cur_doc)) {
|
557
521
|
FRT_SCORER_NULLIFY(rossc->opt_scorer);
|
558
522
|
return req_score;
|
@@ -563,8 +527,7 @@ static float rossc_score(FrtScorer *self)
|
|
563
527
|
: req_score;
|
564
528
|
}
|
565
529
|
|
566
|
-
static bool rossc_next(FrtScorer *self)
|
567
|
-
{
|
530
|
+
static bool rossc_next(FrtScorer *self) {
|
568
531
|
FrtScorer *req_scorer = ROSSc(self)->req_scorer;
|
569
532
|
if (req_scorer->next(req_scorer)) {
|
570
533
|
self->doc = req_scorer->doc;
|
@@ -573,8 +536,7 @@ static bool rossc_next(FrtScorer *self)
|
|
573
536
|
return false;
|
574
537
|
}
|
575
538
|
|
576
|
-
static bool rossc_skip_to(FrtScorer *self, int doc_num)
|
577
|
-
{
|
539
|
+
static bool rossc_skip_to(FrtScorer *self, int doc_num) {
|
578
540
|
FrtScorer *req_scorer = ROSSc(self)->req_scorer;
|
579
541
|
if (req_scorer->skip_to(req_scorer, doc_num)) {
|
580
542
|
self->doc = req_scorer->doc;
|
@@ -583,8 +545,7 @@ static bool rossc_skip_to(FrtScorer *self, int doc_num)
|
|
583
545
|
return false;
|
584
546
|
}
|
585
547
|
|
586
|
-
static FrtExplanation *rossc_explain(FrtScorer *self, int doc_num)
|
587
|
-
{
|
548
|
+
static FrtExplanation *rossc_explain(FrtScorer *self, int doc_num) {
|
588
549
|
FrtScorer *req_scorer = ROSSc(self)->req_scorer;
|
589
550
|
FrtScorer *opt_scorer = ROSSc(self)->opt_scorer;
|
590
551
|
|
@@ -594,8 +555,7 @@ static FrtExplanation *rossc_explain(FrtScorer *self, int doc_num)
|
|
594
555
|
return e;
|
595
556
|
}
|
596
557
|
|
597
|
-
static void rossc_destroy(FrtScorer *self)
|
598
|
-
{
|
558
|
+
static void rossc_destroy(FrtScorer *self) {
|
599
559
|
ReqOptSumScorer *rossc = ROSSc(self);
|
600
560
|
if (rossc->req_scorer) {
|
601
561
|
rossc->req_scorer->destroy(rossc->req_scorer);
|
@@ -607,8 +567,7 @@ static void rossc_destroy(FrtScorer *self)
|
|
607
567
|
}
|
608
568
|
|
609
569
|
|
610
|
-
static FrtScorer *req_opt_sum_scorer_new(FrtScorer *req_scorer, FrtScorer *opt_scorer)
|
611
|
-
{
|
570
|
+
static FrtScorer *req_opt_sum_scorer_new(FrtScorer *req_scorer, FrtScorer *opt_scorer) {
|
612
571
|
FrtScorer *self = frt_scorer_new(ReqOptSumScorer, NULL);
|
613
572
|
|
614
573
|
ROSSc(self)->req_scorer = req_scorer;
|
@@ -629,16 +588,14 @@ static FrtScorer *req_opt_sum_scorer_new(FrtScorer *req_scorer, FrtScorer *opt_s
|
|
629
588
|
***************************************************************************/
|
630
589
|
|
631
590
|
#define RXSc(scorer) ((ReqExclScorer *)(scorer))
|
632
|
-
typedef struct ReqExclScorer
|
633
|
-
{
|
591
|
+
typedef struct ReqExclScorer {
|
634
592
|
FrtScorer super;
|
635
593
|
FrtScorer *req_scorer;
|
636
594
|
FrtScorer *excl_scorer;
|
637
595
|
bool first_time;
|
638
596
|
} ReqExclScorer;
|
639
597
|
|
640
|
-
static bool rxsc_to_non_excluded(FrtScorer *self)
|
641
|
-
{
|
598
|
+
static bool rxsc_to_non_excluded(FrtScorer *self) {
|
642
599
|
FrtScorer *req_scorer = RXSc(self)->req_scorer;
|
643
600
|
FrtScorer *excl_scorer = RXSc(self)->excl_scorer;
|
644
601
|
int excl_doc = excl_scorer->doc, req_doc;
|
@@ -650,8 +607,7 @@ static bool rxsc_to_non_excluded(FrtScorer *self)
|
|
650
607
|
/* req_scorer advanced to before excl_scorer, ie. not excluded */
|
651
608
|
self->doc = req_doc;
|
652
609
|
return true;
|
653
|
-
}
|
654
|
-
else if (req_doc > excl_doc) {
|
610
|
+
} else if (req_doc > excl_doc) {
|
655
611
|
if (! excl_scorer->skip_to(excl_scorer, req_doc)) {
|
656
612
|
/* emptied, no more exclusions */
|
657
613
|
FRT_SCORER_NULLIFY(RXSc(self)->excl_scorer);
|
@@ -670,8 +626,7 @@ static bool rxsc_to_non_excluded(FrtScorer *self)
|
|
670
626
|
return false;
|
671
627
|
}
|
672
628
|
|
673
|
-
static bool rxsc_next(FrtScorer *self)
|
674
|
-
{
|
629
|
+
static bool rxsc_next(FrtScorer *self) {
|
675
630
|
ReqExclScorer *rxsc = RXSc(self);
|
676
631
|
FrtScorer *req_scorer = rxsc->req_scorer;
|
677
632
|
FrtScorer *excl_scorer = rxsc->excl_scorer;
|
@@ -700,8 +655,7 @@ static bool rxsc_next(FrtScorer *self)
|
|
700
655
|
return rxsc_to_non_excluded(self);
|
701
656
|
}
|
702
657
|
|
703
|
-
static bool rxsc_skip_to(FrtScorer *self, int doc_num)
|
704
|
-
{
|
658
|
+
static bool rxsc_skip_to(FrtScorer *self, int doc_num) {
|
705
659
|
ReqExclScorer *rxsc = RXSc(self);
|
706
660
|
FrtScorer *req_scorer = rxsc->req_scorer;
|
707
661
|
FrtScorer *excl_scorer = rxsc->excl_scorer;
|
@@ -731,14 +685,12 @@ static bool rxsc_skip_to(FrtScorer *self, int doc_num)
|
|
731
685
|
return rxsc_to_non_excluded(self);
|
732
686
|
}
|
733
687
|
|
734
|
-
static float rxsc_score(FrtScorer *self)
|
735
|
-
{
|
688
|
+
static float rxsc_score(FrtScorer *self) {
|
736
689
|
FrtScorer *req_scorer = RXSc(self)->req_scorer;
|
737
690
|
return req_scorer->score(req_scorer);
|
738
691
|
}
|
739
692
|
|
740
|
-
static FrtExplanation *rxsc_explain(FrtScorer *self, int doc_num)
|
741
|
-
{
|
693
|
+
static FrtExplanation *rxsc_explain(FrtScorer *self, int doc_num) {
|
742
694
|
ReqExclScorer *rxsc = RXSc(self);
|
743
695
|
FrtScorer *req_scorer = rxsc->req_scorer;
|
744
696
|
FrtScorer *excl_scorer = rxsc->excl_scorer;
|
@@ -747,16 +699,14 @@ static FrtExplanation *rxsc_explain(FrtScorer *self, int doc_num)
|
|
747
699
|
if (excl_scorer->skip_to(excl_scorer, doc_num)
|
748
700
|
&& excl_scorer->doc == doc_num) {
|
749
701
|
e = frt_expl_new(0.0, "excluded:");
|
750
|
-
}
|
751
|
-
else {
|
702
|
+
} else {
|
752
703
|
e = frt_expl_new(0.0, "not excluded:");
|
753
704
|
frt_expl_add_detail(e, req_scorer->explain(req_scorer, doc_num));
|
754
705
|
}
|
755
706
|
return e;
|
756
707
|
}
|
757
708
|
|
758
|
-
static void rxsc_destroy(FrtScorer *self)
|
759
|
-
{
|
709
|
+
static void rxsc_destroy(FrtScorer *self) {
|
760
710
|
ReqExclScorer *rxsc = RXSc(self);
|
761
711
|
if (rxsc->req_scorer) {
|
762
712
|
rxsc->req_scorer->destroy(rxsc->req_scorer);
|
@@ -767,8 +717,7 @@ static void rxsc_destroy(FrtScorer *self)
|
|
767
717
|
frt_scorer_destroy_i(self);
|
768
718
|
}
|
769
719
|
|
770
|
-
static FrtScorer *req_excl_scorer_new(FrtScorer *req_scorer, FrtScorer *excl_scorer)
|
771
|
-
{
|
720
|
+
static FrtScorer *req_excl_scorer_new(FrtScorer *req_scorer, FrtScorer *excl_scorer) {
|
772
721
|
FrtScorer *self = frt_scorer_new(ReqExclScorer, NULL);
|
773
722
|
RXSc(self)->req_scorer = req_scorer;
|
774
723
|
RXSc(self)->excl_scorer = excl_scorer;
|
@@ -787,26 +736,22 @@ static FrtScorer *req_excl_scorer_new(FrtScorer *req_scorer, FrtScorer *excl_sco
|
|
787
736
|
* NonMatchScorer
|
788
737
|
***************************************************************************/
|
789
738
|
|
790
|
-
static float nmsc_score(FrtScorer *self)
|
791
|
-
{
|
739
|
+
static float nmsc_score(FrtScorer *self) {
|
792
740
|
(void)self;
|
793
741
|
return 0.0;
|
794
742
|
}
|
795
743
|
|
796
|
-
static bool nmsc_next(FrtScorer *self)
|
797
|
-
{
|
744
|
+
static bool nmsc_next(FrtScorer *self) {
|
798
745
|
(void)self;
|
799
746
|
return false;
|
800
747
|
}
|
801
748
|
|
802
|
-
static bool nmsc_skip_to(FrtScorer *self, int doc_num)
|
803
|
-
{
|
749
|
+
static bool nmsc_skip_to(FrtScorer *self, int doc_num) {
|
804
750
|
(void)self; (void)doc_num;
|
805
751
|
return false;
|
806
752
|
}
|
807
753
|
|
808
|
-
static FrtExplanation *nmsc_explain(FrtScorer *self, int doc_num)
|
809
|
-
{
|
754
|
+
static FrtExplanation *nmsc_explain(FrtScorer *self, int doc_num) {
|
810
755
|
(void)self; (void)doc_num;
|
811
756
|
return frt_expl_new(0.0, "No documents matched");
|
812
757
|
}
|
@@ -845,14 +790,12 @@ static FrtScorer *counting_sum_scorer_create3(BooleanScorer *bsc, FrtScorer *req
|
|
845
790
|
if (bsc->ps_cnt == 0) {
|
846
791
|
/* no prohibited */
|
847
792
|
return req_opt_sum_scorer_new(req_scorer, opt_scorer);
|
848
|
-
}
|
849
|
-
else if (bsc->ps_cnt == 1) {
|
793
|
+
} else if (bsc->ps_cnt == 1) {
|
850
794
|
/* 1 prohibited */
|
851
795
|
return req_opt_sum_scorer_new(
|
852
796
|
req_excl_scorer_new(req_scorer, bsc->prohibited_scorers[0]),
|
853
797
|
opt_scorer);
|
854
|
-
}
|
855
|
-
else {
|
798
|
+
} else {
|
856
799
|
/* more prohibited */
|
857
800
|
return req_opt_sum_scorer_new(
|
858
801
|
req_excl_scorer_new(
|
@@ -866,31 +809,26 @@ static FrtScorer *counting_sum_scorer_create3(BooleanScorer *bsc, FrtScorer *req
|
|
866
809
|
static FrtScorer *counting_sum_scorer_create2(BooleanScorer *bsc,
|
867
810
|
FrtScorer *req_scorer,
|
868
811
|
FrtScorer **optional_scorers,
|
869
|
-
int os_cnt)
|
870
|
-
{
|
812
|
+
int os_cnt) {
|
871
813
|
if (os_cnt == 0) {
|
872
814
|
if (bsc->ps_cnt == 0) {
|
873
815
|
return req_scorer;
|
874
|
-
}
|
875
|
-
else if (bsc->ps_cnt == 1) {
|
816
|
+
} else if (bsc->ps_cnt == 1) {
|
876
817
|
return req_excl_scorer_new(req_scorer,
|
877
818
|
bsc->prohibited_scorers[0]);
|
878
|
-
}
|
879
|
-
else {
|
819
|
+
} else {
|
880
820
|
/* no optional, more than 1 prohibited */
|
881
821
|
return req_excl_scorer_new(
|
882
822
|
req_scorer,
|
883
823
|
disjunction_sum_scorer_new(bsc->prohibited_scorers,
|
884
824
|
bsc->ps_cnt, 1));
|
885
825
|
}
|
886
|
-
}
|
887
|
-
else if (os_cnt == 1) {
|
826
|
+
} else if (os_cnt == 1) {
|
888
827
|
return counting_sum_scorer_create3(
|
889
828
|
bsc,
|
890
829
|
req_scorer,
|
891
830
|
single_match_scorer_new(bsc->coordinator, optional_scorers[0]));
|
892
|
-
}
|
893
|
-
else {
|
831
|
+
} else {
|
894
832
|
/* more optional */
|
895
833
|
return counting_sum_scorer_create3(
|
896
834
|
bsc,
|
@@ -900,8 +838,7 @@ static FrtScorer *counting_sum_scorer_create2(BooleanScorer *bsc,
|
|
900
838
|
}
|
901
839
|
}
|
902
840
|
|
903
|
-
static FrtScorer *counting_sum_scorer_create(BooleanScorer *bsc)
|
904
|
-
{
|
841
|
+
static FrtScorer *counting_sum_scorer_create(BooleanScorer *bsc) {
|
905
842
|
if (bsc->rs_cnt == 0) {
|
906
843
|
if (bsc->os_cnt == 0) {
|
907
844
|
int i;
|
@@ -911,16 +848,14 @@ static FrtScorer *counting_sum_scorer_create(BooleanScorer *bsc)
|
|
911
848
|
bsc->prohibited_scorers[i]);
|
912
849
|
}
|
913
850
|
return non_matching_scorer_new();
|
914
|
-
}
|
915
|
-
else if (bsc->os_cnt == 1) {
|
851
|
+
} else if (bsc->os_cnt == 1) {
|
916
852
|
/* the only optional scorer is required */
|
917
853
|
return counting_sum_scorer_create2(
|
918
854
|
bsc,
|
919
855
|
single_match_scorer_new(bsc->coordinator,
|
920
856
|
bsc->optional_scorers[0]),
|
921
857
|
NULL, 0); /* no optional scorers left */
|
922
|
-
}
|
923
|
-
else {
|
858
|
+
} else {
|
924
859
|
/* more than 1 optional_scorers, no required scorers */
|
925
860
|
return counting_sum_scorer_create2(
|
926
861
|
bsc,
|
@@ -929,15 +864,13 @@ static FrtScorer *counting_sum_scorer_create(BooleanScorer *bsc)
|
|
929
864
|
bsc->os_cnt, 1),
|
930
865
|
NULL, 0); /* no optional scorers left */
|
931
866
|
}
|
932
|
-
}
|
933
|
-
else if (bsc->rs_cnt == 1) {
|
867
|
+
} else if (bsc->rs_cnt == 1) {
|
934
868
|
/* 1 required */
|
935
869
|
return counting_sum_scorer_create2(
|
936
870
|
bsc,
|
937
871
|
single_match_scorer_new(bsc->coordinator, bsc->required_scorers[0]),
|
938
872
|
bsc->optional_scorers, bsc->os_cnt);
|
939
|
-
}
|
940
|
-
else {
|
873
|
+
} else {
|
941
874
|
/* more required scorers */
|
942
875
|
return counting_sum_scorer_create2(
|
943
876
|
bsc,
|
@@ -948,14 +881,12 @@ static FrtScorer *counting_sum_scorer_create(BooleanScorer *bsc)
|
|
948
881
|
}
|
949
882
|
}
|
950
883
|
|
951
|
-
static FrtScorer *bsc_init_counting_sum_scorer(BooleanScorer *bsc)
|
952
|
-
{
|
884
|
+
static FrtScorer *bsc_init_counting_sum_scorer(BooleanScorer *bsc) {
|
953
885
|
coord_init(bsc->coordinator);
|
954
886
|
return bsc->counting_sum_scorer = counting_sum_scorer_create(bsc);
|
955
887
|
}
|
956
888
|
|
957
|
-
static void bsc_add_scorer(FrtScorer *self, FrtScorer *scorer, unsigned int occur)
|
958
|
-
{
|
889
|
+
static void bsc_add_scorer(FrtScorer *self, FrtScorer *scorer, unsigned int occur) {
|
959
890
|
BooleanScorer *bsc = BSc(self);
|
960
891
|
if (occur != FRT_BC_MUST_NOT) {
|
961
892
|
bsc->coordinator->max_coord++;
|
@@ -980,8 +911,7 @@ static void bsc_add_scorer(FrtScorer *self, FrtScorer *scorer, unsigned int occu
|
|
980
911
|
}
|
981
912
|
}
|
982
913
|
|
983
|
-
static float bsc_score(FrtScorer *self)
|
984
|
-
{
|
914
|
+
static float bsc_score(FrtScorer *self) {
|
985
915
|
BooleanScorer *bsc = BSc(self);
|
986
916
|
Coordinator *coord = bsc->coordinator;
|
987
917
|
float sum;
|
@@ -990,8 +920,7 @@ static float bsc_score(FrtScorer *self)
|
|
990
920
|
return sum * coord->coord_factors[coord->num_matches];
|
991
921
|
}
|
992
922
|
|
993
|
-
static bool bsc_next(FrtScorer *self)
|
994
|
-
{
|
923
|
+
static bool bsc_next(FrtScorer *self) {
|
995
924
|
FrtScorer *cnt_sum_sc = BSc(self)->counting_sum_scorer;
|
996
925
|
|
997
926
|
if (!cnt_sum_sc) {
|
@@ -1000,14 +929,12 @@ static bool bsc_next(FrtScorer *self)
|
|
1000
929
|
if (cnt_sum_sc->next(cnt_sum_sc)) {
|
1001
930
|
self->doc = cnt_sum_sc->doc;
|
1002
931
|
return true;
|
1003
|
-
}
|
1004
|
-
else {
|
932
|
+
} else {
|
1005
933
|
return false;
|
1006
934
|
}
|
1007
935
|
}
|
1008
936
|
|
1009
|
-
static bool bsc_skip_to(FrtScorer *self, int doc_num)
|
1010
|
-
{
|
937
|
+
static bool bsc_skip_to(FrtScorer *self, int doc_num) {
|
1011
938
|
FrtScorer *cnt_sum_sc = BSc(self)->counting_sum_scorer;
|
1012
939
|
|
1013
940
|
if (!BSc(self)->counting_sum_scorer) {
|
@@ -1016,14 +943,12 @@ static bool bsc_skip_to(FrtScorer *self, int doc_num)
|
|
1016
943
|
if (cnt_sum_sc->skip_to(cnt_sum_sc, doc_num)) {
|
1017
944
|
self->doc = cnt_sum_sc->doc;
|
1018
945
|
return true;
|
1019
|
-
}
|
1020
|
-
else {
|
946
|
+
} else {
|
1021
947
|
return false;
|
1022
948
|
}
|
1023
949
|
}
|
1024
950
|
|
1025
|
-
static void bsc_destroy(FrtScorer *self)
|
1026
|
-
{
|
951
|
+
static void bsc_destroy(FrtScorer *self) {
|
1027
952
|
BooleanScorer *bsc = BSc(self);
|
1028
953
|
Coordinator *coord = bsc->coordinator;
|
1029
954
|
|
@@ -1032,8 +957,7 @@ static void bsc_destroy(FrtScorer *self)
|
|
1032
957
|
|
1033
958
|
if (bsc->counting_sum_scorer) {
|
1034
959
|
bsc->counting_sum_scorer->destroy(bsc->counting_sum_scorer);
|
1035
|
-
}
|
1036
|
-
else {
|
960
|
+
} else {
|
1037
961
|
int i;
|
1038
962
|
for (i = 0; i < bsc->rs_cnt; i++) {
|
1039
963
|
bsc->required_scorers[i]->destroy(bsc->required_scorers[i]);
|
@@ -1053,14 +977,12 @@ static void bsc_destroy(FrtScorer *self)
|
|
1053
977
|
frt_scorer_destroy_i(self);
|
1054
978
|
}
|
1055
979
|
|
1056
|
-
static FrtExplanation *bsc_explain(FrtScorer *self, int doc_num)
|
1057
|
-
{
|
980
|
+
static FrtExplanation *bsc_explain(FrtScorer *self, int doc_num) {
|
1058
981
|
(void)self; (void)doc_num;
|
1059
982
|
return frt_expl_new(0.0, "This explanation is not supported");
|
1060
983
|
}
|
1061
984
|
|
1062
|
-
static FrtScorer *bsc_new(FrtSimilarity *similarity)
|
1063
|
-
{
|
985
|
+
static FrtScorer *bsc_new(FrtSimilarity *similarity) {
|
1064
986
|
FrtScorer *self = frt_scorer_new(BooleanScorer, similarity);
|
1065
987
|
BSc(self)->coordinator = coord_new(similarity);
|
1066
988
|
BSc(self)->counting_sum_scorer = NULL;
|
@@ -1079,16 +1001,14 @@ static FrtScorer *bsc_new(FrtSimilarity *similarity)
|
|
1079
1001
|
*
|
1080
1002
|
***************************************************************************/
|
1081
1003
|
|
1082
|
-
typedef struct BooleanWeight
|
1083
|
-
{
|
1004
|
+
typedef struct BooleanWeight {
|
1084
1005
|
FrtWeight w;
|
1085
1006
|
FrtWeight **weights;
|
1086
1007
|
int w_cnt;
|
1087
1008
|
} BooleanWeight;
|
1088
1009
|
|
1089
1010
|
|
1090
|
-
static float bw_sum_of_squared_weights(FrtWeight *self)
|
1091
|
-
{
|
1011
|
+
static float bw_sum_of_squared_weights(FrtWeight *self) {
|
1092
1012
|
FrtBooleanQuery *bq = BQ(self->query);
|
1093
1013
|
float sum = 0.0f;
|
1094
1014
|
int i;
|
@@ -1106,8 +1026,7 @@ static float bw_sum_of_squared_weights(FrtWeight *self)
|
|
1106
1026
|
return sum;
|
1107
1027
|
}
|
1108
1028
|
|
1109
|
-
static void bw_normalize(FrtWeight *self, float normalization_factor)
|
1110
|
-
{
|
1029
|
+
static void bw_normalize(FrtWeight *self, float normalization_factor) {
|
1111
1030
|
FrtBooleanQuery *bq = BQ(self->query);
|
1112
1031
|
int i;
|
1113
1032
|
|
@@ -1122,8 +1041,7 @@ static void bw_normalize(FrtWeight *self, float normalization_factor)
|
|
1122
1041
|
}
|
1123
1042
|
}
|
1124
1043
|
|
1125
|
-
static FrtScorer *bw_scorer(FrtWeight *self, FrtIndexReader *ir)
|
1126
|
-
{
|
1044
|
+
static FrtScorer *bw_scorer(FrtWeight *self, FrtIndexReader *ir) {
|
1127
1045
|
FrtScorer *bsc = bsc_new(self->similarity);
|
1128
1046
|
FrtBooleanQuery *bq = BQ(self->query);
|
1129
1047
|
int i;
|
@@ -1134,8 +1052,7 @@ static FrtScorer *bw_scorer(FrtWeight *self, FrtIndexReader *ir)
|
|
1134
1052
|
FrtScorer *sub_scorer = weight->scorer(weight, ir);
|
1135
1053
|
if (sub_scorer) {
|
1136
1054
|
bsc_add_scorer(bsc, sub_scorer, clause->occur);
|
1137
|
-
}
|
1138
|
-
else if (clause->is_required) {
|
1055
|
+
} else if (clause->is_required) {
|
1139
1056
|
bsc->destroy(bsc);
|
1140
1057
|
return NULL;
|
1141
1058
|
}
|
@@ -1144,13 +1061,11 @@ static FrtScorer *bw_scorer(FrtWeight *self, FrtIndexReader *ir)
|
|
1144
1061
|
return bsc;
|
1145
1062
|
}
|
1146
1063
|
|
1147
|
-
static char *bw_to_s(FrtWeight *self)
|
1148
|
-
{
|
1064
|
+
static char *bw_to_s(FrtWeight *self) {
|
1149
1065
|
return frt_strfmt("BooleanWeight(%f)", self->value);
|
1150
1066
|
}
|
1151
1067
|
|
1152
|
-
static void bw_destroy(FrtWeight *self)
|
1153
|
-
{
|
1068
|
+
static void bw_destroy(FrtWeight *self) {
|
1154
1069
|
int i;
|
1155
1070
|
|
1156
1071
|
for (i = 0; i < BW(self)->w_cnt; i++) {
|
@@ -1333,8 +1248,7 @@ static FrtQuery *bq_rewrite(FrtQuery *self, FrtIndexReader *ir) {
|
|
1333
1248
|
if ((q == clause->query) && BQ(self)->original_boost) {
|
1334
1249
|
/* rewrite was no-op */
|
1335
1250
|
q->boost = BQ(self)->original_boost * self->boost;
|
1336
|
-
}
|
1337
|
-
else {
|
1251
|
+
} else {
|
1338
1252
|
/* save original boost in case query is rewritten again */
|
1339
1253
|
BQ(self)->original_boost = q->boost;
|
1340
1254
|
q->boost *= self->boost;
|