isomorfeus-ferret 0.17.2 → 0.17.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) 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 +161 -187
  10. data/ext/isomorfeus_ferret_ext/frb_lazy_doc.c +14 -16
  11. data/ext/isomorfeus_ferret_ext/frb_search.c +77 -69
  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 +5 -33
  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 +14 -33
  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_filter.c +2 -2
  31. data/ext/isomorfeus_ferret_ext/frt_global.c +10 -4
  32. data/ext/isomorfeus_ferret_ext/frt_global.h +11 -15
  33. data/ext/isomorfeus_ferret_ext/frt_hash.c +8 -8
  34. data/ext/isomorfeus_ferret_ext/frt_hash.h +1 -2
  35. data/ext/isomorfeus_ferret_ext/frt_hashset.c +20 -40
  36. data/ext/isomorfeus_ferret_ext/frt_hashset.h +1 -2
  37. data/ext/isomorfeus_ferret_ext/frt_helper.c +7 -15
  38. data/ext/isomorfeus_ferret_ext/frt_in_stream.c +35 -45
  39. data/ext/isomorfeus_ferret_ext/frt_in_stream.h +3 -2
  40. data/ext/isomorfeus_ferret_ext/frt_ind.c +21 -39
  41. data/ext/isomorfeus_ferret_ext/frt_ind.h +1 -1
  42. data/ext/isomorfeus_ferret_ext/frt_index.c +334 -848
  43. data/ext/isomorfeus_ferret_ext/frt_index.h +4 -105
  44. data/ext/isomorfeus_ferret_ext/frt_lang.c +5 -10
  45. data/ext/isomorfeus_ferret_ext/frt_lazy_doc.c +3 -3
  46. data/ext/isomorfeus_ferret_ext/frt_lazy_doc.h +1 -1
  47. data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.c +18 -25
  48. data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.h +5 -5
  49. data/ext/isomorfeus_ferret_ext/frt_mdbx_store.c +102 -70
  50. data/ext/isomorfeus_ferret_ext/frt_mempool.c +8 -16
  51. data/ext/isomorfeus_ferret_ext/frt_multimapper.c +23 -46
  52. data/ext/isomorfeus_ferret_ext/frt_multimapper.h +4 -8
  53. data/ext/isomorfeus_ferret_ext/frt_out_stream.c +31 -43
  54. data/ext/isomorfeus_ferret_ext/frt_out_stream.h +2 -2
  55. data/ext/isomorfeus_ferret_ext/frt_posh.c +6 -819
  56. data/ext/isomorfeus_ferret_ext/frt_posh.h +0 -57
  57. data/ext/isomorfeus_ferret_ext/frt_priorityqueue.c +11 -22
  58. data/ext/isomorfeus_ferret_ext/frt_priorityqueue.h +1 -2
  59. data/ext/isomorfeus_ferret_ext/frt_q_boolean.c +131 -217
  60. data/ext/isomorfeus_ferret_ext/frt_q_const_score.c +2 -2
  61. data/ext/isomorfeus_ferret_ext/frt_q_filtered_query.c +4 -4
  62. data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +18 -26
  63. data/ext/isomorfeus_ferret_ext/frt_q_multi_term.c +27 -28
  64. data/ext/isomorfeus_ferret_ext/frt_q_parser.c +49 -98
  65. data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +64 -116
  66. data/ext/isomorfeus_ferret_ext/frt_q_range.c +8 -14
  67. data/ext/isomorfeus_ferret_ext/frt_q_span.c +251 -365
  68. data/ext/isomorfeus_ferret_ext/frt_q_term.c +9 -9
  69. data/ext/isomorfeus_ferret_ext/frt_q_wildcard.c +1 -2
  70. data/ext/isomorfeus_ferret_ext/frt_ram_store.c +134 -85
  71. data/ext/isomorfeus_ferret_ext/frt_search.c +109 -191
  72. data/ext/isomorfeus_ferret_ext/frt_search.h +6 -6
  73. data/ext/isomorfeus_ferret_ext/frt_similarity.c +12 -23
  74. data/ext/isomorfeus_ferret_ext/frt_similarity.h +1 -2
  75. data/ext/isomorfeus_ferret_ext/frt_sort.c +20 -20
  76. data/ext/isomorfeus_ferret_ext/frt_store.c +13 -25
  77. data/ext/isomorfeus_ferret_ext/frt_store.h +86 -52
  78. data/ext/isomorfeus_ferret_ext/frt_term_vectors.c +8 -16
  79. data/ext/isomorfeus_ferret_ext/frt_win32.h +5 -10
  80. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +12 -11
  81. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.h +11 -13
  82. data/ext/isomorfeus_ferret_ext/lz4.c +422 -195
  83. data/ext/isomorfeus_ferret_ext/lz4.h +114 -46
  84. data/ext/isomorfeus_ferret_ext/lz4frame.c +421 -242
  85. data/ext/isomorfeus_ferret_ext/lz4frame.h +122 -53
  86. data/ext/isomorfeus_ferret_ext/lz4hc.c +127 -111
  87. data/ext/isomorfeus_ferret_ext/lz4hc.h +14 -14
  88. data/ext/isomorfeus_ferret_ext/lz4xxhash.h +1 -1
  89. data/ext/isomorfeus_ferret_ext/mdbx.c +3762 -2526
  90. data/ext/isomorfeus_ferret_ext/mdbx.h +115 -70
  91. data/ext/isomorfeus_ferret_ext/test.c +41 -88
  92. data/ext/isomorfeus_ferret_ext/test.h +3 -6
  93. data/ext/isomorfeus_ferret_ext/test_1710.c +11 -13
  94. data/ext/isomorfeus_ferret_ext/test_analysis.c +32 -64
  95. data/ext/isomorfeus_ferret_ext/test_array.c +6 -12
  96. data/ext/isomorfeus_ferret_ext/test_bitvector.c +12 -24
  97. data/ext/isomorfeus_ferret_ext/test_document.c +23 -33
  98. data/ext/isomorfeus_ferret_ext/test_except.c +10 -21
  99. data/ext/isomorfeus_ferret_ext/test_fields.c +62 -68
  100. data/ext/isomorfeus_ferret_ext/test_file_deleter.c +16 -25
  101. data/ext/isomorfeus_ferret_ext/test_filter.c +22 -33
  102. data/ext/isomorfeus_ferret_ext/test_global.c +14 -29
  103. data/ext/isomorfeus_ferret_ext/test_hash.c +19 -38
  104. data/ext/isomorfeus_ferret_ext/test_hashset.c +8 -16
  105. data/ext/isomorfeus_ferret_ext/test_helper.c +4 -8
  106. data/ext/isomorfeus_ferret_ext/test_highlighter.c +16 -28
  107. data/ext/isomorfeus_ferret_ext/test_index.c +307 -519
  108. data/ext/isomorfeus_ferret_ext/test_lang.c +7 -14
  109. data/ext/isomorfeus_ferret_ext/test_mdbx_store.c +2 -5
  110. data/ext/isomorfeus_ferret_ext/test_mempool.c +5 -10
  111. data/ext/isomorfeus_ferret_ext/test_multimapper.c +3 -6
  112. data/ext/isomorfeus_ferret_ext/test_priorityqueue.c +9 -18
  113. data/ext/isomorfeus_ferret_ext/test_q_const_score.c +4 -6
  114. data/ext/isomorfeus_ferret_ext/test_q_filtered.c +3 -4
  115. data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +9 -15
  116. data/ext/isomorfeus_ferret_ext/test_q_parser.c +8 -16
  117. data/ext/isomorfeus_ferret_ext/test_q_span.c +19 -35
  118. data/ext/isomorfeus_ferret_ext/test_ram_store.c +14 -13
  119. data/ext/isomorfeus_ferret_ext/test_search.c +66 -115
  120. data/ext/isomorfeus_ferret_ext/test_segments.c +8 -13
  121. data/ext/isomorfeus_ferret_ext/test_similarity.c +2 -4
  122. data/ext/isomorfeus_ferret_ext/test_sort.c +17 -27
  123. data/ext/isomorfeus_ferret_ext/test_store.c +96 -115
  124. data/ext/isomorfeus_ferret_ext/test_term.c +9 -15
  125. data/ext/isomorfeus_ferret_ext/test_term_vectors.c +9 -14
  126. data/ext/isomorfeus_ferret_ext/test_test.c +4 -8
  127. data/ext/isomorfeus_ferret_ext/test_threading.c +15 -21
  128. data/ext/isomorfeus_ferret_ext/testhelper.c +11 -21
  129. data/ext/isomorfeus_ferret_ext/testhelper.h +1 -1
  130. data/ext/isomorfeus_ferret_ext/tests_all.h +1 -2
  131. data/lib/isomorfeus/ferret/index/index.rb +8 -8
  132. data/lib/isomorfeus/ferret/version.rb +1 -1
  133. metadata +32 -6
@@ -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,73 +60,62 @@ 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
- int doc;
70
- int index;
71
- int freq;
72
- int *positions;
73
- FrtTermVector *tv;
65
+ int doc_num;
66
+ int index;
67
+ int freq;
68
+ int *positions;
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;
81
76
  if (tv_term) {
82
- tv_tde->doc = -1;
77
+ tv_tde->doc_num = -1;
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 {
88
- tv_tde->doc = INT_MAX;
81
+ } else {
82
+ tv_tde->doc_num = INT_MAX;
89
83
  }
90
84
  }
91
85
 
92
- static bool tv_tde_next(FrtTermDocEnum *tde)
93
- {
94
- if (TV_TDE(tde)->doc == -1) {
95
- TV_TDE(tde)->doc = 0;
86
+ static bool tv_tde_next(FrtTermDocEnum *tde) {
87
+ if (TV_TDE(tde)->doc_num == -1) {
88
+ TV_TDE(tde)->doc_num = 0;
96
89
  return true;
97
- }
98
- else {
99
- TV_TDE(tde)->doc = INT_MAX;
90
+ } else {
91
+ TV_TDE(tde)->doc_num = 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
- TV_TDE(tde)->doc = 0;
98
+ TV_TDE(tde)->doc_num = 0;
108
99
  return true;
109
- }
110
- else {
111
- TV_TDE(tde)->doc = INT_MAX;
100
+ } else {
101
+ TV_TDE(tde)->doc_num = 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
- {
128
- return TV_TDE(tde)->doc;
114
+ static int tv_tde_doc_num(FrtTermDocEnum *tde) {
115
+ return TV_TDE(tde)->doc_num;
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,31 +166,28 @@ 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
- {
185
- FrtScorer super;
186
- FrtIndexReader *ir;
187
- FrtSpanEnum *spans;
188
- FrtSimilarity *sim;
189
- frt_uchar *norms;
190
- FrtWeight *weight;
169
+ typedef struct SpanScorer {
170
+ FrtScorer super;
171
+ FrtIndexReader *ir;
172
+ FrtSpanEnum *spans;
173
+ FrtSimilarity *sim;
174
+ frt_uchar *norms;
175
+ FrtWeight *weight;
191
176
  float value;
192
177
  float freq;
193
178
  bool first_time : 1;
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
 
202
186
  /* normalize */
203
- return raw * frt_sim_decode_norm(self->similarity, spansc->norms[self->doc]);
187
+ return raw * frt_sim_decode_norm(self->similarity, spansc->norms[self->doc_num]);
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;
@@ -219,19 +202,18 @@ static bool spansc_next(FrtScorer *self)
219
202
  }
220
203
 
221
204
  spansc->freq = 0.0f;
222
- self->doc = se->doc(se);
205
+ self->doc_num = se->doc_num(se);
223
206
 
224
207
  do {
225
208
  match_length = se->end(se) - se->start(se);
226
209
  spansc->freq += frt_sim_sloppy_freq(spansc->sim, match_length);
227
210
  spansc->more = se->next(se);
228
- } while (spansc->more && (self->doc == se->doc(se)));
211
+ } while (spansc->more && (self->doc_num == se->doc_num(se)));
229
212
 
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
 
@@ -241,9 +223,9 @@ static bool spansc_skip_to(FrtScorer *self, int target)
241
223
  }
242
224
 
243
225
  spansc->freq = 0.0f;
244
- self->doc = se->doc(se);
226
+ self->doc_num = se->doc_num(se);
245
227
 
246
- while (spansc->more && (se->doc(se) == target)) {
228
+ while (spansc->more && (se->doc_num(se) == target)) {
247
229
  spansc->freq += frt_sim_sloppy_freq(spansc->sim, se->end(se) - se->start(se));
248
230
  spansc->more = se->next(se);
249
231
  if (spansc->first_time) {
@@ -254,13 +236,12 @@ 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;
262
243
  self->skip_to(self, target);
263
- phrase_freq = (self->doc == target) ? spansc->freq : (float)0.0;
244
+ phrase_freq = (self->doc_num == target) ? spansc->freq : (float)0.0;
264
245
 
265
246
  tf_explanation = frt_expl_new(frt_sim_tf(self->similarity, phrase_freq),
266
247
  "tf(phrase_freq(%f)", 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,28 +257,27 @@ 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) {
285
264
  FrtQuery *spanq = weight->query;
286
265
  self = frt_scorer_new(SpanScorer, weight->similarity);
287
266
 
288
- SpSc(self)->first_time = true;
289
- SpSc(self)->more = true;
290
- SpSc(self)->spans = SpQ(spanq)->get_spans(spanq, ir);
291
- SpSc(self)->sim = weight->similarity;
292
- SpSc(self)->norms = ir->get_norms(ir, field_num);
293
- SpSc(self)->weight = weight;
294
- SpSc(self)->value = weight->value;
295
- SpSc(self)->freq = 0.0f;
296
-
297
- self->score = &spansc_score;
298
- self->next = &spansc_next;
299
- self->skip_to = &spansc_skip_to;
300
- self->explain = &spansc_explain;
301
- self->destroy = &spansc_destroy;
267
+ SpSc(self)->first_time = true;
268
+ SpSc(self)->more = true;
269
+ SpSc(self)->spans = SpQ(spanq)->get_spans(spanq, ir);
270
+ SpSc(self)->sim = weight->similarity;
271
+ SpSc(self)->norms = ir->get_norms(ir, field_num);
272
+ SpSc(self)->weight = weight;
273
+ SpSc(self)->value = weight->value;
274
+ SpSc(self)->freq = 0.0f;
275
+
276
+ self->score = &spansc_score;
277
+ self->next = &spansc_next;
278
+ self->skip_to = &spansc_skip_to;
279
+ self->explain = &spansc_explain;
280
+ self->destroy = &spansc_destroy;
302
281
  }
303
282
  return self;
304
283
  }
@@ -310,28 +289,25 @@ 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
- {
315
- FrtSpanEnum super;
292
+ typedef struct SpanTermEnum {
293
+ FrtSpanEnum super;
316
294
  FrtTermDocEnum *positions;
317
- int position;
318
- int doc;
319
- int count;
320
- int freq;
295
+ int position;
296
+ int doc_num;
297
+ int count;
298
+ int freq;
321
299
  } SpanTermEnum;
322
300
 
323
-
324
- static bool spante_next(FrtSpanEnum *self)
325
- {
301
+ static bool spante_next(FrtSpanEnum *self) {
326
302
  SpanTermEnum *ste = SpTEn(self);
327
303
  FrtTermDocEnum *tde = ste->positions;
328
304
 
329
305
  if (ste->count == ste->freq) {
330
306
  if (! tde->next(tde)) {
331
- ste->doc = INT_MAX;
307
+ ste->doc_num = INT_MAX;
332
308
  return false;
333
309
  }
334
- ste->doc = tde->doc_num(tde);
310
+ ste->doc_num = tde->doc_num(tde);
335
311
  ste->freq = tde->freq(tde);
336
312
  ste->count = 0;
337
313
  }
@@ -340,8 +316,7 @@ static bool spante_next(FrtSpanEnum *self)
340
316
  return true;
341
317
  }
342
318
 
343
- static bool spante_skip_to(FrtSpanEnum *self, int target)
344
- {
319
+ static bool spante_skip_to(FrtSpanEnum *self, int target) {
345
320
  SpanTermEnum *ste = SpTEn(self);
346
321
  FrtTermDocEnum *tde = ste->positions;
347
322
 
@@ -354,11 +329,11 @@ static bool spante_skip_to(FrtSpanEnum *self, int target)
354
329
  */
355
330
 
356
331
  if (! tde->skip_to(tde, target)) {
357
- ste->doc = INT_MAX;
332
+ ste->doc_num = INT_MAX;
358
333
  return false;
359
334
  }
360
335
 
361
- ste->doc = tde->doc_num(tde);
336
+ ste->doc_num = tde->doc_num(tde);
362
337
  ste->freq = tde->freq(tde);
363
338
  ste->count = 0;
364
339
 
@@ -367,18 +342,15 @@ static bool spante_skip_to(FrtSpanEnum *self, int target)
367
342
  return true;
368
343
  }
369
344
 
370
- static int spante_doc(FrtSpanEnum *self)
371
- {
372
- return SpTEn(self)->doc;
345
+ static int spante_doc_num(FrtSpanEnum *self) {
346
+ return SpTEn(self)->doc_num;
373
347
  }
374
348
 
375
- static int spante_start(FrtSpanEnum *self)
376
- {
349
+ static int spante_start(FrtSpanEnum *self) {
377
350
  return SpTEn(self)->position;
378
351
  }
379
352
 
380
- static int spante_end(FrtSpanEnum *self)
381
- {
353
+ static int spante_end(FrtSpanEnum *self) {
382
354
  return SpTEn(self)->position + 1;
383
355
  }
384
356
 
@@ -389,16 +361,14 @@ static char *spante_to_s(FrtSpanEnum *self) {
389
361
  int pos;
390
362
  char *str = FRT_ALLOC_N(char, len + 40);
391
363
 
392
- if (self->doc(self) < 0) {
364
+ if (self->doc_num(self) < 0) {
393
365
  sprintf(pos_str, "START");
394
- }
395
- else {
396
- if (self->doc(self) == INT_MAX) {
366
+ } else {
367
+ if (self->doc_num(self) == INT_MAX) {
397
368
  sprintf(pos_str, "END");
398
- }
399
- else {
369
+ } else {
400
370
  pos = SpTEn(self)->position;
401
- sprintf(pos_str, "%d", self->doc(self) - pos);
371
+ sprintf(pos_str, "%d", self->doc_num(self) - pos);
402
372
  }
403
373
  }
404
374
  sprintf(str, "SpanTermEnum(%s)@%s", query_str, pos_str);
@@ -406,33 +376,31 @@ static char *spante_to_s(FrtSpanEnum *self) {
406
376
  return str;
407
377
  }
408
378
 
409
- static void spante_destroy(FrtSpanEnum *self)
410
- {
379
+ static void spante_destroy(FrtSpanEnum *self) {
411
380
  FrtTermDocEnum *tde = SpTEn(self)->positions;
412
381
  tde->close(tde);
413
382
  free(self);
414
383
  }
415
384
 
416
- static FrtSpanEnum *spante_new(FrtQuery *query, FrtIndexReader *ir)
417
- {
385
+ static FrtSpanEnum *spante_new(FrtQuery *query, FrtIndexReader *ir) {
418
386
  char *term = SpTQ(query)->term;
419
387
  FrtSpanEnum *self = (FrtSpanEnum *)FRT_ALLOC(SpanTermEnum);
420
388
 
421
- SpTEn(self)->positions = frt_ir_term_positions_for(ir, SpQ(query)->field,
389
+ SpTEn(self)->positions = frt_ir_term_positions_for(ir, SpQ(query)->field,
422
390
  term);
423
- SpTEn(self)->position = -1;
424
- SpTEn(self)->doc = -1;
425
- SpTEn(self)->count = 0;
426
- SpTEn(self)->freq = 0;
427
-
428
- self->query = query;
429
- self->next = &spante_next;
430
- self->skip_to = &spante_skip_to;
431
- self->doc = &spante_doc;
432
- self->start = &spante_start;
433
- self->end = &spante_end;
434
- self->destroy = &spante_destroy;
435
- self->to_s = &spante_to_s;
391
+ SpTEn(self)->position = -1;
392
+ SpTEn(self)->doc_num = -1;
393
+ SpTEn(self)->count = 0;
394
+ SpTEn(self)->freq = 0;
395
+
396
+ self->query = query;
397
+ self->next = &spante_next;
398
+ self->skip_to = &spante_skip_to;
399
+ self->doc_num = &spante_doc_num;
400
+ self->start = &spante_start;
401
+ self->end = &spante_end;
402
+ self->destroy = &spante_destroy;
403
+ self->to_s = &spante_to_s;
436
404
 
437
405
  return self;
438
406
  }
@@ -444,77 +412,68 @@ static FrtSpanEnum *spante_new(FrtQuery *query, FrtIndexReader *ir)
444
412
  /* * TermPosEnumWrapper * */
445
413
  #define TPE_READ_SIZE 16
446
414
 
447
- typedef struct TermPosEnumWrapper
448
- {
449
- const char *term;
415
+ typedef struct TermPosEnumWrapper {
416
+ const char *term;
450
417
  FrtTermDocEnum *tpe;
451
- int doc;
452
- int pos;
418
+ int doc_num;
419
+ int pos;
453
420
  } TermPosEnumWrapper;
454
421
 
455
422
  static bool tpew_less_than(const TermPosEnumWrapper *tpew1,
456
- const TermPosEnumWrapper *tpew2)
457
- {
458
- return (tpew1->doc < tpew2->doc)
459
- || (tpew1->doc == tpew2->doc && tpew1->pos < tpew2->pos);
423
+ const TermPosEnumWrapper *tpew2) {
424
+ return (tpew1->doc_num < tpew2->doc_num)
425
+ || (tpew1->doc_num == tpew2->doc_num && tpew1->pos < tpew2->pos);
460
426
  }
461
427
 
462
- static bool tpew_next(TermPosEnumWrapper *self)
463
- {
428
+ static bool tpew_next(TermPosEnumWrapper *self) {
464
429
  FrtTermDocEnum *tpe = self->tpe;
465
430
  if (0 > (self->pos = tpe->next_position(tpe))) {
466
431
  if (!tpe->next(tpe)) return false;
467
- self->doc = tpe->doc_num(tpe);
432
+ self->doc_num = tpe->doc_num(tpe);
468
433
  self->pos = tpe->next_position(tpe);
469
434
  }
470
435
  return true;
471
436
  }
472
437
 
473
- static bool tpew_skip_to(TermPosEnumWrapper *self, int doc_num)
474
- {
438
+ static bool tpew_skip_to(TermPosEnumWrapper *self, int doc_num) {
475
439
  FrtTermDocEnum *tpe = self->tpe;
476
440
 
477
441
  if (tpe->skip_to(tpe, doc_num)) {
478
- self->doc = tpe->doc_num(tpe);
442
+ self->doc_num = tpe->doc_num(tpe);
479
443
  self->pos = tpe->next_position(tpe);
480
444
  return true;
481
- }
482
- else {
445
+ } else {
483
446
  return false;
484
447
  }
485
448
  }
486
449
 
487
- static void tpew_destroy(TermPosEnumWrapper *self)
488
- {
450
+ static void tpew_destroy(TermPosEnumWrapper *self) {
489
451
  self->tpe->close(self->tpe);
490
452
  free(self);
491
453
  }
492
454
 
493
- static TermPosEnumWrapper *tpew_new(const char *term, FrtTermDocEnum *tpe)
494
- {
455
+ static TermPosEnumWrapper *tpew_new(const char *term, FrtTermDocEnum *tpe) {
495
456
  TermPosEnumWrapper *self = FRT_ALLOC_AND_ZERO(TermPosEnumWrapper);
496
457
  self->term = term;
497
458
  self->tpe = tpe;
498
- self->doc = -1;
459
+ self->doc_num = -1;
499
460
  self->pos = -1;
500
461
  return self;
501
462
  }
502
463
  #define SpMTEn(span_enum) ((SpanMultiTermEnum *)(span_enum))
503
464
  #define SpMTQ(query) ((FrtSpanMultiTermQuery *)(query))
504
465
 
505
- typedef struct SpanMultiTermEnum
506
- {
507
- FrtSpanEnum super;
508
- FrtPriorityQueue *tpew_pq;
466
+ typedef struct SpanMultiTermEnum {
467
+ FrtSpanEnum super;
468
+ FrtPriorityQueue *tpew_pq;
509
469
  TermPosEnumWrapper **tpews;
510
- int tpew_cnt;
511
- int pos;
512
- int doc;
470
+ int tpew_cnt;
471
+ int pos;
472
+ int doc_num;
513
473
  } SpanMultiTermEnum;
514
474
 
515
- static bool spanmte_next(FrtSpanEnum *self)
516
- {
517
- int curr_doc, curr_pos;
475
+ static bool spanmte_next(FrtSpanEnum *self) {
476
+ int curr_doc_num, curr_pos;
518
477
  TermPosEnumWrapper *tpew;
519
478
  SpanMultiTermEnum *mte = SpMTEn(self);
520
479
  FrtPriorityQueue *tpew_pq = mte->tpew_pq;
@@ -535,23 +494,21 @@ static bool spanmte_next(FrtSpanEnum *self)
535
494
  return false;
536
495
  }
537
496
 
538
- mte->doc = curr_doc = tpew->doc;
497
+ mte->doc_num = curr_doc_num = tpew->doc_num;
539
498
  mte->pos = curr_pos = tpew->pos;
540
499
 
541
500
  do {
542
501
  if (tpew_next(tpew)) {
543
502
  frt_pq_down(tpew_pq);
544
- }
545
- else {
503
+ } else {
546
504
  frt_pq_pop(tpew_pq);
547
505
  }
548
506
  } while (((tpew = (TermPosEnumWrapper *)frt_pq_top(tpew_pq)) != NULL)
549
- && tpew->doc == curr_doc && tpew->pos == curr_pos);
507
+ && tpew->doc_num == curr_doc_num && tpew->pos == curr_pos);
550
508
  return true;
551
509
  }
552
510
 
553
- static bool spanmte_skip_to(FrtSpanEnum *self, int target)
554
- {
511
+ static bool spanmte_skip_to(FrtSpanEnum *self, int target) {
555
512
  SpanMultiTermEnum *mte = SpMTEn(self);
556
513
  FrtPriorityQueue *tpew_pq = mte->tpew_pq;
557
514
  TermPosEnumWrapper *tpew;
@@ -566,38 +523,33 @@ static bool spanmte_skip_to(FrtSpanEnum *self, int target)
566
523
  mte->tpew_pq = tpew_pq;
567
524
  }
568
525
  if (tpew_pq->size == 0) {
569
- mte->doc = -1;
526
+ mte->doc_num = -1;
570
527
  return false;
571
528
  }
572
529
  while ((tpew = (TermPosEnumWrapper *)frt_pq_top(tpew_pq)) != NULL
573
- && (target > tpew->doc)) {
530
+ && (target > tpew->doc_num)) {
574
531
  if (tpew_skip_to(tpew, target)) {
575
532
  frt_pq_down(tpew_pq);
576
- }
577
- else {
533
+ } else {
578
534
  frt_pq_pop(tpew_pq);
579
535
  }
580
536
  }
581
537
  return spanmte_next(self);
582
538
  }
583
539
 
584
- static int spanmte_doc(FrtSpanEnum *self)
585
- {
586
- return SpMTEn(self)->doc;
540
+ static int spanmte_doc_num(FrtSpanEnum *self) {
541
+ return SpMTEn(self)->doc_num;
587
542
  }
588
543
 
589
- static int spanmte_start(FrtSpanEnum *self)
590
- {
544
+ static int spanmte_start(FrtSpanEnum *self) {
591
545
  return SpMTEn(self)->pos;
592
546
  }
593
547
 
594
- static int spanmte_end(FrtSpanEnum *self)
595
- {
548
+ static int spanmte_end(FrtSpanEnum *self) {
596
549
  return SpMTEn(self)->pos + 1;
597
550
  }
598
551
 
599
- static void spanmte_destroy(FrtSpanEnum *self)
600
- {
552
+ static void spanmte_destroy(FrtSpanEnum *self) {
601
553
  SpanMultiTermEnum *mte = SpMTEn(self);
602
554
  int i;
603
555
  if (mte->tpew_pq) frt_pq_destroy(mte->tpew_pq);
@@ -608,8 +560,7 @@ static void spanmte_destroy(FrtSpanEnum *self)
608
560
  free(self);
609
561
  }
610
562
 
611
- static FrtSpanEnum *spanmte_new(FrtQuery *query, FrtIndexReader *ir)
612
- {
563
+ static FrtSpanEnum *spanmte_new(FrtQuery *query, FrtIndexReader *ir) {
613
564
  FrtSpanEnum *self = (FrtSpanEnum *)FRT_ALLOC(SpanMultiTermEnum);
614
565
  SpanMultiTermEnum *smte = SpMTEn(self);
615
566
  FrtSpanMultiTermQuery *smtq = SpMTQ(query);
@@ -625,12 +576,12 @@ static FrtSpanEnum *spanmte_new(FrtQuery *query, FrtIndexReader *ir)
625
576
  smte->tpew_cnt = smtq->term_cnt;
626
577
  smte->tpew_pq = NULL;
627
578
  smte->pos = -1;
628
- smte->doc = -1;
579
+ smte->doc_num = -1;
629
580
 
630
581
  self->query = query;
631
582
  self->next = &spanmte_next;
632
583
  self->skip_to = &spanmte_skip_to;
633
- self->doc = &spanmte_doc;
584
+ self->doc_num = &spanmte_doc_num;
634
585
  self->start = &spanmte_start;
635
586
  self->end = &spanmte_end;
636
587
  self->destroy = &spanmte_destroy;
@@ -647,15 +598,13 @@ static FrtSpanEnum *spanmte_new(FrtQuery *query, FrtIndexReader *ir)
647
598
  #define SpFEn(span_enum) ((SpanFirstEnum *)(span_enum))
648
599
  #define SpFQ(query) ((FrtSpanFirstQuery *)(query))
649
600
 
650
- typedef struct SpanFirstEnum
651
- {
601
+ typedef struct SpanFirstEnum {
652
602
  FrtSpanEnum super;
653
603
  FrtSpanEnum *sub_enum;
654
604
  } SpanFirstEnum;
655
605
 
656
606
 
657
- static bool spanfe_next(FrtSpanEnum *self)
658
- {
607
+ static bool spanfe_next(FrtSpanEnum *self) {
659
608
  FrtSpanEnum *sub_enum = SpFEn(self)->sub_enum;
660
609
  int end = SpFQ(self->query)->end;
661
610
  while (sub_enum->next(sub_enum)) { /* scan to next match */
@@ -666,8 +615,7 @@ static bool spanfe_next(FrtSpanEnum *self)
666
615
  return false;
667
616
  }
668
617
 
669
- static bool spanfe_skip_to(FrtSpanEnum *self, int target)
670
- {
618
+ static bool spanfe_skip_to(FrtSpanEnum *self, int target) {
671
619
  FrtSpanEnum *sub_enum = SpFEn(self)->sub_enum;
672
620
  int end = SpFQ(self->query)->end;
673
621
 
@@ -682,20 +630,17 @@ static bool spanfe_skip_to(FrtSpanEnum *self, int target)
682
630
  return spanfe_next(self); /* scan to next match */
683
631
  }
684
632
 
685
- static int spanfe_doc(FrtSpanEnum *self)
686
- {
633
+ static int spanfe_doc_num(FrtSpanEnum *self) {
687
634
  FrtSpanEnum *sub_enum = SpFEn(self)->sub_enum;
688
- return sub_enum->doc(sub_enum);
635
+ return sub_enum->doc_num(sub_enum);
689
636
  }
690
637
 
691
- static int spanfe_start(FrtSpanEnum *self)
692
- {
638
+ static int spanfe_start(FrtSpanEnum *self) {
693
639
  FrtSpanEnum *sub_enum = SpFEn(self)->sub_enum;
694
640
  return sub_enum->start(sub_enum);
695
641
  }
696
642
 
697
- static int spanfe_end(FrtSpanEnum *self)
698
- {
643
+ static int spanfe_end(FrtSpanEnum *self) {
699
644
  FrtSpanEnum *sub_enum = SpFEn(self)->sub_enum;
700
645
  return sub_enum->end(sub_enum);
701
646
  }
@@ -707,15 +652,13 @@ static char *spanfe_to_s(FrtSpanEnum *self) {
707
652
  return res;
708
653
  }
709
654
 
710
- static void spanfe_destroy(FrtSpanEnum *self)
711
- {
655
+ static void spanfe_destroy(FrtSpanEnum *self) {
712
656
  FrtSpanEnum *sub_enum = SpFEn(self)->sub_enum;
713
657
  sub_enum->destroy(sub_enum);
714
658
  free(self);
715
659
  }
716
660
 
717
- static FrtSpanEnum *spanfe_new(FrtQuery *query, FrtIndexReader *ir)
718
- {
661
+ static FrtSpanEnum *spanfe_new(FrtQuery *query, FrtIndexReader *ir) {
719
662
  FrtSpanEnum *self = (FrtSpanEnum *)FRT_ALLOC(SpanFirstEnum);
720
663
  FrtSpanFirstQuery *sfq = SpFQ(query);
721
664
 
@@ -724,7 +667,7 @@ static FrtSpanEnum *spanfe_new(FrtQuery *query, FrtIndexReader *ir)
724
667
  self->query = query;
725
668
  self->next = &spanfe_next;
726
669
  self->skip_to = &spanfe_skip_to;
727
- self->doc = &spanfe_doc;
670
+ self->doc_num = &spanfe_doc_num;
728
671
  self->start = &spanfe_start;
729
672
  self->end = &spanfe_end;
730
673
  self->destroy = &spanfe_destroy;
@@ -741,8 +684,7 @@ static FrtSpanEnum *spanfe_new(FrtQuery *query, FrtIndexReader *ir)
741
684
  #define SpOEn(span_enum) ((SpanOrEnum *)(span_enum))
742
685
  #define SpOQ(query) ((FrtSpanOrQuery *)(query))
743
686
 
744
- typedef struct SpanOrEnum
745
- {
687
+ typedef struct SpanOrEnum {
746
688
  FrtSpanEnum super;
747
689
  FrtPriorityQueue *queue;
748
690
  FrtSpanEnum **span_enums;
@@ -751,26 +693,22 @@ typedef struct SpanOrEnum
751
693
  } SpanOrEnum;
752
694
 
753
695
 
754
- static bool span_less_than(FrtSpanEnum *s1, FrtSpanEnum *s2)
755
- {
696
+ static bool span_less_than(FrtSpanEnum *s1, FrtSpanEnum *s2) {
756
697
  int doc_diff, start_diff;
757
- doc_diff = s1->doc(s1) - s2->doc(s2);
698
+ doc_diff = s1->doc_num(s1) - s2->doc_num(s2);
758
699
  if (doc_diff == 0) {
759
700
  start_diff = s1->start(s1) - s2->start(s2);
760
701
  if (start_diff == 0) {
761
702
  return s1->end(s1) < s2->end(s2);
762
- }
763
- else {
703
+ } else {
764
704
  return start_diff < 0;
765
705
  }
766
- }
767
- else {
706
+ } else {
768
707
  return doc_diff < 0;
769
708
  }
770
709
  }
771
710
 
772
- static bool spanoe_next(FrtSpanEnum *self)
773
- {
711
+ static bool spanoe_next(FrtSpanEnum *self) {
774
712
  SpanOrEnum *soe = SpOEn(self);
775
713
  FrtSpanEnum *se;
776
714
  int i;
@@ -801,8 +739,7 @@ static bool spanoe_next(FrtSpanEnum *self)
801
739
  return soe->queue->size != 0;
802
740
  }
803
741
 
804
- static bool spanoe_skip_to(FrtSpanEnum *self, int target)
805
- {
742
+ static bool spanoe_skip_to(FrtSpanEnum *self, int target) {
806
743
  SpanOrEnum *soe = SpOEn(self);
807
744
  FrtSpanEnum *se;
808
745
  int i;
@@ -815,15 +752,13 @@ static bool spanoe_skip_to(FrtSpanEnum *self, int target)
815
752
  }
816
753
  }
817
754
  soe->first_time = false;
818
- }
819
- else {
755
+ } else {
820
756
  while ((soe->queue->size != 0) &&
821
757
  ((se = (FrtSpanEnum *)frt_pq_top(soe->queue)) != NULL) &&
822
- (se->doc(se) < target)) {
758
+ (se->doc_num(se) < target)) {
823
759
  if (se->skip_to(se, target)) {
824
760
  frt_pq_down(soe->queue);
825
- }
826
- else {
761
+ } else {
827
762
  frt_pq_pop(soe->queue);
828
763
  }
829
764
  }
@@ -834,20 +769,17 @@ static bool spanoe_skip_to(FrtSpanEnum *self, int target)
834
769
 
835
770
  #define SpOEn_Top_SE(self) (FrtSpanEnum *)frt_pq_top(SpOEn(self)->queue)
836
771
 
837
- static int spanoe_doc(FrtSpanEnum *self)
838
- {
772
+ static int spanoe_doc_num(FrtSpanEnum *self) {
839
773
  FrtSpanEnum *se = SpOEn_Top_SE(self);
840
- return se->doc(se);
774
+ return se->doc_num(se);
841
775
  }
842
776
 
843
- static int spanoe_start(FrtSpanEnum *self)
844
- {
777
+ static int spanoe_start(FrtSpanEnum *self) {
845
778
  FrtSpanEnum *se = SpOEn_Top_SE(self);
846
779
  return se->start(se);
847
780
  }
848
781
 
849
- static int spanoe_end(FrtSpanEnum *self)
850
- {
782
+ static int spanoe_end(FrtSpanEnum *self) {
851
783
  FrtSpanEnum *se = SpOEn_Top_SE(self);
852
784
  return se->end(se);
853
785
  }
@@ -861,13 +793,11 @@ static char *spanoe_to_s(FrtSpanEnum *self) {
861
793
 
862
794
  if (soe->first_time) {
863
795
  sprintf(doc_str, "START");
864
- }
865
- else {
796
+ } else {
866
797
  if (soe->queue->size == 0) {
867
798
  sprintf(doc_str, "END");
868
- }
869
- else {
870
- sprintf(doc_str, "%d:%d-%d", self->doc(self),
799
+ } else {
800
+ sprintf(doc_str, "%d:%d-%d", self->doc_num(self),
871
801
  self->start(self), self->end(self));
872
802
  }
873
803
  }
@@ -876,8 +806,7 @@ static char *spanoe_to_s(FrtSpanEnum *self) {
876
806
  return str;
877
807
  }
878
808
 
879
- static void spanoe_destroy(FrtSpanEnum *self)
880
- {
809
+ static void spanoe_destroy(FrtSpanEnum *self) {
881
810
  FrtSpanEnum *se;
882
811
  SpanOrEnum *soe = SpOEn(self);
883
812
  int i;
@@ -890,8 +819,7 @@ static void spanoe_destroy(FrtSpanEnum *self)
890
819
  free(self);
891
820
  }
892
821
 
893
- static FrtSpanEnum *spanoe_new(FrtQuery *query, FrtIndexReader *ir)
894
- {
822
+ static FrtSpanEnum *spanoe_new(FrtQuery *query, FrtIndexReader *ir) {
895
823
  FrtQuery *clause;
896
824
  FrtSpanEnum *self = (FrtSpanEnum *)FRT_ALLOC(SpanOrEnum);
897
825
  FrtSpanOrQuery *soq = SpOQ(query);
@@ -912,7 +840,7 @@ static FrtSpanEnum *spanoe_new(FrtQuery *query, FrtIndexReader *ir)
912
840
  self->query = query;
913
841
  self->next = &spanoe_next;
914
842
  self->skip_to = &spanoe_skip_to;
915
- self->doc = &spanoe_doc;
843
+ self->doc_num = &spanoe_doc_num;
916
844
  self->start = &spanoe_start;
917
845
  self->end = &spanoe_end;
918
846
  self->destroy = &spanoe_destroy;
@@ -928,14 +856,13 @@ static FrtSpanEnum *spanoe_new(FrtQuery *query, FrtIndexReader *ir)
928
856
  #define SpNEn(span_enum) ((SpanNearEnum *)(span_enum))
929
857
  #define SpNQ(query) ((FrtSpanNearQuery *)(query))
930
858
 
931
- typedef struct SpanNearEnum
932
- {
933
- FrtSpanEnum super;
934
- FrtSpanEnum **span_enums;
859
+ typedef struct SpanNearEnum {
860
+ FrtSpanEnum super;
861
+ FrtSpanEnum **span_enums;
935
862
  int s_cnt;
936
863
  int slop;
937
864
  int current;
938
- int doc;
865
+ int doc_num;
939
866
  int start;
940
867
  int end;
941
868
  bool first_time : 1;
@@ -948,45 +875,42 @@ typedef struct SpanNearEnum
948
875
  se = sne->span_enums[sne->current];\
949
876
  } while (0);
950
877
 
951
- static bool sne_init(SpanNearEnum *sne)
952
- {
878
+ static bool sne_init(SpanNearEnum *sne) {
953
879
  FrtSpanEnum *se = sne->span_enums[sne->current];
954
- int prev_doc = se->doc(se);
880
+ int prev_doc_num = se->doc_num(se);
955
881
  int i;
956
882
 
957
883
  for (i = 1; i < sne->s_cnt; i++) {
958
884
  SpNEn_NEXT();
959
- if (!se->skip_to(se, prev_doc)) {
885
+ if (!se->skip_to(se, prev_doc_num)) {
960
886
  return false;
961
887
  }
962
- prev_doc = se->doc(se);
888
+ prev_doc_num = se->doc_num(se);
963
889
  }
964
890
  return true;
965
891
  }
966
892
 
967
- static bool sne_goto_next_doc(SpanNearEnum *sne)
968
- {
893
+ static bool sne_goto_next_doc(SpanNearEnum *sne) {
969
894
  FrtSpanEnum *se = sne->span_enums[sne->current];
970
- int prev_doc = se->doc(se);
895
+ int prev_doc_num = se->doc_num(se);
971
896
 
972
897
  SpNEn_NEXT();
973
898
 
974
- while (se->doc(se) < prev_doc) {
975
- if (! se->skip_to(se, prev_doc)) {
899
+ while (se->doc_num(se) < prev_doc_num) {
900
+ if (! se->skip_to(se, prev_doc_num)) {
976
901
  return false;
977
902
  }
978
- prev_doc = se->doc(se);
903
+ prev_doc_num = se->doc_num(se);
979
904
  SpNEn_NEXT();
980
905
  }
981
906
  return true;
982
907
  }
983
908
 
984
- static bool sne_next_unordered_match(FrtSpanEnum *self)
985
- {
909
+ static bool sne_next_unordered_match(FrtSpanEnum *self) {
986
910
  SpanNearEnum *sne = SpNEn(self);
987
911
  FrtSpanEnum *se, *min_se = NULL;
988
912
  int i;
989
- int max_end, end, min_start, start, doc;
913
+ int max_end, end, min_start, start, doc_num;
990
914
  int lengths_sum;
991
915
 
992
916
  while (true) {
@@ -1011,34 +935,33 @@ static bool sne_next_unordered_match(FrtSpanEnum *self)
1011
935
  /* we have a match */
1012
936
  sne->start = min_start;
1013
937
  sne->end = max_end;
1014
- sne->doc = min_se->doc(min_se);
938
+ sne->doc_num = min_se->doc_num(min_se);
1015
939
  return true;
1016
940
  }
1017
941
 
1018
942
  /* increment the minimum span_enum and try again */
1019
- doc = min_se->doc(min_se);
943
+ doc_num = min_se->doc_num(min_se);
1020
944
  if (!min_se->next(min_se)) {
1021
945
  return false;
1022
946
  }
1023
- if (doc < min_se->doc(min_se)) {
947
+ if (doc_num < min_se->doc_num(min_se)) {
1024
948
  if (!sne_goto_next_doc(sne)) return false;
1025
949
  }
1026
950
  }
1027
951
  }
1028
952
 
1029
- static bool sne_next_ordered_match(FrtSpanEnum *self)
1030
- {
953
+ static bool sne_next_ordered_match(FrtSpanEnum *self) {
1031
954
  SpanNearEnum *sne = SpNEn(self);
1032
955
  FrtSpanEnum *se;
1033
956
  int i;
1034
- int prev_doc, prev_start, prev_end;
1035
- int doc=0, start=0, end=0;
957
+ int prev_doc_num, prev_start, prev_end;
958
+ int doc_num = 0, start = 0, end = 0;
1036
959
  int lengths_sum;
1037
960
 
1038
961
  while (true) {
1039
962
  se = sne->span_enums[0];
1040
963
 
1041
- prev_doc = se->doc(se);
964
+ prev_doc_num = se->doc_num(se);
1042
965
  sne->start = prev_start = se->start(se);
1043
966
  prev_end = se->end(se);
1044
967
 
@@ -1047,19 +970,19 @@ static bool sne_next_ordered_match(FrtSpanEnum *self)
1047
970
 
1048
971
  while (i < sne->s_cnt) {
1049
972
  se = sne->span_enums[i];
1050
- doc = se->doc(se);
973
+ doc_num = se->doc_num(se);
1051
974
  start = se->start(se);
1052
975
  end = se->end(se);
1053
- while ((doc == prev_doc) && ((start < prev_start) ||
976
+ while ((doc_num == prev_doc_num) && ((start < prev_start) ||
1054
977
  ((start == prev_start) && (end < prev_end)))) {
1055
978
  if (!se->next(se)) {
1056
979
  return false;
1057
980
  }
1058
- doc = se->doc(se);
981
+ doc_num = se->doc_num(se);
1059
982
  start = se->start(se);
1060
983
  end = se->end(se);
1061
984
  }
1062
- if (doc != prev_doc) {
985
+ if (doc_num != prev_doc_num) {
1063
986
  sne->current = i;
1064
987
  if (!sne_goto_next_doc(sne)) {
1065
988
  return false;
@@ -1068,7 +991,7 @@ static bool sne_next_ordered_match(FrtSpanEnum *self)
1068
991
  }
1069
992
  i++;
1070
993
  lengths_sum += end - start;
1071
- prev_doc = doc;
994
+ prev_doc_num = doc_num;
1072
995
  prev_start = start;
1073
996
  prev_end = end;
1074
997
  }
@@ -1076,20 +999,19 @@ static bool sne_next_ordered_match(FrtSpanEnum *self)
1076
999
  if ((end - sne->start - lengths_sum) <= sne->slop) {
1077
1000
  /* we have a match */
1078
1001
  sne->end = end;
1079
- sne->doc = doc;
1002
+ sne->doc_num = doc_num;
1080
1003
 
1081
1004
  /* the minimum span is always the first span so it needs to be
1082
1005
  * incremented next time around */
1083
1006
  sne->current = 0;
1084
1007
  return true;
1085
1008
 
1086
- }
1087
- else {
1009
+ } else {
1088
1010
  se = sne->span_enums[0];
1089
1011
  if (!se->next(se)) {
1090
1012
  return false;
1091
1013
  }
1092
- if (se->doc(se) != prev_doc) {
1014
+ if (se->doc_num(se) != prev_doc_num) {
1093
1015
  sne->current = 0;
1094
1016
  if (!sne_goto_next_doc(sne)) {
1095
1017
  return false;
@@ -1100,8 +1022,7 @@ static bool sne_next_ordered_match(FrtSpanEnum *self)
1100
1022
  }
1101
1023
  }
1102
1024
 
1103
- static bool sne_next_match(FrtSpanEnum *self)
1104
- {
1025
+ static bool sne_next_match(FrtSpanEnum *self) {
1105
1026
  SpanNearEnum *sne = SpNEn(self);
1106
1027
  FrtSpanEnum *se_curr, *se_next;
1107
1028
 
@@ -1113,7 +1034,7 @@ static bool sne_next_match(FrtSpanEnum *self)
1113
1034
  }
1114
1035
  se_curr = sne->span_enums[sne->current];
1115
1036
  se_next = sne->span_enums[(sne->current+1)%sne->s_cnt];
1116
- if (se_curr->doc(se_curr) > se_next->doc(se_next)) {
1037
+ if (se_curr->doc_num(se_curr) > se_next->doc_num(se_next)) {
1117
1038
  if (!sne_goto_next_doc(sne)) {
1118
1039
  return false;
1119
1040
  }
@@ -1121,14 +1042,12 @@ static bool sne_next_match(FrtSpanEnum *self)
1121
1042
 
1122
1043
  if (sne->in_order) {
1123
1044
  return sne_next_ordered_match(self);
1124
- }
1125
- else {
1045
+ } else {
1126
1046
  return sne_next_unordered_match(self);
1127
1047
  }
1128
1048
  }
1129
1049
 
1130
- static bool spanne_next(FrtSpanEnum *self)
1131
- {
1050
+ static bool spanne_next(FrtSpanEnum *self) {
1132
1051
  SpanNearEnum *sne = SpNEn(self);
1133
1052
  FrtSpanEnum *se;
1134
1053
 
@@ -1138,8 +1057,7 @@ static bool spanne_next(FrtSpanEnum *self)
1138
1057
  return sne_next_match(self);
1139
1058
  }
1140
1059
 
1141
- static bool spanne_skip_to(FrtSpanEnum *self, int target)
1142
- {
1060
+ static bool spanne_skip_to(FrtSpanEnum *self, int target) {
1143
1061
  FrtSpanEnum *se = SpNEn(self)->span_enums[SpNEn(self)->current];
1144
1062
  if (!se->skip_to(se, target)) {
1145
1063
  return false;
@@ -1148,18 +1066,15 @@ static bool spanne_skip_to(FrtSpanEnum *self, int target)
1148
1066
  return sne_next_match(self);
1149
1067
  }
1150
1068
 
1151
- static int spanne_doc(FrtSpanEnum *self)
1152
- {
1153
- return SpNEn(self)->doc;
1069
+ static int spanne_doc_num(FrtSpanEnum *self) {
1070
+ return SpNEn(self)->doc_num;
1154
1071
  }
1155
1072
 
1156
- static int spanne_start(FrtSpanEnum *self)
1157
- {
1073
+ static int spanne_start(FrtSpanEnum *self) {
1158
1074
  return SpNEn(self)->start;
1159
1075
  }
1160
1076
 
1161
- static int spanne_end(FrtSpanEnum *self)
1162
- {
1077
+ static int spanne_end(FrtSpanEnum *self) {
1163
1078
  return SpNEn(self)->end;
1164
1079
  }
1165
1080
 
@@ -1172,9 +1087,8 @@ static char *spanne_to_s(FrtSpanEnum *self) {
1172
1087
 
1173
1088
  if (sne->first_time) {
1174
1089
  sprintf(doc_str, "START");
1175
- }
1176
- else {
1177
- sprintf(doc_str, "%d:%d-%d", self->doc(self),
1090
+ } else {
1091
+ sprintf(doc_str, "%d:%d-%d", self->doc_num(self),
1178
1092
  self->start(self), self->end(self));
1179
1093
  }
1180
1094
  sprintf(str, "SpanNearEnum(%s)@%s", query_str, doc_str);
@@ -1182,8 +1096,7 @@ static char *spanne_to_s(FrtSpanEnum *self) {
1182
1096
  return str;
1183
1097
  }
1184
1098
 
1185
- static void spanne_destroy(FrtSpanEnum *self)
1186
- {
1099
+ static void spanne_destroy(FrtSpanEnum *self) {
1187
1100
  FrtSpanEnum *se;
1188
1101
  SpanNearEnum *sne = SpNEn(self);
1189
1102
  int i;
@@ -1195,12 +1108,11 @@ static void spanne_destroy(FrtSpanEnum *self)
1195
1108
  free(self);
1196
1109
  }
1197
1110
 
1198
- static FrtSpanEnum *spanne_new(FrtQuery *query, FrtIndexReader *ir)
1199
- {
1111
+ static FrtSpanEnum *spanne_new(FrtQuery *query, FrtIndexReader *ir) {
1200
1112
  int i;
1201
1113
  FrtQuery *clause;
1202
- FrtSpanEnum *self = (FrtSpanEnum *)FRT_ALLOC(SpanNearEnum);
1203
- FrtSpanNearQuery *snq = SpNQ(query);
1114
+ FrtSpanEnum *self = (FrtSpanEnum *)FRT_ALLOC(SpanNearEnum);
1115
+ FrtSpanNearQuery *snq = SpNQ(query);
1204
1116
 
1205
1117
  SpNEn(self)->first_time = true;
1206
1118
  SpNEn(self)->in_order = snq->in_order;
@@ -1214,14 +1126,14 @@ static FrtSpanEnum *spanne_new(FrtQuery *query, FrtIndexReader *ir)
1214
1126
  }
1215
1127
  SpNEn(self)->current = 0;
1216
1128
 
1217
- SpNEn(self)->doc = -1;
1129
+ SpNEn(self)->doc_num = -1;
1218
1130
  SpNEn(self)->start = -1;
1219
1131
  SpNEn(self)->end = -1;
1220
1132
 
1221
1133
  self->query = query;
1222
1134
  self->next = &spanne_next;
1223
1135
  self->skip_to = &spanne_skip_to;
1224
- self->doc = &spanne_doc;
1136
+ self->doc_num = &spanne_doc_num;
1225
1137
  self->start = &spanne_start;
1226
1138
  self->end = &spanne_end;
1227
1139
  self->destroy = &spanne_destroy;
@@ -1239,8 +1151,7 @@ static FrtSpanEnum *spanne_new(FrtQuery *query, FrtIndexReader *ir)
1239
1151
  #define SpXEn(span_enum) ((SpanNotEnum *)(span_enum))
1240
1152
  #define SpXQ(query) ((FrtSpanNotQuery *)(query))
1241
1153
 
1242
- typedef struct SpanNotEnum
1243
- {
1154
+ typedef struct SpanNotEnum {
1244
1155
  FrtSpanEnum super;
1245
1156
  FrtSpanEnum *inc;
1246
1157
  FrtSpanEnum *exc;
@@ -1249,8 +1160,7 @@ typedef struct SpanNotEnum
1249
1160
  } SpanNotEnum;
1250
1161
 
1251
1162
 
1252
- static bool spanxe_next(FrtSpanEnum *self)
1253
- {
1163
+ static bool spanxe_next(FrtSpanEnum *self) {
1254
1164
  SpanNotEnum *sxe = SpXEn(self);
1255
1165
  FrtSpanEnum *inc = sxe->inc, *exc = sxe->exc;
1256
1166
  if (sxe->more_inc) { /* move to next incl */
@@ -1258,18 +1168,18 @@ static bool spanxe_next(FrtSpanEnum *self)
1258
1168
  }
1259
1169
 
1260
1170
  while (sxe->more_inc && sxe->more_exc) {
1261
- if (inc->doc(inc) > exc->doc(exc)) { /* skip excl */
1262
- sxe->more_exc = exc->skip_to(exc, inc->doc(inc));
1171
+ if (inc->doc_num(inc) > exc->doc_num(exc)) { /* skip excl */
1172
+ sxe->more_exc = exc->skip_to(exc, inc->doc_num(inc));
1263
1173
  }
1264
1174
 
1265
1175
  while (sxe->more_exc /* while excl is before */
1266
- && (inc->doc(inc) == exc->doc(exc))
1176
+ && (inc->doc_num(inc) == exc->doc_num(exc))
1267
1177
  && (exc->end(exc) <= inc->start(inc))) {
1268
1178
  sxe->more_exc = exc->next(exc); /* increment excl */
1269
1179
  }
1270
1180
 
1271
1181
  if (! sxe->more_exc || /* if no intersection */
1272
- (inc->doc(inc) != exc->doc(exc)) ||
1182
+ (inc->doc_num(inc) != exc->doc_num(exc)) ||
1273
1183
  inc->end(inc) <= exc->start(exc)) {
1274
1184
  break; /* we found a match */
1275
1185
  }
@@ -1279,28 +1189,27 @@ static bool spanxe_next(FrtSpanEnum *self)
1279
1189
  return sxe->more_inc;
1280
1190
  }
1281
1191
 
1282
- static bool spanxe_skip_to(FrtSpanEnum *self, int target)
1283
- {
1192
+ static bool spanxe_skip_to(FrtSpanEnum *self, int target) {
1284
1193
  SpanNotEnum *sxe = SpXEn(self);
1285
1194
  FrtSpanEnum *inc = sxe->inc, *exc = sxe->exc;
1286
- int doc;
1195
+ int doc_num;
1287
1196
 
1288
1197
  if (sxe->more_inc) { /* move to next incl */
1289
1198
  if (!(sxe->more_inc=sxe->inc->skip_to(sxe->inc, target))) return false;
1290
1199
  }
1291
1200
 
1292
- if (sxe->more_inc && ((doc=inc->doc(inc)) > exc->doc(exc))) {
1293
- sxe->more_exc = exc->skip_to(exc, doc);
1201
+ if (sxe->more_inc && ((doc_num = inc->doc_num(inc)) > exc->doc_num(exc))) {
1202
+ sxe->more_exc = exc->skip_to(exc, doc_num);
1294
1203
  }
1295
1204
 
1296
1205
  while (sxe->more_exc /* while excl is before */
1297
- && inc->doc(inc) == exc->doc(exc)
1206
+ && inc->doc_num(inc) == exc->doc_num(exc)
1298
1207
  && exc->end(exc) <= inc->start(inc)) {
1299
1208
  sxe->more_exc = exc->next(exc); /* increment excl */
1300
1209
  }
1301
1210
 
1302
1211
  if (!sxe->more_exc || /* if no intersection */
1303
- inc->doc(inc) != exc->doc(exc) ||
1212
+ inc->doc_num(inc) != exc->doc_num(exc) ||
1304
1213
  inc->end(inc) <= exc->start(exc)) {
1305
1214
  return true; /* we found a match */
1306
1215
  }
@@ -1308,20 +1217,17 @@ static bool spanxe_skip_to(FrtSpanEnum *self, int target)
1308
1217
  return spanxe_next(self); /* scan to next match */
1309
1218
  }
1310
1219
 
1311
- static int spanxe_doc(FrtSpanEnum *self)
1312
- {
1220
+ static int spanxe_doc_num(FrtSpanEnum *self) {
1313
1221
  FrtSpanEnum *inc = SpXEn(self)->inc;
1314
- return inc->doc(inc);
1222
+ return inc->doc_num(inc);
1315
1223
  }
1316
1224
 
1317
- static int spanxe_start(FrtSpanEnum *self)
1318
- {
1225
+ static int spanxe_start(FrtSpanEnum *self) {
1319
1226
  FrtSpanEnum *inc = SpXEn(self)->inc;
1320
1227
  return inc->start(inc);
1321
1228
  }
1322
1229
 
1323
- static int spanxe_end(FrtSpanEnum *self)
1324
- {
1230
+ static int spanxe_end(FrtSpanEnum *self) {
1325
1231
  FrtSpanEnum *inc = SpXEn(self)->inc;
1326
1232
  return inc->end(inc);
1327
1233
  }
@@ -1333,19 +1239,17 @@ static char *spanxe_to_s(FrtSpanEnum *self) {
1333
1239
  return res;
1334
1240
  }
1335
1241
 
1336
- static void spanxe_destroy(FrtSpanEnum *self)
1337
- {
1242
+ static void spanxe_destroy(FrtSpanEnum *self) {
1338
1243
  SpanNotEnum *sxe = SpXEn(self);
1339
1244
  sxe->inc->destroy(sxe->inc);
1340
1245
  sxe->exc->destroy(sxe->exc);
1341
1246
  free(self);
1342
1247
  }
1343
1248
 
1344
- static FrtSpanEnum *spanxe_new(FrtQuery *query, FrtIndexReader *ir)
1345
- {
1346
- FrtSpanEnum *self = (FrtSpanEnum *)FRT_ALLOC(SpanNotEnum);
1249
+ static FrtSpanEnum *spanxe_new(FrtQuery *query, FrtIndexReader *ir) {
1250
+ FrtSpanEnum *self = (FrtSpanEnum *)FRT_ALLOC(SpanNotEnum);
1347
1251
  SpanNotEnum *sxe = SpXEn(self);
1348
- FrtSpanNotQuery *sxq = SpXQ(query);
1252
+ FrtSpanNotQuery *sxq = SpXQ(query);
1349
1253
 
1350
1254
  sxe->inc = SpQ(sxq->inc)->get_spans(sxq->inc, ir);
1351
1255
  sxe->exc = SpQ(sxq->exc)->get_spans(sxq->exc, ir);
@@ -1355,7 +1259,7 @@ static FrtSpanEnum *spanxe_new(FrtQuery *query, FrtIndexReader *ir)
1355
1259
  self->query = query;
1356
1260
  self->next = &spanxe_next;
1357
1261
  self->skip_to = &spanxe_skip_to;
1358
- self->doc = &spanxe_doc;
1262
+ self->doc_num = &spanxe_doc_num;
1359
1263
  self->start = &spanxe_start;
1360
1264
  self->end = &spanxe_end;
1361
1265
  self->destroy = &spanxe_destroy;
@@ -1413,8 +1317,7 @@ static FrtExplanation *spanw_explain(FrtWeight *self, FrtIndexReader *ir, int ta
1413
1317
  if (terms->size > 0) {
1414
1318
  df_i -= 2;
1415
1319
  doc_freqs[df_i] = '\0';
1416
- }
1417
- else {
1320
+ } else {
1418
1321
  doc_freqs = frt_estrdup("");
1419
1322
  }
1420
1323
 
@@ -1468,27 +1371,23 @@ static FrtExplanation *spanw_explain(FrtWeight *self, FrtIndexReader *ir, int ta
1468
1371
  if (query_expl->value == 1.0) {
1469
1372
  frt_expl_destroy(expl);
1470
1373
  return field_expl;
1471
- }
1472
- else {
1374
+ } else {
1473
1375
  expl->value = (query_expl->value * field_expl->value);
1474
1376
  frt_expl_add_detail(expl, field_expl);
1475
1377
  return expl;
1476
1378
  }
1477
1379
  }
1478
1380
 
1479
- static char *spanw_to_s(FrtWeight *self)
1480
- {
1381
+ static char *spanw_to_s(FrtWeight *self) {
1481
1382
  return frt_strfmt("SpanWeight(%f)", self->value);
1482
1383
  }
1483
1384
 
1484
- static void spanw_destroy(FrtWeight *self)
1485
- {
1385
+ static void spanw_destroy(FrtWeight *self) {
1486
1386
  frt_hs_destroy(SpW(self)->terms);
1487
1387
  frt_w_destroy(self);
1488
1388
  }
1489
1389
 
1490
- static FrtWeight *spanw_new(FrtQuery *query, FrtSearcher *searcher)
1491
- {
1390
+ static FrtWeight *spanw_new(FrtQuery *query, FrtSearcher *searcher) {
1492
1391
  FrtHashSetEntry *hse;
1493
1392
  FrtWeight *self = w_new(SpanWeight, query);
1494
1393
  FrtHashSet *terms = SpQ(query)->get_terms(query);
@@ -1943,8 +1842,7 @@ FrtQuery *frt_spanoq_new(void) {
1943
1842
  return frt_spanoq_init(self);
1944
1843
  }
1945
1844
 
1946
- FrtQuery *frt_spanoq_add_clause_nr(FrtQuery *self, FrtQuery *clause)
1947
- {
1845
+ FrtQuery *frt_spanoq_add_clause_nr(FrtQuery *self, FrtQuery *clause) {
1948
1846
  const int curr_index = SpOQ(self)->c_cnt++;
1949
1847
  if (clause->type < SPAN_TERM_QUERY || clause->type > SPAN_NEAR_QUERY) {
1950
1848
  FRT_RAISE(FRT_ARG_ERROR, "Tried to add a %s to a SpanOrQuery. This is not a "
@@ -1952,8 +1850,7 @@ FrtQuery *frt_spanoq_add_clause_nr(FrtQuery *self, FrtQuery *clause)
1952
1850
  }
1953
1851
  if (curr_index == 0) {
1954
1852
  SpQ(self)->field = SpQ(clause)->field;
1955
- }
1956
- else if (SpQ(self)->field != SpQ(clause)->field) {
1853
+ } else if (SpQ(self)->field != SpQ(clause)->field) {
1957
1854
  FRT_RAISE(FRT_ARG_ERROR, "All clauses in a SpanQuery must have the same field. "
1958
1855
  "Attempted to add a SpanQuery with field \"%s\" to a SpanOrQuery "
1959
1856
  "with field \"%s\"", rb_id2name(SpQ(clause)->field), rb_id2name(SpQ(self)->field));
@@ -1966,8 +1863,7 @@ FrtQuery *frt_spanoq_add_clause_nr(FrtQuery *self, FrtQuery *clause)
1966
1863
  return clause;
1967
1864
  }
1968
1865
 
1969
- FrtQuery *frt_spanoq_add_clause(FrtQuery *self, FrtQuery *clause)
1970
- {
1866
+ FrtQuery *frt_spanoq_add_clause(FrtQuery *self, FrtQuery *clause) {
1971
1867
  FRT_REF(clause);
1972
1868
  return frt_spanoq_add_clause_nr(self, clause);
1973
1869
  }
@@ -2004,8 +1900,7 @@ static char *spannq_to_s(FrtQuery *self, ID field) {
2004
1900
  return res;
2005
1901
  }
2006
1902
 
2007
- static void spannq_extract_terms(FrtQuery *self, FrtHashSet *terms)
2008
- {
1903
+ static void spannq_extract_terms(FrtQuery *self, FrtHashSet *terms) {
2009
1904
  FrtSpanNearQuery *snq = SpNQ(self);
2010
1905
  int i;
2011
1906
  for (i = 0; i < snq->c_cnt; i++) {
@@ -2014,8 +1909,7 @@ static void spannq_extract_terms(FrtQuery *self, FrtHashSet *terms)
2014
1909
  }
2015
1910
  }
2016
1911
 
2017
- static FrtHashSet *spannq_get_terms(FrtQuery *self)
2018
- {
1912
+ static FrtHashSet *spannq_get_terms(FrtQuery *self) {
2019
1913
  FrtSpanNearQuery *snq = SpNQ(self);
2020
1914
  FrtHashSet *terms = frt_hs_new_str(&free);
2021
1915
  int i;
@@ -2028,8 +1922,7 @@ static FrtHashSet *spannq_get_terms(FrtQuery *self)
2028
1922
  return terms;
2029
1923
  }
2030
1924
 
2031
- static FrtSpanEnum *spannq_get_spans(FrtQuery *self, FrtIndexReader *ir)
2032
- {
1925
+ static FrtSpanEnum *spannq_get_spans(FrtQuery *self, FrtIndexReader *ir) {
2033
1926
  FrtSpanNearQuery *snq = SpNQ(self);
2034
1927
 
2035
1928
  if (snq->c_cnt == 1) {
@@ -2040,8 +1933,7 @@ static FrtSpanEnum *spannq_get_spans(FrtQuery *self, FrtIndexReader *ir)
2040
1933
  return spanne_new(self, ir);
2041
1934
  }
2042
1935
 
2043
- static FrtQuery *spannq_rewrite(FrtQuery *self, FrtIndexReader *ir)
2044
- {
1936
+ static FrtQuery *spannq_rewrite(FrtQuery *self, FrtIndexReader *ir) {
2045
1937
  FrtSpanNearQuery *snq = SpNQ(self);
2046
1938
  int i;
2047
1939
  for (i = 0; i < snq->c_cnt; i++) {
@@ -2055,8 +1947,7 @@ static FrtQuery *spannq_rewrite(FrtQuery *self, FrtIndexReader *ir)
2055
1947
  return self;
2056
1948
  }
2057
1949
 
2058
- static void spannq_destroy(FrtQuery *self)
2059
- {
1950
+ static void spannq_destroy(FrtQuery *self) {
2060
1951
  FrtSpanNearQuery *snq = SpNQ(self);
2061
1952
 
2062
1953
  int i;
@@ -2069,8 +1960,7 @@ static void spannq_destroy(FrtQuery *self)
2069
1960
  spanq_destroy_i(self);
2070
1961
  }
2071
1962
 
2072
- static unsigned long long spannq_hash(FrtQuery *self)
2073
- {
1963
+ static unsigned long long spannq_hash(FrtQuery *self) {
2074
1964
  int i;
2075
1965
  unsigned long long hash = spanq_hash(self);
2076
1966
  FrtSpanNearQuery *snq = SpNQ(self);
@@ -2082,8 +1972,7 @@ static unsigned long long spannq_hash(FrtQuery *self)
2082
1972
  return ((hash ^ snq->slop) << 1) | snq->in_order;
2083
1973
  }
2084
1974
 
2085
- static int spannq_eq(FrtQuery *self, FrtQuery *o)
2086
- {
1975
+ static int spannq_eq(FrtQuery *self, FrtQuery *o) {
2087
1976
  int i;
2088
1977
  FrtQuery *q1, *q2;
2089
1978
  FrtSpanNearQuery *snq1 = SpNQ(self);
@@ -2138,8 +2027,7 @@ FrtQuery *frt_spannq_new(int slop, bool in_order) {
2138
2027
  return frt_spannq_init(self, slop, in_order);
2139
2028
  }
2140
2029
 
2141
- FrtQuery *frt_spannq_add_clause_nr(FrtQuery *self, FrtQuery *clause)
2142
- {
2030
+ FrtQuery *frt_spannq_add_clause_nr(FrtQuery *self, FrtQuery *clause) {
2143
2031
  const int curr_index = SpNQ(self)->c_cnt++;
2144
2032
  if (clause->type < SPAN_TERM_QUERY || clause->type > SPAN_NEAR_QUERY) {
2145
2033
  FRT_RAISE(FRT_ARG_ERROR, "Tried to add a %s to a SpanNearQuery. This is not a "
@@ -2147,8 +2035,7 @@ FrtQuery *frt_spannq_add_clause_nr(FrtQuery *self, FrtQuery *clause)
2147
2035
  }
2148
2036
  if (curr_index == 0) {
2149
2037
  SpQ(self)->field = SpQ(clause)->field;
2150
- }
2151
- else if (SpQ(self)->field != SpQ(clause)->field) {
2038
+ } else if (SpQ(self)->field != SpQ(clause)->field) {
2152
2039
  FRT_RAISE(FRT_ARG_ERROR, "All clauses in a SpanQuery must have the same field. "
2153
2040
  "Attempted to add a SpanQuery with field \"%s\" to SpanNearQuery "
2154
2041
  "with field \"%s\"", rb_id2name(SpQ(clause)->field), rb_id2name(SpQ(self)->field));
@@ -2161,8 +2048,7 @@ FrtQuery *frt_spannq_add_clause_nr(FrtQuery *self, FrtQuery *clause)
2161
2048
  return clause;
2162
2049
  }
2163
2050
 
2164
- FrtQuery *frt_spannq_add_clause(FrtQuery *self, FrtQuery *clause)
2165
- {
2051
+ FrtQuery *frt_spannq_add_clause(FrtQuery *self, FrtQuery *clause) {
2166
2052
  FRT_REF(clause);
2167
2053
  return frt_spannq_add_clause_nr(self, clause);
2168
2054
  }