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 @@ typedef struct MatchAllScorer {
16
16
  float score;
17
17
  } MatchAllScorer;
18
18
 
19
- static float masc_score(FrtScorer *self)
20
- {
19
+ static float masc_score(FrtScorer *self) {
21
20
  return MASc(self)->score;
22
21
  }
23
22
 
24
- static bool masc_next(FrtScorer *self)
25
- {
23
+ static bool masc_next(FrtScorer *self) {
26
24
  while (self->doc < (MASc(self)->max_doc - 1)) {
27
25
  self->doc++;
28
26
  if (!MASc(self)->ir->is_deleted(MASc(self)->ir, self->doc)) {
@@ -32,14 +30,12 @@ static bool masc_next(FrtScorer *self)
32
30
  return false;
33
31
  }
34
32
 
35
- static bool masc_skip_to(FrtScorer *self, int doc_num)
36
- {
33
+ static bool masc_skip_to(FrtScorer *self, int doc_num) {
37
34
  self->doc = doc_num - 1;
38
35
  return masc_next(self);
39
36
  }
40
37
 
41
- static FrtExplanation *masc_explain(FrtScorer *self, int doc_num)
42
- {
38
+ static FrtExplanation *masc_explain(FrtScorer *self, int doc_num) {
43
39
  (void)self;
44
40
  (void)doc_num;
45
41
  return frt_expl_new(1.0, "MatchAllScorer");
@@ -72,13 +68,11 @@ static FrtScorer *masc_new(FrtWeight *weight, FrtIndexReader *ir) {
72
68
  *
73
69
  ***************************************************************************/
74
70
 
75
- static char *maw_to_s(FrtWeight *self)
76
- {
71
+ static char *maw_to_s(FrtWeight *self) {
77
72
  return frt_strfmt("MatchAllWeight(%f)", self->value);
78
73
  }
79
74
 
80
- static FrtExplanation *maw_explain(FrtWeight *self, FrtIndexReader *ir, int doc_num)
81
- {
75
+ static FrtExplanation *maw_explain(FrtWeight *self, FrtIndexReader *ir, int doc_num) {
82
76
  FrtExplanation *expl;
83
77
  if (!ir->is_deleted(ir, doc_num)) {
84
78
  expl = frt_expl_new(self->value, "MatchAllQuery: product of:");
@@ -117,14 +111,12 @@ static char *maq_to_s(FrtQuery *self, ID default_field) {
117
111
  }
118
112
  }
119
113
 
120
- static unsigned long long maq_hash(FrtQuery *self)
121
- {
114
+ static unsigned long long maq_hash(FrtQuery *self) {
122
115
  (void)self;
123
116
  return 0;
124
117
  }
125
118
 
126
- static int maq_eq(FrtQuery *self, FrtQuery *o)
127
- {
119
+ static int maq_eq(FrtQuery *self, FrtQuery *o) {
128
120
  (void)self; (void)o;
129
121
  return true;
130
122
  }
@@ -76,8 +76,7 @@ static bool tdew_next(TermDocEnumWrapper *self) {
76
76
  self->pointer_max = self->tde->read(self->tde, self->docs, self->freqs, TDE_READ_SIZE);
77
77
  if (self->pointer_max != 0) {
78
78
  self->pointer = 0;
79
- }
80
- else {
79
+ } else {
81
80
  return false;
82
81
  }
83
82
  }
@@ -1957,8 +1957,7 @@ static const char *not_word = " \t()[]{}!\"~^|<>=";
1957
1957
  * Note that +get_word+ is also responsible for returning field names and
1958
1958
  * matching the special tokens 'AND', 'NOT', 'REQ' and 'OR'.
1959
1959
  */
1960
- static int get_word(YYSTYPE *lvalp, FrtQParser *qp)
1961
- {
1960
+ static int get_word(YYSTYPE *lvalp, FrtQParser *qp) {
1962
1961
  bool is_wild = false;
1963
1962
  int len;
1964
1963
  char c;
@@ -1978,8 +1977,7 @@ static int get_word(YYSTYPE *lvalp, FrtQParser *qp)
1978
1977
  case '\\':
1979
1978
  if ((c = *qp->qstrp) == '\0') {
1980
1979
  *bufp++ = '\\';
1981
- }
1982
- else {
1980
+ } else {
1983
1981
  *bufp++ = c;
1984
1982
  qp->qstrp++;
1985
1983
  }
@@ -1989,8 +1987,7 @@ static int get_word(YYSTYPE *lvalp, FrtQParser *qp)
1989
1987
  qp->qstrp++;
1990
1988
  *bufp++ = ':';
1991
1989
  *bufp++ = ':';
1992
- }
1993
- else {
1990
+ } else {
1994
1991
  goto get_word_done;
1995
1992
  }
1996
1993
  break;
@@ -2061,8 +2058,7 @@ get_word_done:
2061
2058
  * If no special characters or tokens are found then yylex delegates to
2062
2059
  * +get_word+ which will fetch the next query-word.
2063
2060
  */
2064
- static int yylex(YYSTYPE *lvalp, FrtQParser *qp)
2065
- {
2061
+ static int yylex(YYSTYPE *lvalp, FrtQParser *qp) {
2066
2062
  char c, nc;
2067
2063
 
2068
2064
  while ((c=*qp->qstrp++) == ' ' || c == '\t') {
@@ -2104,8 +2100,7 @@ static int yylex(YYSTYPE *lvalp, FrtQParser *qp)
2104
2100
  * It is responsible for clearing any memory that was allocated during the
2105
2101
  * parsing process.
2106
2102
  */
2107
- static int yyerror(FrtQParser *qp, rb_encoding *encoding, char const *msg)
2108
- {
2103
+ static int yyerror(FrtQParser *qp, rb_encoding *encoding, char const *msg) {
2109
2104
  (void)encoding;
2110
2105
  qp->destruct = true;
2111
2106
  if (!qp->handle_parse_errors) {
@@ -2143,12 +2138,10 @@ static FrtTokenStream *get_cached_ts(FrtQParser *qp, ID field, char *text, rb_en
2143
2138
  if (!ts) {
2144
2139
  ts = frt_a_get_ts(qp->analyzer, field, text, encoding);
2145
2140
  frt_h_set(qp->ts_cache, (void *)field, ts);
2146
- }
2147
- else {
2141
+ } else {
2148
2142
  ts->reset(ts, text, encoding);
2149
2143
  }
2150
- }
2151
- else {
2144
+ } else {
2152
2145
  ts = qp->non_tokenizer;
2153
2146
  ts->reset(ts, text, encoding);
2154
2147
  }
@@ -2160,29 +2153,25 @@ static FrtTokenStream *get_cached_ts(FrtQParser *qp, ID field, char *text, rb_en
2160
2153
  * if 0 or 1 clauses are present to NULL or the actual query in the clause
2161
2154
  * respectively.
2162
2155
  */
2163
- static FrtQuery *get_bool_q(FrtBCArray *bca)
2164
- {
2156
+ static FrtQuery *get_bool_q(FrtBCArray *bca) {
2165
2157
  FrtQuery *q;
2166
2158
  const int clause_count = bca->size;
2167
2159
 
2168
2160
  if (clause_count == 0) {
2169
2161
  q = NULL;
2170
2162
  free(bca->clauses);
2171
- }
2172
- else if (clause_count == 1) {
2163
+ } else if (clause_count == 1) {
2173
2164
  FrtBooleanClause *bc = bca->clauses[0];
2174
2165
  if (bc->is_prohibited) {
2175
2166
  q = frt_bq_new(false);
2176
2167
  frt_bq_add_query_nr(q, bc->query, FRT_BC_MUST_NOT);
2177
2168
  frt_bq_add_query_nr(q, frt_maq_new(), FRT_BC_MUST);
2178
- }
2179
- else {
2169
+ } else {
2180
2170
  q = bc->query;
2181
2171
  }
2182
2172
  free(bc);
2183
2173
  free(bca->clauses);
2184
- }
2185
- else {
2174
+ } else {
2186
2175
  q = frt_bq_new(false);
2187
2176
  /* copy clauses into query */
2188
2177
 
@@ -2199,8 +2188,7 @@ static FrtQuery *get_bool_q(FrtBCArray *bca)
2199
2188
  * Base method for appending BooleanClauses to a FrtBooleanClause array. This
2200
2189
  * method doesn't care about the type of clause (MUST, SHOULD, MUST_NOT).
2201
2190
  */
2202
- static void bca_add_clause(FrtBCArray *bca, FrtBooleanClause *clause)
2203
- {
2191
+ static void bca_add_clause(FrtBCArray *bca, FrtBooleanClause *clause) {
2204
2192
  if (bca->size >= bca->capa) {
2205
2193
  bca->capa <<= 1;
2206
2194
  FRT_REALLOC_N(bca->clauses, FrtBooleanClause *, bca->capa);
@@ -2213,8 +2201,7 @@ static void bca_add_clause(FrtBCArray *bca, FrtBooleanClause *clause)
2213
2201
  * Add the first clause to a BooleanClause array. This method is also
2214
2202
  * responsible for allocating a new BooleanClause array.
2215
2203
  */
2216
- static FrtBCArray *first_cls(FrtBooleanClause *clause)
2217
- {
2204
+ static FrtBCArray *first_cls(FrtBooleanClause *clause) {
2218
2205
  FrtBCArray *bca = FRT_ALLOC_AND_ZERO(FrtBCArray);
2219
2206
  bca->capa = BCA_INIT_CAPA;
2220
2207
  bca->clauses = FRT_ALLOC_N(FrtBooleanClause *, BCA_INIT_CAPA);
@@ -2230,8 +2217,7 @@ static FrtBCArray *first_cls(FrtBooleanClause *clause)
2230
2217
  * MUST clauses. (If they are currently MUST_NOT clauses they stay as they
2231
2218
  * are.)
2232
2219
  */
2233
- static FrtBCArray *add_and_cls(FrtBCArray *bca, FrtBooleanClause *clause)
2234
- {
2220
+ static FrtBCArray *add_and_cls(FrtBCArray *bca, FrtBooleanClause *clause) {
2235
2221
  if (clause) {
2236
2222
  if (bca->size == 1) {
2237
2223
  if (!bca->clauses[0]->is_prohibited) {
@@ -2249,8 +2235,7 @@ static FrtBCArray *add_and_cls(FrtBCArray *bca, FrtBooleanClause *clause)
2249
2235
  /**
2250
2236
  * Add SHOULD clause to the BooleanClause array.
2251
2237
  */
2252
- static FrtBCArray *add_or_cls(FrtBCArray *bca, FrtBooleanClause *clause)
2253
- {
2238
+ static FrtBCArray *add_or_cls(FrtBCArray *bca, FrtBooleanClause *clause) {
2254
2239
  if (clause) {
2255
2240
  bca_add_clause(bca, clause);
2256
2241
  }
@@ -2262,12 +2247,10 @@ static FrtBCArray *add_or_cls(FrtBCArray *bca, FrtBooleanClause *clause)
2262
2247
  * clause type.
2263
2248
  */
2264
2249
  static FrtBCArray *add_default_cls(FrtQParser *qp, FrtBCArray *bca,
2265
- FrtBooleanClause *clause)
2266
- {
2250
+ FrtBooleanClause *clause) {
2267
2251
  if (qp->or_default) {
2268
2252
  add_or_cls(bca, clause);
2269
- }
2270
- else {
2253
+ } else {
2271
2254
  add_and_cls(bca, clause);
2272
2255
  }
2273
2256
  return bca;
@@ -2276,8 +2259,7 @@ static FrtBCArray *add_default_cls(FrtQParser *qp, FrtBCArray *bca,
2276
2259
  /**
2277
2260
  * destroy array of BooleanClauses
2278
2261
  */
2279
- static void bca_destroy(FrtBCArray *bca)
2280
- {
2262
+ static void bca_destroy(FrtBCArray *bca) {
2281
2263
  int i;
2282
2264
  for (i = 0; i < bca->size; i++) {
2283
2265
  frt_bc_deref(bca->clauses[i]);
@@ -2289,12 +2271,10 @@ static void bca_destroy(FrtBCArray *bca)
2289
2271
  /**
2290
2272
  * Turn a query into a BooleanClause for addition to a BooleanQuery.
2291
2273
  */
2292
- static FrtBooleanClause *get_bool_cls(FrtQuery *q, FrtBCType occur)
2293
- {
2274
+ static FrtBooleanClause *get_bool_cls(FrtQuery *q, FrtBCType occur) {
2294
2275
  if (q) {
2295
2276
  return frt_bc_new(q, occur);
2296
- }
2297
- else {
2277
+ } else {
2298
2278
  return NULL;
2299
2279
  }
2300
2280
  }
@@ -2314,8 +2294,7 @@ static FrtQuery *get_term_q(FrtQParser *qp, ID field, char *word, rb_encoding *e
2314
2294
 
2315
2295
  if ((token = frt_ts_next(stream)) == NULL) {
2316
2296
  q = NULL;
2317
- }
2318
- else {
2297
+ } else {
2319
2298
  q = frt_tq_new(field, token->text);
2320
2299
  if ((token = frt_ts_next(stream)) != NULL) {
2321
2300
  /* Less likely case, destroy the term query and create a
@@ -2329,8 +2308,7 @@ static FrtQuery *get_term_q(FrtQParser *qp, ID field, char *word, rb_encoding *e
2329
2308
  frt_phq_add_term(q, token->text, token->pos_inc);
2330
2309
  /* add some slop since single term was expected */
2331
2310
  ((FrtPhraseQuery *)q)->slop++;
2332
- }
2333
- else {
2311
+ } else {
2334
2312
  frt_phq_append_multi_term(q, token->text);
2335
2313
  }
2336
2314
  } while ((token = frt_ts_next(stream)) != NULL);
@@ -2351,8 +2329,7 @@ static FrtQuery *get_fuzzy_q(FrtQParser *qp, ID field, char *word, char *slop_st
2351
2329
 
2352
2330
  if ((token = frt_ts_next(stream)) == NULL) {
2353
2331
  q = NULL;
2354
- }
2355
- else {
2332
+ } else {
2356
2333
  /* it only makes sense to find one term in a fuzzy query */
2357
2334
  float slop = frt_qp_default_fuzzy_min_sim;
2358
2335
  if (slop_str) {
@@ -2423,8 +2400,7 @@ static FrtQuery *get_wild_q(FrtQParser *qp, ID field, char *pattern, rb_encoding
2423
2400
  pattern[len - 1] = 0;
2424
2401
  q = frt_prefixq_new(field, pattern);
2425
2402
  pattern[len - 1] = '*';
2426
- }
2427
- else {
2403
+ } else {
2428
2404
  q = frt_wcq_new(field, pattern);
2429
2405
  }
2430
2406
  FrtMTQMaxTerms(q) = qp->max_clauses;
@@ -2447,8 +2423,7 @@ static FrtHashSet *add_field(FrtQParser *qp, const char *field_name) {
2447
2423
  * will push a new FieldStack object onto the stack and add +field+ to its
2448
2424
  * fields set.
2449
2425
  */
2450
- static FrtHashSet *first_field(FrtQParser *qp, const char *field_name)
2451
- {
2426
+ static FrtHashSet *first_field(FrtQParser *qp, const char *field_name) {
2452
2427
  qp_push_fields(qp, frt_hs_new_ptr(NULL), true);
2453
2428
  return add_field(qp, field_name);
2454
2429
  }
@@ -2456,8 +2431,7 @@ static FrtHashSet *first_field(FrtQParser *qp, const char *field_name)
2456
2431
  /**
2457
2432
  * Destroy a phrase object freeing all allocated memory.
2458
2433
  */
2459
- static void ph_destroy(Phrase *self)
2460
- {
2434
+ static void ph_destroy(Phrase *self) {
2461
2435
  int i;
2462
2436
  for (i = 0; i < self->size; i++) {
2463
2437
  frt_ary_destroy(self->positions[i].terms, &free);
@@ -2470,8 +2444,7 @@ static void ph_destroy(Phrase *self)
2470
2444
  /**
2471
2445
  * Allocate a new Phrase object
2472
2446
  */
2473
- static Phrase *ph_new()
2474
- {
2447
+ static Phrase *ph_new() {
2475
2448
  Phrase *self = FRT_ALLOC_AND_ZERO(Phrase);
2476
2449
  self->capa = PHRASE_INIT_CAPA;
2477
2450
  self->positions = FRT_ALLOC_AND_ZERO_N(FrtPhrasePosition, PHRASE_INIT_CAPA);
@@ -2482,8 +2455,7 @@ static Phrase *ph_new()
2482
2455
  * Add the first word to the phrase. This method is also in charge of
2483
2456
  * allocating a new Phrase object.
2484
2457
  */
2485
- static Phrase *ph_first_word(char *word)
2486
- {
2458
+ static Phrase *ph_first_word(char *word) {
2487
2459
  Phrase *self = ph_new();
2488
2460
  if (word) { /* no point in adding NULL in start */
2489
2461
  self->positions[0].terms = frt_ary_new_type_capa(char *, 1);
@@ -2496,8 +2468,7 @@ static Phrase *ph_first_word(char *word)
2496
2468
  /**
2497
2469
  * Add a new word to the Phrase
2498
2470
  */
2499
- static Phrase *ph_add_word(Phrase *self, char *word)
2500
- {
2471
+ static Phrase *ph_add_word(Phrase *self, char *word) {
2501
2472
  if (word) {
2502
2473
  const int index = self->size;
2503
2474
  FrtPhrasePosition *pp = self->positions;
@@ -2511,8 +2482,7 @@ static Phrase *ph_add_word(Phrase *self, char *word)
2511
2482
  frt_ary_push(pp[index].terms, frt_estrdup(word));
2512
2483
  self->size++;
2513
2484
  self->pos_inc = 0;
2514
- }
2515
- else {
2485
+ } else {
2516
2486
  self->pos_inc++;
2517
2487
  }
2518
2488
  return self;
@@ -2522,8 +2492,7 @@ static Phrase *ph_add_word(Phrase *self, char *word)
2522
2492
  * Adds a word to the Phrase object in the same position as the previous word
2523
2493
  * added to the Phrase. This will later be turned into a multi-PhraseQuery.
2524
2494
  */
2525
- static Phrase *ph_add_multi_word(Phrase *self, char *word)
2526
- {
2495
+ static Phrase *ph_add_multi_word(Phrase *self, char *word) {
2527
2496
  const int index = self->size - 1;
2528
2497
  FrtPhrasePosition *pp = self->positions;
2529
2498
 
@@ -2570,8 +2539,7 @@ static FrtQuery *get_phrase_query(FrtQParser *qp, ID field, Phrase *phrase, char
2570
2539
  const int word_count = frt_ary_size(words);
2571
2540
  if (word_count == 1) {
2572
2541
  q = get_term_q(qp, field, words[0], encoding);
2573
- }
2574
- else {
2542
+ } else {
2575
2543
  int i;
2576
2544
  int term_cnt = 0;
2577
2545
  FrtToken *token;
@@ -2583,8 +2551,7 @@ static FrtQuery *get_phrase_query(FrtQParser *qp, ID field, Phrase *phrase, char
2583
2551
  free(words[i]);
2584
2552
  last_word = words[i] = frt_estrdup(token->text);
2585
2553
  ++term_cnt;
2586
- }
2587
- else {
2554
+ } else {
2588
2555
  /* empty words will later be ignored */
2589
2556
  words[i][0] = '\0';
2590
2557
  }
@@ -2608,8 +2575,7 @@ static FrtQuery *get_phrase_query(FrtQParser *qp, ID field, Phrase *phrase, char
2608
2575
  break;
2609
2576
  }
2610
2577
  }
2611
- }
2612
- else if (pos_cnt > 1) {
2578
+ } else if (pos_cnt > 1) {
2613
2579
  FrtToken *token;
2614
2580
  FrtTokenStream *stream;
2615
2581
  int i, j;
@@ -2635,15 +2601,13 @@ static FrtQuery *get_phrase_query(FrtQParser *qp, ID field, Phrase *phrase, char
2635
2601
  if (token->pos_inc) {
2636
2602
  frt_phq_add_term(q, token->text,
2637
2603
  pos_inc ? pos_inc : token->pos_inc);
2638
- }
2639
- else {
2604
+ } else {
2640
2605
  frt_phq_append_multi_term(q, token->text);
2641
2606
  ((FrtPhraseQuery *)q)->slop++;
2642
2607
  }
2643
2608
  pos_inc = 0;
2644
2609
  }
2645
- }
2646
- else {
2610
+ } else {
2647
2611
  bool added_position = false;
2648
2612
 
2649
2613
  for (j = 0; j < word_count; j++) {
@@ -2654,8 +2618,7 @@ static FrtQuery *get_phrase_query(FrtQParser *qp, ID field, Phrase *phrase, char
2654
2618
  pos_inc ? pos_inc : token->pos_inc);
2655
2619
  added_position = true;
2656
2620
  pos_inc = 0;
2657
- }
2658
- else {
2621
+ } else {
2659
2622
  frt_phq_append_multi_term(q, token->text);
2660
2623
  }
2661
2624
  }
@@ -2671,8 +2634,7 @@ static FrtQuery *get_phrase_query(FrtQParser *qp, ID field, Phrase *phrase, char
2671
2634
  * the query parser as the all PhraseQuery didn't work well for this. Once the
2672
2635
  * PhraseQuery has been built the Phrase object needs to be destroyed.
2673
2636
  */
2674
- static FrtQuery *get_phrase_q(FrtQParser *qp, Phrase *phrase, char *slop_str, rb_encoding *encoding)
2675
- {
2637
+ static FrtQuery *get_phrase_q(FrtQParser *qp, Phrase *phrase, char *slop_str, rb_encoding *encoding) {
2676
2638
  FrtQuery *volatile q = NULL;
2677
2639
  FLDS(q, get_phrase_query(qp, field, phrase, slop_str, encoding));
2678
2640
  ph_destroy(phrase);
@@ -2724,8 +2686,7 @@ static FrtQuery *get_r_q(FrtQParser *qp, ID field, char *from, char *to, bool in
2724
2686
  * the bottom of the stack (ie the very first set of fields pushed onto the
2725
2687
  * stack).
2726
2688
  */
2727
- static void qp_push_fields(FrtQParser *self, FrtHashSet *fields, bool destroy)
2728
- {
2689
+ static void qp_push_fields(FrtQParser *self, FrtHashSet *fields, bool destroy) {
2729
2690
  FrtFieldStack *fs = FRT_ALLOC(FrtFieldStack);
2730
2691
 
2731
2692
  fs->next = self->fields_top;
@@ -2741,8 +2702,7 @@ static void qp_push_fields(FrtQParser *self, FrtHashSet *fields, bool destroy)
2741
2702
  * get called when query modified by a field modifier ("field1|field2:") has
2742
2703
  * been fully parsed and the field specifier no longer applies.
2743
2704
  */
2744
- static void qp_pop_fields(FrtQParser *self)
2745
- {
2705
+ static void qp_pop_fields(FrtQParser *self) {
2746
2706
  FrtFieldStack *fs = self->fields_top;
2747
2707
 
2748
2708
  if (fs->destroy) {
@@ -2758,8 +2718,7 @@ static void qp_pop_fields(FrtQParser *self)
2758
2718
  /**
2759
2719
  * Free all memory allocated by the QueryParser.
2760
2720
  */
2761
- void frt_qp_destroy(FrtQParser *self)
2762
- {
2721
+ void frt_qp_destroy(FrtQParser *self) {
2763
2722
  if (self->tokenized_fields != self->all_fields) {
2764
2723
  frt_hs_destroy(self->tokenized_fields);
2765
2724
  }
@@ -2838,8 +2797,7 @@ static const char *PHRASE_CHARS = "<>|\"";
2838
2797
  * +str_insert_char+ inserts a character at the beginning of a string by
2839
2798
  * shifting the rest of the string right.
2840
2799
  */
2841
- static void str_insert_char(char *str, int len, char chr)
2842
- {
2800
+ static void str_insert_char(char *str, int len, char chr) {
2843
2801
  memmove(str+1, str, len*sizeof(char));
2844
2802
  *str = chr;
2845
2803
  }
@@ -2857,8 +2815,7 @@ static void str_insert_char(char *str, int len, char chr)
2857
2815
  * ( <>,|," ). Note that '<' and '>' will also be escaped unless the appear
2858
2816
  * together like so; '<>'.
2859
2817
  */
2860
- char *frt_qp_clean_str(char *str)
2861
- {
2818
+ char *frt_qp_clean_str(char *str) {
2862
2819
  int b, pb = -1;
2863
2820
  int br_cnt = 0;
2864
2821
  bool quote_open = false;
@@ -2892,8 +2849,7 @@ char *frt_qp_clean_str(char *str)
2892
2849
  case '(':
2893
2850
  if (!quote_open) {
2894
2851
  br_cnt++;
2895
- }
2896
- else {
2852
+ } else {
2897
2853
  *nsp++ = '\\';
2898
2854
  }
2899
2855
  *nsp++ = b;
@@ -2903,12 +2859,10 @@ char *frt_qp_clean_str(char *str)
2903
2859
  if (br_cnt == 0) {
2904
2860
  str_insert_char(new_str, (int)(nsp - new_str), '(');
2905
2861
  nsp++;
2906
- }
2907
- else {
2862
+ } else {
2908
2863
  br_cnt--;
2909
2864
  }
2910
- }
2911
- else {
2865
+ } else {
2912
2866
  *nsp++ = '\\';
2913
2867
  }
2914
2868
  *nsp++ = b;
@@ -2919,8 +2873,7 @@ char *frt_qp_clean_str(char *str)
2919
2873
  /* remove the escape character */
2920
2874
  nsp--;
2921
2875
  nsp[-1] = '<';
2922
- }
2923
- else {
2876
+ } else {
2924
2877
  *nsp++ = '\\';
2925
2878
  }
2926
2879
  }
@@ -2951,8 +2904,7 @@ char *frt_qp_clean_str(char *str)
2951
2904
  * analyzer. It then turns these tokens (if any) into a boolean query. If it
2952
2905
  * fails to find any tokens, this method will return NULL.
2953
2906
  */
2954
- static FrtQuery *qp_get_bad_query(FrtQParser *qp, char *str, rb_encoding *encoding)
2955
- {
2907
+ static FrtQuery *qp_get_bad_query(FrtQParser *qp, char *str, rb_encoding *encoding) {
2956
2908
  FrtQuery *volatile q = NULL;
2957
2909
  qp->recovering = true;
2958
2910
  assert(qp->fields_top->next == NULL);
@@ -2968,8 +2920,7 @@ static FrtQuery *qp_get_bad_query(FrtQParser *qp, char *str, rb_encoding *encodi
2968
2920
  * and turns them into a boolean query on the default fields.
2969
2921
  */
2970
2922
 
2971
- FrtQuery *qp_parse(FrtQParser *self, char *query_string, rb_encoding *encoding)
2972
- {
2923
+ FrtQuery *qp_parse(FrtQParser *self, char *query_string, rb_encoding *encoding) {
2973
2924
  FrtQuery *result = NULL;
2974
2925
  char *qstr;
2975
2926
  unsigned char *dp_start = NULL;