isomorfeus-ferret 0.17.2 → 0.17.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/ext/isomorfeus_ferret_ext/benchmark.c +9 -20
  3. data/ext/isomorfeus_ferret_ext/benchmarks_all.h +1 -2
  4. data/ext/isomorfeus_ferret_ext/bm_hash.c +1 -2
  5. data/ext/isomorfeus_ferret_ext/brotli_dec_decode.c +4 -2
  6. data/ext/isomorfeus_ferret_ext/brotli_enc_encode.c +3 -2
  7. data/ext/isomorfeus_ferret_ext/frb_analysis.c +4 -5
  8. data/ext/isomorfeus_ferret_ext/frb_field_info.c +3 -4
  9. data/ext/isomorfeus_ferret_ext/frb_index.c +118 -125
  10. data/ext/isomorfeus_ferret_ext/frb_lazy_doc.c +14 -16
  11. data/ext/isomorfeus_ferret_ext/frb_search.c +31 -23
  12. data/ext/isomorfeus_ferret_ext/frb_store.c +27 -13
  13. data/ext/isomorfeus_ferret_ext/frb_utils.c +3 -6
  14. data/ext/isomorfeus_ferret_ext/frt_analysis.c +39 -46
  15. data/ext/isomorfeus_ferret_ext/frt_analysis.h +9 -9
  16. data/ext/isomorfeus_ferret_ext/frt_array.c +11 -22
  17. data/ext/isomorfeus_ferret_ext/frt_bitvector.h +3 -6
  18. data/ext/isomorfeus_ferret_ext/frt_doc_field.c +87 -0
  19. data/ext/isomorfeus_ferret_ext/frt_doc_field.h +26 -0
  20. data/ext/isomorfeus_ferret_ext/frt_document.c +4 -97
  21. data/ext/isomorfeus_ferret_ext/frt_document.h +2 -27
  22. data/ext/isomorfeus_ferret_ext/frt_except.c +8 -6
  23. data/ext/isomorfeus_ferret_ext/frt_except.h +1 -2
  24. data/ext/isomorfeus_ferret_ext/frt_field_index.c +13 -32
  25. data/ext/isomorfeus_ferret_ext/frt_field_index.h +0 -6
  26. data/ext/isomorfeus_ferret_ext/frt_field_info.c +69 -0
  27. data/ext/isomorfeus_ferret_ext/frt_field_info.h +49 -0
  28. data/ext/isomorfeus_ferret_ext/frt_field_infos.c +196 -0
  29. data/ext/isomorfeus_ferret_ext/frt_field_infos.h +35 -0
  30. data/ext/isomorfeus_ferret_ext/frt_global.c +10 -4
  31. data/ext/isomorfeus_ferret_ext/frt_global.h +11 -15
  32. data/ext/isomorfeus_ferret_ext/frt_hash.c +8 -8
  33. data/ext/isomorfeus_ferret_ext/frt_hash.h +1 -2
  34. data/ext/isomorfeus_ferret_ext/frt_hashset.c +20 -40
  35. data/ext/isomorfeus_ferret_ext/frt_hashset.h +1 -2
  36. data/ext/isomorfeus_ferret_ext/frt_helper.c +7 -15
  37. data/ext/isomorfeus_ferret_ext/frt_in_stream.c +35 -45
  38. data/ext/isomorfeus_ferret_ext/frt_in_stream.h +3 -2
  39. data/ext/isomorfeus_ferret_ext/frt_ind.c +20 -38
  40. data/ext/isomorfeus_ferret_ext/frt_index.c +292 -790
  41. data/ext/isomorfeus_ferret_ext/frt_index.h +1 -102
  42. data/ext/isomorfeus_ferret_ext/frt_lang.c +5 -10
  43. data/ext/isomorfeus_ferret_ext/frt_lazy_doc.c +3 -3
  44. data/ext/isomorfeus_ferret_ext/frt_lazy_doc.h +1 -1
  45. data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.c +18 -25
  46. data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.h +5 -5
  47. data/ext/isomorfeus_ferret_ext/frt_mdbx_store.c +102 -70
  48. data/ext/isomorfeus_ferret_ext/frt_mempool.c +8 -16
  49. data/ext/isomorfeus_ferret_ext/frt_multimapper.c +23 -46
  50. data/ext/isomorfeus_ferret_ext/frt_multimapper.h +4 -8
  51. data/ext/isomorfeus_ferret_ext/frt_out_stream.c +31 -43
  52. data/ext/isomorfeus_ferret_ext/frt_out_stream.h +2 -2
  53. data/ext/isomorfeus_ferret_ext/frt_posh.c +6 -819
  54. data/ext/isomorfeus_ferret_ext/frt_posh.h +0 -57
  55. data/ext/isomorfeus_ferret_ext/frt_priorityqueue.c +11 -22
  56. data/ext/isomorfeus_ferret_ext/frt_priorityqueue.h +1 -2
  57. data/ext/isomorfeus_ferret_ext/frt_q_boolean.c +85 -171
  58. data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +8 -16
  59. data/ext/isomorfeus_ferret_ext/frt_q_multi_term.c +1 -2
  60. data/ext/isomorfeus_ferret_ext/frt_q_parser.c +49 -98
  61. data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +52 -104
  62. data/ext/isomorfeus_ferret_ext/frt_q_range.c +6 -12
  63. data/ext/isomorfeus_ferret_ext/frt_q_span.c +113 -226
  64. data/ext/isomorfeus_ferret_ext/frt_q_wildcard.c +1 -2
  65. data/ext/isomorfeus_ferret_ext/frt_ram_store.c +134 -85
  66. data/ext/isomorfeus_ferret_ext/frt_search.c +82 -164
  67. data/ext/isomorfeus_ferret_ext/frt_similarity.c +11 -22
  68. data/ext/isomorfeus_ferret_ext/frt_similarity.h +1 -2
  69. data/ext/isomorfeus_ferret_ext/frt_store.c +13 -25
  70. data/ext/isomorfeus_ferret_ext/frt_store.h +86 -52
  71. data/ext/isomorfeus_ferret_ext/frt_term_vectors.c +8 -16
  72. data/ext/isomorfeus_ferret_ext/frt_win32.h +5 -10
  73. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +12 -11
  74. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.h +11 -13
  75. data/ext/isomorfeus_ferret_ext/lz4.c +422 -195
  76. data/ext/isomorfeus_ferret_ext/lz4.h +114 -46
  77. data/ext/isomorfeus_ferret_ext/lz4frame.c +421 -242
  78. data/ext/isomorfeus_ferret_ext/lz4frame.h +122 -53
  79. data/ext/isomorfeus_ferret_ext/lz4hc.c +127 -111
  80. data/ext/isomorfeus_ferret_ext/lz4hc.h +14 -14
  81. data/ext/isomorfeus_ferret_ext/lz4xxhash.h +1 -1
  82. data/ext/isomorfeus_ferret_ext/mdbx.c +3762 -2526
  83. data/ext/isomorfeus_ferret_ext/mdbx.h +115 -70
  84. data/ext/isomorfeus_ferret_ext/test.c +40 -87
  85. data/ext/isomorfeus_ferret_ext/test.h +3 -6
  86. data/ext/isomorfeus_ferret_ext/test_1710.c +11 -13
  87. data/ext/isomorfeus_ferret_ext/test_analysis.c +32 -64
  88. data/ext/isomorfeus_ferret_ext/test_array.c +6 -12
  89. data/ext/isomorfeus_ferret_ext/test_bitvector.c +12 -24
  90. data/ext/isomorfeus_ferret_ext/test_document.c +23 -33
  91. data/ext/isomorfeus_ferret_ext/test_except.c +10 -21
  92. data/ext/isomorfeus_ferret_ext/test_fields.c +62 -68
  93. data/ext/isomorfeus_ferret_ext/test_file_deleter.c +15 -23
  94. data/ext/isomorfeus_ferret_ext/test_filter.c +17 -27
  95. data/ext/isomorfeus_ferret_ext/test_global.c +14 -29
  96. data/ext/isomorfeus_ferret_ext/test_hash.c +19 -38
  97. data/ext/isomorfeus_ferret_ext/test_hashset.c +8 -16
  98. data/ext/isomorfeus_ferret_ext/test_helper.c +4 -8
  99. data/ext/isomorfeus_ferret_ext/test_highlighter.c +16 -28
  100. data/ext/isomorfeus_ferret_ext/test_index.c +277 -487
  101. data/ext/isomorfeus_ferret_ext/test_lang.c +7 -14
  102. data/ext/isomorfeus_ferret_ext/test_mdbx_store.c +2 -5
  103. data/ext/isomorfeus_ferret_ext/test_mempool.c +5 -10
  104. data/ext/isomorfeus_ferret_ext/test_multimapper.c +3 -6
  105. data/ext/isomorfeus_ferret_ext/test_priorityqueue.c +9 -18
  106. data/ext/isomorfeus_ferret_ext/test_q_const_score.c +4 -6
  107. data/ext/isomorfeus_ferret_ext/test_q_filtered.c +3 -4
  108. data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +9 -15
  109. data/ext/isomorfeus_ferret_ext/test_q_parser.c +8 -16
  110. data/ext/isomorfeus_ferret_ext/test_q_span.c +19 -35
  111. data/ext/isomorfeus_ferret_ext/test_ram_store.c +14 -13
  112. data/ext/isomorfeus_ferret_ext/test_search.c +60 -109
  113. data/ext/isomorfeus_ferret_ext/test_segments.c +8 -13
  114. data/ext/isomorfeus_ferret_ext/test_similarity.c +2 -4
  115. data/ext/isomorfeus_ferret_ext/test_sort.c +14 -24
  116. data/ext/isomorfeus_ferret_ext/test_store.c +96 -115
  117. data/ext/isomorfeus_ferret_ext/test_term.c +9 -15
  118. data/ext/isomorfeus_ferret_ext/test_term_vectors.c +9 -14
  119. data/ext/isomorfeus_ferret_ext/test_test.c +4 -8
  120. data/ext/isomorfeus_ferret_ext/test_threading.c +14 -20
  121. data/ext/isomorfeus_ferret_ext/testhelper.c +11 -21
  122. data/ext/isomorfeus_ferret_ext/testhelper.h +1 -1
  123. data/ext/isomorfeus_ferret_ext/tests_all.h +1 -2
  124. data/lib/isomorfeus/ferret/index/index.rb +1 -1
  125. data/lib/isomorfeus/ferret/version.rb +1 -1
  126. metadata +24 -4
@@ -11,8 +11,7 @@
11
11
 
12
12
  static ID date, field, cat, number;
13
13
 
14
- static void test_byte_float_conversion(TestCase *tc, void *data)
15
- {
14
+ static void test_byte_float_conversion(TestCase *tc, void *data) {
16
15
  int i;
17
16
  (void)data;
18
17
 
@@ -26,14 +25,12 @@ static int my_doc_freq(FrtSearcher *searcher, ID field, const char *term) {
26
25
  return 9;
27
26
  }
28
27
 
29
- static int my_max_doc(FrtSearcher *searcher)
30
- {
28
+ static int my_max_doc(FrtSearcher *searcher) {
31
29
  (void)searcher;
32
30
  return 10;
33
31
  }
34
32
 
35
- static void test_explanation(TestCase *tc, void *data)
36
- {
33
+ static void test_explanation(TestCase *tc, void *data) {
37
34
  FrtExplanation *expl = frt_expl_new(1.6f, "short description");
38
35
  char *str = frt_expl_to_s(expl);
39
36
  (void)data;
@@ -56,8 +53,7 @@ static void test_explanation(TestCase *tc, void *data)
56
53
  free(str);
57
54
  }
58
55
 
59
- static void test_default_similarity(TestCase *tc, void *data)
60
- {
56
+ static void test_default_similarity(TestCase *tc, void *data) {
61
57
  FrtPhrasePosition positions[4];
62
58
  FrtSearcher searcher;
63
59
  FrtSimilarity *dsim = frt_sim_create_default();
@@ -108,8 +104,7 @@ typedef struct DoubleFilter {
108
104
  FrtToken *tk;
109
105
  } DoubleFilter;
110
106
 
111
- static FrtToken *dbl_tf_next(FrtTokenStream *ts)
112
- {
107
+ static FrtToken *dbl_tf_next(FrtTokenStream *ts) {
113
108
  FrtToken *tk;
114
109
  tk = ((DoubleFilter *)ts)->tk;
115
110
  if (tk && islower(tk->text[0])) {
@@ -119,8 +114,7 @@ static FrtToken *dbl_tf_next(FrtTokenStream *ts)
119
114
  t++;
120
115
  }
121
116
  tk->pos_inc = 1;
122
- }
123
- else {
117
+ } else {
124
118
  tk = ((DoubleFilter *)ts)->tk
125
119
  = ((FrtTokenFilter *)ts)->sub_ts->next(((FrtTokenFilter *)ts)->sub_ts);
126
120
  if (tk && islower(tk->text[0])) {
@@ -130,13 +124,11 @@ static FrtToken *dbl_tf_next(FrtTokenStream *ts)
130
124
  return tk;
131
125
  }
132
126
 
133
- static FrtTokenStream *dbl_tf_clone_i(FrtTokenStream *ts)
134
- {
127
+ static FrtTokenStream *dbl_tf_clone_i(FrtTokenStream *ts) {
135
128
  return frt_filter_clone_size(ts, sizeof(DoubleFilter));
136
129
  }
137
130
 
138
- static FrtTokenStream *dbl_tf_new(FrtTokenStream *sub_ts)
139
- {
131
+ static FrtTokenStream *dbl_tf_new(FrtTokenStream *sub_ts) {
140
132
  FrtTokenStream *ts = frt_tf_new_i(sizeof(DoubleFilter), sub_ts);
141
133
  ts->next = &dbl_tf_next;
142
134
  ts->clone_i = &dbl_tf_clone_i;
@@ -200,8 +192,7 @@ struct Data test_data[SEARCH_DOCS_SIZE] = {
200
192
  "cat1/", "-1.0"}
201
193
  };
202
194
 
203
- static void prepare_search_index(FrtStore *store)
204
- {
195
+ static void prepare_search_index(FrtStore *store) {
205
196
  int i;
206
197
  FrtIndexWriter *iw;
207
198
 
@@ -216,18 +207,17 @@ static void prepare_search_index(FrtStore *store)
216
207
  for (i = 0; i < SEARCH_DOCS_SIZE; i++) {
217
208
  FrtDocument *doc = frt_doc_new();
218
209
  doc->boost = (float)(i+1);
219
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(date), (char *)test_data[i].date, enc));
220
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(field), (char *)test_data[i].field, enc));
221
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(cat), (char *)test_data[i].cat, enc));
222
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(number), (char *)test_data[i].number, enc));
210
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(date), test_data[i].date, enc));
211
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(field), test_data[i].field, enc));
212
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(cat), test_data[i].cat, enc));
213
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(number), test_data[i].number, enc));
223
214
  frt_iw_add_doc(iw, doc);
224
215
  frt_doc_destroy(doc);
225
216
  }
226
217
  frt_iw_close(iw);
227
218
  }
228
219
 
229
- static void test_get_doc(TestCase *tc, void *data)
230
- {
220
+ static void test_get_doc(TestCase *tc, void *data) {
231
221
  FrtSearcher *searcher = (FrtSearcher *)data;
232
222
  FrtDocument *doc;
233
223
  FrtDocField *df;
@@ -252,15 +242,13 @@ static void test_get_doc(TestCase *tc, void *data)
252
242
  frt_doc_destroy(doc);
253
243
  }
254
244
 
255
- void check_to_s(TestCase *tc, FrtQuery *query, ID field, const char *q_str)
256
- {
245
+ void check_to_s(TestCase *tc, FrtQuery *query, ID field, const char *q_str) {
257
246
  char *q_res = query->to_s(query, field);
258
247
  Asequal(q_str, q_res);
259
248
  free(q_res);
260
249
  }
261
250
 
262
- void tst_check_hits(TestCase *tc, FrtSearcher *searcher, FrtQuery *query, const char *expected_hits, int top)
263
- {
251
+ void tst_check_hits(TestCase *tc, FrtSearcher *searcher, FrtQuery *query, const char *expected_hits, int top) {
264
252
  static int num_array[ARRAY_SIZE];
265
253
  static int num_array2[ARRAY_SIZE];
266
254
  int i, count;
@@ -316,8 +304,7 @@ void tst_check_hits(TestCase *tc, FrtSearcher *searcher, FrtQuery *query, const
316
304
  }
317
305
 
318
306
  void check_match_vector(TestCase *tc, FrtSearcher *searcher, FrtQuery *query,
319
- int doc, ID field, const char *ranges)
320
- {
307
+ int doc, ID field, const char *ranges) {
321
308
  static int range_array[ARRAY_SIZE];
322
309
  FrtMatchVector *mv = frt_searcher_get_match_vector(searcher, query, doc, field);
323
310
  int num_matches = s2l(ranges, range_array)/2;
@@ -331,8 +318,7 @@ void check_match_vector(TestCase *tc, FrtSearcher *searcher, FrtQuery *query,
331
318
  frt_matchv_destroy(mv);
332
319
  }
333
320
 
334
- static void test_term_query(TestCase *tc, void *data)
335
- {
321
+ static void test_term_query(TestCase *tc, void *data) {
336
322
  FrtHashSet *hs;
337
323
  FrtSearcher *searcher = (FrtSearcher *)data;
338
324
  FrtTopDocs *top_docs;
@@ -401,8 +387,7 @@ static void test_term_query(TestCase *tc, void *data)
401
387
  frt_q_deref(tq);
402
388
  }
403
389
 
404
- static void test_term_query_hash(TestCase *tc, void *data)
405
- {
390
+ static void test_term_query_hash(TestCase *tc, void *data) {
406
391
  FrtQuery *q1, *q2;
407
392
  (void)data;
408
393
  q1 = frt_tq_new(rb_intern("A"), "a");
@@ -426,8 +411,7 @@ static void test_term_query_hash(TestCase *tc, void *data)
426
411
  frt_q_deref(q1);
427
412
  }
428
413
 
429
- static void test_boolean_query(TestCase *tc, void *data)
430
- {
414
+ static void test_boolean_query(TestCase *tc, void *data) {
431
415
  FrtSearcher *searcher = (FrtSearcher *)data;
432
416
  FrtQuery *bq = frt_bq_new(false);
433
417
  FrtQuery *tq1 = frt_tq_new(field, "word1");
@@ -483,8 +467,7 @@ static void test_boolean_query(TestCase *tc, void *data)
483
467
  frt_q_deref(bq);
484
468
  }
485
469
 
486
- static void test_boolean_query_hash(TestCase *tc, void *data)
487
- {
470
+ static void test_boolean_query_hash(TestCase *tc, void *data) {
488
471
  FrtQuery *tq1, *tq2, *tq3, *q1, *q2;
489
472
  (void)data;
490
473
 
@@ -543,8 +526,7 @@ static void test_boolean_query_hash(TestCase *tc, void *data)
543
526
  frt_q_deref(tq3);
544
527
  }
545
528
 
546
- static void test_phrase_query(TestCase *tc, void *data)
547
- {
529
+ static void test_phrase_query(TestCase *tc, void *data) {
548
530
  FrtSearcher *searcher = (FrtSearcher *)data;
549
531
  FrtExplanation *explanation;
550
532
  FrtQuery *q;
@@ -673,8 +655,7 @@ static void test_phrase_query(TestCase *tc, void *data)
673
655
  frt_q_deref(phq);
674
656
  }
675
657
 
676
- static void test_phrase_query_hash(TestCase *tc, void *data)
677
- {
658
+ static void test_phrase_query_hash(TestCase *tc, void *data) {
678
659
  FrtQuery *q1, *q2;
679
660
  (void)data;
680
661
 
@@ -726,12 +707,10 @@ static void test_phrase_query_hash(TestCase *tc, void *data)
726
707
  frt_q_deref(q1);
727
708
  }
728
709
 
729
- static void test_multi_phrase_query(TestCase *tc, void *data)
730
- {
710
+ static void test_multi_phrase_query(TestCase *tc, void *data) {
731
711
  FrtSearcher *searcher = (FrtSearcher *)data;
732
712
  FrtQuery *phq, *q;
733
713
 
734
-
735
714
  phq = frt_phq_new(field);
736
715
  /* ok to use append_multi_term to start */
737
716
  frt_phq_append_multi_term(phq, "quick");
@@ -819,8 +798,7 @@ static void test_multi_phrase_query(TestCase *tc, void *data)
819
798
  frt_q_deref(phq);
820
799
  }
821
800
 
822
- static void test_multi_phrase_query_hash(TestCase *tc, void *data)
823
- {
801
+ static void test_multi_phrase_query_hash(TestCase *tc, void *data) {
824
802
  FrtQuery *q1, *q2;
825
803
  (void)data;
826
804
 
@@ -882,11 +860,9 @@ static void test_multi_phrase_query_hash(TestCase *tc, void *data)
882
860
  frt_q_deref(q1);
883
861
  }
884
862
 
885
- static void mtq_zero_max_terms(void *p)
886
- { (void)p; frt_multi_tq_new_conf(field, 0, 0.5); }
863
+ static void mtq_zero_max_terms(void *p) { (void)p; frt_multi_tq_new_conf(field, 0, 0.5); }
887
864
 
888
- static void test_multi_term_query(TestCase *tc, void *data)
889
- {
865
+ static void test_multi_term_query(TestCase *tc, void *data) {
890
866
  FrtWeight *w;
891
867
  char *t, e[100];
892
868
  FrtSearcher *searcher = (FrtSearcher *)data;
@@ -905,7 +881,6 @@ static void test_multi_term_query(TestCase *tc, void *data)
905
881
  check_to_s(tc, mtq, field, "\"brown\"");
906
882
  check_to_s(tc, mtq, (ID)NULL, "field:\"brown\"");
907
883
 
908
-
909
884
  /* 0.4f boost is below the 0.5 threshold so term is ignored */
910
885
  frt_multi_tq_add_term_boost(mtq, "fox", 0.4f);
911
886
  tst_check_hits(tc, searcher, mtq, "1, 8, 16, 17", -1);
@@ -969,13 +944,11 @@ static void test_multi_term_query(TestCase *tc, void *data)
969
944
  frt_q_deref(mtq);
970
945
  }
971
946
 
972
- static void test_multi_term_query_hash(TestCase *tc, void *data)
973
- {
947
+ static void test_multi_term_query_hash(TestCase *tc, void *data) {
974
948
  FrtQuery *q1 = frt_multi_tq_new_conf(field, 100, 0.4);
975
949
  FrtQuery *q2 = frt_multi_tq_new(field);
976
950
  (void)data;
977
951
 
978
-
979
952
  check_to_s(tc, q1, (ID)NULL, "field:\"\"");
980
953
  Assert(frt_q_hash(q1) == frt_q_hash(q2), "Queries should be equal");
981
954
  Assert(frt_q_eq(q1, q1), "Same queries should be equal");
@@ -1001,8 +974,7 @@ static void test_multi_term_query_hash(TestCase *tc, void *data)
1001
974
  frt_q_deref(q2);
1002
975
  }
1003
976
 
1004
- static void test_prefix_query(TestCase *tc, void *data)
1005
- {
977
+ static void test_prefix_query(TestCase *tc, void *data) {
1006
978
  FrtSearcher *searcher = (FrtSearcher *)data;
1007
979
  FrtQuery *prq = frt_prefixq_new(cat, "cat1");
1008
980
  check_to_s(tc, prq, cat, "cat1*");
@@ -1032,8 +1004,7 @@ static void test_prefix_query(TestCase *tc, void *data)
1032
1004
  frt_q_deref(prq);
1033
1005
  }
1034
1006
 
1035
- static void test_prefix_query_hash(TestCase *tc, void *data)
1036
- {
1007
+ static void test_prefix_query_hash(TestCase *tc, void *data) {
1037
1008
  FrtQuery *q1, *q2;
1038
1009
  (void)data;
1039
1010
  q1 = frt_prefixq_new(rb_intern("A"), "a");
@@ -1057,20 +1028,15 @@ static void test_prefix_query_hash(TestCase *tc, void *data)
1057
1028
  frt_q_deref(q1);
1058
1029
  }
1059
1030
 
1060
- static void rq_new_lower_gt_upper(void *p)
1061
- { (void)p; frt_rq_new(date, "20050101", "20040101", true, true); }
1031
+ static void rq_new_lower_gt_upper(void *p) { (void)p; frt_rq_new(date, "20050101", "20040101", true, true); }
1062
1032
 
1063
- static void rq_new_include_lower_and_null_lower(void *p)
1064
- { (void)p; frt_rq_new(date, NULL, "20040101", true, true); }
1033
+ static void rq_new_include_lower_and_null_lower(void *p) { (void)p; frt_rq_new(date, NULL, "20040101", true, true); }
1065
1034
 
1066
- static void rq_new_include_upper_and_null_upper(void *p)
1067
- { (void)p; frt_rq_new(date, "20050101", NULL, true, true); }
1035
+ static void rq_new_include_upper_and_null_upper(void *p) { (void)p; frt_rq_new(date, "20050101", NULL, true, true); }
1068
1036
 
1069
- static void rq_new_null_lower_and_upper(void *p)
1070
- { (void)p; frt_rq_new(date, NULL, NULL, false, false); }
1037
+ static void rq_new_null_lower_and_upper(void *p) { (void)p; frt_rq_new(date, NULL, NULL, false, false); }
1071
1038
 
1072
- static void test_range_query(TestCase *tc, void *data)
1073
- {
1039
+ static void test_range_query(TestCase *tc, void *data) {
1074
1040
  FrtSearcher *searcher = (FrtSearcher *)data;
1075
1041
  FrtQuery *rq;
1076
1042
 
@@ -1165,8 +1131,7 @@ static void test_range_query(TestCase *tc, void *data)
1165
1131
  frt_q_deref(rq);
1166
1132
  }
1167
1133
 
1168
- static void test_range_query_hash(TestCase *tc, void *data)
1169
- {
1134
+ static void test_range_query_hash(TestCase *tc, void *data) {
1170
1135
  FrtQuery *q1, *q2;
1171
1136
  (void)data;
1172
1137
  q1 = frt_rq_new(date, "20051006", "20051010", true, true);
@@ -1228,26 +1193,19 @@ static void test_range_query_hash(TestCase *tc, void *data)
1228
1193
  frt_q_deref(q1);
1229
1194
  }
1230
1195
 
1231
- static void trq_new_int_lower_gt_upper(void *p)
1232
- { (void)p; frt_trq_new(date, "20050101", "20040101", true, true); }
1196
+ static void trq_new_int_lower_gt_upper(void *p) { (void)p; frt_trq_new(date, "20050101", "20040101", true, true); }
1233
1197
 
1234
- static void trq_new_float_lower_gt_upper(void *p)
1235
- { (void)p; frt_trq_new(number, "2.5", "-2.5", true, true); }
1198
+ static void trq_new_float_lower_gt_upper(void *p) { (void)p; frt_trq_new(number, "2.5", "-2.5", true, true); }
1236
1199
 
1237
- static void trq_new_string_lower_gt_upper(void *p)
1238
- { (void)p; frt_trq_new(cat, "cat_b", "cat_a", true, true); }
1200
+ static void trq_new_string_lower_gt_upper(void *p) { (void)p; frt_trq_new(cat, "cat_b", "cat_a", true, true); }
1239
1201
 
1240
- static void trq_new_include_lower_and_null_lower(void *p)
1241
- { (void)p; frt_trq_new(date, NULL, "20040101", true, true); }
1202
+ static void trq_new_include_lower_and_null_lower(void *p) { (void)p; frt_trq_new(date, NULL, "20040101", true, true); }
1242
1203
 
1243
- static void trq_new_include_upper_and_null_upper(void *p)
1244
- { (void)p; frt_trq_new(date, "20050101", NULL, true, true); }
1204
+ static void trq_new_include_upper_and_null_upper(void *p) { (void)p; frt_trq_new(date, "20050101", NULL, true, true); }
1245
1205
 
1246
- static void trq_new_null_lower_and_upper(void *p)
1247
- { (void)p; frt_trq_new(date, NULL, NULL, false, false); }
1206
+ static void trq_new_null_lower_and_upper(void *p) { (void)p; frt_trq_new(date, NULL, NULL, false, false); }
1248
1207
 
1249
- static void test_typed_range_query(TestCase *tc, void *data)
1250
- {
1208
+ static void test_typed_range_query(TestCase *tc, void *data) {
1251
1209
  FrtSearcher *searcher = (FrtSearcher *)data;
1252
1210
  FrtQuery *trq;
1253
1211
 
@@ -1397,8 +1355,7 @@ static void test_typed_range_query(TestCase *tc, void *data)
1397
1355
  frt_q_deref(trq);
1398
1356
  }
1399
1357
 
1400
- static void test_typed_range_query_hash(TestCase *tc, void *data)
1401
- {
1358
+ static void test_typed_range_query_hash(TestCase *tc, void *data) {
1402
1359
  FrtQuery *q1, *q2;
1403
1360
  (void)data;
1404
1361
  q1 = frt_trq_new(date, "20051006", "20051010", true, true);
@@ -1467,8 +1424,7 @@ static void test_typed_range_query_hash(TestCase *tc, void *data)
1467
1424
  frt_q_deref(q1);
1468
1425
  }
1469
1426
 
1470
- static void test_wildcard_match(TestCase *tc, void *data)
1471
- {
1427
+ static void test_wildcard_match(TestCase *tc, void *data) {
1472
1428
  (void)data;
1473
1429
  (void)tc;
1474
1430
  Assert(!frt_wc_match("", "abc"), "Empty pattern matches nothing");
@@ -1500,8 +1456,7 @@ static void test_wildcard_match(TestCase *tc, void *data)
1500
1456
  Assert(!frt_wc_match("cat1*", "cat2/sub1"), "Do not match");
1501
1457
  }
1502
1458
 
1503
- static void test_wildcard_query(TestCase *tc, void *data)
1504
- {
1459
+ static void test_wildcard_query(TestCase *tc, void *data) {
1505
1460
  FrtSearcher *searcher = (FrtSearcher *)data;
1506
1461
  FrtQuery *wq = frt_wcq_new(cat, "cat1*"), *bq;
1507
1462
  tst_check_hits(tc, searcher, wq, "0, 1, 2, 3, 4, 13, 14, 15, 16, 17", -1);
@@ -1538,8 +1493,7 @@ static void test_wildcard_query(TestCase *tc, void *data)
1538
1493
  frt_q_deref(bq);
1539
1494
  }
1540
1495
 
1541
- static void test_wildcard_query_hash(TestCase *tc, void *data)
1542
- {
1496
+ static void test_wildcard_query_hash(TestCase *tc, void *data) {
1543
1497
  FrtQuery *q1, *q2;
1544
1498
  (void)data;
1545
1499
  q1 = frt_wcq_new(rb_intern("A"), "a*");
@@ -1563,8 +1517,7 @@ static void test_wildcard_query_hash(TestCase *tc, void *data)
1563
1517
  frt_q_deref(q1);
1564
1518
  }
1565
1519
 
1566
- static void test_match_all_query_hash(TestCase *tc, void *data)
1567
- {
1520
+ static void test_match_all_query_hash(TestCase *tc, void *data) {
1568
1521
  FrtQuery *q1, *q2;
1569
1522
  (void)data;
1570
1523
  q1 = frt_maq_new();
@@ -1583,8 +1536,7 @@ static void test_match_all_query_hash(TestCase *tc, void *data)
1583
1536
  frt_q_deref(q1);
1584
1537
  }
1585
1538
 
1586
- static void test_search_unscored(TestCase *tc, void *data)
1587
- {
1539
+ static void test_search_unscored(TestCase *tc, void *data) {
1588
1540
  FrtSearcher *searcher = (FrtSearcher *)data;
1589
1541
  int buf[5], expected[5], count;
1590
1542
  FrtQuery *tq = frt_tq_new(field, "word1");
@@ -1633,9 +1585,9 @@ static void test_search_unscored(TestCase *tc, void *data)
1633
1585
  frt_q_deref(tq);
1634
1586
  }
1635
1587
 
1636
- TestSuite *ts_search(TestSuite *suite)
1637
- {
1588
+ TestSuite *ts_search(TestSuite *suite) {
1638
1589
  FrtStore *store = frt_open_ram_store(NULL);
1590
+ store->create_folder(store, segm_idx_name);
1639
1591
  FrtIndexReader *ir;
1640
1592
  FrtSearcher *searcher;
1641
1593
 
@@ -1697,8 +1649,7 @@ TestSuite *ts_search(TestSuite *suite)
1697
1649
 
1698
1650
 
1699
1651
  static void prepare_multi_search_index(FrtStore *store, struct Data data[],
1700
- int d_cnt, int w)
1701
- {
1652
+ int d_cnt, int w) {
1702
1653
  int i;
1703
1654
  FrtIndexWriter *iw;
1704
1655
  FrtFieldInfos *fis = frt_fis_new(0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM | FRT_FI_STORE_TERM_VECTOR_BM | FRT_FI_STORE_POSITIONS_BM | FRT_FI_STORE_OFFSETS_BM);
@@ -1712,18 +1663,17 @@ static void prepare_multi_search_index(FrtStore *store, struct Data data[],
1712
1663
  for (i = 0; i < d_cnt; i++) {
1713
1664
  FrtDocument *doc = frt_doc_new();
1714
1665
  doc->boost = (float)(i+w);
1715
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(date), (char *)data[i].date, enc));
1716
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(field), (char *)data[i].field, enc));
1717
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(cat), (char *)data[i].cat, enc));
1718
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(number), (char *)data[i].number, enc));
1666
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(date), data[i].date, enc));
1667
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(field), data[i].field, enc));
1668
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(cat), data[i].cat, enc));
1669
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(number), data[i].number, enc));
1719
1670
  frt_iw_add_doc(iw, doc);
1720
1671
  frt_doc_destroy(doc);
1721
1672
  }
1722
1673
  frt_iw_close(iw);
1723
1674
  }
1724
1675
 
1725
- static void test_query_combine(TestCase *tc, void *data)
1726
- {
1676
+ static void test_query_combine(TestCase *tc, void *data) {
1727
1677
  FrtQuery *q, *cq, **queries;
1728
1678
  FrtBooleanQuery *bq;
1729
1679
  (void)data;
@@ -1822,10 +1772,11 @@ static void test_query_combine(TestCase *tc, void *data)
1822
1772
  free(queries);
1823
1773
  }
1824
1774
 
1825
- TestSuite *ts_multi_search(TestSuite *suite)
1826
- {
1775
+ TestSuite *ts_multi_search(TestSuite *suite) {
1827
1776
  FrtStore *store0 = frt_open_ram_store(NULL);
1777
+ store0->create_folder(store0, segm_idx_name);
1828
1778
  FrtStore *store1 = frt_open_ram_store(NULL);
1779
+ store1->create_folder(store1, segm_idx_name);
1829
1780
 
1830
1781
  FrtIndexReader *ir0, *ir1;
1831
1782
  FrtSearcher **searchers;
@@ -29,21 +29,18 @@ static int tst_si_eql(int line_num,
29
29
  FrtSegmentInfo *si,
30
30
  const char *name,
31
31
  int doc_cnt,
32
- FrtStore *store)
33
- {
32
+ FrtStore *store) {
34
33
  if (tst_str_equal(line_num, tc, name, si->name) &&
35
34
  tst_int_equal(line_num, tc, doc_cnt, si->doc_cnt) &&
36
35
  tst_ptr_equal(line_num, tc, store, si->store)) {
37
36
  return true;
38
- }
39
- else {
37
+ } else {
40
38
  return false;
41
39
  }
42
40
 
43
41
  }
44
42
 
45
- static void test_si(TestCase *tc, void *data)
46
- {
43
+ static void test_si(TestCase *tc, void *data) {
47
44
  FrtStore *store = (FrtStore *)data;
48
45
  FrtSegmentInfo *si = frt_si_new(frt_estrdup("_1"), 10, store);
49
46
  Asi_has_vals(si, "_1", 10, store);
@@ -66,8 +63,7 @@ static void test_si(TestCase *tc, void *data)
66
63
  ***************************************************************************/
67
64
 
68
65
 
69
- void test_sis_add_del(TestCase *tc, void *data)
70
- {
66
+ void test_sis_add_del(TestCase *tc, void *data) {
71
67
  FrtStore *store = (FrtStore *)data;
72
68
  FrtSegmentInfos *sis = frt_sis_new(&dummy_fis);
73
69
  FrtSegmentInfo *seg0 = frt_sis_new_segment(sis, 123, store);
@@ -97,8 +93,7 @@ void test_sis_add_del(TestCase *tc, void *data)
97
93
  frt_sis_destroy(sis);
98
94
  }
99
95
 
100
- void test_sis_rw(TestCase *tc, void *data)
101
- {
96
+ void test_sis_rw(TestCase *tc, void *data) {
102
97
  frt_u64 version;
103
98
  FrtStore *store = (FrtStore *)data;
104
99
  FrtSegmentInfos *sis = frt_sis_new(&dummy_fis);
@@ -120,7 +115,7 @@ void test_sis_rw(TestCase *tc, void *data)
120
115
  Apequal(seg2, sis->segs[2]);
121
116
  frt_sis_write(sis, store, NULL);
122
117
  version = frt_sis_read_current_version(store);
123
- Assert(store->exists(store, "segments_0"),
118
+ Assert(store->exists(store, segm_idx_name, "segments_0"),
124
119
  "segments file should have been created");
125
120
  sis2 = frt_sis_read(store);
126
121
  Aiequal(3, sis2->size);
@@ -143,9 +138,9 @@ void test_sis_rw(TestCase *tc, void *data)
143
138
  frt_sis_destroy(sis3);
144
139
  }
145
140
 
146
- TestSuite *ts_segments(TestSuite *suite)
147
- {
141
+ TestSuite *ts_segments(TestSuite *suite) {
148
142
  FrtStore *store = frt_open_ram_store(NULL);
143
+ store->create_folder(store, segm_idx_name);
149
144
 
150
145
  suite = ADD_SUITE(suite);
151
146
 
@@ -2,8 +2,7 @@
2
2
  #include "frt_similarity.h"
3
3
  #include "test.h"
4
4
 
5
- void test_default_similarity(TestCase *tc, void *data)
6
- {
5
+ void test_default_similarity(TestCase *tc, void *data) {
7
6
  FrtSimilarity *dsim = frt_sim_create_default();
8
7
  (void)data;
9
8
 
@@ -15,8 +14,7 @@ void test_default_similarity(TestCase *tc, void *data)
15
14
  Afequal(4.0, frt_sim_coord(dsim, 12, 3));
16
15
  }
17
16
 
18
- TestSuite *ts_similarity(TestSuite *suite)
19
- {
17
+ TestSuite *ts_similarity(TestSuite *suite) {
20
18
  suite = ADD_SUITE(suite);
21
19
 
22
20
  tst_run_test(suite, test_default_similarity, NULL);
@@ -16,14 +16,13 @@ typedef struct SortTestData {
16
16
  const char *flt;
17
17
  } SortTestData;
18
18
 
19
- static void add_sort_test_data(SortTestData *std, FrtIndexWriter *iw)
20
- {
19
+ static void add_sort_test_data(SortTestData *std, FrtIndexWriter *iw) {
21
20
  FrtDocument *doc = frt_doc_new();
22
21
  rb_encoding *enc = rb_enc_find("ASCII-8BIT");
23
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(search), (char *)std->search, enc));
24
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(string), (char *)std->string, enc));
25
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(integer), (char *)std->integer, enc));
26
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(flt), (char *)std->flt, enc));
22
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(search), std->search, enc));
23
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(string), std->string, enc));
24
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(integer), std->integer, enc));
25
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(flt), std->flt, enc));
27
26
 
28
27
  sscanf(std->flt, "%f", &doc->boost);
29
28
 
@@ -44,8 +43,7 @@ static SortTestData data[] = { /* len mod */
44
43
  {"findall","b","4","0.000001"} /* 8 0 */
45
44
  };
46
45
 
47
- static void sort_test_setup(FrtStore *store)
48
- {
46
+ static void sort_test_setup(FrtStore *store) {
49
47
  int i;
50
48
  FrtIndexWriter *iw;
51
49
  FrtFieldInfos *fis = frt_fis_new(0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM | FRT_FI_STORE_TERM_VECTOR_BM);
@@ -60,8 +58,7 @@ static void sort_test_setup(FrtStore *store)
60
58
  frt_iw_close(iw);
61
59
  }
62
60
 
63
- static void sort_multi_test_setup(FrtStore *store1, FrtStore *store2)
64
- {
61
+ static void sort_multi_test_setup(FrtStore *store1, FrtStore *store2) {
65
62
  int i;
66
63
  FrtFieldInfos *fis = frt_fis_new(0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM | FRT_FI_STORE_TERM_VECTOR_BM);
67
64
  FrtIndexWriter *iw;
@@ -87,8 +84,7 @@ static void sort_multi_test_setup(FrtStore *store1, FrtStore *store2)
87
84
 
88
85
  #define R_START 3
89
86
  #define R_END 6
90
- static void do_test_top_docs(TestCase *tc, FrtSearcher *searcher, FrtQuery *query, const char *expected_hits, FrtSort *sort)
91
- {
87
+ static void do_test_top_docs(TestCase *tc, FrtSearcher *searcher, FrtQuery *query, const char *expected_hits, FrtSort *sort) {
92
88
  static int num_array[ARRAY_SIZE];
93
89
  int i;
94
90
  int total_hits = s2l(expected_hits, num_array);
@@ -147,8 +143,7 @@ static void do_test_top_docs(TestCase *tc, FrtSearcher *searcher, FrtQuery *quer
147
143
  } while (0)
148
144
 
149
145
 
150
- static void test_sort_field_to_s(TestCase *tc, void *data)
151
- {
146
+ static void test_sort_field_to_s(TestCase *tc, void *data) {
152
147
  (void)data;
153
148
  TEST_SF_TO_S("<SCORE>", frt_sort_field_score_new(false));
154
149
  TEST_SF_TO_S("<SCORE>!", frt_sort_field_score_new(true));
@@ -171,8 +166,7 @@ static void test_sort_field_to_s(TestCase *tc, void *data)
171
166
  free(_str);\
172
167
  } while (0)
173
168
 
174
- static void test_sort_to_s(TestCase *tc, void *data)
175
- {
169
+ static void test_sort_to_s(TestCase *tc, void *data) {
176
170
  FrtSort *sort = frt_sort_new();
177
171
  (void)data;
178
172
 
@@ -198,8 +192,7 @@ static void test_sort_to_s(TestCase *tc, void *data)
198
192
  }
199
193
 
200
194
  static bool do_byte_test = true;
201
- static void test_sorts(TestCase *tc, void *data)
202
- {
195
+ static void test_sorts(TestCase *tc, void *data) {
203
196
  FrtSearcher *sea = (FrtSearcher *)data;
204
197
  FrtQuery *q;
205
198
  FrtSort *sort = NULL;
@@ -288,10 +281,10 @@ static void test_sorts(TestCase *tc, void *data)
288
281
  frt_q_deref(q);
289
282
  }
290
283
 
291
- TestSuite *ts_sort(TestSuite *suite)
292
- {
284
+ TestSuite *ts_sort(TestSuite *suite) {
293
285
  FrtSearcher *sea, **searchers;
294
286
  FrtStore *store = frt_open_ram_store(NULL), *fs_store;
287
+ store->create_folder(store, segm_idx_name);
295
288
  FrtIndexReader *ir0;
296
289
  FrtIndexReader *ir1;
297
290
 
@@ -317,11 +310,8 @@ TestSuite *ts_sort(TestSuite *suite)
317
310
 
318
311
  do_byte_test = false;
319
312
 
320
- #if defined POSH_OS_WIN32 || defined POSH_OS_WIN64
321
- fs_store = frt_open_mdbx_store(".\\test\\testdir\\store");
322
- #else
323
313
  fs_store = frt_open_mdbx_store("./test/testdir/store");
324
- #endif
314
+
325
315
  sort_multi_test_setup(store, fs_store);
326
316
 
327
317
  searchers = FRT_ALLOC_N(FrtSearcher *, 2);