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.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/ext/isomorfeus_ferret_ext/benchmark.c +9 -20
  3. data/ext/isomorfeus_ferret_ext/benchmarks_all.h +1 -2
  4. data/ext/isomorfeus_ferret_ext/bm_hash.c +1 -2
  5. data/ext/isomorfeus_ferret_ext/brotli_dec_decode.c +4 -2
  6. data/ext/isomorfeus_ferret_ext/brotli_enc_encode.c +3 -2
  7. data/ext/isomorfeus_ferret_ext/frb_analysis.c +4 -5
  8. data/ext/isomorfeus_ferret_ext/frb_field_info.c +3 -4
  9. data/ext/isomorfeus_ferret_ext/frb_index.c +118 -125
  10. data/ext/isomorfeus_ferret_ext/frb_lazy_doc.c +14 -16
  11. data/ext/isomorfeus_ferret_ext/frb_search.c +31 -23
  12. data/ext/isomorfeus_ferret_ext/frb_store.c +27 -13
  13. data/ext/isomorfeus_ferret_ext/frb_utils.c +3 -6
  14. data/ext/isomorfeus_ferret_ext/frt_analysis.c +39 -46
  15. data/ext/isomorfeus_ferret_ext/frt_analysis.h +9 -9
  16. data/ext/isomorfeus_ferret_ext/frt_array.c +11 -22
  17. data/ext/isomorfeus_ferret_ext/frt_bitvector.h +3 -6
  18. data/ext/isomorfeus_ferret_ext/frt_doc_field.c +87 -0
  19. data/ext/isomorfeus_ferret_ext/frt_doc_field.h +26 -0
  20. data/ext/isomorfeus_ferret_ext/frt_document.c +4 -97
  21. data/ext/isomorfeus_ferret_ext/frt_document.h +2 -27
  22. data/ext/isomorfeus_ferret_ext/frt_except.c +8 -6
  23. data/ext/isomorfeus_ferret_ext/frt_except.h +1 -2
  24. data/ext/isomorfeus_ferret_ext/frt_field_index.c +13 -32
  25. data/ext/isomorfeus_ferret_ext/frt_field_index.h +0 -6
  26. data/ext/isomorfeus_ferret_ext/frt_field_info.c +69 -0
  27. data/ext/isomorfeus_ferret_ext/frt_field_info.h +49 -0
  28. data/ext/isomorfeus_ferret_ext/frt_field_infos.c +196 -0
  29. data/ext/isomorfeus_ferret_ext/frt_field_infos.h +35 -0
  30. data/ext/isomorfeus_ferret_ext/frt_global.c +10 -4
  31. data/ext/isomorfeus_ferret_ext/frt_global.h +11 -15
  32. data/ext/isomorfeus_ferret_ext/frt_hash.c +8 -8
  33. data/ext/isomorfeus_ferret_ext/frt_hash.h +1 -2
  34. data/ext/isomorfeus_ferret_ext/frt_hashset.c +20 -40
  35. data/ext/isomorfeus_ferret_ext/frt_hashset.h +1 -2
  36. data/ext/isomorfeus_ferret_ext/frt_helper.c +7 -15
  37. data/ext/isomorfeus_ferret_ext/frt_in_stream.c +35 -45
  38. data/ext/isomorfeus_ferret_ext/frt_in_stream.h +3 -2
  39. data/ext/isomorfeus_ferret_ext/frt_ind.c +20 -38
  40. data/ext/isomorfeus_ferret_ext/frt_index.c +292 -790
  41. data/ext/isomorfeus_ferret_ext/frt_index.h +1 -102
  42. data/ext/isomorfeus_ferret_ext/frt_lang.c +5 -10
  43. data/ext/isomorfeus_ferret_ext/frt_lazy_doc.c +3 -3
  44. data/ext/isomorfeus_ferret_ext/frt_lazy_doc.h +1 -1
  45. data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.c +18 -25
  46. data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.h +5 -5
  47. data/ext/isomorfeus_ferret_ext/frt_mdbx_store.c +102 -70
  48. data/ext/isomorfeus_ferret_ext/frt_mempool.c +8 -16
  49. data/ext/isomorfeus_ferret_ext/frt_multimapper.c +23 -46
  50. data/ext/isomorfeus_ferret_ext/frt_multimapper.h +4 -8
  51. data/ext/isomorfeus_ferret_ext/frt_out_stream.c +31 -43
  52. data/ext/isomorfeus_ferret_ext/frt_out_stream.h +2 -2
  53. data/ext/isomorfeus_ferret_ext/frt_posh.c +6 -819
  54. data/ext/isomorfeus_ferret_ext/frt_posh.h +0 -57
  55. data/ext/isomorfeus_ferret_ext/frt_priorityqueue.c +11 -22
  56. data/ext/isomorfeus_ferret_ext/frt_priorityqueue.h +1 -2
  57. data/ext/isomorfeus_ferret_ext/frt_q_boolean.c +85 -171
  58. data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +8 -16
  59. data/ext/isomorfeus_ferret_ext/frt_q_multi_term.c +1 -2
  60. data/ext/isomorfeus_ferret_ext/frt_q_parser.c +49 -98
  61. data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +52 -104
  62. data/ext/isomorfeus_ferret_ext/frt_q_range.c +6 -12
  63. data/ext/isomorfeus_ferret_ext/frt_q_span.c +113 -226
  64. data/ext/isomorfeus_ferret_ext/frt_q_wildcard.c +1 -2
  65. data/ext/isomorfeus_ferret_ext/frt_ram_store.c +134 -85
  66. data/ext/isomorfeus_ferret_ext/frt_search.c +82 -164
  67. data/ext/isomorfeus_ferret_ext/frt_similarity.c +11 -22
  68. data/ext/isomorfeus_ferret_ext/frt_similarity.h +1 -2
  69. data/ext/isomorfeus_ferret_ext/frt_store.c +13 -25
  70. data/ext/isomorfeus_ferret_ext/frt_store.h +86 -52
  71. data/ext/isomorfeus_ferret_ext/frt_term_vectors.c +8 -16
  72. data/ext/isomorfeus_ferret_ext/frt_win32.h +5 -10
  73. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +12 -11
  74. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.h +11 -13
  75. data/ext/isomorfeus_ferret_ext/lz4.c +422 -195
  76. data/ext/isomorfeus_ferret_ext/lz4.h +114 -46
  77. data/ext/isomorfeus_ferret_ext/lz4frame.c +421 -242
  78. data/ext/isomorfeus_ferret_ext/lz4frame.h +122 -53
  79. data/ext/isomorfeus_ferret_ext/lz4hc.c +127 -111
  80. data/ext/isomorfeus_ferret_ext/lz4hc.h +14 -14
  81. data/ext/isomorfeus_ferret_ext/lz4xxhash.h +1 -1
  82. data/ext/isomorfeus_ferret_ext/mdbx.c +3762 -2526
  83. data/ext/isomorfeus_ferret_ext/mdbx.h +115 -70
  84. data/ext/isomorfeus_ferret_ext/test.c +40 -87
  85. data/ext/isomorfeus_ferret_ext/test.h +3 -6
  86. data/ext/isomorfeus_ferret_ext/test_1710.c +11 -13
  87. data/ext/isomorfeus_ferret_ext/test_analysis.c +32 -64
  88. data/ext/isomorfeus_ferret_ext/test_array.c +6 -12
  89. data/ext/isomorfeus_ferret_ext/test_bitvector.c +12 -24
  90. data/ext/isomorfeus_ferret_ext/test_document.c +23 -33
  91. data/ext/isomorfeus_ferret_ext/test_except.c +10 -21
  92. data/ext/isomorfeus_ferret_ext/test_fields.c +62 -68
  93. data/ext/isomorfeus_ferret_ext/test_file_deleter.c +15 -23
  94. data/ext/isomorfeus_ferret_ext/test_filter.c +17 -27
  95. data/ext/isomorfeus_ferret_ext/test_global.c +14 -29
  96. data/ext/isomorfeus_ferret_ext/test_hash.c +19 -38
  97. data/ext/isomorfeus_ferret_ext/test_hashset.c +8 -16
  98. data/ext/isomorfeus_ferret_ext/test_helper.c +4 -8
  99. data/ext/isomorfeus_ferret_ext/test_highlighter.c +16 -28
  100. data/ext/isomorfeus_ferret_ext/test_index.c +277 -487
  101. data/ext/isomorfeus_ferret_ext/test_lang.c +7 -14
  102. data/ext/isomorfeus_ferret_ext/test_mdbx_store.c +2 -5
  103. data/ext/isomorfeus_ferret_ext/test_mempool.c +5 -10
  104. data/ext/isomorfeus_ferret_ext/test_multimapper.c +3 -6
  105. data/ext/isomorfeus_ferret_ext/test_priorityqueue.c +9 -18
  106. data/ext/isomorfeus_ferret_ext/test_q_const_score.c +4 -6
  107. data/ext/isomorfeus_ferret_ext/test_q_filtered.c +3 -4
  108. data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +9 -15
  109. data/ext/isomorfeus_ferret_ext/test_q_parser.c +8 -16
  110. data/ext/isomorfeus_ferret_ext/test_q_span.c +19 -35
  111. data/ext/isomorfeus_ferret_ext/test_ram_store.c +14 -13
  112. data/ext/isomorfeus_ferret_ext/test_search.c +60 -109
  113. data/ext/isomorfeus_ferret_ext/test_segments.c +8 -13
  114. data/ext/isomorfeus_ferret_ext/test_similarity.c +2 -4
  115. data/ext/isomorfeus_ferret_ext/test_sort.c +14 -24
  116. data/ext/isomorfeus_ferret_ext/test_store.c +96 -115
  117. data/ext/isomorfeus_ferret_ext/test_term.c +9 -15
  118. data/ext/isomorfeus_ferret_ext/test_term_vectors.c +9 -14
  119. data/ext/isomorfeus_ferret_ext/test_test.c +4 -8
  120. data/ext/isomorfeus_ferret_ext/test_threading.c +14 -20
  121. data/ext/isomorfeus_ferret_ext/testhelper.c +11 -21
  122. data/ext/isomorfeus_ferret_ext/testhelper.h +1 -1
  123. data/ext/isomorfeus_ferret_ext/tests_all.h +1 -2
  124. data/lib/isomorfeus/ferret/index/index.rb +1 -1
  125. data/lib/isomorfeus/ferret/version.rb +1 -1
  126. metadata +24 -4
@@ -16,13 +16,11 @@
16
16
 
17
17
  #define SpQ(query) ((FrtSpanQuery *)(query))
18
18
 
19
- static unsigned long long spanq_hash(FrtQuery *self)
20
- {
19
+ static unsigned long long spanq_hash(FrtQuery *self) {
21
20
  return SpQ(self)->field ? frt_str_hash(rb_id2name(SpQ(self)->field)) : 0;
22
21
  }
23
22
 
24
- static int spanq_eq(FrtQuery *self, FrtQuery *o)
25
- {
23
+ static int spanq_eq(FrtQuery *self, FrtQuery *o) {
26
24
  return SpQ(self)->field == SpQ(o)->field;
27
25
  }
28
26
 
@@ -31,8 +29,7 @@ static void spanq_destroy_i(FrtQuery *self) {
31
29
  }
32
30
 
33
31
  static FrtMatchVector *mv_to_term_mv(FrtMatchVector *term_mv, FrtMatchVector *full_mv,
34
- FrtHashSet *terms, FrtTermVector *tv)
35
- {
32
+ FrtHashSet *terms, FrtTermVector *tv) {
36
33
  FrtHashSetEntry *hse;
37
34
  for (hse = terms->first; hse; hse = hse->next) {
38
35
  char *term = (char *)hse->elem;
@@ -63,8 +60,7 @@ static FrtMatchVector *mv_to_term_mv(FrtMatchVector *term_mv, FrtMatchVector *fu
63
60
 
64
61
  #define TV_TDE(tde) ((TVTermDocEnum *)(tde))
65
62
 
66
- typedef struct TVTermDocEnum
67
- {
63
+ typedef struct TVTermDocEnum {
68
64
  FrtTermDocEnum super;
69
65
  int doc;
70
66
  int index;
@@ -73,8 +69,7 @@ typedef struct TVTermDocEnum
73
69
  FrtTermVector *tv;
74
70
  } TVTermDocEnum;
75
71
 
76
- static void tv_tde_seek(FrtTermDocEnum *tde, int field_num, const char *term)
77
- {
72
+ static void tv_tde_seek(FrtTermDocEnum *tde, int field_num, const char *term) {
78
73
  TVTermDocEnum *tv_tde = TV_TDE(tde);
79
74
  FrtTVTerm *tv_term = frt_tv_get_tv_term(tv_tde->tv, term);
80
75
  (void)field_num;
@@ -83,53 +78,44 @@ static void tv_tde_seek(FrtTermDocEnum *tde, int field_num, const char *term)
83
78
  tv_tde->index = 0;
84
79
  tv_tde->freq = tv_term->freq;
85
80
  tv_tde->positions = tv_term->positions;
86
- }
87
- else {
81
+ } else {
88
82
  tv_tde->doc = INT_MAX;
89
83
  }
90
84
  }
91
85
 
92
- static bool tv_tde_next(FrtTermDocEnum *tde)
93
- {
86
+ static bool tv_tde_next(FrtTermDocEnum *tde) {
94
87
  if (TV_TDE(tde)->doc == -1) {
95
88
  TV_TDE(tde)->doc = 0;
96
89
  return true;
97
- }
98
- else {
90
+ } else {
99
91
  TV_TDE(tde)->doc = INT_MAX;
100
92
  return false;
101
93
  }
102
94
  }
103
95
 
104
- static bool tv_tde_skip_to(FrtTermDocEnum *tde, int doc_num)
105
- {
96
+ static bool tv_tde_skip_to(FrtTermDocEnum *tde, int doc_num) {
106
97
  if (doc_num == 0) {
107
98
  TV_TDE(tde)->doc = 0;
108
99
  return true;
109
- }
110
- else {
100
+ } else {
111
101
  TV_TDE(tde)->doc = INT_MAX;
112
102
  return false;
113
103
  }
114
104
  }
115
105
 
116
- static int tv_tde_next_position(FrtTermDocEnum *tde)
117
- {
106
+ static int tv_tde_next_position(FrtTermDocEnum *tde) {
118
107
  return TV_TDE(tde)->positions[TV_TDE(tde)->index++];
119
108
  }
120
109
 
121
- static int tv_tde_freq(FrtTermDocEnum *tde)
122
- {
110
+ static int tv_tde_freq(FrtTermDocEnum *tde) {
123
111
  return TV_TDE(tde)->freq;
124
112
  }
125
113
 
126
- static int tv_tde_doc_num(FrtTermDocEnum *tde)
127
- {
114
+ static int tv_tde_doc_num(FrtTermDocEnum *tde) {
128
115
  return TV_TDE(tde)->doc;
129
116
  }
130
117
 
131
- static FrtTermDocEnum *spanq_ir_term_positions(FrtIndexReader *ir)
132
- {
118
+ static FrtTermDocEnum *spanq_ir_term_positions(FrtIndexReader *ir) {
133
119
  TVTermDocEnum *tv_tde = FRT_ALLOC(TVTermDocEnum);
134
120
  FrtTermDocEnum *tde = (FrtTermDocEnum *)tv_tde;
135
121
  tv_tde->tv = (FrtTermVector *)ir->store;
@@ -180,8 +166,7 @@ static FrtMatchVector *spanq_get_matchv_i(FrtQuery *self, FrtMatchVector *mv, Fr
180
166
  ***************************************************************************/
181
167
 
182
168
  #define SpSc(scorer) ((SpanScorer *)(scorer))
183
- typedef struct SpanScorer
184
- {
169
+ typedef struct SpanScorer {
185
170
  FrtScorer super;
186
171
  FrtIndexReader *ir;
187
172
  FrtSpanEnum *spans;
@@ -194,8 +179,7 @@ typedef struct SpanScorer
194
179
  bool more : 1;
195
180
  } SpanScorer;
196
181
 
197
- static float spansc_score(FrtScorer *self)
198
- {
182
+ static float spansc_score(FrtScorer *self) {
199
183
  SpanScorer *spansc = SpSc(self);
200
184
  float raw = frt_sim_tf(spansc->sim, spansc->freq) * spansc->value;
201
185
 
@@ -203,8 +187,7 @@ static float spansc_score(FrtScorer *self)
203
187
  return raw * frt_sim_decode_norm(self->similarity, spansc->norms[self->doc]);
204
188
  }
205
189
 
206
- static bool spansc_next(FrtScorer *self)
207
- {
190
+ static bool spansc_next(FrtScorer *self) {
208
191
  SpanScorer *spansc = SpSc(self);
209
192
  FrtSpanEnum *se = spansc->spans;
210
193
  int match_length;
@@ -230,8 +213,7 @@ static bool spansc_next(FrtScorer *self)
230
213
  return (spansc->more || (spansc->freq != 0.0));
231
214
  }
232
215
 
233
- static bool spansc_skip_to(FrtScorer *self, int target)
234
- {
216
+ static bool spansc_skip_to(FrtScorer *self, int target) {
235
217
  SpanScorer *spansc = SpSc(self);
236
218
  FrtSpanEnum *se = spansc->spans;
237
219
 
@@ -254,8 +236,7 @@ static bool spansc_skip_to(FrtScorer *self, int target)
254
236
  return (spansc->more || (spansc->freq != 0.0));
255
237
  }
256
238
 
257
- static FrtExplanation *spansc_explain(FrtScorer *self, int target)
258
- {
239
+ static FrtExplanation *spansc_explain(FrtScorer *self, int target) {
259
240
  FrtExplanation *tf_explanation;
260
241
  SpanScorer *spansc = SpSc(self);
261
242
  float phrase_freq;
@@ -268,8 +249,7 @@ static FrtExplanation *spansc_explain(FrtScorer *self, int target)
268
249
  return tf_explanation;
269
250
  }
270
251
 
271
- static void spansc_destroy(FrtScorer *self)
272
- {
252
+ static void spansc_destroy(FrtScorer *self) {
273
253
  SpanScorer *spansc = SpSc(self);
274
254
  if (spansc->spans) {
275
255
  spansc->spans->destroy(spansc->spans);
@@ -277,8 +257,7 @@ static void spansc_destroy(FrtScorer *self)
277
257
  frt_scorer_destroy_i(self);
278
258
  }
279
259
 
280
- static FrtScorer *spansc_new(FrtWeight *weight, FrtIndexReader *ir)
281
- {
260
+ static FrtScorer *spansc_new(FrtWeight *weight, FrtIndexReader *ir) {
282
261
  FrtScorer *self = NULL;
283
262
  const int field_num = frt_fis_get_field_num(ir->fis, SpQ(weight->query)->field);
284
263
  if (field_num >= 0) {
@@ -310,8 +289,7 @@ static FrtScorer *spansc_new(FrtWeight *weight, FrtIndexReader *ir)
310
289
  #define SpTEn(span_enum) ((SpanTermEnum *)(span_enum))
311
290
  #define SpTQ(query) ((FrtSpanTermQuery *)(query))
312
291
 
313
- typedef struct SpanTermEnum
314
- {
292
+ typedef struct SpanTermEnum {
315
293
  FrtSpanEnum super;
316
294
  FrtTermDocEnum *positions;
317
295
  int position;
@@ -321,8 +299,7 @@ typedef struct SpanTermEnum
321
299
  } SpanTermEnum;
322
300
 
323
301
 
324
- static bool spante_next(FrtSpanEnum *self)
325
- {
302
+ static bool spante_next(FrtSpanEnum *self) {
326
303
  SpanTermEnum *ste = SpTEn(self);
327
304
  FrtTermDocEnum *tde = ste->positions;
328
305
 
@@ -340,8 +317,7 @@ static bool spante_next(FrtSpanEnum *self)
340
317
  return true;
341
318
  }
342
319
 
343
- static bool spante_skip_to(FrtSpanEnum *self, int target)
344
- {
320
+ static bool spante_skip_to(FrtSpanEnum *self, int target) {
345
321
  SpanTermEnum *ste = SpTEn(self);
346
322
  FrtTermDocEnum *tde = ste->positions;
347
323
 
@@ -367,18 +343,15 @@ static bool spante_skip_to(FrtSpanEnum *self, int target)
367
343
  return true;
368
344
  }
369
345
 
370
- static int spante_doc(FrtSpanEnum *self)
371
- {
346
+ static int spante_doc(FrtSpanEnum *self) {
372
347
  return SpTEn(self)->doc;
373
348
  }
374
349
 
375
- static int spante_start(FrtSpanEnum *self)
376
- {
350
+ static int spante_start(FrtSpanEnum *self) {
377
351
  return SpTEn(self)->position;
378
352
  }
379
353
 
380
- static int spante_end(FrtSpanEnum *self)
381
- {
354
+ static int spante_end(FrtSpanEnum *self) {
382
355
  return SpTEn(self)->position + 1;
383
356
  }
384
357
 
@@ -391,12 +364,10 @@ static char *spante_to_s(FrtSpanEnum *self) {
391
364
 
392
365
  if (self->doc(self) < 0) {
393
366
  sprintf(pos_str, "START");
394
- }
395
- else {
367
+ } else {
396
368
  if (self->doc(self) == INT_MAX) {
397
369
  sprintf(pos_str, "END");
398
- }
399
- else {
370
+ } else {
400
371
  pos = SpTEn(self)->position;
401
372
  sprintf(pos_str, "%d", self->doc(self) - pos);
402
373
  }
@@ -406,15 +377,13 @@ static char *spante_to_s(FrtSpanEnum *self) {
406
377
  return str;
407
378
  }
408
379
 
409
- static void spante_destroy(FrtSpanEnum *self)
410
- {
380
+ static void spante_destroy(FrtSpanEnum *self) {
411
381
  FrtTermDocEnum *tde = SpTEn(self)->positions;
412
382
  tde->close(tde);
413
383
  free(self);
414
384
  }
415
385
 
416
- static FrtSpanEnum *spante_new(FrtQuery *query, FrtIndexReader *ir)
417
- {
386
+ static FrtSpanEnum *spante_new(FrtQuery *query, FrtIndexReader *ir) {
418
387
  char *term = SpTQ(query)->term;
419
388
  FrtSpanEnum *self = (FrtSpanEnum *)FRT_ALLOC(SpanTermEnum);
420
389
 
@@ -444,8 +413,7 @@ static FrtSpanEnum *spante_new(FrtQuery *query, FrtIndexReader *ir)
444
413
  /* * TermPosEnumWrapper * */
445
414
  #define TPE_READ_SIZE 16
446
415
 
447
- typedef struct TermPosEnumWrapper
448
- {
416
+ typedef struct TermPosEnumWrapper {
449
417
  const char *term;
450
418
  FrtTermDocEnum *tpe;
451
419
  int doc;
@@ -453,14 +421,12 @@ typedef struct TermPosEnumWrapper
453
421
  } TermPosEnumWrapper;
454
422
 
455
423
  static bool tpew_less_than(const TermPosEnumWrapper *tpew1,
456
- const TermPosEnumWrapper *tpew2)
457
- {
424
+ const TermPosEnumWrapper *tpew2) {
458
425
  return (tpew1->doc < tpew2->doc)
459
426
  || (tpew1->doc == tpew2->doc && tpew1->pos < tpew2->pos);
460
427
  }
461
428
 
462
- static bool tpew_next(TermPosEnumWrapper *self)
463
- {
429
+ static bool tpew_next(TermPosEnumWrapper *self) {
464
430
  FrtTermDocEnum *tpe = self->tpe;
465
431
  if (0 > (self->pos = tpe->next_position(tpe))) {
466
432
  if (!tpe->next(tpe)) return false;
@@ -470,28 +436,24 @@ static bool tpew_next(TermPosEnumWrapper *self)
470
436
  return true;
471
437
  }
472
438
 
473
- static bool tpew_skip_to(TermPosEnumWrapper *self, int doc_num)
474
- {
439
+ static bool tpew_skip_to(TermPosEnumWrapper *self, int doc_num) {
475
440
  FrtTermDocEnum *tpe = self->tpe;
476
441
 
477
442
  if (tpe->skip_to(tpe, doc_num)) {
478
443
  self->doc = tpe->doc_num(tpe);
479
444
  self->pos = tpe->next_position(tpe);
480
445
  return true;
481
- }
482
- else {
446
+ } else {
483
447
  return false;
484
448
  }
485
449
  }
486
450
 
487
- static void tpew_destroy(TermPosEnumWrapper *self)
488
- {
451
+ static void tpew_destroy(TermPosEnumWrapper *self) {
489
452
  self->tpe->close(self->tpe);
490
453
  free(self);
491
454
  }
492
455
 
493
- static TermPosEnumWrapper *tpew_new(const char *term, FrtTermDocEnum *tpe)
494
- {
456
+ static TermPosEnumWrapper *tpew_new(const char *term, FrtTermDocEnum *tpe) {
495
457
  TermPosEnumWrapper *self = FRT_ALLOC_AND_ZERO(TermPosEnumWrapper);
496
458
  self->term = term;
497
459
  self->tpe = tpe;
@@ -502,8 +464,7 @@ static TermPosEnumWrapper *tpew_new(const char *term, FrtTermDocEnum *tpe)
502
464
  #define SpMTEn(span_enum) ((SpanMultiTermEnum *)(span_enum))
503
465
  #define SpMTQ(query) ((FrtSpanMultiTermQuery *)(query))
504
466
 
505
- typedef struct SpanMultiTermEnum
506
- {
467
+ typedef struct SpanMultiTermEnum {
507
468
  FrtSpanEnum super;
508
469
  FrtPriorityQueue *tpew_pq;
509
470
  TermPosEnumWrapper **tpews;
@@ -512,8 +473,7 @@ typedef struct SpanMultiTermEnum
512
473
  int doc;
513
474
  } SpanMultiTermEnum;
514
475
 
515
- static bool spanmte_next(FrtSpanEnum *self)
516
- {
476
+ static bool spanmte_next(FrtSpanEnum *self) {
517
477
  int curr_doc, curr_pos;
518
478
  TermPosEnumWrapper *tpew;
519
479
  SpanMultiTermEnum *mte = SpMTEn(self);
@@ -541,8 +501,7 @@ static bool spanmte_next(FrtSpanEnum *self)
541
501
  do {
542
502
  if (tpew_next(tpew)) {
543
503
  frt_pq_down(tpew_pq);
544
- }
545
- else {
504
+ } else {
546
505
  frt_pq_pop(tpew_pq);
547
506
  }
548
507
  } while (((tpew = (TermPosEnumWrapper *)frt_pq_top(tpew_pq)) != NULL)
@@ -550,8 +509,7 @@ static bool spanmte_next(FrtSpanEnum *self)
550
509
  return true;
551
510
  }
552
511
 
553
- static bool spanmte_skip_to(FrtSpanEnum *self, int target)
554
- {
512
+ static bool spanmte_skip_to(FrtSpanEnum *self, int target) {
555
513
  SpanMultiTermEnum *mte = SpMTEn(self);
556
514
  FrtPriorityQueue *tpew_pq = mte->tpew_pq;
557
515
  TermPosEnumWrapper *tpew;
@@ -573,31 +531,26 @@ static bool spanmte_skip_to(FrtSpanEnum *self, int target)
573
531
  && (target > tpew->doc)) {
574
532
  if (tpew_skip_to(tpew, target)) {
575
533
  frt_pq_down(tpew_pq);
576
- }
577
- else {
534
+ } else {
578
535
  frt_pq_pop(tpew_pq);
579
536
  }
580
537
  }
581
538
  return spanmte_next(self);
582
539
  }
583
540
 
584
- static int spanmte_doc(FrtSpanEnum *self)
585
- {
541
+ static int spanmte_doc(FrtSpanEnum *self) {
586
542
  return SpMTEn(self)->doc;
587
543
  }
588
544
 
589
- static int spanmte_start(FrtSpanEnum *self)
590
- {
545
+ static int spanmte_start(FrtSpanEnum *self) {
591
546
  return SpMTEn(self)->pos;
592
547
  }
593
548
 
594
- static int spanmte_end(FrtSpanEnum *self)
595
- {
549
+ static int spanmte_end(FrtSpanEnum *self) {
596
550
  return SpMTEn(self)->pos + 1;
597
551
  }
598
552
 
599
- static void spanmte_destroy(FrtSpanEnum *self)
600
- {
553
+ static void spanmte_destroy(FrtSpanEnum *self) {
601
554
  SpanMultiTermEnum *mte = SpMTEn(self);
602
555
  int i;
603
556
  if (mte->tpew_pq) frt_pq_destroy(mte->tpew_pq);
@@ -608,8 +561,7 @@ static void spanmte_destroy(FrtSpanEnum *self)
608
561
  free(self);
609
562
  }
610
563
 
611
- static FrtSpanEnum *spanmte_new(FrtQuery *query, FrtIndexReader *ir)
612
- {
564
+ static FrtSpanEnum *spanmte_new(FrtQuery *query, FrtIndexReader *ir) {
613
565
  FrtSpanEnum *self = (FrtSpanEnum *)FRT_ALLOC(SpanMultiTermEnum);
614
566
  SpanMultiTermEnum *smte = SpMTEn(self);
615
567
  FrtSpanMultiTermQuery *smtq = SpMTQ(query);
@@ -647,15 +599,13 @@ static FrtSpanEnum *spanmte_new(FrtQuery *query, FrtIndexReader *ir)
647
599
  #define SpFEn(span_enum) ((SpanFirstEnum *)(span_enum))
648
600
  #define SpFQ(query) ((FrtSpanFirstQuery *)(query))
649
601
 
650
- typedef struct SpanFirstEnum
651
- {
602
+ typedef struct SpanFirstEnum {
652
603
  FrtSpanEnum super;
653
604
  FrtSpanEnum *sub_enum;
654
605
  } SpanFirstEnum;
655
606
 
656
607
 
657
- static bool spanfe_next(FrtSpanEnum *self)
658
- {
608
+ static bool spanfe_next(FrtSpanEnum *self) {
659
609
  FrtSpanEnum *sub_enum = SpFEn(self)->sub_enum;
660
610
  int end = SpFQ(self->query)->end;
661
611
  while (sub_enum->next(sub_enum)) { /* scan to next match */
@@ -666,8 +616,7 @@ static bool spanfe_next(FrtSpanEnum *self)
666
616
  return false;
667
617
  }
668
618
 
669
- static bool spanfe_skip_to(FrtSpanEnum *self, int target)
670
- {
619
+ static bool spanfe_skip_to(FrtSpanEnum *self, int target) {
671
620
  FrtSpanEnum *sub_enum = SpFEn(self)->sub_enum;
672
621
  int end = SpFQ(self->query)->end;
673
622
 
@@ -682,20 +631,17 @@ static bool spanfe_skip_to(FrtSpanEnum *self, int target)
682
631
  return spanfe_next(self); /* scan to next match */
683
632
  }
684
633
 
685
- static int spanfe_doc(FrtSpanEnum *self)
686
- {
634
+ static int spanfe_doc(FrtSpanEnum *self) {
687
635
  FrtSpanEnum *sub_enum = SpFEn(self)->sub_enum;
688
636
  return sub_enum->doc(sub_enum);
689
637
  }
690
638
 
691
- static int spanfe_start(FrtSpanEnum *self)
692
- {
639
+ static int spanfe_start(FrtSpanEnum *self) {
693
640
  FrtSpanEnum *sub_enum = SpFEn(self)->sub_enum;
694
641
  return sub_enum->start(sub_enum);
695
642
  }
696
643
 
697
- static int spanfe_end(FrtSpanEnum *self)
698
- {
644
+ static int spanfe_end(FrtSpanEnum *self) {
699
645
  FrtSpanEnum *sub_enum = SpFEn(self)->sub_enum;
700
646
  return sub_enum->end(sub_enum);
701
647
  }
@@ -707,15 +653,13 @@ static char *spanfe_to_s(FrtSpanEnum *self) {
707
653
  return res;
708
654
  }
709
655
 
710
- static void spanfe_destroy(FrtSpanEnum *self)
711
- {
656
+ static void spanfe_destroy(FrtSpanEnum *self) {
712
657
  FrtSpanEnum *sub_enum = SpFEn(self)->sub_enum;
713
658
  sub_enum->destroy(sub_enum);
714
659
  free(self);
715
660
  }
716
661
 
717
- static FrtSpanEnum *spanfe_new(FrtQuery *query, FrtIndexReader *ir)
718
- {
662
+ static FrtSpanEnum *spanfe_new(FrtQuery *query, FrtIndexReader *ir) {
719
663
  FrtSpanEnum *self = (FrtSpanEnum *)FRT_ALLOC(SpanFirstEnum);
720
664
  FrtSpanFirstQuery *sfq = SpFQ(query);
721
665
 
@@ -741,8 +685,7 @@ static FrtSpanEnum *spanfe_new(FrtQuery *query, FrtIndexReader *ir)
741
685
  #define SpOEn(span_enum) ((SpanOrEnum *)(span_enum))
742
686
  #define SpOQ(query) ((FrtSpanOrQuery *)(query))
743
687
 
744
- typedef struct SpanOrEnum
745
- {
688
+ typedef struct SpanOrEnum {
746
689
  FrtSpanEnum super;
747
690
  FrtPriorityQueue *queue;
748
691
  FrtSpanEnum **span_enums;
@@ -751,26 +694,22 @@ typedef struct SpanOrEnum
751
694
  } SpanOrEnum;
752
695
 
753
696
 
754
- static bool span_less_than(FrtSpanEnum *s1, FrtSpanEnum *s2)
755
- {
697
+ static bool span_less_than(FrtSpanEnum *s1, FrtSpanEnum *s2) {
756
698
  int doc_diff, start_diff;
757
699
  doc_diff = s1->doc(s1) - s2->doc(s2);
758
700
  if (doc_diff == 0) {
759
701
  start_diff = s1->start(s1) - s2->start(s2);
760
702
  if (start_diff == 0) {
761
703
  return s1->end(s1) < s2->end(s2);
762
- }
763
- else {
704
+ } else {
764
705
  return start_diff < 0;
765
706
  }
766
- }
767
- else {
707
+ } else {
768
708
  return doc_diff < 0;
769
709
  }
770
710
  }
771
711
 
772
- static bool spanoe_next(FrtSpanEnum *self)
773
- {
712
+ static bool spanoe_next(FrtSpanEnum *self) {
774
713
  SpanOrEnum *soe = SpOEn(self);
775
714
  FrtSpanEnum *se;
776
715
  int i;
@@ -801,8 +740,7 @@ static bool spanoe_next(FrtSpanEnum *self)
801
740
  return soe->queue->size != 0;
802
741
  }
803
742
 
804
- static bool spanoe_skip_to(FrtSpanEnum *self, int target)
805
- {
743
+ static bool spanoe_skip_to(FrtSpanEnum *self, int target) {
806
744
  SpanOrEnum *soe = SpOEn(self);
807
745
  FrtSpanEnum *se;
808
746
  int i;
@@ -815,15 +753,13 @@ static bool spanoe_skip_to(FrtSpanEnum *self, int target)
815
753
  }
816
754
  }
817
755
  soe->first_time = false;
818
- }
819
- else {
756
+ } else {
820
757
  while ((soe->queue->size != 0) &&
821
758
  ((se = (FrtSpanEnum *)frt_pq_top(soe->queue)) != NULL) &&
822
759
  (se->doc(se) < target)) {
823
760
  if (se->skip_to(se, target)) {
824
761
  frt_pq_down(soe->queue);
825
- }
826
- else {
762
+ } else {
827
763
  frt_pq_pop(soe->queue);
828
764
  }
829
765
  }
@@ -834,20 +770,17 @@ static bool spanoe_skip_to(FrtSpanEnum *self, int target)
834
770
 
835
771
  #define SpOEn_Top_SE(self) (FrtSpanEnum *)frt_pq_top(SpOEn(self)->queue)
836
772
 
837
- static int spanoe_doc(FrtSpanEnum *self)
838
- {
773
+ static int spanoe_doc(FrtSpanEnum *self) {
839
774
  FrtSpanEnum *se = SpOEn_Top_SE(self);
840
775
  return se->doc(se);
841
776
  }
842
777
 
843
- static int spanoe_start(FrtSpanEnum *self)
844
- {
778
+ static int spanoe_start(FrtSpanEnum *self) {
845
779
  FrtSpanEnum *se = SpOEn_Top_SE(self);
846
780
  return se->start(se);
847
781
  }
848
782
 
849
- static int spanoe_end(FrtSpanEnum *self)
850
- {
783
+ static int spanoe_end(FrtSpanEnum *self) {
851
784
  FrtSpanEnum *se = SpOEn_Top_SE(self);
852
785
  return se->end(se);
853
786
  }
@@ -861,12 +794,10 @@ static char *spanoe_to_s(FrtSpanEnum *self) {
861
794
 
862
795
  if (soe->first_time) {
863
796
  sprintf(doc_str, "START");
864
- }
865
- else {
797
+ } else {
866
798
  if (soe->queue->size == 0) {
867
799
  sprintf(doc_str, "END");
868
- }
869
- else {
800
+ } else {
870
801
  sprintf(doc_str, "%d:%d-%d", self->doc(self),
871
802
  self->start(self), self->end(self));
872
803
  }
@@ -876,8 +807,7 @@ static char *spanoe_to_s(FrtSpanEnum *self) {
876
807
  return str;
877
808
  }
878
809
 
879
- static void spanoe_destroy(FrtSpanEnum *self)
880
- {
810
+ static void spanoe_destroy(FrtSpanEnum *self) {
881
811
  FrtSpanEnum *se;
882
812
  SpanOrEnum *soe = SpOEn(self);
883
813
  int i;
@@ -890,8 +820,7 @@ static void spanoe_destroy(FrtSpanEnum *self)
890
820
  free(self);
891
821
  }
892
822
 
893
- static FrtSpanEnum *spanoe_new(FrtQuery *query, FrtIndexReader *ir)
894
- {
823
+ static FrtSpanEnum *spanoe_new(FrtQuery *query, FrtIndexReader *ir) {
895
824
  FrtQuery *clause;
896
825
  FrtSpanEnum *self = (FrtSpanEnum *)FRT_ALLOC(SpanOrEnum);
897
826
  FrtSpanOrQuery *soq = SpOQ(query);
@@ -928,8 +857,7 @@ static FrtSpanEnum *spanoe_new(FrtQuery *query, FrtIndexReader *ir)
928
857
  #define SpNEn(span_enum) ((SpanNearEnum *)(span_enum))
929
858
  #define SpNQ(query) ((FrtSpanNearQuery *)(query))
930
859
 
931
- typedef struct SpanNearEnum
932
- {
860
+ typedef struct SpanNearEnum {
933
861
  FrtSpanEnum super;
934
862
  FrtSpanEnum **span_enums;
935
863
  int s_cnt;
@@ -948,8 +876,7 @@ typedef struct SpanNearEnum
948
876
  se = sne->span_enums[sne->current];\
949
877
  } while (0);
950
878
 
951
- static bool sne_init(SpanNearEnum *sne)
952
- {
879
+ static bool sne_init(SpanNearEnum *sne) {
953
880
  FrtSpanEnum *se = sne->span_enums[sne->current];
954
881
  int prev_doc = se->doc(se);
955
882
  int i;
@@ -964,8 +891,7 @@ static bool sne_init(SpanNearEnum *sne)
964
891
  return true;
965
892
  }
966
893
 
967
- static bool sne_goto_next_doc(SpanNearEnum *sne)
968
- {
894
+ static bool sne_goto_next_doc(SpanNearEnum *sne) {
969
895
  FrtSpanEnum *se = sne->span_enums[sne->current];
970
896
  int prev_doc = se->doc(se);
971
897
 
@@ -981,8 +907,7 @@ static bool sne_goto_next_doc(SpanNearEnum *sne)
981
907
  return true;
982
908
  }
983
909
 
984
- static bool sne_next_unordered_match(FrtSpanEnum *self)
985
- {
910
+ static bool sne_next_unordered_match(FrtSpanEnum *self) {
986
911
  SpanNearEnum *sne = SpNEn(self);
987
912
  FrtSpanEnum *se, *min_se = NULL;
988
913
  int i;
@@ -1026,8 +951,7 @@ static bool sne_next_unordered_match(FrtSpanEnum *self)
1026
951
  }
1027
952
  }
1028
953
 
1029
- static bool sne_next_ordered_match(FrtSpanEnum *self)
1030
- {
954
+ static bool sne_next_ordered_match(FrtSpanEnum *self) {
1031
955
  SpanNearEnum *sne = SpNEn(self);
1032
956
  FrtSpanEnum *se;
1033
957
  int i;
@@ -1083,8 +1007,7 @@ static bool sne_next_ordered_match(FrtSpanEnum *self)
1083
1007
  sne->current = 0;
1084
1008
  return true;
1085
1009
 
1086
- }
1087
- else {
1010
+ } else {
1088
1011
  se = sne->span_enums[0];
1089
1012
  if (!se->next(se)) {
1090
1013
  return false;
@@ -1100,8 +1023,7 @@ static bool sne_next_ordered_match(FrtSpanEnum *self)
1100
1023
  }
1101
1024
  }
1102
1025
 
1103
- static bool sne_next_match(FrtSpanEnum *self)
1104
- {
1026
+ static bool sne_next_match(FrtSpanEnum *self) {
1105
1027
  SpanNearEnum *sne = SpNEn(self);
1106
1028
  FrtSpanEnum *se_curr, *se_next;
1107
1029
 
@@ -1121,14 +1043,12 @@ static bool sne_next_match(FrtSpanEnum *self)
1121
1043
 
1122
1044
  if (sne->in_order) {
1123
1045
  return sne_next_ordered_match(self);
1124
- }
1125
- else {
1046
+ } else {
1126
1047
  return sne_next_unordered_match(self);
1127
1048
  }
1128
1049
  }
1129
1050
 
1130
- static bool spanne_next(FrtSpanEnum *self)
1131
- {
1051
+ static bool spanne_next(FrtSpanEnum *self) {
1132
1052
  SpanNearEnum *sne = SpNEn(self);
1133
1053
  FrtSpanEnum *se;
1134
1054
 
@@ -1138,8 +1058,7 @@ static bool spanne_next(FrtSpanEnum *self)
1138
1058
  return sne_next_match(self);
1139
1059
  }
1140
1060
 
1141
- static bool spanne_skip_to(FrtSpanEnum *self, int target)
1142
- {
1061
+ static bool spanne_skip_to(FrtSpanEnum *self, int target) {
1143
1062
  FrtSpanEnum *se = SpNEn(self)->span_enums[SpNEn(self)->current];
1144
1063
  if (!se->skip_to(se, target)) {
1145
1064
  return false;
@@ -1148,18 +1067,15 @@ static bool spanne_skip_to(FrtSpanEnum *self, int target)
1148
1067
  return sne_next_match(self);
1149
1068
  }
1150
1069
 
1151
- static int spanne_doc(FrtSpanEnum *self)
1152
- {
1070
+ static int spanne_doc(FrtSpanEnum *self) {
1153
1071
  return SpNEn(self)->doc;
1154
1072
  }
1155
1073
 
1156
- static int spanne_start(FrtSpanEnum *self)
1157
- {
1074
+ static int spanne_start(FrtSpanEnum *self) {
1158
1075
  return SpNEn(self)->start;
1159
1076
  }
1160
1077
 
1161
- static int spanne_end(FrtSpanEnum *self)
1162
- {
1078
+ static int spanne_end(FrtSpanEnum *self) {
1163
1079
  return SpNEn(self)->end;
1164
1080
  }
1165
1081
 
@@ -1172,8 +1088,7 @@ static char *spanne_to_s(FrtSpanEnum *self) {
1172
1088
 
1173
1089
  if (sne->first_time) {
1174
1090
  sprintf(doc_str, "START");
1175
- }
1176
- else {
1091
+ } else {
1177
1092
  sprintf(doc_str, "%d:%d-%d", self->doc(self),
1178
1093
  self->start(self), self->end(self));
1179
1094
  }
@@ -1182,8 +1097,7 @@ static char *spanne_to_s(FrtSpanEnum *self) {
1182
1097
  return str;
1183
1098
  }
1184
1099
 
1185
- static void spanne_destroy(FrtSpanEnum *self)
1186
- {
1100
+ static void spanne_destroy(FrtSpanEnum *self) {
1187
1101
  FrtSpanEnum *se;
1188
1102
  SpanNearEnum *sne = SpNEn(self);
1189
1103
  int i;
@@ -1195,8 +1109,7 @@ static void spanne_destroy(FrtSpanEnum *self)
1195
1109
  free(self);
1196
1110
  }
1197
1111
 
1198
- static FrtSpanEnum *spanne_new(FrtQuery *query, FrtIndexReader *ir)
1199
- {
1112
+ static FrtSpanEnum *spanne_new(FrtQuery *query, FrtIndexReader *ir) {
1200
1113
  int i;
1201
1114
  FrtQuery *clause;
1202
1115
  FrtSpanEnum *self = (FrtSpanEnum *)FRT_ALLOC(SpanNearEnum);
@@ -1239,8 +1152,7 @@ static FrtSpanEnum *spanne_new(FrtQuery *query, FrtIndexReader *ir)
1239
1152
  #define SpXEn(span_enum) ((SpanNotEnum *)(span_enum))
1240
1153
  #define SpXQ(query) ((FrtSpanNotQuery *)(query))
1241
1154
 
1242
- typedef struct SpanNotEnum
1243
- {
1155
+ typedef struct SpanNotEnum {
1244
1156
  FrtSpanEnum super;
1245
1157
  FrtSpanEnum *inc;
1246
1158
  FrtSpanEnum *exc;
@@ -1249,8 +1161,7 @@ typedef struct SpanNotEnum
1249
1161
  } SpanNotEnum;
1250
1162
 
1251
1163
 
1252
- static bool spanxe_next(FrtSpanEnum *self)
1253
- {
1164
+ static bool spanxe_next(FrtSpanEnum *self) {
1254
1165
  SpanNotEnum *sxe = SpXEn(self);
1255
1166
  FrtSpanEnum *inc = sxe->inc, *exc = sxe->exc;
1256
1167
  if (sxe->more_inc) { /* move to next incl */
@@ -1279,8 +1190,7 @@ static bool spanxe_next(FrtSpanEnum *self)
1279
1190
  return sxe->more_inc;
1280
1191
  }
1281
1192
 
1282
- static bool spanxe_skip_to(FrtSpanEnum *self, int target)
1283
- {
1193
+ static bool spanxe_skip_to(FrtSpanEnum *self, int target) {
1284
1194
  SpanNotEnum *sxe = SpXEn(self);
1285
1195
  FrtSpanEnum *inc = sxe->inc, *exc = sxe->exc;
1286
1196
  int doc;
@@ -1308,20 +1218,17 @@ static bool spanxe_skip_to(FrtSpanEnum *self, int target)
1308
1218
  return spanxe_next(self); /* scan to next match */
1309
1219
  }
1310
1220
 
1311
- static int spanxe_doc(FrtSpanEnum *self)
1312
- {
1221
+ static int spanxe_doc(FrtSpanEnum *self) {
1313
1222
  FrtSpanEnum *inc = SpXEn(self)->inc;
1314
1223
  return inc->doc(inc);
1315
1224
  }
1316
1225
 
1317
- static int spanxe_start(FrtSpanEnum *self)
1318
- {
1226
+ static int spanxe_start(FrtSpanEnum *self) {
1319
1227
  FrtSpanEnum *inc = SpXEn(self)->inc;
1320
1228
  return inc->start(inc);
1321
1229
  }
1322
1230
 
1323
- static int spanxe_end(FrtSpanEnum *self)
1324
- {
1231
+ static int spanxe_end(FrtSpanEnum *self) {
1325
1232
  FrtSpanEnum *inc = SpXEn(self)->inc;
1326
1233
  return inc->end(inc);
1327
1234
  }
@@ -1333,16 +1240,14 @@ static char *spanxe_to_s(FrtSpanEnum *self) {
1333
1240
  return res;
1334
1241
  }
1335
1242
 
1336
- static void spanxe_destroy(FrtSpanEnum *self)
1337
- {
1243
+ static void spanxe_destroy(FrtSpanEnum *self) {
1338
1244
  SpanNotEnum *sxe = SpXEn(self);
1339
1245
  sxe->inc->destroy(sxe->inc);
1340
1246
  sxe->exc->destroy(sxe->exc);
1341
1247
  free(self);
1342
1248
  }
1343
1249
 
1344
- static FrtSpanEnum *spanxe_new(FrtQuery *query, FrtIndexReader *ir)
1345
- {
1250
+ static FrtSpanEnum *spanxe_new(FrtQuery *query, FrtIndexReader *ir) {
1346
1251
  FrtSpanEnum *self = (FrtSpanEnum *)FRT_ALLOC(SpanNotEnum);
1347
1252
  SpanNotEnum *sxe = SpXEn(self);
1348
1253
  FrtSpanNotQuery *sxq = SpXQ(query);
@@ -1413,8 +1318,7 @@ static FrtExplanation *spanw_explain(FrtWeight *self, FrtIndexReader *ir, int ta
1413
1318
  if (terms->size > 0) {
1414
1319
  df_i -= 2;
1415
1320
  doc_freqs[df_i] = '\0';
1416
- }
1417
- else {
1321
+ } else {
1418
1322
  doc_freqs = frt_estrdup("");
1419
1323
  }
1420
1324
 
@@ -1468,27 +1372,23 @@ static FrtExplanation *spanw_explain(FrtWeight *self, FrtIndexReader *ir, int ta
1468
1372
  if (query_expl->value == 1.0) {
1469
1373
  frt_expl_destroy(expl);
1470
1374
  return field_expl;
1471
- }
1472
- else {
1375
+ } else {
1473
1376
  expl->value = (query_expl->value * field_expl->value);
1474
1377
  frt_expl_add_detail(expl, field_expl);
1475
1378
  return expl;
1476
1379
  }
1477
1380
  }
1478
1381
 
1479
- static char *spanw_to_s(FrtWeight *self)
1480
- {
1382
+ static char *spanw_to_s(FrtWeight *self) {
1481
1383
  return frt_strfmt("SpanWeight(%f)", self->value);
1482
1384
  }
1483
1385
 
1484
- static void spanw_destroy(FrtWeight *self)
1485
- {
1386
+ static void spanw_destroy(FrtWeight *self) {
1486
1387
  frt_hs_destroy(SpW(self)->terms);
1487
1388
  frt_w_destroy(self);
1488
1389
  }
1489
1390
 
1490
- static FrtWeight *spanw_new(FrtQuery *query, FrtSearcher *searcher)
1491
- {
1391
+ static FrtWeight *spanw_new(FrtQuery *query, FrtSearcher *searcher) {
1492
1392
  FrtHashSetEntry *hse;
1493
1393
  FrtWeight *self = w_new(SpanWeight, query);
1494
1394
  FrtHashSet *terms = SpQ(query)->get_terms(query);
@@ -1943,8 +1843,7 @@ FrtQuery *frt_spanoq_new(void) {
1943
1843
  return frt_spanoq_init(self);
1944
1844
  }
1945
1845
 
1946
- FrtQuery *frt_spanoq_add_clause_nr(FrtQuery *self, FrtQuery *clause)
1947
- {
1846
+ FrtQuery *frt_spanoq_add_clause_nr(FrtQuery *self, FrtQuery *clause) {
1948
1847
  const int curr_index = SpOQ(self)->c_cnt++;
1949
1848
  if (clause->type < SPAN_TERM_QUERY || clause->type > SPAN_NEAR_QUERY) {
1950
1849
  FRT_RAISE(FRT_ARG_ERROR, "Tried to add a %s to a SpanOrQuery. This is not a "
@@ -1952,8 +1851,7 @@ FrtQuery *frt_spanoq_add_clause_nr(FrtQuery *self, FrtQuery *clause)
1952
1851
  }
1953
1852
  if (curr_index == 0) {
1954
1853
  SpQ(self)->field = SpQ(clause)->field;
1955
- }
1956
- else if (SpQ(self)->field != SpQ(clause)->field) {
1854
+ } else if (SpQ(self)->field != SpQ(clause)->field) {
1957
1855
  FRT_RAISE(FRT_ARG_ERROR, "All clauses in a SpanQuery must have the same field. "
1958
1856
  "Attempted to add a SpanQuery with field \"%s\" to a SpanOrQuery "
1959
1857
  "with field \"%s\"", rb_id2name(SpQ(clause)->field), rb_id2name(SpQ(self)->field));
@@ -1966,8 +1864,7 @@ FrtQuery *frt_spanoq_add_clause_nr(FrtQuery *self, FrtQuery *clause)
1966
1864
  return clause;
1967
1865
  }
1968
1866
 
1969
- FrtQuery *frt_spanoq_add_clause(FrtQuery *self, FrtQuery *clause)
1970
- {
1867
+ FrtQuery *frt_spanoq_add_clause(FrtQuery *self, FrtQuery *clause) {
1971
1868
  FRT_REF(clause);
1972
1869
  return frt_spanoq_add_clause_nr(self, clause);
1973
1870
  }
@@ -2004,8 +1901,7 @@ static char *spannq_to_s(FrtQuery *self, ID field) {
2004
1901
  return res;
2005
1902
  }
2006
1903
 
2007
- static void spannq_extract_terms(FrtQuery *self, FrtHashSet *terms)
2008
- {
1904
+ static void spannq_extract_terms(FrtQuery *self, FrtHashSet *terms) {
2009
1905
  FrtSpanNearQuery *snq = SpNQ(self);
2010
1906
  int i;
2011
1907
  for (i = 0; i < snq->c_cnt; i++) {
@@ -2014,8 +1910,7 @@ static void spannq_extract_terms(FrtQuery *self, FrtHashSet *terms)
2014
1910
  }
2015
1911
  }
2016
1912
 
2017
- static FrtHashSet *spannq_get_terms(FrtQuery *self)
2018
- {
1913
+ static FrtHashSet *spannq_get_terms(FrtQuery *self) {
2019
1914
  FrtSpanNearQuery *snq = SpNQ(self);
2020
1915
  FrtHashSet *terms = frt_hs_new_str(&free);
2021
1916
  int i;
@@ -2028,8 +1923,7 @@ static FrtHashSet *spannq_get_terms(FrtQuery *self)
2028
1923
  return terms;
2029
1924
  }
2030
1925
 
2031
- static FrtSpanEnum *spannq_get_spans(FrtQuery *self, FrtIndexReader *ir)
2032
- {
1926
+ static FrtSpanEnum *spannq_get_spans(FrtQuery *self, FrtIndexReader *ir) {
2033
1927
  FrtSpanNearQuery *snq = SpNQ(self);
2034
1928
 
2035
1929
  if (snq->c_cnt == 1) {
@@ -2040,8 +1934,7 @@ static FrtSpanEnum *spannq_get_spans(FrtQuery *self, FrtIndexReader *ir)
2040
1934
  return spanne_new(self, ir);
2041
1935
  }
2042
1936
 
2043
- static FrtQuery *spannq_rewrite(FrtQuery *self, FrtIndexReader *ir)
2044
- {
1937
+ static FrtQuery *spannq_rewrite(FrtQuery *self, FrtIndexReader *ir) {
2045
1938
  FrtSpanNearQuery *snq = SpNQ(self);
2046
1939
  int i;
2047
1940
  for (i = 0; i < snq->c_cnt; i++) {
@@ -2055,8 +1948,7 @@ static FrtQuery *spannq_rewrite(FrtQuery *self, FrtIndexReader *ir)
2055
1948
  return self;
2056
1949
  }
2057
1950
 
2058
- static void spannq_destroy(FrtQuery *self)
2059
- {
1951
+ static void spannq_destroy(FrtQuery *self) {
2060
1952
  FrtSpanNearQuery *snq = SpNQ(self);
2061
1953
 
2062
1954
  int i;
@@ -2069,8 +1961,7 @@ static void spannq_destroy(FrtQuery *self)
2069
1961
  spanq_destroy_i(self);
2070
1962
  }
2071
1963
 
2072
- static unsigned long long spannq_hash(FrtQuery *self)
2073
- {
1964
+ static unsigned long long spannq_hash(FrtQuery *self) {
2074
1965
  int i;
2075
1966
  unsigned long long hash = spanq_hash(self);
2076
1967
  FrtSpanNearQuery *snq = SpNQ(self);
@@ -2082,8 +1973,7 @@ static unsigned long long spannq_hash(FrtQuery *self)
2082
1973
  return ((hash ^ snq->slop) << 1) | snq->in_order;
2083
1974
  }
2084
1975
 
2085
- static int spannq_eq(FrtQuery *self, FrtQuery *o)
2086
- {
1976
+ static int spannq_eq(FrtQuery *self, FrtQuery *o) {
2087
1977
  int i;
2088
1978
  FrtQuery *q1, *q2;
2089
1979
  FrtSpanNearQuery *snq1 = SpNQ(self);
@@ -2138,8 +2028,7 @@ FrtQuery *frt_spannq_new(int slop, bool in_order) {
2138
2028
  return frt_spannq_init(self, slop, in_order);
2139
2029
  }
2140
2030
 
2141
- FrtQuery *frt_spannq_add_clause_nr(FrtQuery *self, FrtQuery *clause)
2142
- {
2031
+ FrtQuery *frt_spannq_add_clause_nr(FrtQuery *self, FrtQuery *clause) {
2143
2032
  const int curr_index = SpNQ(self)->c_cnt++;
2144
2033
  if (clause->type < SPAN_TERM_QUERY || clause->type > SPAN_NEAR_QUERY) {
2145
2034
  FRT_RAISE(FRT_ARG_ERROR, "Tried to add a %s to a SpanNearQuery. This is not a "
@@ -2147,8 +2036,7 @@ FrtQuery *frt_spannq_add_clause_nr(FrtQuery *self, FrtQuery *clause)
2147
2036
  }
2148
2037
  if (curr_index == 0) {
2149
2038
  SpQ(self)->field = SpQ(clause)->field;
2150
- }
2151
- else if (SpQ(self)->field != SpQ(clause)->field) {
2039
+ } else if (SpQ(self)->field != SpQ(clause)->field) {
2152
2040
  FRT_RAISE(FRT_ARG_ERROR, "All clauses in a SpanQuery must have the same field. "
2153
2041
  "Attempted to add a SpanQuery with field \"%s\" to SpanNearQuery "
2154
2042
  "with field \"%s\"", rb_id2name(SpQ(clause)->field), rb_id2name(SpQ(self)->field));
@@ -2161,8 +2049,7 @@ FrtQuery *frt_spannq_add_clause_nr(FrtQuery *self, FrtQuery *clause)
2161
2049
  return clause;
2162
2050
  }
2163
2051
 
2164
- FrtQuery *frt_spannq_add_clause(FrtQuery *self, FrtQuery *clause)
2165
- {
2052
+ FrtQuery *frt_spannq_add_clause(FrtQuery *self, FrtQuery *clause) {
2166
2053
  FRT_REF(clause);
2167
2054
  return frt_spannq_add_clause_nr(self, clause);
2168
2055
  }