isomorfeus-ferret 0.12.6 → 0.13.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (249) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +101 -19
  3. data/README.md +85 -16
  4. data/ext/isomorfeus_ferret_ext/bm_bitvector.c +22 -30
  5. data/ext/isomorfeus_ferret_ext/bm_hash.c +6 -12
  6. data/ext/isomorfeus_ferret_ext/bm_micro_string.c +3 -6
  7. data/ext/isomorfeus_ferret_ext/bm_store.c +11 -22
  8. data/ext/isomorfeus_ferret_ext/brotli_common_constants.c +15 -0
  9. data/ext/isomorfeus_ferret_ext/brotli_common_constants.h +200 -0
  10. data/ext/isomorfeus_ferret_ext/brotli_common_context.c +156 -0
  11. data/ext/isomorfeus_ferret_ext/brotli_common_context.h +113 -0
  12. data/ext/isomorfeus_ferret_ext/brotli_common_dictionary.c +5914 -0
  13. data/ext/isomorfeus_ferret_ext/brotli_common_dictionary.h +64 -0
  14. data/ext/isomorfeus_ferret_ext/brotli_common_platform.c +22 -0
  15. data/ext/isomorfeus_ferret_ext/brotli_common_platform.h +594 -0
  16. data/ext/isomorfeus_ferret_ext/brotli_common_transform.c +291 -0
  17. data/ext/isomorfeus_ferret_ext/brotli_common_transform.h +85 -0
  18. data/ext/isomorfeus_ferret_ext/brotli_common_version.h +26 -0
  19. data/ext/isomorfeus_ferret_ext/brotli_dec_bit_reader.c +76 -0
  20. data/ext/isomorfeus_ferret_ext/brotli_dec_bit_reader.h +351 -0
  21. data/ext/isomorfeus_ferret_ext/brotli_dec_decode.c +2608 -0
  22. data/ext/isomorfeus_ferret_ext/brotli_dec_huffman.c +339 -0
  23. data/ext/isomorfeus_ferret_ext/brotli_dec_huffman.h +121 -0
  24. data/ext/isomorfeus_ferret_ext/brotli_dec_prefix.h +732 -0
  25. data/ext/isomorfeus_ferret_ext/brotli_dec_state.c +159 -0
  26. data/ext/isomorfeus_ferret_ext/brotli_dec_state.h +365 -0
  27. data/ext/isomorfeus_ferret_ext/brotli_decode.h +344 -0
  28. data/ext/isomorfeus_ferret_ext/brotli_enc_backward_references.c +145 -0
  29. data/ext/isomorfeus_ferret_ext/brotli_enc_backward_references.h +39 -0
  30. data/ext/isomorfeus_ferret_ext/brotli_enc_backward_references_hq.c +843 -0
  31. data/ext/isomorfeus_ferret_ext/brotli_enc_backward_references_hq.h +95 -0
  32. data/ext/isomorfeus_ferret_ext/brotli_enc_backward_references_inc.h +163 -0
  33. data/ext/isomorfeus_ferret_ext/brotli_enc_bit_cost.c +35 -0
  34. data/ext/isomorfeus_ferret_ext/brotli_enc_bit_cost.h +63 -0
  35. data/ext/isomorfeus_ferret_ext/brotli_enc_bit_cost_inc.h +127 -0
  36. data/ext/isomorfeus_ferret_ext/brotli_enc_block_encoder_inc.h +34 -0
  37. data/ext/isomorfeus_ferret_ext/brotli_enc_block_splitter.c +194 -0
  38. data/ext/isomorfeus_ferret_ext/brotli_enc_block_splitter.h +51 -0
  39. data/ext/isomorfeus_ferret_ext/brotli_enc_block_splitter_inc.h +440 -0
  40. data/ext/isomorfeus_ferret_ext/brotli_enc_brotli_bit_stream.c +1314 -0
  41. data/ext/isomorfeus_ferret_ext/brotli_enc_brotli_bit_stream.h +84 -0
  42. data/ext/isomorfeus_ferret_ext/brotli_enc_cluster.c +56 -0
  43. data/ext/isomorfeus_ferret_ext/brotli_enc_cluster.h +48 -0
  44. data/ext/isomorfeus_ferret_ext/brotli_enc_cluster_inc.h +320 -0
  45. data/ext/isomorfeus_ferret_ext/brotli_enc_command.c +28 -0
  46. data/ext/isomorfeus_ferret_ext/brotli_enc_command.h +190 -0
  47. data/ext/isomorfeus_ferret_ext/brotli_enc_compress_fragment.c +790 -0
  48. data/ext/isomorfeus_ferret_ext/brotli_enc_compress_fragment.h +61 -0
  49. data/ext/isomorfeus_ferret_ext/brotli_enc_compress_fragment_two_pass.c +645 -0
  50. data/ext/isomorfeus_ferret_ext/brotli_enc_compress_fragment_two_pass.h +54 -0
  51. data/ext/isomorfeus_ferret_ext/brotli_enc_dictionary_hash.c +1846 -0
  52. data/ext/isomorfeus_ferret_ext/brotli_enc_dictionary_hash.h +25 -0
  53. data/ext/isomorfeus_ferret_ext/brotli_enc_encode.c +1927 -0
  54. data/ext/isomorfeus_ferret_ext/brotli_enc_encoder_dict.c +33 -0
  55. data/ext/isomorfeus_ferret_ext/brotli_enc_encoder_dict.h +43 -0
  56. data/ext/isomorfeus_ferret_ext/brotli_enc_entropy_encode.c +503 -0
  57. data/ext/isomorfeus_ferret_ext/brotli_enc_entropy_encode.h +122 -0
  58. data/ext/isomorfeus_ferret_ext/brotli_enc_entropy_encode_static.h +539 -0
  59. data/ext/isomorfeus_ferret_ext/brotli_enc_fast_log.c +105 -0
  60. data/ext/isomorfeus_ferret_ext/brotli_enc_fast_log.h +66 -0
  61. data/ext/isomorfeus_ferret_ext/brotli_enc_find_match_length.h +79 -0
  62. data/ext/isomorfeus_ferret_ext/brotli_enc_hash.h +488 -0
  63. data/ext/isomorfeus_ferret_ext/brotli_enc_hash_composite_inc.h +125 -0
  64. data/ext/isomorfeus_ferret_ext/brotli_enc_hash_forgetful_chain_inc.h +293 -0
  65. data/ext/isomorfeus_ferret_ext/brotli_enc_hash_longest_match64_inc.h +267 -0
  66. data/ext/isomorfeus_ferret_ext/brotli_enc_hash_longest_match_inc.h +262 -0
  67. data/ext/isomorfeus_ferret_ext/brotli_enc_hash_longest_match_quickly_inc.h +266 -0
  68. data/ext/isomorfeus_ferret_ext/brotli_enc_hash_rolling_inc.h +212 -0
  69. data/ext/isomorfeus_ferret_ext/brotli_enc_hash_to_binary_tree_inc.h +329 -0
  70. data/ext/isomorfeus_ferret_ext/brotli_enc_histogram.c +100 -0
  71. data/ext/isomorfeus_ferret_ext/brotli_enc_histogram.h +63 -0
  72. data/ext/isomorfeus_ferret_ext/brotli_enc_histogram_inc.h +51 -0
  73. data/ext/isomorfeus_ferret_ext/brotli_enc_literal_cost.c +175 -0
  74. data/ext/isomorfeus_ferret_ext/brotli_enc_literal_cost.h +30 -0
  75. data/ext/isomorfeus_ferret_ext/brotli_enc_memory.c +170 -0
  76. data/ext/isomorfeus_ferret_ext/brotli_enc_memory.h +114 -0
  77. data/ext/isomorfeus_ferret_ext/brotli_enc_metablock.c +663 -0
  78. data/ext/isomorfeus_ferret_ext/brotli_enc_metablock.h +105 -0
  79. data/ext/isomorfeus_ferret_ext/brotli_enc_metablock_inc.h +183 -0
  80. data/ext/isomorfeus_ferret_ext/brotli_enc_params.h +46 -0
  81. data/ext/isomorfeus_ferret_ext/brotli_enc_prefix.h +53 -0
  82. data/ext/isomorfeus_ferret_ext/brotli_enc_quality.h +165 -0
  83. data/ext/isomorfeus_ferret_ext/brotli_enc_ringbuffer.h +167 -0
  84. data/ext/isomorfeus_ferret_ext/brotli_enc_static_dict.c +486 -0
  85. data/ext/isomorfeus_ferret_ext/brotli_enc_static_dict.h +40 -0
  86. data/ext/isomorfeus_ferret_ext/brotli_enc_static_dict_lut.h +5864 -0
  87. data/ext/isomorfeus_ferret_ext/brotli_enc_utf8_util.c +85 -0
  88. data/ext/isomorfeus_ferret_ext/brotli_enc_utf8_util.h +32 -0
  89. data/ext/isomorfeus_ferret_ext/brotli_enc_write_bits.h +87 -0
  90. data/ext/isomorfeus_ferret_ext/brotli_encode.h +448 -0
  91. data/ext/isomorfeus_ferret_ext/brotli_port.h +288 -0
  92. data/ext/isomorfeus_ferret_ext/brotli_types.h +83 -0
  93. data/ext/isomorfeus_ferret_ext/bzlib.c +1572 -0
  94. data/ext/isomorfeus_ferret_ext/bzlib.h +282 -0
  95. data/ext/isomorfeus_ferret_ext/bzlib_blocksort.c +1094 -0
  96. data/ext/isomorfeus_ferret_ext/bzlib_compress.c +672 -0
  97. data/ext/isomorfeus_ferret_ext/bzlib_crctable.c +104 -0
  98. data/ext/isomorfeus_ferret_ext/bzlib_decompress.c +652 -0
  99. data/ext/isomorfeus_ferret_ext/bzlib_huffman.c +205 -0
  100. data/ext/isomorfeus_ferret_ext/bzlib_private.h +509 -0
  101. data/ext/isomorfeus_ferret_ext/bzlib_randtable.c +84 -0
  102. data/ext/isomorfeus_ferret_ext/fio_tmpfile.h +53 -53
  103. data/ext/isomorfeus_ferret_ext/frb_analysis.c +785 -1192
  104. data/ext/isomorfeus_ferret_ext/frb_index.c +513 -464
  105. data/ext/isomorfeus_ferret_ext/frb_qparser.c +48 -60
  106. data/ext/isomorfeus_ferret_ext/frb_search.c +1520 -1002
  107. data/ext/isomorfeus_ferret_ext/frb_store.c +96 -96
  108. data/ext/isomorfeus_ferret_ext/frb_threading.h +0 -1
  109. data/ext/isomorfeus_ferret_ext/frb_utils.c +147 -196
  110. data/ext/isomorfeus_ferret_ext/frt_analysis.c +695 -1090
  111. data/ext/isomorfeus_ferret_ext/frt_analysis.h +174 -170
  112. data/ext/isomorfeus_ferret_ext/frt_array.c +2 -4
  113. data/ext/isomorfeus_ferret_ext/frt_bitvector.c +9 -16
  114. data/ext/isomorfeus_ferret_ext/frt_bitvector.h +32 -81
  115. data/ext/isomorfeus_ferret_ext/frt_document.c +15 -20
  116. data/ext/isomorfeus_ferret_ext/frt_document.h +10 -9
  117. data/ext/isomorfeus_ferret_ext/frt_except.c +5 -12
  118. data/ext/isomorfeus_ferret_ext/frt_field_index.c +3 -3
  119. data/ext/isomorfeus_ferret_ext/frt_field_index.h +6 -7
  120. data/ext/isomorfeus_ferret_ext/frt_filter.c +35 -46
  121. data/ext/isomorfeus_ferret_ext/frt_fs_store.c +2 -0
  122. data/ext/isomorfeus_ferret_ext/frt_global.c +91 -200
  123. data/ext/isomorfeus_ferret_ext/frt_global.h +7 -18
  124. data/ext/isomorfeus_ferret_ext/frt_hash.c +1 -2
  125. data/ext/isomorfeus_ferret_ext/frt_ind.c +32 -35
  126. data/ext/isomorfeus_ferret_ext/frt_ind.h +9 -9
  127. data/ext/isomorfeus_ferret_ext/frt_index.c +714 -384
  128. data/ext/isomorfeus_ferret_ext/frt_index.h +274 -290
  129. data/ext/isomorfeus_ferret_ext/frt_lang.c +0 -2
  130. data/ext/isomorfeus_ferret_ext/frt_mempool.c +1 -2
  131. data/ext/isomorfeus_ferret_ext/frt_multimapper.c +4 -7
  132. data/ext/isomorfeus_ferret_ext/frt_q_boolean.c +68 -91
  133. data/ext/isomorfeus_ferret_ext/frt_q_const_score.c +35 -38
  134. data/ext/isomorfeus_ferret_ext/frt_q_filtered_query.c +53 -72
  135. data/ext/isomorfeus_ferret_ext/frt_q_fuzzy.c +25 -32
  136. data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +21 -23
  137. data/ext/isomorfeus_ferret_ext/frt_q_multi_term.c +66 -103
  138. data/ext/isomorfeus_ferret_ext/frt_q_parser.c +207 -195
  139. data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +20 -16
  140. data/ext/isomorfeus_ferret_ext/frt_q_prefix.c +17 -14
  141. data/ext/isomorfeus_ferret_ext/frt_q_range.c +102 -131
  142. data/ext/isomorfeus_ferret_ext/frt_q_span.c +179 -178
  143. data/ext/isomorfeus_ferret_ext/frt_q_term.c +47 -60
  144. data/ext/isomorfeus_ferret_ext/frt_q_wildcard.c +18 -16
  145. data/ext/isomorfeus_ferret_ext/frt_ram_store.c +46 -84
  146. data/ext/isomorfeus_ferret_ext/frt_search.c +105 -146
  147. data/ext/isomorfeus_ferret_ext/frt_search.h +331 -320
  148. data/ext/isomorfeus_ferret_ext/frt_similarity.c +5 -13
  149. data/ext/isomorfeus_ferret_ext/frt_similarity.h +7 -12
  150. data/ext/isomorfeus_ferret_ext/frt_sort.c +105 -149
  151. data/ext/isomorfeus_ferret_ext/frt_store.c +13 -7
  152. data/ext/isomorfeus_ferret_ext/frt_store.h +10 -2
  153. data/ext/isomorfeus_ferret_ext/frt_threading.h +0 -1
  154. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +22 -112
  155. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.h +2 -32
  156. data/ext/isomorfeus_ferret_ext/lz4.c +2495 -0
  157. data/ext/isomorfeus_ferret_ext/lz4.h +774 -0
  158. data/ext/isomorfeus_ferret_ext/lz4frame.c +1899 -0
  159. data/ext/isomorfeus_ferret_ext/lz4frame.h +623 -0
  160. data/ext/isomorfeus_ferret_ext/lz4hc.c +1615 -0
  161. data/ext/isomorfeus_ferret_ext/lz4hc.h +413 -0
  162. data/ext/isomorfeus_ferret_ext/lz4xxhash.c +1030 -0
  163. data/ext/isomorfeus_ferret_ext/lz4xxhash.h +328 -0
  164. data/ext/isomorfeus_ferret_ext/stem_modules.h +0 -86
  165. data/ext/isomorfeus_ferret_ext/test.c +0 -17
  166. data/ext/isomorfeus_ferret_ext/test_1710.c +11 -12
  167. data/ext/isomorfeus_ferret_ext/test_analysis.c +590 -583
  168. data/ext/isomorfeus_ferret_ext/test_compound_io.c +1 -1
  169. data/ext/isomorfeus_ferret_ext/test_document.c +19 -15
  170. data/ext/isomorfeus_ferret_ext/test_except.c +1 -2
  171. data/ext/isomorfeus_ferret_ext/test_fields.c +111 -100
  172. data/ext/isomorfeus_ferret_ext/test_file_deleter.c +10 -27
  173. data/ext/isomorfeus_ferret_ext/test_filter.c +11 -8
  174. data/ext/isomorfeus_ferret_ext/test_global.c +0 -46
  175. data/ext/isomorfeus_ferret_ext/test_hash.c +2 -2
  176. data/ext/isomorfeus_ferret_ext/test_hashset.c +1 -1
  177. data/ext/isomorfeus_ferret_ext/test_highlighter.c +15 -11
  178. data/ext/isomorfeus_ferret_ext/test_index.c +373 -363
  179. data/ext/isomorfeus_ferret_ext/test_q_const_score.c +5 -3
  180. data/ext/isomorfeus_ferret_ext/test_q_filtered.c +5 -3
  181. data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +13 -10
  182. data/ext/isomorfeus_ferret_ext/test_q_parser.c +45 -7
  183. data/ext/isomorfeus_ferret_ext/test_q_span.c +15 -12
  184. data/ext/isomorfeus_ferret_ext/test_ram_store.c +3 -3
  185. data/ext/isomorfeus_ferret_ext/test_search.c +60 -64
  186. data/ext/isomorfeus_ferret_ext/test_segments.c +5 -4
  187. data/ext/isomorfeus_ferret_ext/test_sort.c +17 -14
  188. data/ext/isomorfeus_ferret_ext/test_store.c +2 -0
  189. data/ext/isomorfeus_ferret_ext/test_term.c +3 -1
  190. data/ext/isomorfeus_ferret_ext/test_term_vectors.c +9 -10
  191. data/ext/isomorfeus_ferret_ext/test_test.c +1 -2
  192. data/ext/isomorfeus_ferret_ext/test_threading.c +9 -10
  193. data/ext/isomorfeus_ferret_ext/testhelper.c +1 -2
  194. data/lib/isomorfeus/ferret/version.rb +1 -1
  195. metadata +113 -58
  196. data/ext/isomorfeus_ferret_ext/email.rl +0 -21
  197. data/ext/isomorfeus_ferret_ext/frt_scanner.c +0 -900
  198. data/ext/isomorfeus_ferret_ext/frt_scanner.h +0 -28
  199. data/ext/isomorfeus_ferret_ext/frt_scanner_mb.c +0 -6706
  200. data/ext/isomorfeus_ferret_ext/frt_scanner_utf8.c +0 -4420
  201. data/ext/isomorfeus_ferret_ext/scanner.h +0 -28
  202. data/ext/isomorfeus_ferret_ext/scanner.in +0 -43
  203. data/ext/isomorfeus_ferret_ext/scanner.rl +0 -84
  204. data/ext/isomorfeus_ferret_ext/scanner_mb.rl +0 -200
  205. data/ext/isomorfeus_ferret_ext/scanner_utf8.rl +0 -85
  206. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_basque.c +0 -1167
  207. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_basque.h +0 -6
  208. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_catalan.c +0 -1433
  209. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_catalan.h +0 -6
  210. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_danish.c +0 -301
  211. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_danish.h +0 -6
  212. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_dutch.c +0 -590
  213. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_dutch.h +0 -6
  214. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_english.c +0 -1049
  215. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_english.h +0 -6
  216. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_finnish.c +0 -705
  217. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_finnish.h +0 -6
  218. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_french.c +0 -1239
  219. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_french.h +0 -6
  220. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_german.c +0 -477
  221. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_german.h +0 -6
  222. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_hungarian.c +0 -1217
  223. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_hungarian.h +0 -7
  224. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_indonesian.c +0 -394
  225. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_indonesian.h +0 -6
  226. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_irish.c +0 -457
  227. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_irish.h +0 -6
  228. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_italian.c +0 -1009
  229. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_italian.h +0 -6
  230. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_norwegian.c +0 -259
  231. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_norwegian.h +0 -6
  232. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_porter.c +0 -704
  233. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_porter.h +0 -6
  234. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_portuguese.c +0 -948
  235. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_portuguese.h +0 -6
  236. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_spanish.c +0 -1028
  237. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_spanish.h +0 -6
  238. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_swedish.c +0 -275
  239. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_swedish.h +0 -6
  240. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_hungarian.c +0 -849
  241. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_hungarian.h +0 -6
  242. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_romanian.c +0 -952
  243. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_romanian.h +0 -6
  244. data/ext/isomorfeus_ferret_ext/stem_KOI8_R_russian.c +0 -669
  245. data/ext/isomorfeus_ferret_ext/stem_KOI8_R_russian.h +0 -6
  246. data/ext/isomorfeus_ferret_ext/stem_modules.txt +0 -63
  247. data/ext/isomorfeus_ferret_ext/uchar-ucs4.rl +0 -1854
  248. data/ext/isomorfeus_ferret_ext/uchar-utf8.rl +0 -1999
  249. data/ext/isomorfeus_ferret_ext/url.rl +0 -27
@@ -61,7 +61,6 @@ void FRT_VEXIT(const char *err_type, const char *fmt, va_list args)
61
61
  # endif
62
62
  {
63
63
  fflush(stdout);
64
- fprintf(EXCEPTION_STREAM, "\n%s: ", frt_progname());
65
64
 
66
65
  # ifdef FRT_HAS_VARARGS
67
66
  fprintf(EXCEPTION_STREAM, "%s occurred at <%s>:%d in %s\n",
@@ -76,7 +75,6 @@ void FRT_VEXIT(const char *err_type, const char *fmt, va_list args)
76
75
  }
77
76
 
78
77
  fprintf(EXCEPTION_STREAM, "\n");
79
- frt_print_stacktrace();
80
78
  if (frt_x_abort_on_exception) {
81
79
  exit(2); /* conventional value for failed execution */
82
80
  }
@@ -16,8 +16,7 @@ FrtMemoryPool *frt_mp_new_capa(int chuck_size, int init_buf_capa)
16
16
  return mp;
17
17
  }
18
18
 
19
- FrtMemoryPool *frt_mp_new()
20
- {
19
+ FrtMemoryPool *frt_mp_new(void) {
21
20
  return frt_mp_new_capa(FRT_MP_BUF_SIZE, FRT_MP_INIT_CAPA);
22
21
  }
23
22
 
@@ -18,8 +18,8 @@ typedef struct LetterState
18
18
  int val;
19
19
  char *mapping;
20
20
  } LetterState;
21
- #define LSt(state) ((LetterState *)(state))
22
21
 
22
+ #define LSt(state) ((LetterState *)(state))
23
23
 
24
24
  static int lstate_next(LetterState *self, int c, int *states)
25
25
  {
@@ -84,8 +84,7 @@ static void ndstate_add(NonDeterministicState *self, int c, int state)
84
84
  self->states[c][self->size[c]++] = state;
85
85
  }
86
86
 
87
- static void ndstate_destroy_i(NonDeterministicState *self)
88
- {
87
+ static void ndstate_destroy_i(NonDeterministicState *self) {
89
88
  int i;
90
89
  for (i = 0; i < 256; i++) {
91
90
  free(self->states[i]);
@@ -99,8 +98,7 @@ static int ndstate_is_match(FrtState *self, char **mapping)
99
98
  return 0;
100
99
  }
101
100
 
102
- static NonDeterministicState *ndstate_new()
103
- {
101
+ static NonDeterministicState *ndstate_new(void) {
104
102
  NonDeterministicState *self = FRT_ALLOC_AND_ZERO(NonDeterministicState);
105
103
  St(self)->next = (int (*)(FrtState *, int, int *))&ndstate_next;
106
104
  St(self)->destroy_i = (void (*)(FrtState *))&ndstate_destroy_i;
@@ -108,8 +106,7 @@ static NonDeterministicState *ndstate_new()
108
106
  return self;
109
107
  }
110
108
 
111
- FrtMultiMapper *frt_mulmap_new()
112
- {
109
+ FrtMultiMapper *frt_mulmap_new(void) {
113
110
  FrtMultiMapper *self = FRT_ALLOC_AND_ZERO(FrtMultiMapper);
114
111
  self->capa = 128;
115
112
  self->mappings = FRT_ALLOC_N(FrtMapping *, 128);
@@ -15,23 +15,20 @@
15
15
  * Coordinator
16
16
  ***************************************************************************/
17
17
 
18
- typedef struct Coordinator
19
- {
18
+ typedef struct Coordinator {
20
19
  int max_coord;
21
20
  float *coord_factors;
22
21
  FrtSimilarity *similarity;
23
22
  int num_matches;
24
23
  } Coordinator;
25
24
 
26
- static Coordinator *coord_new(FrtSimilarity *similarity)
27
- {
25
+ static Coordinator *coord_new(FrtSimilarity *similarity) {
28
26
  Coordinator *self = FRT_ALLOC_AND_ZERO(Coordinator);
29
27
  self->similarity = similarity;
30
28
  return self;
31
29
  }
32
30
 
33
- static Coordinator *coord_init(Coordinator *self)
34
- {
31
+ static Coordinator *coord_init(Coordinator *self) {
35
32
  int i;
36
33
  self->coord_factors = FRT_ALLOC_N(float, self->max_coord + 1);
37
34
 
@@ -49,8 +46,7 @@ static Coordinator *coord_init(Coordinator *self)
49
46
 
50
47
  #define DSSc(scorer) ((DisjunctionSumScorer *)(scorer))
51
48
 
52
- typedef struct DisjunctionSumScorer
53
- {
49
+ typedef struct DisjunctionSumScorer {
54
50
  FrtScorer super;
55
51
  float cum_score;
56
52
  int num_matches;
@@ -61,13 +57,11 @@ typedef struct DisjunctionSumScorer
61
57
  Coordinator *coordinator;
62
58
  } DisjunctionSumScorer;
63
59
 
64
- static float dssc_score(FrtScorer *self)
65
- {
60
+ static float dssc_score(FrtScorer *self) {
66
61
  return DSSc(self)->cum_score;
67
62
  }
68
63
 
69
- static void dssc_init_scorer_queue(DisjunctionSumScorer *dssc)
70
- {
64
+ static void dssc_init_scorer_queue(DisjunctionSumScorer *dssc) {
71
65
  int i;
72
66
  FrtScorer *sub_scorer;
73
67
  FrtPriorityQueue *pq = dssc->scorer_queue
@@ -81,8 +75,7 @@ static void dssc_init_scorer_queue(DisjunctionSumScorer *dssc)
81
75
  }
82
76
  }
83
77
 
84
- static bool dssc_advance_after_current(FrtScorer *self)
85
- {
78
+ static bool dssc_advance_after_current(FrtScorer *self) {
86
79
  DisjunctionSumScorer *dssc = DSSc(self);
87
80
  FrtPriorityQueue *scorer_queue = dssc->scorer_queue;
88
81
 
@@ -130,8 +123,7 @@ static bool dssc_advance_after_current(FrtScorer *self)
130
123
  }
131
124
  }
132
125
 
133
- static bool dssc_next(FrtScorer *self)
134
- {
126
+ static bool dssc_next(FrtScorer *self) {
135
127
  if (DSSc(self)->scorer_queue == NULL) {
136
128
  dssc_init_scorer_queue(DSSc(self));
137
129
  }
@@ -144,8 +136,7 @@ static bool dssc_next(FrtScorer *self)
144
136
  }
145
137
  }
146
138
 
147
- static bool dssc_skip_to(FrtScorer *self, int doc_num)
148
- {
139
+ static bool dssc_skip_to(FrtScorer *self, int doc_num) {
149
140
  DisjunctionSumScorer *dssc = DSSc(self);
150
141
  FrtPriorityQueue *scorer_queue = dssc->scorer_queue;
151
142
 
@@ -820,9 +811,8 @@ static FrtExplanation *nmsc_explain(FrtScorer *self, int doc_num)
820
811
  return frt_expl_new(0.0, "No documents matched");
821
812
  }
822
813
 
823
- static FrtScorer *non_matching_scorer_new()
824
- {
825
- FrtScorer *self = frt_scorer_new(FrtScorer, NULL);
814
+ static FrtScorer *non_matching_scorer_new(void) {
815
+ FrtScorer *self = frt_scorer_new(FrtScorer, NULL);
826
816
  self->score = &nmsc_score;
827
817
  self->next = &nmsc_next;
828
818
  self->skip_to = &nmsc_skip_to;
@@ -836,26 +826,22 @@ static FrtScorer *non_matching_scorer_new()
836
826
  ***************************************************************************/
837
827
 
838
828
  #define BSc(scorer) ((BooleanScorer *)(scorer))
839
- typedef struct BooleanScorer
840
- {
841
- FrtScorer super;
842
- FrtScorer **required_scorers;
843
- int rs_cnt;
844
- int rs_capa;
845
- FrtScorer **optional_scorers;
846
- int os_cnt;
847
- int os_capa;
848
- FrtScorer **prohibited_scorers;
849
- int ps_cnt;
850
- int ps_capa;
851
- FrtScorer *counting_sum_scorer;
852
- Coordinator *coordinator;
829
+ typedef struct BooleanScorer {
830
+ FrtScorer super;
831
+ FrtScorer **required_scorers;
832
+ int rs_cnt;
833
+ int rs_capa;
834
+ FrtScorer **optional_scorers;
835
+ int os_cnt;
836
+ int os_capa;
837
+ FrtScorer **prohibited_scorers;
838
+ int ps_cnt;
839
+ int ps_capa;
840
+ FrtScorer *counting_sum_scorer;
841
+ Coordinator *coordinator;
853
842
  } BooleanScorer;
854
843
 
855
- static FrtScorer *counting_sum_scorer_create3(BooleanScorer *bsc,
856
- FrtScorer *req_scorer,
857
- FrtScorer *opt_scorer)
858
- {
844
+ static FrtScorer *counting_sum_scorer_create3(BooleanScorer *bsc, FrtScorer *req_scorer, FrtScorer *opt_scorer) {
859
845
  if (bsc->ps_cnt == 0) {
860
846
  /* no prohibited */
861
847
  return req_opt_sum_scorer_new(req_scorer, opt_scorer);
@@ -1175,8 +1161,7 @@ static void bw_destroy(FrtWeight *self)
1175
1161
  frt_w_destroy(self);
1176
1162
  }
1177
1163
 
1178
- static FrtExplanation *bw_explain(FrtWeight *self, FrtIndexReader *ir, int doc_num)
1179
- {
1164
+ static FrtExplanation *bw_explain(FrtWeight *self, FrtIndexReader *ir, int doc_num) {
1180
1165
  FrtBooleanQuery *bq = BQ(self->query);
1181
1166
  FrtExplanation *sum_expl = frt_expl_new(0.0f, "sum of:");
1182
1167
  FrtExplanation *explanation;
@@ -1229,8 +1214,7 @@ static FrtExplanation *bw_explain(FrtWeight *self, FrtIndexReader *ir, int doc_n
1229
1214
  }
1230
1215
  }
1231
1216
 
1232
- static FrtWeight *bw_new(FrtQuery *query, FrtSearcher *searcher)
1233
- {
1217
+ static FrtWeight *bw_new(FrtQuery *query, FrtSearcher *searcher) {
1234
1218
  int i;
1235
1219
  FrtWeight *self = w_new(BooleanWeight, query);
1236
1220
 
@@ -1259,8 +1243,7 @@ static FrtWeight *bw_new(FrtQuery *query, FrtSearcher *searcher)
1259
1243
  *
1260
1244
  ***************************************************************************/
1261
1245
 
1262
- void frt_bc_set_occur(FrtBooleanClause *self, FrtBCType occur)
1263
- {
1246
+ void frt_bc_set_occur(FrtBooleanClause *self, FrtBCType occur) {
1264
1247
  self->occur = occur;
1265
1248
  switch (occur) {
1266
1249
  case FRT_BC_SHOULD:
@@ -1281,42 +1264,45 @@ void frt_bc_set_occur(FrtBooleanClause *self, FrtBCType occur)
1281
1264
  }
1282
1265
  }
1283
1266
 
1284
- void frt_bc_deref(FrtBooleanClause *self)
1285
- {
1267
+ void frt_bc_deref(FrtBooleanClause *self) {
1286
1268
  if (--self->ref_cnt <= 0) {
1287
1269
  frt_q_deref(self->query);
1288
1270
  free(self);
1289
1271
  }
1290
1272
  }
1291
1273
 
1292
- static unsigned long long bc_hash(FrtBooleanClause *self)
1293
- {
1274
+ static unsigned long long bc_hash(FrtBooleanClause *self) {
1294
1275
  return ((frt_q_hash(self->query) << 2) | self->occur);
1295
1276
  }
1296
1277
 
1297
- static int bc_eq(FrtBooleanClause *self, FrtBooleanClause *o)
1298
- {
1278
+ static int bc_eq(FrtBooleanClause *self, FrtBooleanClause *o) {
1299
1279
  return ((self->occur == o->occur) && frt_q_eq(self->query, o->query));
1300
1280
  }
1301
1281
 
1302
- FrtBooleanClause *frt_bc_new(FrtQuery *query, FrtBCType occur)
1303
- {
1304
- FrtBooleanClause *self = FRT_ALLOC(FrtBooleanClause);
1282
+ FrtBooleanClause *frt_bc_alloc(void) {
1283
+ return FRT_ALLOC(FrtBooleanClause);
1284
+ }
1285
+
1286
+ FrtBooleanClause *frt_bc_init(FrtBooleanClause *self, FrtQuery *query, FrtBCType occur) {
1305
1287
  self->ref_cnt = 1;
1306
1288
  self->query = query;
1289
+ self->rbc = Qnil;
1307
1290
  frt_bc_set_occur(self, occur);
1308
1291
  return self;
1309
1292
  }
1310
1293
 
1294
+ FrtBooleanClause *frt_bc_new(FrtQuery *query, FrtBCType occur) {
1295
+ FrtBooleanClause *self = frt_bc_alloc();
1296
+ return frt_bc_init(self, query, occur);
1297
+ }
1298
+
1311
1299
  /***************************************************************************
1312
1300
  *
1313
1301
  * BooleanQuery
1314
1302
  *
1315
1303
  ***************************************************************************/
1316
1304
 
1317
- static FrtMatchVector *bq_get_matchv_i(FrtQuery *self, FrtMatchVector *mv,
1318
- FrtTermVector *tv)
1319
- {
1305
+ static FrtMatchVector *bq_get_matchv_i(FrtQuery *self, FrtMatchVector *mv, FrtTermVector *tv) {
1320
1306
  int i;
1321
1307
  for (i = BQ(self)->clause_cnt - 1; i >= 0; i--) {
1322
1308
  if (BQ(self)->clauses[i]->occur != FRT_BC_MUST_NOT) {
@@ -1327,8 +1313,7 @@ static FrtMatchVector *bq_get_matchv_i(FrtQuery *self, FrtMatchVector *mv,
1327
1313
  return mv;
1328
1314
  }
1329
1315
 
1330
- static FrtQuery *bq_rewrite(FrtQuery *self, FrtIndexReader *ir)
1331
- {
1316
+ static FrtQuery *bq_rewrite(FrtQuery *self, FrtIndexReader *ir) {
1332
1317
  int i;
1333
1318
  const int clause_cnt = BQ(self)->clause_cnt;
1334
1319
  bool rewritten = false;
@@ -1397,8 +1382,7 @@ static FrtQuery *bq_rewrite(FrtQuery *self, FrtIndexReader *ir)
1397
1382
  return self;
1398
1383
  }
1399
1384
 
1400
- static void bq_extract_terms(FrtQuery *self, FrtHashSet *terms)
1401
- {
1385
+ static void bq_extract_terms(FrtQuery *self, FrtHashSet *terms) {
1402
1386
  int i;
1403
1387
  for (i = 0; i < BQ(self)->clause_cnt; i++) {
1404
1388
  FrtBooleanClause *clause = BQ(self)->clauses[i];
@@ -1406,8 +1390,7 @@ static void bq_extract_terms(FrtQuery *self, FrtHashSet *terms)
1406
1390
  }
1407
1391
  }
1408
1392
 
1409
- static char *bq_to_s(FrtQuery *self, FrtSymbol field)
1410
- {
1393
+ static char *bq_to_s(FrtQuery *self, ID field) {
1411
1394
  int i;
1412
1395
  FrtBooleanClause *clause;
1413
1396
  FrtQuery *sub_query;
@@ -1439,8 +1422,7 @@ static char *bq_to_s(FrtQuery *self, FrtSymbol field)
1439
1422
  }
1440
1423
  if (clause->is_prohibited) {
1441
1424
  buffer[bp++] = '-';
1442
- }
1443
- else if (clause->is_required) {
1425
+ } else if (clause->is_required) {
1444
1426
  buffer[bp++] = '+';
1445
1427
  }
1446
1428
 
@@ -1451,8 +1433,7 @@ static char *bq_to_s(FrtQuery *self, FrtSymbol field)
1451
1433
  memcpy(buffer + bp, clause_str, sizeof(char) * clause_len);
1452
1434
  bp += clause_len;
1453
1435
  buffer[bp++] = ')';
1454
- }
1455
- else {
1436
+ } else {
1456
1437
  memcpy(buffer + bp, clause_str, sizeof(char) * clause_len);
1457
1438
  bp += clause_len;
1458
1439
  }
@@ -1471,8 +1452,7 @@ static char *bq_to_s(FrtQuery *self, FrtSymbol field)
1471
1452
  return buffer;
1472
1453
  }
1473
1454
 
1474
- static void bq_destroy(FrtQuery *self)
1475
- {
1455
+ static void bq_destroy(FrtQuery *self) {
1476
1456
  int i;
1477
1457
  for (i = 0; i < BQ(self)->clause_cnt; i++) {
1478
1458
  frt_bc_deref(BQ(self)->clauses[i]);
@@ -1484,14 +1464,12 @@ static void bq_destroy(FrtQuery *self)
1484
1464
  frt_q_destroy_i(self);
1485
1465
  }
1486
1466
 
1487
- static float bq_coord_disabled(FrtSimilarity *sim, int overlap, int max_overlap)
1488
- {
1467
+ static float bq_coord_disabled(FrtSimilarity *sim, int overlap, int max_overlap) {
1489
1468
  (void)sim; (void)overlap; (void)max_overlap;
1490
1469
  return 1.0;
1491
1470
  }
1492
1471
 
1493
- static FrtSimilarity *bq_get_similarity(FrtQuery *self, FrtSearcher *searcher)
1494
- {
1472
+ static FrtSimilarity *bq_get_similarity(FrtQuery *self, FrtSearcher *searcher) {
1495
1473
  if (!BQ(self)->similarity) {
1496
1474
  FrtSimilarity *sim = frt_q_get_similarity_i(self, searcher);
1497
1475
  BQ(self)->similarity = FRT_ALLOC(FrtSimilarity);
@@ -1503,8 +1481,7 @@ static FrtSimilarity *bq_get_similarity(FrtQuery *self, FrtSearcher *searcher)
1503
1481
  return BQ(self)->similarity;
1504
1482
  }
1505
1483
 
1506
- static unsigned long long bq_hash(FrtQuery *self)
1507
- {
1484
+ static unsigned long long bq_hash(FrtQuery *self) {
1508
1485
  int i;
1509
1486
  unsigned long long hash = 0;
1510
1487
  for (i = 0; i < BQ(self)->clause_cnt; i++) {
@@ -1513,8 +1490,7 @@ static unsigned long long bq_hash(FrtQuery *self)
1513
1490
  return (hash << 1) | BQ(self)->coord_disabled;
1514
1491
  }
1515
1492
 
1516
- static int bq_eq(FrtQuery *self, FrtQuery *o)
1517
- {
1493
+ static int bq_eq(FrtQuery *self, FrtQuery *o) {
1518
1494
  int i;
1519
1495
  FrtBooleanQuery *bq1 = BQ(self);
1520
1496
  FrtBooleanQuery *bq2 = BQ(o);
@@ -1532,9 +1508,11 @@ static int bq_eq(FrtQuery *self, FrtQuery *o)
1532
1508
  return true;
1533
1509
  }
1534
1510
 
1535
- FrtQuery *frt_bq_new(bool coord_disabled)
1536
- {
1537
- FrtQuery *self = frt_q_new(FrtBooleanQuery);
1511
+ FrtQuery *frt_bq_alloc(void) {
1512
+ return frt_q_new(FrtBooleanQuery);
1513
+ }
1514
+
1515
+ FrtQuery *frt_bq_init(FrtQuery *self, bool coord_disabled) {
1538
1516
  BQ(self)->coord_disabled = coord_disabled;
1539
1517
  if (coord_disabled) {
1540
1518
  self->get_similarity = &bq_get_similarity;
@@ -1559,15 +1537,18 @@ FrtQuery *frt_bq_new(bool coord_disabled)
1559
1537
  return self;
1560
1538
  }
1561
1539
 
1562
- FrtQuery *frt_bq_new_max(bool coord_disabled, int max)
1563
- {
1540
+ FrtQuery *frt_bq_new(bool coord_disabled) {
1541
+ FrtQuery *self = frt_bq_alloc();
1542
+ return frt_bq_init(self, coord_disabled);
1543
+ }
1544
+
1545
+ FrtQuery *frt_bq_new_max(bool coord_disabled, int max) {
1564
1546
  FrtQuery *q = frt_bq_new(coord_disabled);
1565
1547
  BQ(q)->max_clause_cnt = max;
1566
1548
  return q;
1567
1549
  }
1568
1550
 
1569
- FrtBooleanClause *frt_bq_add_clause_nr(FrtQuery *self, FrtBooleanClause *bc)
1570
- {
1551
+ FrtBooleanClause *frt_bq_add_clause_nr(FrtQuery *self, FrtBooleanClause *bc) {
1571
1552
  if (BQ(self)->clause_cnt >= BQ(self)->max_clause_cnt) {
1572
1553
  FRT_RAISE(FRT_STATE_ERROR, "Two many clauses. The max clause limit is set to "
1573
1554
  "<%d> but your query has <%d> clauses. You can try increasing "
@@ -1583,14 +1564,12 @@ FrtBooleanClause *frt_bq_add_clause_nr(FrtQuery *self, FrtBooleanClause *bc)
1583
1564
  return bc;
1584
1565
  }
1585
1566
 
1586
- FrtBooleanClause *frt_bq_add_clause(FrtQuery *self, FrtBooleanClause *bc)
1587
- {
1567
+ FrtBooleanClause *frt_bq_add_clause(FrtQuery *self, FrtBooleanClause *bc) {
1588
1568
  FRT_REF(bc);
1589
1569
  return frt_bq_add_clause_nr(self, bc);
1590
1570
  }
1591
1571
 
1592
- FrtBooleanClause *frt_bq_add_query_nr(FrtQuery *self, FrtQuery *sub_query, FrtBCType occur)
1593
- {
1572
+ FrtBooleanClause *frt_bq_add_query_nr(FrtQuery *self, FrtQuery *sub_query, FrtBCType occur) {
1594
1573
  FrtBooleanClause *bc;
1595
1574
  if (BQ(self)->clause_cnt >= BQ(self)->max_clause_cnt) {
1596
1575
  FRT_RAISE(FRT_STATE_ERROR, "Two many clauses. The max clause limit is set to "
@@ -1604,9 +1583,7 @@ FrtBooleanClause *frt_bq_add_query_nr(FrtQuery *self, FrtQuery *sub_query, FrtBC
1604
1583
  return bc;
1605
1584
  }
1606
1585
 
1607
- FrtBooleanClause *frt_bq_add_query(FrtQuery *self, FrtQuery *sub_query, FrtBCType occur)
1608
- {
1586
+ FrtBooleanClause *frt_bq_add_query(FrtQuery *self, FrtQuery *sub_query, FrtBCType occur) {
1609
1587
  FRT_REF(sub_query);
1610
1588
  return frt_bq_add_query_nr(self, sub_query, occur);
1611
1589
  }
1612
-
@@ -10,36 +10,30 @@
10
10
  #define CScQ(query) ((FrtConstantScoreQuery *)(query))
11
11
  #define CScSc(scorer) ((ConstantScoreScorer *)(scorer))
12
12
 
13
- typedef struct ConstantScoreScorer
14
- {
15
- FrtScorer super;
16
- FrtBitVector *bv;
17
- float score;
13
+ typedef struct ConstantScoreScorer {
14
+ FrtScorer super;
15
+ FrtBitVector *bv;
16
+ float score;
18
17
  } ConstantScoreScorer;
19
18
 
20
- static float cssc_score(FrtScorer *self)
21
- {
19
+ static float cssc_score(FrtScorer *self) {
22
20
  return CScSc(self)->score;
23
21
  }
24
22
 
25
- static bool cssc_next(FrtScorer *self)
26
- {
23
+ static bool cssc_next(FrtScorer *self) {
27
24
  return ((self->doc = frt_bv_scan_next(CScSc(self)->bv)) >= 0);
28
25
  }
29
26
 
30
- static bool cssc_skip_to(FrtScorer *self, int doc_num)
31
- {
27
+ static bool cssc_skip_to(FrtScorer *self, int doc_num) {
32
28
  return ((self->doc = frt_bv_scan_next_from(CScSc(self)->bv, doc_num)) >= 0);
33
29
  }
34
30
 
35
- static FrtExplanation *cssc_explain(FrtScorer *self, int doc_num)
36
- {
31
+ static FrtExplanation *cssc_explain(FrtScorer *self, int doc_num) {
37
32
  (void)self; (void)doc_num;
38
33
  return frt_expl_new(1.0, "ConstantScoreScorer");
39
34
  }
40
35
 
41
- static FrtScorer *cssc_new(FrtWeight *weight, FrtIndexReader *ir)
42
- {
36
+ static FrtScorer *cssc_new(FrtWeight *weight, FrtIndexReader *ir) {
43
37
  FrtScorer *self = frt_scorer_new(ConstantScoreScorer, weight->similarity);
44
38
  FrtFilter *filter = CScQ(weight->query)->filter;
45
39
 
@@ -60,13 +54,11 @@ static FrtScorer *cssc_new(FrtWeight *weight, FrtIndexReader *ir)
60
54
  *
61
55
  ***************************************************************************/
62
56
 
63
- static char *csw_to_s(FrtWeight *self)
64
- {
57
+ static char *csw_to_s(FrtWeight *self) {
65
58
  return frt_strfmt("ConstantScoreWeight(%f)", self->value);
66
59
  }
67
60
 
68
- static FrtExplanation *csw_explain(FrtWeight *self, FrtIndexReader *ir, int doc_num)
69
- {
61
+ static FrtExplanation *csw_explain(FrtWeight *self, FrtIndexReader *ir, int doc_num) {
70
62
  FrtFilter *filter = CScQ(self->query)->filter;
71
63
  FrtExplanation *expl;
72
64
  char *filter_str = filter->to_s(filter);
@@ -83,9 +75,8 @@ static FrtExplanation *csw_explain(FrtWeight *self, FrtIndexReader *ir, int doc_
83
75
  return expl;
84
76
  }
85
77
 
86
- static FrtWeight *csw_new(FrtQuery *query, FrtSearcher *searcher)
87
- {
88
- FrtWeight *self = w_new(FrtWeight, query);
78
+ static FrtWeight *csw_new(FrtQuery *query, FrtSearcher *searcher) {
79
+ FrtWeight *self = w_new(FrtWeight, query);
89
80
 
90
81
  self->scorer = &cssc_new;
91
82
  self->explain = &csw_explain;
@@ -103,42 +94,39 @@ static FrtWeight *csw_new(FrtQuery *query, FrtSearcher *searcher)
103
94
  *
104
95
  ***************************************************************************/
105
96
 
106
- static char *csq_to_s(FrtQuery *self, FrtSymbol default_field)
107
- {
97
+ static char *csq_to_s(FrtQuery *self, ID default_field) {
108
98
  FrtFilter *filter = CScQ(self)->filter;
109
99
  char *filter_str = filter->to_s(filter);
110
100
  char *buffer;
111
101
  (void)default_field;
112
102
  if (self->boost == 1.0) {
113
103
  buffer = frt_strfmt("ConstantScore(%s)", filter_str);
114
- }
115
- else {
104
+ } else {
116
105
  buffer = frt_strfmt("ConstantScore(%s)^%f", filter_str, self->boost);
117
106
  }
118
107
  free(filter_str);
119
108
  return buffer;;
120
109
  }
121
110
 
122
- static void csq_destroy(FrtQuery *self)
123
- {
111
+ static void csq_destroy(FrtQuery *self) {
124
112
  frt_filt_deref(CScQ(self)->filter);
125
113
  frt_q_destroy_i(self);
126
114
  }
127
115
 
128
- static unsigned long long csq_hash(FrtQuery *self)
129
- {
116
+ static unsigned long long csq_hash(FrtQuery *self) {
130
117
  return frt_filt_hash(CScQ(self)->filter);
131
118
  }
132
119
 
133
- static int csq_eq(FrtQuery *self, FrtQuery *o)
134
- {
120
+ static int csq_eq(FrtQuery *self, FrtQuery *o) {
135
121
  return frt_filt_eq(CScQ(self)->filter, CScQ(o)->filter);
136
122
  }
137
123
 
138
- FrtQuery *frt_csq_new_nr(FrtFilter *filter)
139
- {
140
- FrtQuery *self = frt_q_new(FrtConstantScoreQuery);
141
- CScQ(self)->filter = filter;
124
+ FrtQuery *frt_csq_alloc(void) {
125
+ return frt_q_new(FrtConstantScoreQuery);
126
+ }
127
+
128
+ FrtQuery *frt_csq_init_nr(FrtQuery *self, FrtFilter *filter) {
129
+ CScQ(self)->filter = filter;
142
130
 
143
131
  self->type = CONSTANT_QUERY;
144
132
  self->to_s = &csq_to_s;
@@ -150,8 +138,17 @@ FrtQuery *frt_csq_new_nr(FrtFilter *filter)
150
138
  return self;
151
139
  }
152
140
 
153
- FrtQuery *frt_csq_new(FrtFilter *filter)
154
- {
141
+ FrtQuery *frt_csq_new_nr(FrtFilter *filter) {
142
+ FrtQuery *self = frt_csq_alloc();
143
+ return frt_csq_init_nr(self, filter);
144
+ }
145
+
146
+ FrtQuery *frt_csq_init(FrtQuery *self, FrtFilter *filter) {
147
+ FRT_REF(filter);
148
+ return frt_csq_init_nr(self, filter);
149
+ }
150
+
151
+ FrtQuery *frt_csq_new(FrtFilter *filter) {
155
152
  FRT_REF(filter);
156
153
  return frt_csq_new_nr(filter);
157
154
  }