isomorfeus-ferret 0.12.5 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (247) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +101 -19
  3. data/README.md +54 -4
  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/bzip_blocksort.c +1094 -0
  94. data/ext/isomorfeus_ferret_ext/bzip_huffman.c +205 -0
  95. data/ext/isomorfeus_ferret_ext/bzlib.c +1572 -0
  96. data/ext/isomorfeus_ferret_ext/bzlib.h +282 -0
  97. data/ext/isomorfeus_ferret_ext/bzlib_compress.c +672 -0
  98. data/ext/isomorfeus_ferret_ext/bzlib_crctable.c +104 -0
  99. data/ext/isomorfeus_ferret_ext/bzlib_decompress.c +652 -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 +105 -63
  123. data/ext/isomorfeus_ferret_ext/frt_global.h +7 -3
  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_mempool.c +1 -2
  130. data/ext/isomorfeus_ferret_ext/frt_multimapper.c +4 -7
  131. data/ext/isomorfeus_ferret_ext/frt_q_boolean.c +67 -91
  132. data/ext/isomorfeus_ferret_ext/frt_q_const_score.c +35 -38
  133. data/ext/isomorfeus_ferret_ext/frt_q_filtered_query.c +53 -72
  134. data/ext/isomorfeus_ferret_ext/frt_q_fuzzy.c +25 -32
  135. data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +21 -23
  136. data/ext/isomorfeus_ferret_ext/frt_q_multi_term.c +66 -103
  137. data/ext/isomorfeus_ferret_ext/frt_q_parser.c +207 -195
  138. data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +26 -25
  139. data/ext/isomorfeus_ferret_ext/frt_q_prefix.c +17 -14
  140. data/ext/isomorfeus_ferret_ext/frt_q_range.c +102 -131
  141. data/ext/isomorfeus_ferret_ext/frt_q_span.c +179 -178
  142. data/ext/isomorfeus_ferret_ext/frt_q_term.c +47 -60
  143. data/ext/isomorfeus_ferret_ext/frt_q_wildcard.c +18 -16
  144. data/ext/isomorfeus_ferret_ext/frt_ram_store.c +46 -84
  145. data/ext/isomorfeus_ferret_ext/frt_search.c +105 -146
  146. data/ext/isomorfeus_ferret_ext/frt_search.h +331 -320
  147. data/ext/isomorfeus_ferret_ext/frt_similarity.c +5 -13
  148. data/ext/isomorfeus_ferret_ext/frt_similarity.h +7 -12
  149. data/ext/isomorfeus_ferret_ext/frt_sort.c +105 -149
  150. data/ext/isomorfeus_ferret_ext/frt_store.c +13 -7
  151. data/ext/isomorfeus_ferret_ext/frt_store.h +10 -2
  152. data/ext/isomorfeus_ferret_ext/frt_threading.h +0 -1
  153. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +21 -109
  154. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.h +2 -32
  155. data/ext/isomorfeus_ferret_ext/lz4.c +2495 -0
  156. data/ext/isomorfeus_ferret_ext/lz4.h +774 -0
  157. data/ext/isomorfeus_ferret_ext/lz4frame.c +1899 -0
  158. data/ext/isomorfeus_ferret_ext/lz4frame.h +623 -0
  159. data/ext/isomorfeus_ferret_ext/lz4hc.c +1615 -0
  160. data/ext/isomorfeus_ferret_ext/lz4hc.h +413 -0
  161. data/ext/isomorfeus_ferret_ext/lz4xxhash.c +1030 -0
  162. data/ext/isomorfeus_ferret_ext/lz4xxhash.h +328 -0
  163. data/ext/isomorfeus_ferret_ext/stem_modules.h +0 -86
  164. data/ext/isomorfeus_ferret_ext/test.c +1 -2
  165. data/ext/isomorfeus_ferret_ext/test_1710.c +11 -12
  166. data/ext/isomorfeus_ferret_ext/test_analysis.c +590 -583
  167. data/ext/isomorfeus_ferret_ext/test_compound_io.c +1 -1
  168. data/ext/isomorfeus_ferret_ext/test_document.c +19 -15
  169. data/ext/isomorfeus_ferret_ext/test_except.c +1 -2
  170. data/ext/isomorfeus_ferret_ext/test_fields.c +111 -100
  171. data/ext/isomorfeus_ferret_ext/test_file_deleter.c +10 -27
  172. data/ext/isomorfeus_ferret_ext/test_filter.c +11 -8
  173. data/ext/isomorfeus_ferret_ext/test_hash.c +2 -2
  174. data/ext/isomorfeus_ferret_ext/test_hashset.c +1 -1
  175. data/ext/isomorfeus_ferret_ext/test_highlighter.c +15 -11
  176. data/ext/isomorfeus_ferret_ext/test_index.c +373 -363
  177. data/ext/isomorfeus_ferret_ext/test_q_const_score.c +5 -3
  178. data/ext/isomorfeus_ferret_ext/test_q_filtered.c +5 -3
  179. data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +13 -10
  180. data/ext/isomorfeus_ferret_ext/test_q_parser.c +45 -7
  181. data/ext/isomorfeus_ferret_ext/test_q_span.c +15 -12
  182. data/ext/isomorfeus_ferret_ext/test_ram_store.c +3 -3
  183. data/ext/isomorfeus_ferret_ext/test_search.c +60 -62
  184. data/ext/isomorfeus_ferret_ext/test_segments.c +5 -4
  185. data/ext/isomorfeus_ferret_ext/test_sort.c +17 -14
  186. data/ext/isomorfeus_ferret_ext/test_store.c +2 -0
  187. data/ext/isomorfeus_ferret_ext/test_term.c +3 -1
  188. data/ext/isomorfeus_ferret_ext/test_term_vectors.c +9 -10
  189. data/ext/isomorfeus_ferret_ext/test_test.c +1 -2
  190. data/ext/isomorfeus_ferret_ext/test_threading.c +9 -10
  191. data/ext/isomorfeus_ferret_ext/testhelper.c +1 -2
  192. data/lib/isomorfeus/ferret/version.rb +1 -1
  193. metadata +113 -58
  194. data/ext/isomorfeus_ferret_ext/email.rl +0 -21
  195. data/ext/isomorfeus_ferret_ext/frt_scanner.c +0 -900
  196. data/ext/isomorfeus_ferret_ext/frt_scanner.h +0 -28
  197. data/ext/isomorfeus_ferret_ext/frt_scanner_mb.c +0 -6706
  198. data/ext/isomorfeus_ferret_ext/frt_scanner_utf8.c +0 -4420
  199. data/ext/isomorfeus_ferret_ext/scanner.h +0 -28
  200. data/ext/isomorfeus_ferret_ext/scanner.in +0 -43
  201. data/ext/isomorfeus_ferret_ext/scanner.rl +0 -84
  202. data/ext/isomorfeus_ferret_ext/scanner_mb.rl +0 -200
  203. data/ext/isomorfeus_ferret_ext/scanner_utf8.rl +0 -85
  204. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_basque.c +0 -1167
  205. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_basque.h +0 -6
  206. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_catalan.c +0 -1433
  207. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_catalan.h +0 -6
  208. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_danish.c +0 -301
  209. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_danish.h +0 -6
  210. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_dutch.c +0 -590
  211. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_dutch.h +0 -6
  212. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_english.c +0 -1049
  213. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_english.h +0 -6
  214. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_finnish.c +0 -705
  215. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_finnish.h +0 -6
  216. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_french.c +0 -1239
  217. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_french.h +0 -6
  218. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_german.c +0 -477
  219. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_german.h +0 -6
  220. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_hungarian.c +0 -1217
  221. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_hungarian.h +0 -7
  222. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_indonesian.c +0 -394
  223. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_indonesian.h +0 -6
  224. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_irish.c +0 -457
  225. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_irish.h +0 -6
  226. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_italian.c +0 -1009
  227. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_italian.h +0 -6
  228. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_norwegian.c +0 -259
  229. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_norwegian.h +0 -6
  230. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_porter.c +0 -704
  231. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_porter.h +0 -6
  232. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_portuguese.c +0 -948
  233. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_portuguese.h +0 -6
  234. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_spanish.c +0 -1028
  235. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_spanish.h +0 -6
  236. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_swedish.c +0 -275
  237. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_swedish.h +0 -6
  238. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_hungarian.c +0 -849
  239. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_hungarian.h +0 -6
  240. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_romanian.c +0 -952
  241. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_romanian.h +0 -6
  242. data/ext/isomorfeus_ferret_ext/stem_KOI8_R_russian.c +0 -669
  243. data/ext/isomorfeus_ferret_ext/stem_KOI8_R_russian.h +0 -6
  244. data/ext/isomorfeus_ferret_ext/stem_modules.txt +0 -63
  245. data/ext/isomorfeus_ferret_ext/uchar-ucs4.rl +0 -1854
  246. data/ext/isomorfeus_ferret_ext/uchar-utf8.rl +0 -1999
  247. data/ext/isomorfeus_ferret_ext/url.rl +0 -27
@@ -5,6 +5,7 @@
5
5
  #include "frt_field_index.h"
6
6
  #include "frt_bitvector.h"
7
7
  #include "frt_similarity.h"
8
+ #include <ruby/encoding.h>
8
9
 
9
10
  typedef struct FrtQuery FrtQuery;
10
11
  typedef struct FrtWeight FrtWeight;
@@ -17,8 +18,7 @@ typedef struct FrtScorer FrtScorer;
17
18
  ***************************************************************************/
18
19
 
19
20
  #define FRT_EXPLANATION_DETAILS_START_SIZE 4
20
- typedef struct FrtExplanation
21
- {
21
+ typedef struct FrtExplanation {
22
22
  float value;
23
23
  char *description;
24
24
  struct FrtExplanation **details;
@@ -39,18 +39,16 @@ extern char *frt_expl_to_html(FrtExplanation *expl);
39
39
  ***************************************************************************/
40
40
  typedef struct FrtSearcher FrtSearcher;
41
41
 
42
- typedef struct FrtMatchRange
43
- {
44
- int start;
45
- int end;
46
- int start_offset;
47
- int end_offset;
42
+ typedef struct FrtMatchRange {
43
+ int start;
44
+ int end;
45
+ int start_offset;
46
+ int end_offset;
48
47
  double score;
49
48
  } FrtMatchRange;
50
49
 
51
50
  #define FRT_MATCH_VECTOR_INIT_CAPA 8
52
- typedef struct FrtMatchVector
53
- {
51
+ typedef struct FrtMatchVector {
54
52
  int size;
55
53
  int capa;
56
54
  FrtMatchRange *matches;
@@ -69,9 +67,8 @@ extern FrtMatchVector *frt_matchv_compact_with_breaks(FrtMatchVector *self);
69
67
  *
70
68
  ***************************************************************************/
71
69
 
72
- typedef struct FrtHit
73
- {
74
- int doc;
70
+ typedef struct FrtHit {
71
+ int doc;
75
72
  float score;
76
73
  } FrtHit;
77
74
 
@@ -81,16 +78,14 @@ typedef struct FrtHit
81
78
  *
82
79
  ***************************************************************************/
83
80
 
84
- typedef struct FrtTopDocs
85
- {
86
- int total_hits;
87
- int size;
81
+ typedef struct FrtTopDocs {
82
+ int total_hits;
83
+ int size;
88
84
  FrtHit **hits;
89
- float max_score;
85
+ float max_score;
90
86
  } FrtTopDocs;
91
87
 
92
- extern FrtTopDocs *frt_td_new(int total_hits, int size, FrtHit **hits,
93
- float max_score);
88
+ extern FrtTopDocs *frt_td_new(int total_hits, int size, FrtHit **hits, float max_score);
94
89
  extern void frt_td_destroy(FrtTopDocs *td);
95
90
  extern char *frt_td_to_s(FrtTopDocs *td);
96
91
 
@@ -100,9 +95,8 @@ extern char *frt_td_to_s(FrtTopDocs *td);
100
95
  *
101
96
  ***************************************************************************/
102
97
 
103
- typedef struct FrtFilter
104
- {
105
- FrtSymbol name;
98
+ typedef struct FrtFilter {
99
+ ID name;
106
100
  FrtHash *cache;
107
101
  FrtBitVector *(*get_bv_i)(struct FrtFilter *self, FrtIndexReader *ir);
108
102
  char *(*to_s)(struct FrtFilter *self);
@@ -110,10 +104,11 @@ typedef struct FrtFilter
110
104
  int (*eq)(struct FrtFilter *self, struct FrtFilter *o);
111
105
  void (*destroy_i)(struct FrtFilter *self);
112
106
  int ref_cnt;
107
+ VALUE rfilter;
113
108
  } FrtFilter;
114
109
 
115
110
  #define filt_new(type) frt_filt_create(sizeof(type), rb_intern(#type))
116
- extern FrtFilter *frt_filt_create(size_t size, FrtSymbol name);
111
+ extern FrtFilter *frt_filt_create(size_t size, ID name);
117
112
  extern FrtBitVector *frt_filt_get_bv(FrtFilter *filt, FrtIndexReader *ir);
118
113
  extern void frt_filt_destroy_i(FrtFilter *filt);
119
114
  extern void frt_filt_deref(FrtFilter *filt);
@@ -126,8 +121,23 @@ extern int frt_filt_eq(FrtFilter *filt, FrtFilter *o);
126
121
  *
127
122
  ***************************************************************************/
128
123
 
129
- extern FrtFilter *frt_rfilt_new(FrtSymbol field,
130
- const char *lower_term, const char *upper_term,
124
+ typedef struct FrtRange {
125
+ ID field;
126
+ char *lower_term;
127
+ char *upper_term;
128
+ bool include_lower : 1;
129
+ bool include_upper : 1;
130
+ } FrtRange;
131
+
132
+ typedef struct FrtRangeFilter {
133
+ FrtFilter super;
134
+ FrtRange *range;
135
+ } FrtRangeFilter;
136
+
137
+ extern FrtFilter *frt_rfilt_alloc(void);
138
+ extern FrtFilter *frt_rfilt_init(FrtFilter *filt, ID field, const char *lower_term, const char *upper_term,
139
+ bool include_lower, bool include_upper);
140
+ extern FrtFilter *frt_rfilt_new(ID field, const char *lower_term, const char *upper_term,
131
141
  bool include_lower, bool include_upper);
132
142
 
133
143
  /***************************************************************************
@@ -136,8 +146,10 @@ extern FrtFilter *frt_rfilt_new(FrtSymbol field,
136
146
  *
137
147
  ***************************************************************************/
138
148
 
139
- extern FrtFilter *frt_trfilt_new(FrtSymbol field,
140
- const char *lower_term, const char *upper_term,
149
+ extern FrtFilter *frt_trfilt_alloc(void);
150
+ extern FrtFilter *frt_trfilt_init(FrtFilter *filt, ID field, const char *lower_term, const char *upper_term,
151
+ bool include_lower, bool include_upper);
152
+ extern FrtFilter *frt_trfilt_new(ID field, const char *lower_term, const char *upper_term,
141
153
  bool include_lower, bool include_upper);
142
154
 
143
155
  /***************************************************************************
@@ -146,6 +158,13 @@ extern FrtFilter *frt_trfilt_new(FrtSymbol field,
146
158
  *
147
159
  ***************************************************************************/
148
160
 
161
+ typedef struct FrtQueryFilter {
162
+ FrtFilter super;
163
+ FrtQuery *query;
164
+ } FrtQueryFilter;
165
+
166
+ extern FrtFilter *frt_qfilt_alloc(void);
167
+ extern FrtFilter *frt_qfilt_init(FrtFilter *filt, FrtQuery *query);
149
168
  extern FrtFilter *frt_qfilt_new(FrtQuery *query);
150
169
  extern FrtFilter *frt_qfilt_new_nr(FrtQuery *query);
151
170
 
@@ -155,22 +174,21 @@ extern FrtFilter *frt_qfilt_new_nr(FrtQuery *query);
155
174
  *
156
175
  ***************************************************************************/
157
176
 
158
- struct FrtWeight
159
- {
160
- float value;
161
- float qweight;
162
- float qnorm;
163
- float idf;
177
+ struct FrtWeight {
178
+ float value;
179
+ float qweight;
180
+ float qnorm;
181
+ float idf;
164
182
  FrtQuery *query;
165
183
  FrtSimilarity *similarity;
166
184
  FrtQuery *(*get_query)(FrtWeight *self);
167
- float (*get_value)(FrtWeight *self);
168
- void (*normalize)(FrtWeight *self, float normalization_factor);
185
+ float (*get_value)(FrtWeight *self);
186
+ void (*normalize)(FrtWeight *self, float normalization_factor);
169
187
  FrtScorer *(*scorer)(FrtWeight *self, FrtIndexReader *ir);
170
188
  FrtExplanation *(*explain)(FrtWeight *self, FrtIndexReader *ir, int doc_num);
171
- float (*sum_of_squared_weights)(FrtWeight *self);
172
- char *(*to_s)(FrtWeight *self);
173
- void (*destroy)(FrtWeight *self);
189
+ float (*sum_of_squared_weights)(FrtWeight *self);
190
+ char *(*to_s)(FrtWeight *self);
191
+ void (*destroy)(FrtWeight *self);
174
192
  };
175
193
 
176
194
  #define w_new(type, query) frt_w_create(sizeof(type), query)
@@ -187,8 +205,7 @@ extern void frt_w_normalize(FrtWeight *self, float normalization_factor);
187
205
  *
188
206
  ***************************************************************************/
189
207
 
190
- typedef enum
191
- {
208
+ typedef enum {
192
209
  TERM_QUERY,
193
210
  MULTI_TERM_QUERY,
194
211
  BOOLEAN_QUERY,
@@ -210,21 +227,21 @@ typedef enum
210
227
  SPAN_NEAR_QUERY
211
228
  } FrtQueryType;
212
229
 
213
- struct FrtQuery
214
- {
215
- int ref_cnt;
216
- float boost;
217
- FrtWeight *weight;
218
- FrtQuery *(*rewrite)(FrtQuery *self, FrtIndexReader *ir);
219
- void (*extract_terms)(FrtQuery *self, FrtHashSet *terms);
220
- FrtSimilarity *(*get_similarity)(FrtQuery *self, FrtSearcher *searcher);
221
- char *(*to_s)(FrtQuery *self, FrtSymbol field);
230
+ struct FrtQuery {
231
+ int ref_cnt;
232
+ float boost;
233
+ FrtWeight *weight;
234
+ FrtQuery *(*rewrite)(FrtQuery *self, FrtIndexReader *ir);
235
+ void (*extract_terms)(FrtQuery *self, FrtHashSet *terms);
236
+ FrtSimilarity *(*get_similarity)(FrtQuery *self, FrtSearcher *searcher);
237
+ char *(*to_s)(FrtQuery *self, ID field);
222
238
  unsigned long long (*hash)(FrtQuery *self);
223
- int (*eq)(FrtQuery *self, FrtQuery *o);
224
- void (*destroy_i)(FrtQuery *self);
225
- FrtWeight *(*create_weight_i)(FrtQuery *self, FrtSearcher *searcher);
226
- FrtMatchVector *(*get_matchv_i)(FrtQuery *self, FrtMatchVector *mv, FrtTermVector *tv);
227
- FrtQueryType type;
239
+ int (*eq)(FrtQuery *self, FrtQuery *o);
240
+ void (*destroy_i)(FrtQuery *self);
241
+ FrtWeight *(*create_weight_i)(FrtQuery *self, FrtSearcher *searcher);
242
+ FrtMatchVector *(*get_matchv_i)(FrtQuery *self, FrtMatchVector *mv, FrtTermVector *tv);
243
+ FrtQueryType type;
244
+ VALUE rquery;
228
245
  };
229
246
 
230
247
  /* Internal FrtQuery Functions */
@@ -245,37 +262,37 @@ extern FrtQuery *frt_q_create(size_t size);
245
262
  * FrtTermQuery
246
263
  ***************************************************************************/
247
264
 
248
- typedef struct FrtTermQuery
249
- {
250
- FrtQuery super;
251
- FrtSymbol field;
252
- char *term;
265
+ typedef struct FrtTermQuery {
266
+ FrtQuery super;
267
+ ID field;
268
+ char *term;
253
269
  } FrtTermQuery;
254
270
 
255
- FrtQuery *frt_tq_new(FrtSymbol field, const char *term);
271
+ FrtQuery *frt_tq_alloc(void);
272
+ FrtQuery *frt_tq_init(FrtQuery *self, ID field, const char *term);
273
+ FrtQuery *frt_tq_new(ID field, const char *term);
256
274
 
257
275
  /***************************************************************************
258
276
  * FrtBooleanQuery
259
277
  ***************************************************************************/
260
278
 
261
- /* *** FrtBooleanClause *** */
262
-
263
- typedef enum
264
- {
279
+ typedef enum {
265
280
  FRT_BC_SHOULD,
266
281
  FRT_BC_MUST,
267
282
  FRT_BC_MUST_NOT
268
283
  } FrtBCType;
269
284
 
270
- typedef struct FrtBooleanClause
271
- {
272
- int ref_cnt;
273
- FrtQuery *query;
285
+ typedef struct FrtBooleanClause {
286
+ int ref_cnt;
287
+ FrtQuery *query;
274
288
  FrtBCType occur;
275
- bool is_prohibited : 1;
276
- bool is_required : 1;
289
+ bool is_prohibited : 1;
290
+ bool is_required : 1;
291
+ VALUE rbc;
277
292
  } FrtBooleanClause;
278
293
 
294
+ extern FrtBooleanClause *frt_bc_alloc(void);
295
+ extern FrtBooleanClause *frt_bc_init(FrtBooleanClause *self, FrtQuery *query, FrtBCType occur);
279
296
  extern FrtBooleanClause *frt_bc_new(FrtQuery *query, FrtBCType occur);
280
297
  extern void frt_bc_deref(FrtBooleanClause *self);
281
298
  extern void frt_bc_set_occur(FrtBooleanClause *self, FrtBCType occur);
@@ -286,24 +303,23 @@ extern void frt_bc_set_occur(FrtBooleanClause *self, FrtBCType occur);
286
303
  #define FRT_BOOLEAN_CLAUSES_START_CAPA 4
287
304
  #define FRT_QUERY_STRING_START_SIZE 64
288
305
 
289
- typedef struct FrtBooleanQuery
290
- {
291
- FrtQuery super;
292
- bool coord_disabled;
293
- int max_clause_cnt;
294
- int clause_cnt;
295
- int clause_capa;
296
- float original_boost;
306
+ typedef struct FrtBooleanQuery {
307
+ FrtQuery super;
308
+ bool coord_disabled;
309
+ int max_clause_cnt;
310
+ int clause_cnt;
311
+ int clause_capa;
312
+ float original_boost;
297
313
  FrtBooleanClause **clauses;
298
- FrtSimilarity *similarity;
314
+ FrtSimilarity *similarity;
299
315
  } FrtBooleanQuery;
300
316
 
317
+ extern FrtQuery *frt_bq_alloc(void);
318
+ extern FrtQuery *frt_bq_init(FrtQuery *self, bool coord_disabled);
301
319
  extern FrtQuery *frt_bq_new(bool coord_disabled);
302
320
  extern FrtQuery *frt_bq_new_max(bool coord_disabled, int max);
303
- extern FrtBooleanClause *frt_bq_add_query(FrtQuery *self, FrtQuery *sub_query,
304
- FrtBCType occur);
305
- extern FrtBooleanClause *frt_bq_add_query_nr(FrtQuery *self, FrtQuery *sub_query,
306
- FrtBCType occur);
321
+ extern FrtBooleanClause *frt_bq_add_query(FrtQuery *self, FrtQuery *sub_query, FrtBCType occur);
322
+ extern FrtBooleanClause *frt_bq_add_query_nr(FrtQuery *self, FrtQuery *sub_query, FrtBCType occur);
307
323
  extern FrtBooleanClause *frt_bq_add_clause(FrtQuery *self, FrtBooleanClause *bc);
308
324
  extern FrtBooleanClause *frt_bq_add_clause_nr(FrtQuery *self, FrtBooleanClause *bc);
309
325
 
@@ -311,17 +327,18 @@ extern FrtBooleanClause *frt_bq_add_clause_nr(FrtQuery *self, FrtBooleanClause *
311
327
  * FrtPhraseQuery
312
328
  ***************************************************************************/
313
329
 
314
- typedef struct FrtPhraseQuery
315
- {
330
+ typedef struct FrtPhraseQuery {
316
331
  FrtQuery super;
317
332
  int slop;
318
- FrtSymbol field;
333
+ ID field;
319
334
  FrtPhrasePosition *positions;
320
335
  int pos_cnt;
321
336
  int pos_capa;
322
337
  } FrtPhraseQuery;
323
338
 
324
- extern FrtQuery *frt_phq_new(FrtSymbol field);
339
+ extern FrtQuery *frt_phq_alloc(void);
340
+ extern FrtQuery *frt_phq_init(FrtQuery *self, ID field);
341
+ extern FrtQuery *frt_phq_new(ID field);
325
342
  extern void frt_phq_add_term(FrtQuery *self, const char *term, int pos_inc);
326
343
  extern void frt_phq_add_term_abs(FrtQuery *self, const char *term, int position);
327
344
  extern void frt_phq_append_multi_term(FrtQuery *self, const char *term);
@@ -332,25 +349,24 @@ extern void frt_phq_set_slop(FrtQuery *self, int slop);
332
349
  ***************************************************************************/
333
350
 
334
351
  #define MULTI_TERM_QUERY_MAX_TERMS 256
335
- typedef struct FrtMultiTermQuery
336
- {
352
+ typedef struct FrtMultiTermQuery {
337
353
  FrtQuery super;
338
- FrtSymbol field;
354
+ ID field;
339
355
  FrtPriorityQueue *boosted_terms;
340
356
  float min_boost;
341
357
  } FrtMultiTermQuery;
342
358
 
343
359
  extern void frt_multi_tq_add_term(FrtQuery *self, const char *term);
344
360
  extern void frt_multi_tq_add_term_boost(FrtQuery *self, const char *term, float boost);
345
- extern FrtQuery *frt_multi_tq_new(FrtSymbol field);
346
- extern FrtQuery *frt_multi_tq_new_conf(FrtSymbol field, int max_terms,
347
- float min_boost);
361
+ extern FrtQuery *frt_multi_tq_alloc(void);
362
+ extern FrtQuery *frt_multi_tq_new(ID field);
363
+ extern FrtQuery *frt_multi_tq_init_conf(FrtQuery *self, ID field, int max_terms, float min_boost);
364
+ extern FrtQuery *frt_multi_tq_new_conf(ID field, int max_terms, float min_boost);
348
365
 
349
366
  #define FrtMTQMaxTerms(query) (((FrtMTQSubQuery *)(query))->max_terms)
350
- typedef struct FrtMTQSubQuery
351
- {
367
+ typedef struct FrtMTQSubQuery {
352
368
  FrtQuery super;
353
- int max_terms;
369
+ int max_terms;
354
370
  } FrtMTQSubQuery;
355
371
 
356
372
  /***************************************************************************
@@ -359,14 +375,15 @@ typedef struct FrtMTQSubQuery
359
375
 
360
376
  #define PREFIX_QUERY_MAX_TERMS 256
361
377
 
362
- typedef struct FrtPrefixQuery
363
- {
378
+ typedef struct FrtPrefixQuery {
364
379
  FrtMTQSubQuery super;
365
- FrtSymbol field;
380
+ ID field;
366
381
  char *prefix;
367
382
  } FrtPrefixQuery;
368
383
 
369
- extern FrtQuery *frt_prefixq_new(FrtSymbol field, const char *prefix);
384
+ extern FrtQuery *frt_prefixq_alloc(void);
385
+ extern FrtQuery *frt_prefixq_init(FrtQuery *self, ID field, const char *prefix);
386
+ extern FrtQuery *frt_prefixq_new(ID field, const char *prefix);
370
387
 
371
388
  /***************************************************************************
372
389
  * FrtWildCardQuery
@@ -376,15 +393,15 @@ extern FrtQuery *frt_prefixq_new(FrtSymbol field, const char *prefix);
376
393
  #define FRT_WILD_STRING '*'
377
394
  #define FRT_WILD_CARD_QUERY_MAX_TERMS 256
378
395
 
379
- typedef struct FrtWildCardQuery
380
- {
396
+ typedef struct FrtWildCardQuery {
381
397
  FrtMTQSubQuery super;
382
- FrtSymbol field;
398
+ ID field;
383
399
  char *pattern;
384
400
  } FrtWildCardQuery;
385
401
 
386
-
387
- extern FrtQuery *frt_wcq_new(FrtSymbol field, const char *pattern);
402
+ extern FrtQuery *frt_wcq_alloc(void);
403
+ extern FrtQuery *frt_wcq_init(FrtQuery *self, ID field, const char *pattern);
404
+ extern FrtQuery *frt_wcq_new(ID field, const char *pattern);
388
405
  extern bool frt_wc_match(const char *pattern, const char *text);
389
406
 
390
407
  /***************************************************************************
@@ -396,36 +413,37 @@ extern bool frt_wc_match(const char *pattern, const char *text);
396
413
  #define FRT_DEF_MAX_TERMS 256
397
414
  #define FRT_TYPICAL_LONGEST_WORD 20
398
415
 
399
- typedef struct FrtFuzzyQuery
400
- {
416
+ typedef struct FrtFuzzyQuery {
401
417
  FrtMTQSubQuery super;
402
- FrtSymbol field;
403
- char *term;
404
- const char *text; /* term text after prefix */
405
- int text_len;
406
- int pre_len;
407
- float min_sim;
408
- float scale_factor;
409
- int max_distances[FRT_TYPICAL_LONGEST_WORD];
410
- int *da;
418
+ ID field;
419
+ char *term;
420
+ const char *text; /* term text after prefix */
421
+ int text_len;
422
+ int pre_len;
423
+ float min_sim;
424
+ float scale_factor;
425
+ int max_distances[FRT_TYPICAL_LONGEST_WORD];
426
+ int *da;
411
427
  } FrtFuzzyQuery;
412
428
 
413
- extern FrtQuery *frt_fuzq_new(FrtSymbol field, const char *term);
414
- extern FrtQuery *frt_fuzq_new_conf(FrtSymbol field, const char *term,
415
- float min_sim, int pre_len, int max_terms);
429
+ extern FrtQuery *frt_fuzq_alloc(void);
430
+ extern FrtQuery *frt_fuzq_new(ID field, const char *term);
431
+ extern FrtQuery *frt_fuzq_init_conf(FrtQuery *self, ID field, const char *term, float min_sim, int pre_len, int max_terms);
432
+ extern FrtQuery *frt_fuzq_new_conf(ID field, const char *term, float min_sim, int pre_len, int max_terms);
416
433
  extern float frt_fuzq_score(FrtFuzzyQuery *fuzq, const char *target);
417
434
 
418
435
  /***************************************************************************
419
436
  * FrtConstantScoreQuery
420
437
  ***************************************************************************/
421
438
 
422
- typedef struct FrtConstantScoreQuery
423
- {
424
- FrtQuery super;
439
+ typedef struct FrtConstantScoreQuery {
440
+ FrtQuery super;
425
441
  FrtFilter *filter;
426
442
  FrtQuery *original;
427
443
  } FrtConstantScoreQuery;
428
444
 
445
+ extern FrtQuery *frt_csq_alloc(void);
446
+ extern FrtQuery *frt_csq_init(FrtQuery *self, FrtFilter *filter);
429
447
  extern FrtQuery *frt_csq_new(FrtFilter *filter);
430
448
  extern FrtQuery *frt_csq_new_nr(FrtFilter *filter);
431
449
 
@@ -434,38 +452,47 @@ extern FrtQuery *frt_csq_new_nr(FrtFilter *filter);
434
452
  ***************************************************************************/
435
453
 
436
454
  typedef struct FrtFilteredQuery {
437
- FrtQuery super;
455
+ FrtQuery super;
438
456
  FrtQuery *query;
439
457
  FrtFilter *filter;
440
458
  } FrtFilteredQuery;
441
459
 
460
+ extern FrtQuery *frt_fq_alloc(void);
461
+ extern FrtQuery *frt_fq_init(FrtQuery *self, FrtQuery *query, FrtFilter *filter);
442
462
  extern FrtQuery *frt_fq_new(FrtQuery *query, FrtFilter *filter);
443
463
 
444
464
  /***************************************************************************
445
465
  * FrtMatchAllQuery
446
466
  ***************************************************************************/
447
467
 
468
+ extern FrtQuery *frt_maq_alloc(void);
469
+ extern FrtQuery *frt_maq_init(FrtQuery *self);
448
470
  extern FrtQuery *frt_maq_new();
449
471
 
450
472
  /***************************************************************************
451
473
  * FrtRangeQuery
452
474
  ***************************************************************************/
453
475
 
454
- extern FrtQuery *frt_rq_new(FrtSymbol field, const char *lower_term,
455
- const char *upper_term, bool include_lower,
456
- bool include_upper);
457
- extern FrtQuery *frt_rq_new_less(FrtSymbol field, const char *upper_term, bool include_upper);
458
- extern FrtQuery *frt_rq_new_more(FrtSymbol field, const char *lower_term, bool include_lower);
476
+ typedef struct FrtRangeQuery {
477
+ FrtQuery f;
478
+ FrtRange *range;
479
+ } FrtRangeQuery;
480
+
481
+ extern FrtQuery *frt_rq_alloc(void);
482
+ extern FrtQuery *frt_rq_init(FrtQuery *self, ID field, const char *lower_term, const char *upper_term, bool include_lower, bool include_upper);
483
+ extern FrtQuery *frt_rq_new(ID field, const char *lower_term, const char *upper_term, bool include_lower, bool include_upper);
484
+ extern FrtQuery *frt_rq_new_less(ID field, const char *upper_term, bool include_upper);
485
+ extern FrtQuery *frt_rq_new_more(ID field, const char *lower_term, bool include_lower);
459
486
 
460
487
  /***************************************************************************
461
488
  * FrtTypedRangeQuery
462
489
  ***************************************************************************/
463
490
 
464
- extern FrtQuery *frt_trq_new(FrtSymbol field, const char *lower_term,
465
- const char *upper_term, bool include_lower,
466
- bool include_upper);
467
- extern FrtQuery *frt_trq_new_less(FrtSymbol field, const char *upper_term, bool include_upper);
468
- extern FrtQuery *frt_trq_new_more(FrtSymbol field, const char *lower_term, bool include_lower);
491
+ extern FrtQuery *frt_trq_alloc(void);
492
+ extern FrtQuery *frt_trq_init(FrtQuery *self, ID field, const char *lower_term, const char *upper_term, bool include_lower, bool include_upper);
493
+ extern FrtQuery *frt_trq_new(ID field, const char *lower_term, const char *upper_term, bool include_lower, bool include_upper);
494
+ extern FrtQuery *frt_trq_new_less(ID field, const char *upper_term, bool include_upper);
495
+ extern FrtQuery *frt_trq_new_more(ID field, const char *lower_term, bool include_lower);
469
496
 
470
497
  /***************************************************************************
471
498
  * FrtSpanQuery
@@ -473,66 +500,68 @@ extern FrtQuery *frt_trq_new_more(FrtSymbol field, const char *lower_term, bool
473
500
 
474
501
  /* ** FrtSpanEnum ** */
475
502
  typedef struct FrtSpanEnum FrtSpanEnum;
476
- struct FrtSpanEnum
477
- {
503
+ struct FrtSpanEnum {
478
504
  FrtQuery *query;
479
- bool (*next)(FrtSpanEnum *self);
480
- bool (*skip_to)(FrtSpanEnum *self, int target_doc);
481
- int (*doc)(FrtSpanEnum *self);
482
- int (*start)(FrtSpanEnum *self);
483
- int (*end)(FrtSpanEnum *self);
484
- char *(*to_s)(FrtSpanEnum *self);
485
- void (*destroy)(FrtSpanEnum *self);
505
+ bool (*next)(FrtSpanEnum *self);
506
+ bool (*skip_to)(FrtSpanEnum *self, int target_doc);
507
+ int (*doc)(FrtSpanEnum *self);
508
+ int (*start)(FrtSpanEnum *self);
509
+ int (*end)(FrtSpanEnum *self);
510
+ char *(*to_s)(FrtSpanEnum *self);
511
+ void (*destroy)(FrtSpanEnum *self);
486
512
  };
487
513
 
488
514
  /* ** FrtSpanQuery ** */
489
- typedef struct FrtSpanQuery
490
- {
491
- FrtQuery super;
492
- FrtSymbol field;
493
- FrtSpanEnum *(*get_spans)(FrtQuery *self, FrtIndexReader *ir);
494
- FrtHashSet *(*get_terms)(FrtQuery *self);
515
+ typedef struct FrtSpanQuery {
516
+ FrtQuery super;
517
+ ID field;
518
+ FrtSpanEnum *(*get_spans)(FrtQuery *self, FrtIndexReader *ir);
519
+ FrtHashSet *(*get_terms)(FrtQuery *self);
495
520
  } FrtSpanQuery;
496
521
 
497
522
  /***************************************************************************
498
523
  * FrtSpanTermQuery
499
524
  ***************************************************************************/
500
525
 
501
- typedef struct FrtSpanTermQuery
502
- {
526
+ typedef struct FrtSpanTermQuery {
503
527
  FrtSpanQuery super;
504
- char *term;
528
+ char *term;
505
529
  } FrtSpanTermQuery;
506
- extern FrtQuery *frt_spantq_new(FrtSymbol field, const char *term);
530
+
531
+ extern FrtQuery *frt_spantq_alloc(void);
532
+ extern FrtQuery *frt_spantq_init(FrtQuery *self, ID field, const char *term);
533
+ extern FrtQuery *frt_spantq_new(ID field, const char *term);
507
534
 
508
535
  /***************************************************************************
509
536
  * FrtSpanMultiTermQuery
510
537
  ***************************************************************************/
511
538
 
512
539
  #define SPAN_MULTI_TERM_QUERY_CAPA 1024
513
- typedef struct FrtSpanMultiTermQuery
514
- {
540
+ typedef struct FrtSpanMultiTermQuery {
515
541
  FrtSpanQuery super;
516
- char **terms;
517
- int term_cnt;
518
- int term_capa;
542
+ char **terms;
543
+ int term_cnt;
544
+ int term_capa;
519
545
  } FrtSpanMultiTermQuery;
520
546
 
521
- extern FrtQuery *frt_spanmtq_new(FrtSymbol field);
522
- extern FrtQuery *frt_spanmtq_new_conf(FrtSymbol field, int max_size);
547
+ extern FrtQuery *frt_spanmtq_alloc(void);
548
+ extern FrtQuery *frt_spanmtq_init(FrtQuery *self, ID field);
549
+ extern FrtQuery *frt_spanmtq_new(ID field);
550
+ extern FrtQuery *frt_spanmtq_new_conf(ID field, int max_size);
523
551
  extern void frt_spanmtq_add_term(FrtQuery *self, const char *term);
524
552
 
525
553
  /***************************************************************************
526
554
  * FrtSpanFirstQuery
527
555
  ***************************************************************************/
528
556
 
529
- typedef struct FrtSpanFirstQuery
530
- {
531
- FrtSpanQuery super;
532
- int end;
533
- FrtQuery *match;
557
+ typedef struct FrtSpanFirstQuery {
558
+ FrtSpanQuery super;
559
+ int end;
560
+ FrtQuery *match;
534
561
  } FrtSpanFirstQuery;
535
562
 
563
+ extern FrtQuery *frt_spanfq_alloc(void);
564
+ extern FrtQuery *frt_spanfq_init(FrtQuery *self, FrtQuery *match, int end);
536
565
  extern FrtQuery *frt_spanfq_new(FrtQuery *match, int end);
537
566
  extern FrtQuery *frt_spanfq_new_nr(FrtQuery *match, int end);
538
567
 
@@ -540,14 +569,15 @@ extern FrtQuery *frt_spanfq_new_nr(FrtQuery *match, int end);
540
569
  * FrtSpanOrQuery
541
570
  ***************************************************************************/
542
571
 
543
- typedef struct FrtSpanOrQuery
544
- {
545
- FrtSpanQuery super;
572
+ typedef struct FrtSpanOrQuery {
573
+ FrtSpanQuery super;
546
574
  FrtQuery **clauses;
547
- int c_cnt;
548
- int c_capa;
575
+ int c_cnt;
576
+ int c_capa;
549
577
  } FrtSpanOrQuery;
550
578
 
579
+ extern FrtQuery *frt_spanoq_alloc(void);
580
+ extern FrtQuery *frt_spanoq_init(FrtQuery *self);
551
581
  extern FrtQuery *frt_spanoq_new();
552
582
  extern FrtQuery *frt_spanoq_add_clause(FrtQuery *self, FrtQuery *clause);
553
583
  extern FrtQuery *frt_spanoq_add_clause_nr(FrtQuery *self, FrtQuery *clause);
@@ -556,16 +586,17 @@ extern FrtQuery *frt_spanoq_add_clause_nr(FrtQuery *self, FrtQuery *clause);
556
586
  * FrtSpanNearQuery
557
587
  ***************************************************************************/
558
588
 
559
- typedef struct FrtSpanNearQuery
560
- {
561
- FrtSpanQuery super;
589
+ typedef struct FrtSpanNearQuery {
590
+ FrtSpanQuery super;
562
591
  FrtQuery **clauses;
563
- int c_cnt;
564
- int c_capa;
565
- int slop;
566
- bool in_order : 1;
592
+ int c_cnt;
593
+ int c_capa;
594
+ int slop;
595
+ bool in_order : 1;
567
596
  } FrtSpanNearQuery;
568
597
 
598
+ extern FrtQuery *frt_spannq_alloc(void);
599
+ extern FrtQuery *frt_spannq_init(FrtQuery *self, int slop, bool in_order);
569
600
  extern FrtQuery *frt_spannq_new(int slop, bool in_order);
570
601
  extern FrtQuery *frt_spannq_add_clause(FrtQuery *self, FrtQuery *clause);
571
602
  extern FrtQuery *frt_spannq_add_clause_nr(FrtQuery *self, FrtQuery *clause);
@@ -574,32 +605,32 @@ extern FrtQuery *frt_spannq_add_clause_nr(FrtQuery *self, FrtQuery *clause);
574
605
  * FrtSpanNotQuery
575
606
  ***************************************************************************/
576
607
 
577
- typedef struct FrtSpanNotQuery
578
- {
579
- FrtSpanQuery super;
580
- FrtQuery *inc;
581
- FrtQuery *exc;
608
+ typedef struct FrtSpanNotQuery {
609
+ FrtSpanQuery super;
610
+ FrtQuery *inc;
611
+ FrtQuery *exc;
582
612
  } FrtSpanNotQuery;
583
613
 
614
+ extern FrtQuery *frt_spanxq_alloc(void);
615
+ extern FrtQuery *frt_spanxq_init(FrtQuery *self, FrtQuery *inc, FrtQuery *exc);
584
616
  extern FrtQuery *frt_spanxq_new(FrtQuery *inc, FrtQuery *exc);
585
617
  extern FrtQuery *frt_spanxq_new_nr(FrtQuery *inc, FrtQuery *exc);
586
618
 
587
-
588
619
  /***************************************************************************
589
620
  * FrtSpanPrefixQuery
590
621
  ***************************************************************************/
591
622
 
592
623
  #define FRT_SPAN_PREFIX_QUERY_MAX_TERMS 256
593
624
 
594
- typedef struct FrtSpanPrefixQuery
595
- {
596
- FrtSpanQuery super;
597
- char *prefix;
598
- int max_terms;
625
+ typedef struct FrtSpanPrefixQuery {
626
+ FrtSpanQuery super;
627
+ char *prefix;
628
+ int max_terms;
599
629
  } FrtSpanPrefixQuery;
600
630
 
601
- extern FrtQuery *frt_spanprq_new(FrtSymbol field, const char *prefix);
602
-
631
+ extern FrtQuery *frt_spanprq_alloc(void);
632
+ extern FrtQuery *frt_spanprq_init(FrtQuery *self, ID field, const char *prefix);
633
+ extern FrtQuery *frt_spanprq_new(ID field, const char *prefix);
603
634
 
604
635
  /***************************************************************************
605
636
  *
@@ -612,15 +643,14 @@ extern FrtQuery *frt_spanprq_new(FrtSymbol field, const char *prefix);
612
643
  (mscorer) = NULL;\
613
644
  } while (0)
614
645
 
615
- struct FrtScorer
616
- {
646
+ struct FrtScorer {
617
647
  FrtSimilarity *similarity;
618
- int doc;
619
- float (*score)(FrtScorer *self);
620
- bool (*next)(FrtScorer *self);
621
- bool (*skip_to)(FrtScorer *self, int doc_num);
648
+ int doc;
649
+ float (*score)(FrtScorer *self);
650
+ bool (*next)(FrtScorer *self);
651
+ bool (*skip_to)(FrtScorer *self, int doc_num);
622
652
  FrtExplanation *(*explain)(FrtScorer *self, int doc_num);
623
- void (*destroy)(FrtScorer *self);
653
+ void (*destroy)(FrtScorer *self);
624
654
  };
625
655
 
626
656
  #define frt_scorer_new(type, similarity) frt_scorer_create(sizeof(type), similarity)
@@ -634,16 +664,15 @@ extern int frt_scorer_doc_cmp(const void *p1, const void *p2);
634
664
  * FrtComparable
635
665
  ***************************************************************************/
636
666
 
637
- typedef struct FrtComparable
638
- {
639
- int type;
667
+ typedef struct FrtComparable {
668
+ int type;
640
669
  union {
641
670
  long l;
642
671
  float f;
643
- char *s;
644
- void *p;
672
+ char *s;
673
+ void *p;
645
674
  } val;
646
- bool reverse : 1;
675
+ bool reverse : 1;
647
676
  } FrtComparable;
648
677
 
649
678
  /***************************************************************************
@@ -652,8 +681,7 @@ typedef struct FrtComparable
652
681
  *
653
682
  ***************************************************************************/
654
683
 
655
- typedef enum
656
- {
684
+ typedef enum {
657
685
  FRT_SORT_TYPE_SCORE,
658
686
  FRT_SORT_TYPE_DOC,
659
687
  FRT_SORT_TYPE_BYTE,
@@ -667,44 +695,54 @@ typedef enum
667
695
  * FrtSortField
668
696
  ***************************************************************************/
669
697
 
670
- typedef struct FrtSortField
671
- {
698
+ typedef struct FrtSortField {
672
699
  const FrtFieldIndexClass *field_index_class;
673
- FrtSymbol field;
674
- SortType type;
675
- bool reverse : 1;
676
- int (*compare)(void *index_ptr, FrtHit *hit1, FrtHit *hit2);
677
- void (*get_val)(void *index_ptr, FrtHit *hit1, FrtComparable *comparable);
700
+ ID field;
701
+ SortType type;
702
+ bool reverse : 1;
703
+ int (*compare)(void *index_ptr, FrtHit *hit1, FrtHit *hit2);
704
+ void (*get_val)(void *index_ptr, FrtHit *hit1, FrtComparable *comparable);
705
+ VALUE rfield;
678
706
  } FrtSortField;
679
707
 
680
- extern FrtSortField *frt_sort_field_new(FrtSymbol field,
681
- SortType type,
682
- bool reverse);
708
+ extern FrtSortField *frt_sort_field_alloc(void);
709
+ extern FrtSortField *frt_sort_field_init(FrtSortField *self, ID field, SortType type, bool reverse);
710
+ extern FrtSortField *frt_sort_field_new(ID field, SortType type, bool reverse);
711
+ extern FrtSortField *frt_sort_field_score_init(FrtSortField *self, bool reverse);
683
712
  extern FrtSortField *frt_sort_field_score_new(bool reverse);
713
+ extern void frt_sort_field_score_get_val(void *index, FrtHit *hit, FrtComparable *comparable);
714
+ extern int frt_sort_field_score_compare(void *index_ptr, FrtHit *hit2, FrtHit *hit1);
715
+ extern FrtSortField *frt_sort_field_doc_init(FrtSortField *self, bool reverse);
684
716
  extern FrtSortField *frt_sort_field_doc_new(bool reverse);
685
- extern FrtSortField *frt_sort_field_int_new(FrtSymbol field, bool reverse);
686
- extern FrtSortField *frt_sort_field_byte_new(FrtSymbol field, bool reverse);
687
- extern FrtSortField *frt_sort_field_float_new(FrtSymbol field, bool reverse);
688
- extern FrtSortField *frt_sort_field_string_new(FrtSymbol field, bool reverse);
689
- extern FrtSortField *frt_sort_field_auto_new(FrtSymbol field, bool reverse);
717
+ extern void frt_sort_field_doc_get_val(void *index, FrtHit *hit, FrtComparable *comparable);
718
+ extern int frt_sort_field_doc_compare(void *index_ptr, FrtHit *hit1, FrtHit *hit2);
719
+ extern FrtSortField *frt_sort_field_int_init(FrtSortField *self, ID field, bool reverse);
720
+ extern FrtSortField *frt_sort_field_int_new(ID field, bool reverse);
721
+ extern FrtSortField *frt_sort_field_byte_init(FrtSortField *self, ID field, bool reverse);
722
+ extern FrtSortField *frt_sort_field_byte_new(ID field, bool reverse);
723
+ extern FrtSortField *frt_sort_field_float_init(FrtSortField *self, ID field, bool reverse);
724
+ extern FrtSortField *frt_sort_field_float_new(ID field, bool reverse);
725
+ extern FrtSortField *frt_sort_field_string_init(FrtSortField *self, ID field, bool reverse);
726
+ extern FrtSortField *frt_sort_field_string_new(ID field, bool reverse);
727
+ extern FrtSortField *frt_sort_field_auto_init(FrtSortField *self, ID field, bool reverse);
728
+ extern FrtSortField *frt_sort_field_auto_new(ID field, bool reverse);
690
729
  extern void frt_sort_field_destroy(void *p);
691
730
  extern char *frt_sort_field_to_s(FrtSortField *self);
692
731
 
693
- extern const FrtSortField FRT_SORT_FIELD_SCORE;
694
- extern const FrtSortField FRT_SORT_FIELD_SCORE_REV;
695
- extern const FrtSortField FRT_SORT_FIELD_DOC;
696
- extern const FrtSortField FRT_SORT_FIELD_DOC_REV;
732
+ extern FrtSortField *FRT_SORT_FIELD_SCORE;
733
+ extern FrtSortField *FRT_SORT_FIELD_SCORE_REV;
734
+ extern FrtSortField *FRT_SORT_FIELD_DOC;
735
+ extern FrtSortField *FRT_SORT_FIELD_DOC_REV;
697
736
 
698
737
  /***************************************************************************
699
738
  * FrtSort
700
739
  ***************************************************************************/
701
740
 
702
- typedef struct FrtSort
703
- {
741
+ typedef struct FrtSort {
704
742
  FrtSortField **sort_fields;
705
- int size;
706
- int capa;
707
- int start;
743
+ int size;
744
+ int capa;
745
+ int start;
708
746
  bool destroy_all : 1;
709
747
  } FrtSort;
710
748
 
@@ -728,10 +766,9 @@ extern FrtHit *frt_fshq_pq_pop_fd(FrtPriorityQueue *pq);
728
766
  * FrtFieldDoc
729
767
  ***************************************************************************/
730
768
 
731
- typedef struct FrtFieldDoc
732
- {
733
- FrtHit hit;
734
- int size;
769
+ typedef struct FrtFieldDoc {
770
+ FrtHit hit;
771
+ int size;
735
772
  FrtComparable comparables[1];
736
773
  } FrtFieldDoc;
737
774
 
@@ -747,38 +784,22 @@ extern bool frt_fdshq_lt(FrtFieldDoc *fd1, FrtFieldDoc *fd2);
747
784
  *
748
785
  ***************************************************************************/
749
786
 
750
- typedef struct FrtPostFilter
751
- {
787
+ typedef struct FrtPostFilter {
752
788
  float (*filter_func)(int doc_num, float score, FrtSearcher *self, void *arg);
753
- void *arg;
789
+ void *arg;
754
790
  } FrtPostFilter;
755
791
 
756
- struct FrtSearcher
757
- {
792
+ struct FrtSearcher {
758
793
  FrtSimilarity *similarity;
759
- int (*doc_freq)(FrtSearcher *self, FrtSymbol field,
760
- const char *term);
794
+ int (*doc_freq)(FrtSearcher *self, ID field, const char *term);
761
795
  FrtDocument *(*get_doc)(FrtSearcher *self, int doc_num);
762
796
  FrtLazyDoc *(*get_lazy_doc)(FrtSearcher *self, int doc_num);
763
- int (*max_doc)(FrtSearcher *self);
797
+ int (*max_doc)(FrtSearcher *self);
764
798
  FrtWeight *(*create_weight)(FrtSearcher *self, FrtQuery *query);
765
- FrtTopDocs *(*search)(FrtSearcher *self, FrtQuery *query, int first_doc,
766
- int num_docs, FrtFilter *filter, FrtSort *sort,
767
- FrtPostFilter *post_filter,
768
- bool load_fields);
769
- FrtTopDocs *(*search_w)(FrtSearcher *self, FrtWeight *weight, int first_doc,
770
- int num_docs, FrtFilter *filter, FrtSort *sort,
771
- FrtPostFilter *post_filter,
772
- bool load_fields);
773
- void (*search_each)(FrtSearcher *self, FrtQuery *query, FrtFilter *filter,
774
- FrtPostFilter *post_filter,
775
- void (*fn)(FrtSearcher *, int, float, void *),
776
- void *arg);
777
- void (*search_each_w)(FrtSearcher *self, FrtWeight *weight,
778
- FrtFilter *filter,
779
- FrtPostFilter *post_filter,
780
- void (*fn)(FrtSearcher *, int, float, void *),
781
- void *arg);
799
+ FrtTopDocs *(*search)(FrtSearcher *self, FrtQuery *query, int first_doc, int num_docs, FrtFilter *filter, FrtSort *sort, FrtPostFilter *post_filter, bool load_fields);
800
+ FrtTopDocs *(*search_w)(FrtSearcher *self, FrtWeight *weight, int first_doc, int num_docs, FrtFilter *filter, FrtSort *sort, FrtPostFilter *post_filter, bool load_fields);
801
+ void (*search_each)(FrtSearcher *self, FrtQuery *query, FrtFilter *filter, FrtPostFilter *post_filter, void (*fn)(FrtSearcher *, int, float, void *), void *arg);
802
+ void (*search_each_w)(FrtSearcher *self, FrtWeight *weight, FrtFilter *filter, FrtPostFilter *post_filter, void (*fn)(FrtSearcher *, int, float, void *), void *arg);
782
803
  /*
783
804
  * Scan the index for all documents that match a query and write the
784
805
  * results to a buffer. It will stop scanning once the limit is reached
@@ -787,23 +808,15 @@ struct FrtSearcher
787
808
  * Note: Unlike the offset_docnum in other search methods, this
788
809
  * offset_docnum refers to document number and not hit.
789
810
  */
790
- int (*search_unscored)(FrtSearcher *searcher,
791
- FrtQuery *query,
792
- int *buf,
793
- int limit,
794
- int offset_docnum);
795
- int (*search_unscored_w)(FrtSearcher *searcher,
796
- FrtWeight *weight,
797
- int *buf,
798
- int limit,
799
- int offset_docnum);
811
+ int (*search_unscored)(FrtSearcher *searcher, FrtQuery *query, int *buf, int limit, int offset_docnum);
812
+ int (*search_unscored_w)(FrtSearcher *searcher, FrtWeight *weight, int *buf, int limit, int offset_docnum);
800
813
  FrtQuery *(*rewrite)(FrtSearcher *self, FrtQuery *original);
801
814
  FrtExplanation *(*explain)(FrtSearcher *self, FrtQuery *query, int doc_num);
802
815
  FrtExplanation *(*explain_w)(FrtSearcher *self, FrtWeight *weight, int doc_num);
803
- FrtTermVector *(*get_term_vector)(FrtSearcher *self, const int doc_num,
804
- FrtSymbol field);
816
+ FrtTermVector *(*get_term_vector)(FrtSearcher *self, const int doc_num, ID field);
805
817
  FrtSimilarity *(*get_similarity)(FrtSearcher *self);
806
- void (*close)(FrtSearcher *self);
818
+ void (*close)(FrtSearcher *self);
819
+ VALUE rsea;
807
820
  };
808
821
 
809
822
  #define frt_searcher_get_doc(s, dn) s->get_doc(s, dn)
@@ -816,14 +829,11 @@ struct FrtSearcher
816
829
  #define frt_searcher_search_each(s, q, filt, ff, fn, arg) s->search_each(s, q, filt, ff, fn, arg)
817
830
  #define frt_searcher_search_unscored(s, q, buf, limit, offset_docnum) s->search_unscored(s, q, buf, limit, offset_docnum)
818
831
 
819
- extern FrtMatchVector *frt_searcher_get_match_vector(FrtSearcher *self,
820
- FrtQuery *query,
821
- const int doc_num,
822
- FrtSymbol field);
832
+ extern FrtMatchVector *frt_searcher_get_match_vector(FrtSearcher *self, FrtQuery *query, const int doc_num, ID field);
823
833
  extern char **frt_searcher_highlight(FrtSearcher *self,
824
834
  FrtQuery *query,
825
835
  const int doc_num,
826
- FrtSymbol field,
836
+ ID field,
827
837
  const int excerpt_len,
828
838
  const int num_excerpts,
829
839
  const char *pre_tag,
@@ -837,15 +847,15 @@ extern char **frt_searcher_highlight(FrtSearcher *self,
837
847
  ***************************************************************************/
838
848
 
839
849
  typedef struct FrtIndexSearcher {
840
- FrtSearcher super;
841
- FrtIndexReader *ir;
842
- bool close_ir : 1;
850
+ FrtSearcher super;
851
+ FrtIndexReader *ir;
852
+ bool close_ir : 1;
843
853
  } FrtIndexSearcher;
844
854
 
855
+ extern FrtSearcher *frt_isea_alloc(void);
856
+ extern FrtSearcher *frt_isea_init(FrtSearcher *self, FrtIndexReader *ir);
845
857
  extern FrtSearcher *frt_isea_new(FrtIndexReader *ir);
846
- extern int frt_isea_doc_freq(FrtSearcher *self, FrtSymbol field, const char *term);
847
-
848
-
858
+ extern int frt_isea_doc_freq(FrtSearcher *self, ID field, const char *term);
849
859
 
850
860
  /***************************************************************************
851
861
  *
@@ -853,16 +863,17 @@ extern int frt_isea_doc_freq(FrtSearcher *self, FrtSymbol field, const char *ter
853
863
  *
854
864
  ***************************************************************************/
855
865
 
856
- typedef struct FrtMultiSearcher
857
- {
858
- FrtSearcher super;
866
+ typedef struct FrtMultiSearcher {
867
+ FrtSearcher super;
859
868
  int s_cnt;
860
- FrtSearcher **searchers;
861
- int *starts;
869
+ FrtSearcher **searchers;
870
+ int *starts;
862
871
  int max_doc;
863
872
  bool close_subs : 1;
864
873
  } FrtMultiSearcher;
865
874
 
875
+ extern FrtSearcher *frt_msea_alloc(void);
876
+ extern FrtSearcher *frt_msea_init(FrtSearcher *self, FrtSearcher **searchers, int s_cnt, bool close_subs);
866
877
  extern FrtSearcher *frt_msea_new(FrtSearcher **searchers, int s_cnt, bool close_subs);
867
878
 
868
879
  /***************************************************************************
@@ -874,48 +885,48 @@ extern FrtSearcher *frt_msea_new(FrtSearcher **searchers, int s_cnt, bool close_
874
885
  #define FRT_QP_CONC_WORDS 2
875
886
  #define FRT_QP_MAX_CLAUSES 512
876
887
  typedef struct FrtFieldStack {
877
- FrtHashSet *fields;
888
+ FrtHashSet *fields;
878
889
  struct FrtFieldStack *next;
879
- bool destroy : 1;
890
+ bool destroy : 1;
880
891
  } FrtFieldStack;
881
892
 
882
- typedef struct FrtQueryParser
883
- {
884
- frt_mutex_t mutex;
885
- int def_slop;
886
- int max_clauses;
887
- int phq_pos_inc;
888
- char *qstr;
889
- char *qstrp;
890
- char buf[FRT_QP_CONC_WORDS][FRT_MAX_WORD_SIZE];
891
- char *dynbuf;
892
- int buf_index;
893
- FrtHashSet *def_fields;
894
- FrtHashSet *all_fields;
895
- FrtHashSet *tokenized_fields;
896
- FrtHashSet *fields;
897
- FrtFieldStack *fields_top;
898
- FrtAnalyzer *analyzer;
899
- FrtHash *ts_cache;
900
- FrtQuery *result;
893
+ typedef struct FrtQueryParser {
894
+ frt_mutex_t mutex;
895
+ int def_slop;
896
+ int max_clauses;
897
+ int phq_pos_inc;
898
+ char *qstr;
899
+ char *qstrp;
900
+ char buf[FRT_QP_CONC_WORDS][FRT_MAX_WORD_SIZE];
901
+ char *dynbuf;
902
+ int buf_index;
903
+ FrtHashSet *def_fields;
904
+ FrtHashSet *all_fields;
905
+ FrtHashSet *tokenized_fields;
906
+ FrtHashSet *fields;
907
+ FrtFieldStack *fields_top;
908
+ FrtAnalyzer *analyzer;
909
+ FrtHash *ts_cache;
910
+ FrtQuery *result;
901
911
  FrtTokenStream *non_tokenizer;
902
- bool or_default : 1;
903
- bool wild_lower : 1;
904
- bool clean_str : 1;
905
- bool handle_parse_errors : 1;
906
- bool allow_any_fields : 1;
907
- bool destruct : 1;
908
- bool recovering : 1;
909
- bool use_keywords : 1;
910
- bool use_typed_range_query : 1;
912
+ bool or_default : 1;
913
+ bool wild_lower : 1;
914
+ bool clean_str : 1;
915
+ bool handle_parse_errors : 1;
916
+ bool allow_any_fields : 1;
917
+ bool destruct : 1;
918
+ bool recovering : 1;
919
+ bool use_keywords : 1;
920
+ bool use_typed_range_query : 1;
911
921
  } FrtQueryParser;
912
922
  typedef FrtQueryParser FrtQParser; /* FrtQParser is an alias for FrtQueryParser */
913
923
 
924
+ extern FrtQParser *frt_qp_alloc(void);
925
+ extern FrtQParser *frt_qp_init(FrtQParser *, FrtAnalyzer *analyzer);
914
926
  extern FrtQParser *frt_qp_new(FrtAnalyzer *analyzer);
915
- extern void frt_qp_add_field(FrtQParser *self, FrtSymbol field,
916
- bool is_default, bool is_tokenized);
927
+ extern void frt_qp_add_field(FrtQParser *self, ID field, bool is_default, bool is_tokenized);
917
928
  extern void frt_qp_destroy(FrtQParser *self);
918
- extern FrtQuery *qp_parse(FrtQParser *self, char *qstr);
929
+ extern FrtQuery *qp_parse(FrtQParser *self, char *qstr, rb_encoding *encoding);
919
930
  extern char *frt_qp_clean_str(char *str);
920
931
 
921
932
  extern float frt_qp_default_fuzzy_min_sim;