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
@@ -155,7 +155,7 @@ void test_compound_io_many_files(TestCase *tc, void *data)
155
155
 
156
156
  TestSuite *ts_compound_io(TestSuite *suite)
157
157
  {
158
- FrtStore *store = frt_open_ram_store();
158
+ FrtStore *store = frt_open_ram_store(NULL);
159
159
 
160
160
  suite = ADD_SUITE(suite);
161
161
 
@@ -6,8 +6,9 @@ void test_df_standard(TestCase *tc, void *data)
6
6
  char *s;
7
7
  FrtDocField *df;
8
8
  (void)data;
9
+ rb_encoding *enc = rb_enc_find("ASCII-8BIT");
9
10
 
10
- df = frt_df_add_data(frt_df_new(rb_intern("title")), frt_estrdup("Life of Pi"));
11
+ df = frt_df_add_data(frt_df_new(rb_intern("title")), frt_estrdup("Life of Pi"), enc);
11
12
  df->destroy_data = true;
12
13
  Aiequal(1, df->size);
13
14
  Asequal("title", rb_id2name(df->name));
@@ -18,7 +19,7 @@ void test_df_standard(TestCase *tc, void *data)
18
19
  free(s);
19
20
  frt_df_destroy(df);
20
21
 
21
- df = frt_df_add_data_len(frt_df_new(rb_intern("title")), (char *)"new title", 9);
22
+ df = frt_df_add_data_len(frt_df_new(rb_intern("title")), (char *)"new title", 9, enc);
22
23
  Aiequal(1, df->size);
23
24
  Asequal("title", rb_id2name(df->name));
24
25
  Asequal("new title", df->data[0]);
@@ -32,20 +33,21 @@ void test_df_multi_fields(TestCase *tc, void *data)
32
33
  char *s;
33
34
  FrtDocField *df;
34
35
  (void)data;
36
+ rb_encoding *enc = rb_enc_find("ASCII-8BIT");
35
37
 
36
- df = frt_df_add_data(frt_df_new(rb_intern("title")), frt_estrdup("Vernon God Little"));
38
+ df = frt_df_add_data(frt_df_new(rb_intern("title")), frt_estrdup("Vernon God Little"), enc);
37
39
  df->destroy_data = true;
38
40
  Aiequal(1, df->size);
39
41
  Asequal("title", rb_id2name(df->name));
40
42
  Asequal("Vernon God Little", df->data[0]);
41
43
  Aiequal(strlen("Vernon God Little"), df->lengths[0]);
42
44
 
43
- frt_df_add_data(df, frt_estrdup("some more data"));
45
+ frt_df_add_data(df, frt_estrdup("some more data"), enc);
44
46
  Aiequal(2, df->size);
45
47
  Asequal("title: [\"Vernon God Little\", \"some more data\"]",
46
48
  s = frt_df_to_s(df));
47
49
  free(s);
48
- frt_df_add_data_len(df, frt_estrdup("and more data"), 14);
50
+ frt_df_add_data_len(df, frt_estrdup("and more data"), 14, enc);
49
51
  Aiequal(3, df->size);
50
52
  Asequal("title", rb_id2name(df->name));
51
53
  Asequal("Vernon God Little", df->data[0]);
@@ -54,13 +56,13 @@ void test_df_multi_fields(TestCase *tc, void *data)
54
56
 
55
57
  frt_df_destroy(df);
56
58
 
57
- df = frt_df_add_data(frt_df_new(rb_intern("data")), frt_estrdup("start"));
59
+ df = frt_df_add_data(frt_df_new(rb_intern("data")), frt_estrdup("start"), enc);
58
60
  df->destroy_data = true;
59
61
  Aiequal(1, df->size);
60
62
  for (i = 0; i < 1000; i++) {
61
63
  char buf[100];
62
64
  sprintf(buf, "<<%d>>", i);
63
- frt_df_add_data(df, frt_estrdup(buf));
65
+ frt_df_add_data(df, frt_estrdup(buf), enc);
64
66
  Aiequal(i + 2, df->size);
65
67
  }
66
68
  frt_df_destroy(df);
@@ -72,14 +74,15 @@ void test_doc(TestCase *tc, void *data)
72
74
  FrtDocument *doc;
73
75
  FrtDocField *df;
74
76
  (void)data;
77
+ rb_encoding *enc = rb_enc_find("ASCII-8BIT");
75
78
 
76
79
  doc = frt_doc_new();
77
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("title")), (char *)"title"));
80
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("title")), (char *)"title", enc));
78
81
  Aiequal(1, doc->size);
79
- df = frt_df_add_data(frt_df_new(rb_intern("data")), (char *)"data1");
80
- frt_df_add_data(df, (char *)"data2");
81
- frt_df_add_data(df, (char *)"data3");
82
- frt_df_add_data(df, (char *)"data4");
82
+ df = frt_df_add_data(frt_df_new(rb_intern("data")), (char *)"data1", enc);
83
+ frt_df_add_data(df, (char *)"data2", enc);
84
+ frt_df_add_data(df, (char *)"data3", enc);
85
+ frt_df_add_data(df, (char *)"data4", enc);
83
86
  frt_doc_add_field(doc, df);
84
87
  Aiequal(2, doc->size);
85
88
  Asequal("title", rb_id2name(frt_doc_get_field(doc, rb_intern("title"))->name));
@@ -100,7 +103,7 @@ void test_doc(TestCase *tc, void *data)
100
103
  char *bufc;
101
104
  sprintf(buf, "<<%d>>", i);
102
105
  bufc = frt_estrdup(buf);
103
- df = frt_df_add_data(frt_df_new(rb_intern(bufc)), bufc);
106
+ df = frt_df_add_data(frt_df_new(rb_intern(bufc)), bufc, enc);
104
107
  df->destroy_data = true;
105
108
  frt_doc_add_field(doc, df);
106
109
  Aiequal(i + 1, doc->size);
@@ -122,12 +125,13 @@ void test_double_field_exception(TestCase *tc, void *data)
122
125
  FrtDocument *doc;
123
126
  FrtDocField *volatile df = NULL;
124
127
  (void)data;
128
+ rb_encoding *enc = rb_enc_find("ASCII-8BIT");
125
129
 
126
130
  doc = frt_doc_new();
127
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("title")), (char *)"title"));
131
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("title")), (char *)"title", enc));
128
132
 
129
133
  FRT_TRY
130
- df = frt_df_add_data_len(frt_df_new(rb_intern("title")), (char *)"title", 5);
134
+ df = frt_df_add_data_len(frt_df_new(rb_intern("title")), (char *)"title", 5, enc);
131
135
  frt_doc_add_field(doc, df);
132
136
  case FRT_EXCEPTION:
133
137
  exception_thrown = true;
@@ -5,8 +5,7 @@
5
5
  static const char *msg1 = "Message One";
6
6
  static const char *msg2 = "Message Two";
7
7
 
8
- static void raise_exception()
9
- {
8
+ static void raise_exception(void) {
10
9
  FRT_RAISE(FRT_EXCEPTION, "%s", msg1);
11
10
  }
12
11
 
@@ -2,10 +2,10 @@
2
2
  #include "test.h"
3
3
 
4
4
  #define do_field_prop_test(tc, fi, name, boost, is_stored,\
5
- is_indexed, is_tokenized, omit_norms,\
5
+ is_compressed, is_indexed, is_tokenized, omit_norms,\
6
6
  store_term_vector, store_positions, store_offsets)\
7
7
  field_prop_test(tc, __LINE__, fi, name, boost, is_stored,\
8
- is_indexed, is_tokenized, omit_norms,\
8
+ is_compressed, is_indexed, is_tokenized, omit_norms,\
9
9
  store_term_vector, store_positions, store_offsets)
10
10
  #define T 1
11
11
  #define F 0
@@ -13,19 +13,20 @@
13
13
  void field_prop_test(TestCase *tc,
14
14
  int line_num,
15
15
  FrtFieldInfo *fi,
16
- FrtSymbol name,
16
+ ID name,
17
17
  float boost,
18
18
  bool is_stored,
19
+ bool is_compressed,
19
20
  bool is_indexed,
20
21
  bool is_tokenized,
21
22
  bool omit_norms,
22
23
  bool store_term_vector,
23
24
  bool store_positions,
24
- bool store_offsets)
25
- {
25
+ bool store_offsets) {
26
26
  tst_ptr_equal(line_num, tc, (void *)name, (void *)fi->name);
27
27
  tst_flt_equal(line_num, tc, boost, fi->boost);
28
28
  tst_int_equal(line_num, tc, is_stored, fi_is_stored(fi));
29
+ tst_int_equal(line_num, tc, is_compressed, fi_is_compressed(fi));
29
30
  tst_int_equal(line_num, tc, is_indexed, fi_is_indexed(fi));
30
31
  tst_int_equal(line_num, tc, is_tokenized, fi_is_tokenized(fi));
31
32
  tst_int_equal(line_num, tc, omit_norms, fi_omit_norms(fi));
@@ -44,18 +45,21 @@ static void test_fi_new(TestCase *tc, void *data)
44
45
  {
45
46
  FrtFieldInfo *fi;
46
47
  (void)data; /* suppress unused argument warning */
47
- fi = frt_fi_new(rb_intern("name"), FRT_STORE_NO, FRT_INDEX_NO, FRT_TERM_VECTOR_NO);
48
- do_field_prop_test(tc, fi, rb_intern("name"), 1.0, F, F, F, F, F, F, F);
48
+ fi = frt_fi_new(rb_intern("name"), FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_NO, FRT_TERM_VECTOR_NO);
49
+ do_field_prop_test(tc, fi, rb_intern("name"), 1.0, F, F, F, F, F, F, F, F);
50
+ frt_fi_deref(fi);
51
+ fi = frt_fi_new(rb_intern("name"), FRT_STORE_YES, FRT_COMPRESSION_NONE, FRT_INDEX_YES, FRT_TERM_VECTOR_YES);
52
+ do_field_prop_test(tc, fi, rb_intern("name"), 1.0, T, F, T, T, F, T, F, F);
49
53
  frt_fi_deref(fi);
50
- fi = frt_fi_new(rb_intern("name"), FRT_STORE_YES, FRT_INDEX_YES, FRT_TERM_VECTOR_YES);
51
- do_field_prop_test(tc, fi, rb_intern("name"), 1.0, T, T, T, F, T, F, F);
54
+ fi = frt_fi_new(rb_intern("name"), FRT_STORE_YES, FRT_COMPRESSION_BROTLI, FRT_INDEX_UNTOKENIZED, FRT_TERM_VECTOR_WITH_POSITIONS);
55
+ do_field_prop_test(tc, fi, rb_intern("name"), 1.0, T, T, T, F, F, T, T, F);
52
56
  frt_fi_deref(fi);
53
- fi = frt_fi_new(rb_intern("name"), FRT_STORE_NO, FRT_INDEX_YES_OMIT_NORMS, FRT_TERM_VECTOR_WITH_OFFSETS);
54
- do_field_prop_test(tc, fi, rb_intern("name"), 1.0, F, T, T, T, T, F, T);
57
+ fi = frt_fi_new(rb_intern("name"), FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_YES_OMIT_NORMS, FRT_TERM_VECTOR_WITH_OFFSETS);
58
+ do_field_prop_test(tc, fi, rb_intern("name"), 1.0, F, F, T, T, T, T, F, T);
55
59
  frt_fi_deref(fi);
56
- fi = frt_fi_new(rb_intern("name"), FRT_STORE_NO, FRT_INDEX_UNTOKENIZED_OMIT_NORMS, FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS);
60
+ fi = frt_fi_new(rb_intern("name"), FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_UNTOKENIZED_OMIT_NORMS, FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS);
57
61
  fi->boost = 1000.0;
58
- do_field_prop_test(tc, fi, rb_intern("name"), 1000.0, F, T, F, T, T, T, T);
62
+ do_field_prop_test(tc, fi, rb_intern("name"), 1000.0, F, F, T, F, T, T, T, T);
59
63
  frt_fi_deref(fi);
60
64
  }
61
65
 
@@ -72,14 +76,14 @@ static void test_fis_basic(TestCase *tc, void *data)
72
76
  volatile bool arg_error = false;
73
77
  (void)data; /* suppress unused argument warning */
74
78
 
75
- fis = frt_fis_new(FRT_STORE_NO, FRT_INDEX_NO, FRT_TERM_VECTOR_NO);
76
- frt_fis_add_field(fis, frt_fi_new(rb_intern("FFFFFFFF"), FRT_STORE_NO, FRT_INDEX_NO, FRT_TERM_VECTOR_NO));
77
- frt_fis_add_field(fis, frt_fi_new(rb_intern("TFTTFTFF"), FRT_STORE_YES, FRT_INDEX_YES, FRT_TERM_VECTOR_YES));
78
- frt_fis_add_field(fis, frt_fi_new(rb_intern("TTTFFTTF"), FRT_STORE_YES, FRT_INDEX_UNTOKENIZED, FRT_TERM_VECTOR_WITH_POSITIONS));
79
- frt_fis_add_field(fis, frt_fi_new(rb_intern("FFTTTTFT"), FRT_STORE_NO, FRT_INDEX_YES_OMIT_NORMS, FRT_TERM_VECTOR_WITH_OFFSETS));
80
- frt_fis_add_field(fis, frt_fi_new(rb_intern("FFTFTTTT"), FRT_STORE_NO, FRT_INDEX_UNTOKENIZED_OMIT_NORMS, FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS));
79
+ fis = frt_fis_new(FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_NO, FRT_TERM_VECTOR_NO);
80
+ frt_fis_add_field(fis, frt_fi_new(rb_intern("FFFFFFFF"), FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_NO, FRT_TERM_VECTOR_NO));
81
+ frt_fis_add_field(fis, frt_fi_new(rb_intern("TFTTFTFF"), FRT_STORE_YES, FRT_COMPRESSION_NONE, FRT_INDEX_YES, FRT_TERM_VECTOR_YES));
82
+ frt_fis_add_field(fis, frt_fi_new(rb_intern("TTTFFTTF"), FRT_STORE_YES, FRT_COMPRESSION_BROTLI, FRT_INDEX_UNTOKENIZED, FRT_TERM_VECTOR_WITH_POSITIONS));
83
+ frt_fis_add_field(fis, frt_fi_new(rb_intern("FFTTTTFT"), FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_YES_OMIT_NORMS, FRT_TERM_VECTOR_WITH_OFFSETS));
84
+ frt_fis_add_field(fis, frt_fi_new(rb_intern("FFTFTTTT"), FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_UNTOKENIZED_OMIT_NORMS, FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS));
81
85
 
82
- fi = frt_fi_new(rb_intern("FFTFTTTT"), FRT_STORE_NO, FRT_INDEX_UNTOKENIZED_OMIT_NORMS, FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS);
86
+ fi = frt_fi_new(rb_intern("FFTFTTTT"), FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_UNTOKENIZED_OMIT_NORMS, FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS);
83
87
  FRT_TRY
84
88
  Apnull(frt_fis_add_field(fis, fi));
85
89
  case FRT_ARG_ERROR:
@@ -113,11 +117,11 @@ static void test_fis_basic(TestCase *tc, void *data)
113
117
  fis->fields[3]->boost = 4.0;
114
118
  fis->fields[4]->boost = 5.0;
115
119
 
116
- do_field_prop_test(tc, fis->fields[0], rb_intern("FFFFFFFF"), 1.0, F, F, F, F, F, F, F);
117
- do_field_prop_test(tc, fis->fields[1], rb_intern("TFTTFTFF"), 2.0, T, T, T, F, T, F, F);
118
- do_field_prop_test(tc, fis->fields[2], rb_intern("TTTFFTTF"), 3.0, T, T, F, F, T, T, F);
119
- do_field_prop_test(tc, fis->fields[3], rb_intern("FFTTTTFT"), 4.0, F, T, T, T, T, F, T);
120
- do_field_prop_test(tc, fis->fields[4], rb_intern("FFTFTTTT"), 5.0, F, T, F, T, T, T, T);
120
+ do_field_prop_test(tc, fis->fields[0], rb_intern("FFFFFFFF"), 1.0, F, F, F, F, F, F, F, F);
121
+ do_field_prop_test(tc, fis->fields[1], rb_intern("TFTTFTFF"), 2.0, T, F, T, T, F, T, F, F);
122
+ do_field_prop_test(tc, fis->fields[2], rb_intern("TTTFFTTF"), 3.0, T, T, T, F, F, T, T, F);
123
+ do_field_prop_test(tc, fis->fields[3], rb_intern("FFTTTTFT"), 4.0, F, F, T, T, T, T, F, T);
124
+ do_field_prop_test(tc, fis->fields[4], rb_intern("FFTFTTTT"), 5.0, F, F, T, F, T, T, T, T);
121
125
 
122
126
  frt_fis_deref(fis);
123
127
  }
@@ -127,27 +131,27 @@ static void test_fis_with_default(TestCase *tc, void *data)
127
131
  FrtFieldInfos *fis;
128
132
  (void)data; /* suppress unused argument warning */
129
133
 
130
- fis = frt_fis_new(FRT_STORE_NO, FRT_INDEX_NO, FRT_TERM_VECTOR_NO);
131
- do_field_prop_test(tc, frt_fis_get_or_add_field(fis, rb_intern("name")), rb_intern("name"), 1.0, F, F, F, F, F, F, F);
132
- do_field_prop_test(tc, frt_fis_get_or_add_field(fis, rb_intern("dave")), rb_intern("dave"), 1.0, F, F, F, F, F, F, F);
133
- do_field_prop_test(tc, frt_fis_get_or_add_field(fis, rb_intern("wert")), rb_intern("wert"), 1.0, F, F, F, F, F, F, F);
134
- do_field_prop_test(tc, fis->fields[0], rb_intern("name"), 1.0, F, F, F, F, F, F, F);
135
- do_field_prop_test(tc, fis->fields[1], rb_intern("dave"), 1.0, F, F, F, F, F, F, F);
136
- do_field_prop_test(tc, fis->fields[2], rb_intern("wert"), 1.0, F, F, F, F, F, F, F);
134
+ fis = frt_fis_new(FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_NO, FRT_TERM_VECTOR_NO);
135
+ do_field_prop_test(tc, frt_fis_get_or_add_field(fis, rb_intern("name")), rb_intern("name"), 1.0, F, F, F, F, F, F, F, F);
136
+ do_field_prop_test(tc, frt_fis_get_or_add_field(fis, rb_intern("dave")), rb_intern("dave"), 1.0, F, F, F, F, F, F, F, F);
137
+ do_field_prop_test(tc, frt_fis_get_or_add_field(fis, rb_intern("wert")), rb_intern("wert"), 1.0, F, F, F, F, F, F, F, F);
138
+ do_field_prop_test(tc, fis->fields[0], rb_intern("name"), 1.0, F, F, F, F, F, F, F, F);
139
+ do_field_prop_test(tc, fis->fields[1], rb_intern("dave"), 1.0, F, F, F, F, F, F, F, F);
140
+ do_field_prop_test(tc, fis->fields[2], rb_intern("wert"), 1.0, F, F, F, F, F, F, F, F);
137
141
  Apnull(frt_fis_get_field(fis, rb_intern("random")));
138
142
  frt_fis_deref(fis);
139
143
 
140
- fis = frt_fis_new(FRT_STORE_YES, FRT_INDEX_YES, FRT_TERM_VECTOR_YES);
141
- do_field_prop_test(tc, frt_fis_get_or_add_field(fis, rb_intern("name")), rb_intern("name"), 1.0, T, T, T, F, T, F, F);
144
+ fis = frt_fis_new(FRT_STORE_YES, FRT_COMPRESSION_NONE, FRT_INDEX_YES, FRT_TERM_VECTOR_YES);
145
+ do_field_prop_test(tc, frt_fis_get_or_add_field(fis, rb_intern("name")), rb_intern("name"), 1.0, T, F, T, T, F, T, F, F);
142
146
  frt_fis_deref(fis);
143
- fis = frt_fis_new(FRT_STORE_YES, FRT_INDEX_UNTOKENIZED, FRT_TERM_VECTOR_WITH_POSITIONS);
144
- do_field_prop_test(tc, frt_fis_get_or_add_field(fis, rb_intern("name")), rb_intern("name"), 1.0, T, T, F, F, T, T, F);
147
+ fis = frt_fis_new(FRT_STORE_YES, FRT_COMPRESSION_BROTLI, FRT_INDEX_UNTOKENIZED, FRT_TERM_VECTOR_WITH_POSITIONS);
148
+ do_field_prop_test(tc, frt_fis_get_or_add_field(fis, rb_intern("name")), rb_intern("name"), 1.0, T, T, T, F, F, T, T, F);
145
149
  frt_fis_deref(fis);
146
- fis = frt_fis_new(FRT_STORE_NO, FRT_INDEX_YES_OMIT_NORMS, FRT_TERM_VECTOR_WITH_OFFSETS);
147
- do_field_prop_test(tc, frt_fis_get_or_add_field(fis, rb_intern("name")), rb_intern("name"), 1.0, F, T, T, T, T, F, T);
150
+ fis = frt_fis_new(FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_YES_OMIT_NORMS, FRT_TERM_VECTOR_WITH_OFFSETS);
151
+ do_field_prop_test(tc, frt_fis_get_or_add_field(fis, rb_intern("name")), rb_intern("name"), 1.0, F, F, T, T, T, T, F, T);
148
152
  frt_fis_deref(fis);
149
- fis = frt_fis_new(FRT_STORE_NO, FRT_INDEX_UNTOKENIZED_OMIT_NORMS, FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS);
150
- do_field_prop_test(tc, frt_fis_get_or_add_field(fis, rb_intern("name")), rb_intern("name"), 1.0, F, T, F, T, T, T, T);
153
+ fis = frt_fis_new(FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_UNTOKENIZED_OMIT_NORMS, FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS);
154
+ do_field_prop_test(tc, frt_fis_get_or_add_field(fis, rb_intern("name")), rb_intern("name"), 1.0, F, F, T, F, T, T, T, T);
151
155
  frt_fis_deref(fis);
152
156
  }
153
157
 
@@ -155,31 +159,31 @@ static void test_fis_rw(TestCase *tc, void *data)
155
159
  {
156
160
  char *str;
157
161
  FrtFieldInfos *fis;
158
- FrtStore *store = frt_open_ram_store();
162
+ FrtStore *store = frt_open_ram_store(NULL);
159
163
  FrtInStream *is;
160
164
  FrtOutStream *os;
161
165
  (void)data; /* suppress unused argument warning */
162
166
 
163
- fis = frt_fis_new(FRT_STORE_YES, FRT_INDEX_UNTOKENIZED_OMIT_NORMS,
164
- FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS);
165
- frt_fis_add_field(fis, frt_fi_new(rb_intern("FFFFFFFF"), FRT_STORE_NO, FRT_INDEX_NO, FRT_TERM_VECTOR_NO));
166
- frt_fis_add_field(fis, frt_fi_new(rb_intern("TFTTFTFF"), FRT_STORE_YES, FRT_INDEX_YES, FRT_TERM_VECTOR_YES));
167
- frt_fis_add_field(fis, frt_fi_new(rb_intern("FFTTTTFT"), FRT_STORE_NO, FRT_INDEX_YES_OMIT_NORMS, FRT_TERM_VECTOR_WITH_OFFSETS));
168
- frt_fis_add_field(fis, frt_fi_new(rb_intern("FFTFTTTT"), FRT_STORE_NO, FRT_INDEX_UNTOKENIZED_OMIT_NORMS, FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS));
169
- fis->fields[0]->boost = 2.0;
170
- fis->fields[1]->boost = 3.0;
171
- fis->fields[2]->boost = 4.0;
172
- fis->fields[3]->boost = 5.0;
167
+ fis = frt_fis_new(FRT_STORE_YES, FRT_COMPRESSION_NONE, FRT_INDEX_UNTOKENIZED_OMIT_NORMS, FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS);
168
+ frt_fis_add_field(fis, frt_fi_new(rb_intern("FFFFFFFF"), FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_NO, FRT_TERM_VECTOR_NO));
169
+ frt_fis_add_field(fis, frt_fi_new(rb_intern("TFTTFTFF"), FRT_STORE_YES, FRT_COMPRESSION_NONE, FRT_INDEX_YES, FRT_TERM_VECTOR_YES));
170
+ frt_fis_add_field(fis, frt_fi_new(rb_intern("TTTFFTTF"), FRT_STORE_YES, FRT_COMPRESSION_BROTLI, FRT_INDEX_UNTOKENIZED, FRT_TERM_VECTOR_WITH_POSITIONS));
171
+ frt_fis_add_field(fis, frt_fi_new(rb_intern("FFTTTTFT"), FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_YES_OMIT_NORMS, FRT_TERM_VECTOR_WITH_OFFSETS));
172
+ frt_fis_add_field(fis, frt_fi_new(rb_intern("FFTFTTTT"), FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_UNTOKENIZED_OMIT_NORMS, FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS));
173
+ fis->fields[1]->boost = 2.0;
174
+ fis->fields[2]->boost = 3.0;
175
+ fis->fields[3]->boost = 4.0;
176
+ fis->fields[4]->boost = 5.0;
173
177
  os = store->new_output(store, "fields");
174
178
  frt_fis_write(fis, os);
175
179
  frt_os_close(os);
176
180
 
177
181
  /* these fields won't be saved be will added again later */
178
- Aiequal(4, fis->size);
179
- do_field_prop_test(tc, frt_fis_get_or_add_field(fis, rb_intern("new_field")), rb_intern("new_field"), 1.0, T, T, F, T, T, T, T);
180
182
  Aiequal(5, fis->size);
181
- do_field_prop_test(tc, frt_fis_get_or_add_field(fis, rb_intern("another")), rb_intern("another"), 1.0, T, T, F, T, T, T, T);
183
+ do_field_prop_test(tc, frt_fis_get_or_add_field(fis, rb_intern("new_field")), rb_intern("new_field"), 1.0, T, F, T, F, T, T, T, T);
182
184
  Aiequal(6, fis->size);
185
+ do_field_prop_test(tc, frt_fis_get_or_add_field(fis, rb_intern("another")), rb_intern("another"), 1.0, T, F, T, F, T, T, T, T);
186
+ Aiequal(7, fis->size);
183
187
 
184
188
  frt_fis_deref(fis);
185
189
 
@@ -190,15 +194,16 @@ static void test_fis_rw(TestCase *tc, void *data)
190
194
  Aiequal(FRT_INDEX_UNTOKENIZED_OMIT_NORMS, fis->index);
191
195
  Aiequal(FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS, fis->term_vector);
192
196
 
193
- do_field_prop_test(tc, fis->fields[0], rb_intern("FFFFFFFF"), 2.0, F, F, F, F, F, F, F);
194
- do_field_prop_test(tc, fis->fields[1], rb_intern("TFTTFTFF"), 3.0, T, T, T, F, T, F, F);
195
- do_field_prop_test(tc, fis->fields[2], rb_intern("FFTTTTFT"), 4.0, F, T, T, T, T, F, T);
196
- do_field_prop_test(tc, fis->fields[3], rb_intern("FFTFTTTT"), 5.0, F, T, F, T, T, T, T);
197
- Aiequal(4, fis->size);
198
- do_field_prop_test(tc, frt_fis_get_or_add_field(fis, rb_intern("new_field")), rb_intern("new_field"), 1.0, T, T, F, T, T, T, T);
197
+ do_field_prop_test(tc, fis->fields[0], rb_intern("FFFFFFFF"), 1.0, F, F, F, F, F, F, F, F);
198
+ do_field_prop_test(tc, fis->fields[1], rb_intern("TFTTFTFF"), 2.0, T, F, T, T, F, T, F, F);
199
+ do_field_prop_test(tc, fis->fields[2], rb_intern("TTTFFTTF"), 3.0, T, T, T, F, F, T, T, F);
200
+ do_field_prop_test(tc, fis->fields[3], rb_intern("FFTTTTFT"), 4.0, F, F, T, T, T, T, F, T);
201
+ do_field_prop_test(tc, fis->fields[4], rb_intern("FFTFTTTT"), 5.0, F, F, T, F, T, T, T, T);
199
202
  Aiequal(5, fis->size);
200
- do_field_prop_test(tc, frt_fis_get_or_add_field(fis, rb_intern("another")), rb_intern("another"), 1.0, T, T, F, T, T, T, T);
203
+ do_field_prop_test(tc, frt_fis_get_or_add_field(fis, rb_intern("new_field")), rb_intern("new_field"), 1.0, T, F, T, F, T, T, T, T);
201
204
  Aiequal(6, fis->size);
205
+ do_field_prop_test(tc, frt_fis_get_or_add_field(fis, rb_intern("another")), rb_intern("another"), 1.0, T, F, T, F, T, T, T, T);
206
+ Aiequal(7, fis->size);
202
207
  str = frt_fis_to_s(fis);
203
208
  Asequal("default:\n"
204
209
  " store: :yes\n"
@@ -206,15 +211,20 @@ static void test_fis_rw(TestCase *tc, void *data)
206
211
  " term_vector: :with_positions_offsets\n"
207
212
  "fields:\n"
208
213
  " FFFFFFFF:\n"
209
- " boost: 2.000000\n"
214
+ " boost: 1.000000\n"
210
215
  " store: :no\n"
211
216
  " index: :no\n"
212
217
  " term_vector: :no\n"
213
218
  " TFTTFTFF:\n"
214
- " boost: 3.000000\n"
219
+ " boost: 2.000000\n"
215
220
  " store: :yes\n"
216
221
  " index: :yes\n"
217
222
  " term_vector: :yes\n"
223
+ " TTTFFTTF:\n"
224
+ " boost: 3.000000\n"
225
+ " store: :compressed\n"
226
+ " index: :untokenized\n"
227
+ " term_vector: :with_positions\n"
218
228
  " FFTTTTFT:\n"
219
229
  " boost: 4.000000\n"
220
230
  " store: :no\n"
@@ -270,45 +280,44 @@ static char *prepare_bin_data(int len)
270
280
  Assert(memcmp(mdata, df->data[index], mlen) == 0, "Data should be equal");\
271
281
  } while (0)
272
282
 
273
- static FrtDocument *prepare_doc()
274
- {
283
+ static FrtDocument *prepare_doc(void) {
275
284
  FrtDocument *doc = frt_doc_new();
276
285
  FrtDocField *df;
277
286
  char *bin_data = prepare_bin_data(BIN_DATA_LEN);
287
+ rb_encoding *enc = rb_enc_find("ASCII-8BIT");
278
288
 
279
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("ignored")), (char *)"this fld's ignored"));
280
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("unstored")), (char *)"unstored ignored"));
281
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("stored")), (char *)"Yay, a stored field"));
282
- df = frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("stored_array")), (char *)"one"));
289
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("ignored")), (char *)"this fld's ignored", enc));
290
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("unstored")), (char *)"unstored ignored", enc));
291
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("stored")), (char *)"Yay, a stored field", enc));
292
+ df = frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("stored_array")), (char *)"one", enc));
283
293
  df->destroy_data = false;
284
- frt_df_add_data(df, (char *)"two");
285
- frt_df_add_data(df, (char *)"three");
286
- frt_df_add_data(df, (char *)"four");
287
- frt_df_add_data_len(df, bin_data, BIN_DATA_LEN);
294
+ frt_df_add_data(df, (char *)"two", enc);
295
+ frt_df_add_data(df, (char *)"three", enc);
296
+ frt_df_add_data(df, (char *)"four", enc);
297
+ frt_df_add_data_len(df, bin_data, BIN_DATA_LEN, enc);
288
298
  frt_doc_add_field(doc, frt_df_add_data_len(frt_df_new(rb_intern("binary")), bin_data,
289
- BIN_DATA_LEN))->destroy_data = true;
290
- df = frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("array")), (char *)"ichi"));
291
- frt_df_add_data(df, (char *)"ni");
292
- frt_df_add_data(df, (char *)"san");
293
- frt_df_add_data(df, (char *)"yon");
294
- frt_df_add_data(df, (char *)"go");
299
+ BIN_DATA_LEN, enc))->destroy_data = true;
300
+ df = frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("array")), (char *)"ichi", enc));
301
+ frt_df_add_data(df, (char *)"ni", enc);
302
+ frt_df_add_data(df, (char *)"san", enc);
303
+ frt_df_add_data(df, (char *)"yon", enc);
304
+ frt_df_add_data(df, (char *)"go", enc);
295
305
 
296
306
  return doc;
297
307
  }
298
308
 
299
- static FrtFieldInfos *prepare_fis()
300
- {
301
- FrtFieldInfos *fis = frt_fis_new(FRT_STORE_YES, FRT_INDEX_YES, FRT_TERM_VECTOR_NO);
302
- frt_fis_add_field(fis, frt_fi_new(rb_intern("ignored"), FRT_STORE_NO, FRT_INDEX_NO, FRT_TERM_VECTOR_NO));
303
- frt_fis_add_field(fis, frt_fi_new(rb_intern("unstored"), FRT_STORE_NO, FRT_INDEX_YES, FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS));
304
- frt_fis_add_field(fis, frt_fi_new(rb_intern("stored"), FRT_STORE_YES, FRT_INDEX_YES, FRT_TERM_VECTOR_YES));
305
- frt_fis_add_field(fis, frt_fi_new(rb_intern("stored_array"), FRT_STORE_YES, FRT_INDEX_UNTOKENIZED, FRT_TERM_VECTOR_NO));
309
+ static FrtFieldInfos *prepare_fis(void) {
310
+ FrtFieldInfos *fis = frt_fis_new(FRT_STORE_YES, FRT_COMPRESSION_NONE, FRT_INDEX_YES, FRT_TERM_VECTOR_NO);
311
+ frt_fis_add_field(fis, frt_fi_new(rb_intern("ignored"), FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_NO, FRT_TERM_VECTOR_NO));
312
+ frt_fis_add_field(fis, frt_fi_new(rb_intern("unstored"), FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_YES, FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS));
313
+ frt_fis_add_field(fis, frt_fi_new(rb_intern("stored"), FRT_STORE_YES, FRT_COMPRESSION_NONE, FRT_INDEX_YES, FRT_TERM_VECTOR_YES));
314
+ frt_fis_add_field(fis, frt_fi_new(rb_intern("stored_array"), FRT_STORE_YES, FRT_COMPRESSION_BROTLI, FRT_INDEX_UNTOKENIZED, FRT_TERM_VECTOR_NO));
306
315
  return fis;
307
316
  }
308
317
 
309
318
  static void test_fields_rw_single(TestCase *tc, void *data)
310
319
  {
311
- FrtStore *store = frt_open_ram_store();
320
+ FrtStore *store = frt_open_ram_store(NULL);
312
321
  char *bin_data = prepare_bin_data(BIN_DATA_LEN);
313
322
  FrtDocument *doc = prepare_doc();
314
323
  FrtFieldInfos *fis = prepare_fis();
@@ -327,8 +336,8 @@ static void test_fields_rw_single(TestCase *tc, void *data)
327
336
  frt_doc_destroy(doc);
328
337
 
329
338
  Aiequal(6, fis->size);
330
- do_field_prop_test(tc, frt_fis_get_field(fis, rb_intern("binary")), rb_intern("binary"), 1.0, T, T, T, F, F, F, F);
331
- do_field_prop_test(tc, frt_fis_get_field(fis, rb_intern("array")), rb_intern("array"), 1.0, T, T, T, F, F, F, F);
339
+ do_field_prop_test(tc, frt_fis_get_field(fis, rb_intern("binary")), rb_intern("binary"), 1.0, T, F, T, T, F, F, F, F);
340
+ do_field_prop_test(tc, frt_fis_get_field(fis, rb_intern("array")), rb_intern("array"), 1.0, T, F, T, T, F, F, F, F);
332
341
 
333
342
  fr = frt_fr_open(store, "_0", fis);
334
343
  doc = frt_fr_get_doc(fr, 0);
@@ -372,7 +381,7 @@ static void test_fields_rw_single(TestCase *tc, void *data)
372
381
  static void test_fields_rw_multi(TestCase *tc, void *data)
373
382
  {
374
383
  int i;
375
- FrtStore *store = frt_open_ram_store();
384
+ FrtStore *store = frt_open_ram_store(NULL);
376
385
  char *bin_data = prepare_bin_data(BIN_DATA_LEN);
377
386
  FrtDocument *doc;
378
387
  FrtFieldInfos *fis = prepare_fis();
@@ -380,6 +389,7 @@ static void test_fields_rw_multi(TestCase *tc, void *data)
380
389
  FrtFieldsReader *fr;
381
390
  FrtDocField *df;
382
391
  (void)data;
392
+ rb_encoding *enc = rb_enc_find("ASCII-8BIT");
383
393
 
384
394
  fw = frt_fw_open(store, "_as3", fis);
385
395
  for (i = 0; i < 100; i++) {
@@ -388,7 +398,7 @@ static void test_fields_rw_multi(TestCase *tc, void *data)
388
398
  sprintf(buf, "<<%d>>", i);
389
399
  bufc = frt_estrdup(buf);
390
400
  doc = frt_doc_new();
391
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern(bufc)), bufc));
401
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern(bufc)), bufc, enc));
392
402
  frt_fw_add_doc(fw, doc);
393
403
  frt_fw_write_tv_index(fw);
394
404
  frt_doc_destroy(doc);
@@ -401,12 +411,12 @@ static void test_fields_rw_multi(TestCase *tc, void *data)
401
411
  frt_fw_close(fw);
402
412
 
403
413
  Aiequal(106, fis->size);
404
- do_field_prop_test(tc, frt_fis_get_field(fis, rb_intern("binary")), rb_intern("binary"), 1.0, T, T, T, F, F, F, F);
405
- do_field_prop_test(tc, frt_fis_get_field(fis, rb_intern("array")), rb_intern("array"), 1.0, T, T, T, F, F, F, F);
414
+ do_field_prop_test(tc, frt_fis_get_field(fis, rb_intern("binary")), rb_intern("binary"), 1.0, T, F, T, T, F, F, F, F);
415
+ do_field_prop_test(tc, frt_fis_get_field(fis, rb_intern("array")), rb_intern("array"), 1.0, T, F, T, T, F, F, F, F);
406
416
  for (i = 0; i < 100; i++) {
407
417
  char buf[100];
408
418
  sprintf(buf, "<<%d>>", i);
409
- do_field_prop_test(tc, frt_fis_get_field(fis, rb_intern(buf)), rb_intern(buf), 1.0, T, T, T, F, F, F, F);
419
+ do_field_prop_test(tc, frt_fis_get_field(fis, rb_intern(buf)), rb_intern(buf), 1.0, T, F, T, T, F, F, F, F);
410
420
  }
411
421
 
412
422
  fr = frt_fr_open(store, "_as3", fis);
@@ -450,7 +460,7 @@ static void test_fields_rw_multi(TestCase *tc, void *data)
450
460
 
451
461
  static void test_lazy_field_loading(TestCase *tc, void *data)
452
462
  {
453
- FrtStore *store = frt_open_ram_store();
463
+ FrtStore *store = frt_open_ram_store(NULL);
454
464
  FrtDocument *doc;
455
465
  FrtFieldInfos *fis = prepare_fis();
456
466
  FrtFieldsWriter *fw;
@@ -460,15 +470,16 @@ static void test_lazy_field_loading(TestCase *tc, void *data)
460
470
  FrtLazyDocField *lazy_df;
461
471
  char *text, buf[1000];
462
472
  (void)data;
473
+ rb_encoding *enc = rb_enc_find("ASCII-8BIT");
463
474
 
464
475
  fw = frt_fw_open(store, "_as3", fis);
465
476
  doc = frt_doc_new();
466
477
  df = frt_df_new(rb_intern("stored"));
467
- frt_df_add_data(df, (char *)"this is a stored field");
468
- frt_df_add_data(df, (char *)"to be or not to be");
469
- frt_df_add_data(df, (char *)"a stitch in time, saves nine");
470
- frt_df_add_data(df, (char *)"the quick brown fox jumped over the lazy dog");
471
- frt_df_add_data(df, (char *)"that's it folks");
478
+ frt_df_add_data(df, (char *)"this is a stored field", enc);
479
+ frt_df_add_data(df, (char *)"to be or not to be", enc);
480
+ frt_df_add_data(df, (char *)"a stitch in time, saves nine", enc);
481
+ frt_df_add_data(df, (char *)"the quick brown fox jumped over the lazy dog", enc);
482
+ frt_df_add_data(df, (char *)"that's it folks", enc);
472
483
  frt_doc_add_field(doc, df);
473
484
  frt_fw_add_doc(fw, doc);
474
485
  frt_fw_write_tv_index(fw);
@@ -18,9 +18,8 @@ const FrtConfig lucene_config = {
18
18
  };
19
19
 
20
20
 
21
- static FrtFieldInfos *prep_fis()
22
- {
23
- return frt_fis_new(FRT_STORE_NO, FRT_INDEX_YES, FRT_TERM_VECTOR_NO);
21
+ static FrtFieldInfos *prep_fis(void) {
22
+ return frt_fis_new(FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_YES, FRT_TERM_VECTOR_NO);
24
23
  }
25
24
 
26
25
  static void create_index(FrtStore *store)
@@ -30,37 +29,21 @@ static void create_index(FrtStore *store)
30
29
  frt_fis_deref(fis);
31
30
  }
32
31
 
33
- /*
34
- static FrtIndexWriter *create_iw(FrtStore *store)
35
- {
36
- create_index(store);
37
- return frt_iw_open(store, frt_whitespace_analyzer_new(false), &frt_default_config);
38
- }
39
-
40
- static FrtIndexWriter *create_iw_conf(FrtStore *store, int max_buffered_docs,
41
- int merge_factor)
42
- {
43
- FrtConfig config = frt_default_config;
44
- config.max_buffered_docs = max_buffered_docs;
45
- config.merge_factor = merge_factor;
46
- create_index(store);
47
- return frt_iw_open(store, frt_whitespace_analyzer_new(false), &config);
48
- }
49
- */
50
-
51
32
  static FrtIndexWriter *create_iw_lucene(FrtStore *store)
52
33
  {
53
34
  create_index(store);
54
- return frt_iw_open(store, frt_whitespace_analyzer_new(false), &lucene_config);
35
+ return frt_iw_open(NULL, store, frt_whitespace_analyzer_new(false), &lucene_config);
55
36
  }
56
37
 
57
38
  static void add_doc(FrtIndexWriter *iw, int id)
58
39
  {
59
40
  FrtDocument *doc = frt_doc_new();
41
+ rb_encoding *enc = rb_enc_find("ASCII-8BIT");
42
+
60
43
  frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern(content_f)),
61
- frt_estrdup("aaa")))->destroy_data = true;
44
+ frt_estrdup("aaa"), enc))->destroy_data = true;
62
45
  frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern(id_f)),
63
- frt_strfmt("%d", id)))->destroy_data = true;
46
+ frt_strfmt("%d", id), enc))->destroy_data = true;
64
47
  frt_iw_add_doc(iw, doc);
65
48
  frt_doc_destroy(doc);
66
49
  }
@@ -96,7 +79,7 @@ static void test_delete_leftover_files(TestCase *tc, void *data)
96
79
  frt_iw_close(iw);
97
80
 
98
81
  /* Delete one doc so we get a .del file: */
99
- ir = frt_ir_open(store);
82
+ ir = frt_ir_open(NULL, store);
100
83
  frt_ir_delete_doc(ir, 7);
101
84
  Aiequal(1, ir->max_doc(ir) - ir->num_docs(ir));
102
85
 
@@ -158,7 +141,7 @@ static void test_delete_leftover_files(TestCase *tc, void *data)
158
141
 
159
142
 
160
143
  /* Open & close a writer: should delete the above files and nothing more: */
161
- frt_iw_close(frt_iw_open(store, frt_whitespace_analyzer_new(false), &lucene_config));
144
+ frt_iw_close(frt_iw_open(NULL, store, frt_whitespace_analyzer_new(false), &lucene_config));
162
145
 
163
146
  store_after = frt_store_to_s(store);
164
147
 
@@ -175,7 +158,7 @@ static void test_delete_leftover_files(TestCase *tc, void *data)
175
158
 
176
159
  TestSuite *ts_file_deleter(TestSuite *suite)
177
160
  {
178
- FrtStore *store = frt_open_ram_store();
161
+ FrtStore *store = frt_open_ram_store(NULL);
179
162
  suite = ADD_SUITE(suite);
180
163
 
181
164
  tst_run_test(suite, test_delete_leftover_files, store);