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
@@ -1,15 +1,13 @@
1
1
  #include "frt_document.h"
2
2
  #include "test.h"
3
3
 
4
- void test_df_standard(TestCase *tc, void *data)
5
- {
4
+ void test_df_standard(TestCase *tc, void *data) {
6
5
  char *s;
7
6
  FrtDocField *df;
8
7
  (void)data;
9
8
  rb_encoding *enc = rb_enc_find("ASCII-8BIT");
10
9
 
11
- df = frt_df_add_data(frt_df_new(rb_intern("title")), frt_estrdup("Life of Pi"), enc);
12
- df->destroy_data = true;
10
+ df = frt_df_add_data(frt_df_new(rb_intern("title")), "Life of Pi", enc);
13
11
  Aiequal(1, df->size);
14
12
  Asequal("title", rb_id2name(df->name));
15
13
  Asequal("Life of Pi", df->data[0]);
@@ -19,7 +17,7 @@ void test_df_standard(TestCase *tc, void *data)
19
17
  free(s);
20
18
  frt_df_destroy(df);
21
19
 
22
- df = frt_df_add_data_len(frt_df_new(rb_intern("title")), (char *)"new title", 9, enc);
20
+ df = frt_df_add_data_len(frt_df_new(rb_intern("title")), "new title", 9, enc);
23
21
  Aiequal(1, df->size);
24
22
  Asequal("title", rb_id2name(df->name));
25
23
  Asequal("new title", df->data[0]);
@@ -27,27 +25,24 @@ void test_df_standard(TestCase *tc, void *data)
27
25
  frt_df_destroy(df);
28
26
  }
29
27
 
30
- void test_df_multi_fields(TestCase *tc, void *data)
31
- {
28
+ void test_df_multi_fields(TestCase *tc, void *data) {
32
29
  int i;
33
30
  char *s;
34
31
  FrtDocField *df;
35
32
  (void)data;
36
33
  rb_encoding *enc = rb_enc_find("ASCII-8BIT");
37
34
 
38
- df = frt_df_add_data(frt_df_new(rb_intern("title")), frt_estrdup("Vernon God Little"), enc);
39
- df->destroy_data = true;
35
+ df = frt_df_add_data(frt_df_new(rb_intern("title")), "Vernon God Little", enc);
40
36
  Aiequal(1, df->size);
41
37
  Asequal("title", rb_id2name(df->name));
42
38
  Asequal("Vernon God Little", df->data[0]);
43
39
  Aiequal(strlen("Vernon God Little"), df->lengths[0]);
44
40
 
45
- frt_df_add_data(df, frt_estrdup("some more data"), enc);
41
+ frt_df_add_data(df, "some more data", enc);
46
42
  Aiequal(2, df->size);
47
- Asequal("title: [\"Vernon God Little\", \"some more data\"]",
48
- s = frt_df_to_s(df));
43
+ Asequal("title: [\"Vernon God Little\", \"some more data\"]", s = frt_df_to_s(df));
49
44
  free(s);
50
- frt_df_add_data_len(df, frt_estrdup("and more data"), 14, enc);
45
+ frt_df_add_data_len(df, "and more data", 14, enc);
51
46
  Aiequal(3, df->size);
52
47
  Asequal("title", rb_id2name(df->name));
53
48
  Asequal("Vernon God Little", df->data[0]);
@@ -56,20 +51,18 @@ void test_df_multi_fields(TestCase *tc, void *data)
56
51
 
57
52
  frt_df_destroy(df);
58
53
 
59
- df = frt_df_add_data(frt_df_new(rb_intern("data")), frt_estrdup("start"), enc);
60
- df->destroy_data = true;
54
+ df = frt_df_add_data(frt_df_new(rb_intern("data")), "start", enc);
61
55
  Aiequal(1, df->size);
62
56
  for (i = 0; i < 1000; i++) {
63
57
  char buf[100];
64
58
  sprintf(buf, "<<%d>>", i);
65
- frt_df_add_data(df, frt_estrdup(buf), enc);
59
+ frt_df_add_data(df, buf, enc);
66
60
  Aiequal(i + 2, df->size);
67
61
  }
68
62
  frt_df_destroy(df);
69
63
  }
70
64
 
71
- void test_doc(TestCase *tc, void *data)
72
- {
65
+ void test_doc(TestCase *tc, void *data) {
73
66
  int i;
74
67
  FrtDocument *doc;
75
68
  FrtDocField *df;
@@ -77,14 +70,14 @@ void test_doc(TestCase *tc, void *data)
77
70
  rb_encoding *enc = rb_enc_find("ASCII-8BIT");
78
71
 
79
72
  doc = frt_doc_new();
80
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("title")), (char *)"title", enc));
81
- Aiequal(1, doc->size);
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);
73
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("title")), "title", enc));
74
+ Aiequal(1, doc->field_count);
75
+ df = frt_df_add_data(frt_df_new(rb_intern("data")), "data1", enc);
76
+ frt_df_add_data(df, "data2", enc);
77
+ frt_df_add_data(df, "data3", enc);
78
+ frt_df_add_data(df, "data4", enc);
86
79
  frt_doc_add_field(doc, df);
87
- Aiequal(2, doc->size);
80
+ Aiequal(2, doc->field_count);
88
81
  Asequal("title", rb_id2name(frt_doc_get_field(doc, rb_intern("title"))->name));
89
82
  Aiequal(1, frt_doc_get_field(doc, rb_intern("title"))->size);
90
83
  Asequal("title", frt_doc_get_field(doc, rb_intern("title"))->data[0]);
@@ -104,9 +97,8 @@ void test_doc(TestCase *tc, void *data)
104
97
  sprintf(buf, "<<%d>>", i);
105
98
  bufc = frt_estrdup(buf);
106
99
  df = frt_df_add_data(frt_df_new(rb_intern(bufc)), bufc, enc);
107
- df->destroy_data = true;
108
100
  frt_doc_add_field(doc, df);
109
- Aiequal(i + 1, doc->size);
101
+ Aiequal(i + 1, doc->field_count);
110
102
  }
111
103
 
112
104
  for (i = 0; i < 1000; i++) {
@@ -119,8 +111,7 @@ void test_doc(TestCase *tc, void *data)
119
111
  frt_doc_destroy(doc);
120
112
  }
121
113
 
122
- void test_double_field_exception(TestCase *tc, void *data)
123
- {
114
+ void test_double_field_exception(TestCase *tc, void *data) {
124
115
  volatile bool exception_thrown = false;
125
116
  FrtDocument *doc;
126
117
  FrtDocField *volatile df = NULL;
@@ -128,10 +119,10 @@ void test_double_field_exception(TestCase *tc, void *data)
128
119
  rb_encoding *enc = rb_enc_find("ASCII-8BIT");
129
120
 
130
121
  doc = frt_doc_new();
131
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("title")), (char *)"title", enc));
122
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("title")), "title", enc));
132
123
 
133
124
  FRT_TRY
134
- df = frt_df_add_data_len(frt_df_new(rb_intern("title")), (char *)"title", 5, enc);
125
+ df = frt_df_add_data_len(frt_df_new(rb_intern("title")), "title", 5, enc);
135
126
  frt_doc_add_field(doc, df);
136
127
  case FRT_EXCEPTION:
137
128
  exception_thrown = true;
@@ -147,8 +138,7 @@ void test_double_field_exception(TestCase *tc, void *data)
147
138
  frt_doc_destroy(doc);
148
139
  }
149
140
 
150
- TestSuite *ts_document(TestSuite *suite)
151
- {
141
+ TestSuite *ts_document(TestSuite *suite) {
152
142
  suite = ADD_SUITE(suite);
153
143
 
154
144
  tst_run_test(suite, test_df_standard, NULL);
@@ -9,8 +9,7 @@ static void raise_exception(void) {
9
9
  FRT_RAISE(FRT_EXCEPTION, "%s", msg1);
10
10
  }
11
11
 
12
- static void inner_try(TestCase *tc)
13
- {
12
+ static void inner_try(TestCase *tc) {
14
13
  volatile bool exception_handled = false;
15
14
  volatile bool ioerror_called = false;
16
15
 
@@ -38,8 +37,7 @@ static void inner_try(TestCase *tc)
38
37
  FRT_ENDTRY
39
38
  }
40
39
 
41
- static void test_nested_except(TestCase *tc, void *data)
42
- {
40
+ static void test_nested_except(TestCase *tc, void *data) {
43
41
  volatile bool ioerror_handled = false;
44
42
  bool finally_handled = false;
45
43
  (void)data;
@@ -68,8 +66,7 @@ static void test_nested_except(TestCase *tc, void *data)
68
66
  Assert(finally_handled, "Finally wasn't handled");
69
67
  }
70
68
 
71
- static void test_function_except(TestCase *tc, void *data)
72
- {
69
+ static void test_function_except(TestCase *tc, void *data) {
73
70
  volatile bool exception_handled = false;
74
71
  bool finally_handled = false;
75
72
  (void)data; /* suppress warning */
@@ -97,8 +94,7 @@ static void test_function_except(TestCase *tc, void *data)
97
94
  Assert(finally_handled, "Finally wasn't handled");
98
95
  }
99
96
 
100
- static void test_simple_except(TestCase *tc, void *data)
101
- {
97
+ static void test_simple_except(TestCase *tc, void *data) {
102
98
  volatile bool exception_handled = false;
103
99
  bool finally_handled = false;
104
100
  (void)data; /* suppress warning */
@@ -129,8 +125,7 @@ static void test_simple_except(TestCase *tc, void *data)
129
125
  Assert(finally_handled, "Finally wasn't handled");
130
126
  }
131
127
 
132
- static void try_xfinally1(TestCase *tc)
133
- {
128
+ static void try_xfinally1(TestCase *tc) {
134
129
  bool finally_handled = false;
135
130
 
136
131
  FRT_TRY
@@ -143,8 +138,7 @@ static void try_xfinally1(TestCase *tc)
143
138
  Atrue(finally_handled);
144
139
  }
145
140
 
146
- static void try_xfinally2(TestCase *tc)
147
- {
141
+ static void try_xfinally2(TestCase *tc) {
148
142
  bool finally_handled = false;
149
143
 
150
144
  FRT_TRY
@@ -158,8 +152,7 @@ static void try_xfinally2(TestCase *tc)
158
152
  Atrue(finally_handled);
159
153
  }
160
154
 
161
- static void try_xcatchall(TestCase *tc)
162
- {
155
+ static void try_xcatchall(TestCase *tc) {
163
156
  bool catchall_handled = false;
164
157
 
165
158
  FRT_TRY
@@ -174,8 +167,7 @@ static void try_xcatchall(TestCase *tc)
174
167
  Atrue(catchall_handled);
175
168
  }
176
169
 
177
- static void test_xfinally(TestCase *tc, void *data)
178
- {
170
+ static void test_xfinally(TestCase *tc, void *data) {
179
171
  volatile bool exception_handled = false;
180
172
  bool finally_handled = false;
181
173
  (void)data; /* suppress warning */
@@ -202,15 +194,13 @@ static void test_xfinally(TestCase *tc, void *data)
202
194
  Assert(finally_handled, "Finally wasn't handled");
203
195
  }
204
196
 
205
- static void test_uncaught_except(TestCase *tc, void *data)
206
- {
197
+ static void test_uncaught_except(TestCase *tc, void *data) {
207
198
  bool old_abort_setting = frt_x_abort_on_exception;
208
199
  FILE *old_stream_setting = frt_x_exception_stream;
209
200
  int tfd = fio_tmpfile();
210
201
  FILE *exception_output = fdopen(tfd, "w+");
211
202
  (void)data, (void)tc; /* suppress warning */
212
203
 
213
-
214
204
  frt_x_abort_on_exception = false;
215
205
  frt_x_exception_stream = exception_output;
216
206
 
@@ -230,8 +220,7 @@ static void test_uncaught_except(TestCase *tc, void *data)
230
220
  fclose(exception_output);
231
221
  }
232
222
 
233
- TestSuite *ts_except(TestSuite *suite)
234
- {
223
+ TestSuite *ts_except(TestSuite *suite) {
235
224
  suite = ADD_SUITE(suite);
236
225
 
237
226
  tst_run_test(suite, test_simple_except, NULL);
@@ -41,8 +41,7 @@ void field_prop_test(TestCase *tc,
41
41
  *
42
42
  ****************************************************************************/
43
43
 
44
- static void test_fi_new(TestCase *tc, void *data)
45
- {
44
+ static void test_fi_new(TestCase *tc, void *data) {
46
45
  FrtFieldInfo *fi;
47
46
  (void)data; /* suppress unused argument warning */
48
47
  fi = frt_fi_new(rb_intern("name"), 0);
@@ -51,7 +50,7 @@ static void test_fi_new(TestCase *tc, void *data)
51
50
  fi = frt_fi_new(rb_intern("name"), 0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM | FRT_FI_STORE_TERM_VECTOR_BM);
52
51
  do_field_prop_test(tc, fi, rb_intern("name"), 1.0, T, F, T, T, F, T, F, F);
53
52
  frt_fi_deref(fi);
54
- fi = frt_fi_new(rb_intern("name"), 0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_COMPRESSED_BM | FRT_FI_COMPRESSION_BROTLI_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_STORE_TERM_VECTOR_BM | FRT_FI_STORE_POSITIONS_BM);
53
+ fi = frt_fi_new(rb_intern("name"), 0 | FRT_FI_IS_STORED_BM | FRT_FI_COMPRESSION_BROTLI_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_STORE_TERM_VECTOR_BM | FRT_FI_STORE_POSITIONS_BM);
55
54
  do_field_prop_test(tc, fi, rb_intern("name"), 1.0, T, T, T, F, F, T, T, F);
56
55
  frt_fi_deref(fi);
57
56
  fi = frt_fi_new(rb_intern("name"), 0 | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM | FRT_FI_OMIT_NORMS_BM | FRT_FI_STORE_TERM_VECTOR_BM | FRT_FI_STORE_OFFSETS_BM);
@@ -69,8 +68,7 @@ static void test_fi_new(TestCase *tc, void *data)
69
68
  *
70
69
  ****************************************************************************/
71
70
 
72
- static void test_fis_basic(TestCase *tc, void *data)
73
- {
71
+ static void test_fis_basic(TestCase *tc, void *data) {
74
72
  FrtFieldInfos *fis;
75
73
  FrtFieldInfo *fi;
76
74
  volatile bool arg_error = false;
@@ -79,7 +77,7 @@ static void test_fis_basic(TestCase *tc, void *data)
79
77
  fis = frt_fis_new(0);
80
78
  frt_fis_add_field(fis, frt_fi_new(rb_intern("FFFFFFFF"), 0));
81
79
  frt_fis_add_field(fis, frt_fi_new(rb_intern("TFTTFTFF"), 0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM | FRT_FI_STORE_TERM_VECTOR_BM));
82
- frt_fis_add_field(fis, frt_fi_new(rb_intern("TTTFFTTF"), 0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_COMPRESSED_BM | FRT_FI_COMPRESSION_BROTLI_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_STORE_TERM_VECTOR_BM | FRT_FI_STORE_POSITIONS_BM));
80
+ frt_fis_add_field(fis, frt_fi_new(rb_intern("TTTFFTTF"), 0 | FRT_FI_IS_STORED_BM | FRT_FI_COMPRESSION_BROTLI_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_STORE_TERM_VECTOR_BM | FRT_FI_STORE_POSITIONS_BM));
83
81
  frt_fis_add_field(fis, frt_fi_new(rb_intern("FFTTTTFT"), 0 | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM | FRT_FI_OMIT_NORMS_BM | FRT_FI_STORE_TERM_VECTOR_BM | FRT_FI_STORE_OFFSETS_BM));
84
82
  frt_fis_add_field(fis, frt_fi_new(rb_intern("FFTFTTTT"), 0 | FRT_FI_IS_INDEXED_BM | FRT_FI_OMIT_NORMS_BM | FRT_FI_STORE_TERM_VECTOR_BM | FRT_FI_STORE_POSITIONS_BM | FRT_FI_STORE_OFFSETS_BM));
85
83
 
@@ -126,8 +124,7 @@ static void test_fis_basic(TestCase *tc, void *data)
126
124
  frt_fis_deref(fis);
127
125
  }
128
126
 
129
- static void test_fis_with_default(TestCase *tc, void *data)
130
- {
127
+ static void test_fis_with_default(TestCase *tc, void *data) {
131
128
  FrtFieldInfos *fis;
132
129
  (void)data; /* suppress unused argument warning */
133
130
 
@@ -144,7 +141,7 @@ static void test_fis_with_default(TestCase *tc, void *data)
144
141
  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);
145
142
  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);
146
143
  frt_fis_deref(fis);
147
- fis = frt_fis_new(0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_COMPRESSED_BM | FRT_FI_COMPRESSION_BROTLI_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_STORE_TERM_VECTOR_BM | FRT_FI_STORE_POSITIONS_BM);
144
+ fis = frt_fis_new(0 | FRT_FI_IS_STORED_BM | FRT_FI_COMPRESSION_BROTLI_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_STORE_TERM_VECTOR_BM | FRT_FI_STORE_POSITIONS_BM);
148
145
  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);
149
146
  frt_fis_deref(fis);
150
147
  fis = frt_fis_new(0 | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM | FRT_FI_OMIT_NORMS_BM | FRT_FI_STORE_TERM_VECTOR_BM | FRT_FI_STORE_OFFSETS_BM);
@@ -155,11 +152,11 @@ static void test_fis_with_default(TestCase *tc, void *data)
155
152
  frt_fis_deref(fis);
156
153
  }
157
154
 
158
- static void test_fis_rw(TestCase *tc, void *data)
159
- {
155
+ static void test_fis_rw(TestCase *tc, void *data) {
160
156
  char *str;
161
157
  FrtFieldInfos *fis;
162
158
  FrtStore *store = frt_open_ram_store(NULL);
159
+ store->create_folder(store, segm_idx_name);
163
160
  FrtInStream *is;
164
161
  FrtOutStream *os;
165
162
  (void)data; /* suppress unused argument warning */
@@ -167,14 +164,14 @@ static void test_fis_rw(TestCase *tc, void *data)
167
164
  fis = frt_fis_new(0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_OMIT_NORMS_BM | FRT_FI_STORE_TERM_VECTOR_BM | FRT_FI_STORE_POSITIONS_BM | FRT_FI_STORE_OFFSETS_BM);
168
165
  frt_fis_add_field(fis, frt_fi_new(rb_intern("FFFFFFFF"), 0));
169
166
  frt_fis_add_field(fis, frt_fi_new(rb_intern("TFTTFTFF"), 0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM | FRT_FI_STORE_TERM_VECTOR_BM));
170
- frt_fis_add_field(fis, frt_fi_new(rb_intern("TTTFFTTF"), 0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_COMPRESSED_BM | FRT_FI_COMPRESSION_BROTLI_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_STORE_TERM_VECTOR_BM | FRT_FI_STORE_POSITIONS_BM));
167
+ frt_fis_add_field(fis, frt_fi_new(rb_intern("TTTFFTTF"), 0 | FRT_FI_IS_STORED_BM | FRT_FI_COMPRESSION_BROTLI_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_STORE_TERM_VECTOR_BM | FRT_FI_STORE_POSITIONS_BM));
171
168
  frt_fis_add_field(fis, frt_fi_new(rb_intern("FFTTTTFT"), 0 | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM | FRT_FI_OMIT_NORMS_BM | FRT_FI_STORE_TERM_VECTOR_BM | FRT_FI_STORE_OFFSETS_BM));
172
169
  frt_fis_add_field(fis, frt_fi_new(rb_intern("FFTFTTTT"), 0 | FRT_FI_IS_INDEXED_BM | FRT_FI_OMIT_NORMS_BM | FRT_FI_STORE_TERM_VECTOR_BM | FRT_FI_STORE_POSITIONS_BM | FRT_FI_STORE_OFFSETS_BM));
173
170
  fis->fields[1]->boost = 2.0;
174
171
  fis->fields[2]->boost = 3.0;
175
172
  fis->fields[3]->boost = 4.0;
176
173
  fis->fields[4]->boost = 5.0;
177
- os = store->new_output(store, "fields");
174
+ os = store->new_output(store, segm_idx_name, "fields");
178
175
  frt_fis_write(fis, os);
179
176
  frt_os_close(os);
180
177
 
@@ -187,7 +184,7 @@ static void test_fis_rw(TestCase *tc, void *data)
187
184
 
188
185
  frt_fis_deref(fis);
189
186
 
190
- is = store->open_input(store, "fields");
187
+ is = store->open_input(store, segm_idx_name, "fields");
191
188
  fis = frt_fis_read(is);
192
189
  frt_is_close(is);
193
190
  Aiequal(true, bits_is_stored(fis->bits));
@@ -258,8 +255,7 @@ static void test_fis_rw(TestCase *tc, void *data)
258
255
 
259
256
  #define BIN_DATA_LEN 1234
260
257
 
261
- static char *prepare_bin_data(int len)
262
- {
258
+ static char *prepare_bin_data(int len) {
263
259
  int i;
264
260
  char *bin_data = FRT_ALLOC_N(char, len);
265
261
  for (i = 0; i < len; i++) {
@@ -286,22 +282,20 @@ static FrtDocument *prepare_doc(void) {
286
282
  char *bin_data = prepare_bin_data(BIN_DATA_LEN);
287
283
  rb_encoding *enc = rb_enc_find("ASCII-8BIT");
288
284
 
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));
293
- df->destroy_data = false;
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);
285
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("ignored")), "this fld's ignored", enc));
286
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("unstored")), "unstored ignored", enc));
287
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("stored")), "Yay, a stored field", enc));
288
+ df = frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("stored_array")), "one ", enc));
289
+ frt_df_add_data(df, "two ", enc);
290
+ frt_df_add_data(df, "three ", enc);
291
+ frt_df_add_data(df, "four", enc);
297
292
  frt_df_add_data_len(df, bin_data, BIN_DATA_LEN, enc);
298
- frt_doc_add_field(doc, frt_df_add_data_len(frt_df_new(rb_intern("binary")), bin_data,
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);
293
+ frt_doc_add_field(doc, frt_df_add_data_len(frt_df_new(rb_intern("binary")), bin_data, BIN_DATA_LEN, enc));
294
+ df = frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("array")), "ichi ", enc));
295
+ frt_df_add_data(df, "ni ", enc);
296
+ frt_df_add_data(df, "san ", enc);
297
+ frt_df_add_data(df, "yon ", enc);
298
+ frt_df_add_data(df, "go", enc);
305
299
 
306
300
  return doc;
307
301
  }
@@ -311,13 +305,13 @@ static FrtFieldInfos *prepare_fis(void) {
311
305
  frt_fis_add_field(fis, frt_fi_new(rb_intern("ignored"), 0));
312
306
  frt_fis_add_field(fis, frt_fi_new(rb_intern("unstored"), 0 | 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));
313
307
  frt_fis_add_field(fis, frt_fi_new(rb_intern("stored"), 0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM | FRT_FI_STORE_TERM_VECTOR_BM));
314
- frt_fis_add_field(fis, frt_fi_new(rb_intern("stored_array"), 0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_COMPRESSED_BM | FRT_FI_COMPRESSION_BROTLI_BM | FRT_FI_IS_INDEXED_BM));
308
+ frt_fis_add_field(fis, frt_fi_new(rb_intern("stored_array"), 0 | FRT_FI_IS_STORED_BM | FRT_FI_COMPRESSION_BROTLI_BM | FRT_FI_IS_INDEXED_BM));
315
309
  return fis;
316
310
  }
317
311
 
318
- static void test_fields_rw_single(TestCase *tc, void *data)
319
- {
312
+ static void test_fields_rw_single(TestCase *tc, void *data) {
320
313
  FrtStore *store = frt_open_ram_store(NULL);
314
+ store->create_folder(store, segm_idx_name);
321
315
  char *bin_data = prepare_bin_data(BIN_DATA_LEN);
322
316
  FrtDocument *doc = prepare_doc();
323
317
  FrtFieldInfos *fis = prepare_fis();
@@ -327,13 +321,13 @@ static void test_fields_rw_single(TestCase *tc, void *data)
327
321
  (void)data;
328
322
 
329
323
  Aiequal(4, fis->size);
330
- Aiequal(6, doc->size);
324
+ Aiequal(6, doc->field_count);
331
325
 
332
326
  fw = frt_fw_open(store, "_0", fis);
333
327
  frt_fw_add_doc(fw, doc);
334
328
  frt_fw_write_tv_index(fw);
335
329
  frt_fw_close(fw);
336
- frt_doc_destroy(doc);
330
+ frt_doc_destroy(doc);
337
331
 
338
332
  Aiequal(6, fis->size);
339
333
  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);
@@ -343,7 +337,7 @@ static void test_fields_rw_single(TestCase *tc, void *data)
343
337
  doc = frt_fr_get_doc(fr, 0);
344
338
  frt_fr_close(fr);
345
339
 
346
- Aiequal(4, doc->size);
340
+ Aiequal(4, doc->field_count);
347
341
 
348
342
  Apnull(frt_doc_get_field(doc, rb_intern("ignored")));
349
343
  Apnull(frt_doc_get_field(doc, rb_intern("unstored")));
@@ -354,9 +348,9 @@ static void test_fields_rw_single(TestCase *tc, void *data)
354
348
 
355
349
  df = frt_doc_get_field(doc, rb_intern("stored_array"));
356
350
  Aiequal(5, df->size);
357
- check_df_data(df, 0, "one");
358
- check_df_data(df, 1, "two");
359
- check_df_data(df, 2, "three");
351
+ check_df_data(df, 0, "one ");
352
+ check_df_data(df, 1, "two ");
353
+ check_df_data(df, 2, "three ");
360
354
  check_df_data(df, 3, "four");
361
355
  check_df_bin_data(df, 4, bin_data, BIN_DATA_LEN);
362
356
 
@@ -366,10 +360,10 @@ static void test_fields_rw_single(TestCase *tc, void *data)
366
360
 
367
361
  df = frt_doc_get_field(doc, rb_intern("array"));
368
362
  Aiequal(5, df->size);
369
- check_df_data(df, 0, "ichi");
370
- check_df_data(df, 1, "ni");
371
- check_df_data(df, 2, "san");
372
- check_df_data(df, 3, "yon");
363
+ check_df_data(df, 0, "ichi ");
364
+ check_df_data(df, 1, "ni ");
365
+ check_df_data(df, 2, "san ");
366
+ check_df_data(df, 3, "yon ");
373
367
  check_df_data(df, 4, "go");
374
368
 
375
369
  free(bin_data);
@@ -378,10 +372,10 @@ static void test_fields_rw_single(TestCase *tc, void *data)
378
372
  frt_fis_deref(fis);
379
373
  }
380
374
 
381
- static void test_fields_rw_multi(TestCase *tc, void *data)
382
- {
375
+ static void test_fields_rw_multi(TestCase *tc, void *data) {
383
376
  int i;
384
377
  FrtStore *store = frt_open_ram_store(NULL);
378
+ store->create_folder(store, segm_idx_name);
385
379
  char *bin_data = prepare_bin_data(BIN_DATA_LEN);
386
380
  FrtDocument *doc;
387
381
  FrtFieldInfos *fis = prepare_fis();
@@ -401,13 +395,13 @@ static void test_fields_rw_multi(TestCase *tc, void *data)
401
395
  frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern(bufc)), bufc, enc));
402
396
  frt_fw_add_doc(fw, doc);
403
397
  frt_fw_write_tv_index(fw);
404
- frt_doc_destroy(doc);
398
+ frt_doc_destroy(doc);
405
399
  }
406
400
 
407
401
  doc = prepare_doc();
408
402
  frt_fw_add_doc(fw, doc);
409
403
  frt_fw_write_tv_index(fw);
410
- frt_doc_destroy(doc);
404
+ frt_doc_destroy(doc);
411
405
  frt_fw_close(fw);
412
406
 
413
407
  Aiequal(106, fis->size);
@@ -423,7 +417,7 @@ static void test_fields_rw_multi(TestCase *tc, void *data)
423
417
  doc = frt_fr_get_doc(fr, 100);
424
418
  frt_fr_close(fr);
425
419
 
426
- Aiequal(4, doc->size);
420
+ Aiequal(4, doc->field_count);
427
421
 
428
422
  Apnull(frt_doc_get_field(doc, rb_intern("ignored")));
429
423
  Apnull(frt_doc_get_field(doc, rb_intern("unstored")));
@@ -434,9 +428,9 @@ static void test_fields_rw_multi(TestCase *tc, void *data)
434
428
 
435
429
  df = frt_doc_get_field(doc, rb_intern("stored_array"));
436
430
  Aiequal(5, df->size);
437
- check_df_data(df, 0, "one");
438
- check_df_data(df, 1, "two");
439
- check_df_data(df, 2, "three");
431
+ check_df_data(df, 0, "one ");
432
+ check_df_data(df, 1, "two ");
433
+ check_df_data(df, 2, "three ");
440
434
  check_df_data(df, 3, "four");
441
435
  check_df_bin_data(df, 4, bin_data, BIN_DATA_LEN);
442
436
 
@@ -446,10 +440,10 @@ static void test_fields_rw_multi(TestCase *tc, void *data)
446
440
 
447
441
  df = frt_doc_get_field(doc, rb_intern("array"));
448
442
  Aiequal(5, df->size);
449
- check_df_data(df, 0, "ichi");
450
- check_df_data(df, 1, "ni");
451
- check_df_data(df, 2, "san");
452
- check_df_data(df, 3, "yon");
443
+ check_df_data(df, 0, "ichi ");
444
+ check_df_data(df, 1, "ni ");
445
+ check_df_data(df, 2, "san ");
446
+ check_df_data(df, 3, "yon ");
453
447
  check_df_data(df, 4, "go");
454
448
 
455
449
  free(bin_data);
@@ -458,9 +452,9 @@ static void test_fields_rw_multi(TestCase *tc, void *data)
458
452
  frt_fis_deref(fis);
459
453
  }
460
454
 
461
- static void test_lazy_field_loading(TestCase *tc, void *data)
462
- {
455
+ static void test_lazy_field_loading(TestCase *tc, void *data) {
463
456
  FrtStore *store = frt_open_ram_store(NULL);
457
+ store->create_folder(store, segm_idx_name);
464
458
  FrtDocument *doc;
465
459
  FrtFieldInfos *fis = prepare_fis();
466
460
  FrtFieldsWriter *fw;
@@ -468,18 +462,19 @@ static void test_lazy_field_loading(TestCase *tc, void *data)
468
462
  FrtDocField *df;
469
463
  FrtLazyDoc *lazy_doc;
470
464
  FrtLazyDocField *lazy_df;
471
- char *text, buf[1000];
465
+ const char *text;
466
+ char buf[1000];
472
467
  (void)data;
473
468
  rb_encoding *enc = rb_enc_find("ASCII-8BIT");
474
469
 
475
470
  fw = frt_fw_open(store, "_as3", fis);
476
471
  doc = frt_doc_new();
477
472
  df = frt_df_new(rb_intern("stored"));
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);
473
+ frt_df_add_data(df, "this is a stored field ", enc);
474
+ frt_df_add_data(df, "to be or not to be ", enc);
475
+ frt_df_add_data(df, "a stitch in time, saves nine ", enc);
476
+ frt_df_add_data(df, "the quick brown fox jumped over the lazy dog ", enc);
477
+ frt_df_add_data(df, "that's it folks", enc);
483
478
  frt_doc_add_field(doc, df);
484
479
  frt_fw_add_doc(fw, doc);
485
480
  frt_fw_write_tv_index(fw);
@@ -494,8 +489,8 @@ static void test_lazy_field_loading(TestCase *tc, void *data)
494
489
 
495
490
  lazy_df = frt_lazy_doc_get(lazy_doc, rb_intern("stored"));
496
491
  Apnull(lazy_doc->fields[0]->data[0].text);
497
- Asequal("this is a stored field", text = frt_lazy_df_get_data(lazy_df, 0));
498
- Asequal("this is a stored field", lazy_doc->fields[0]->data[0].text);
492
+ Asequal("this is a stored field ", text = frt_lazy_df_get_data(lazy_df, 0));
493
+ Asequal("this is a stored field ", lazy_doc->fields[0]->data[0].text);
499
494
  Apequal(text, frt_lazy_df_get_data(lazy_df, 0));
500
495
 
501
496
  Apnull(lazy_doc->fields[0]->data[4].text);
@@ -518,8 +513,7 @@ static void test_lazy_field_loading(TestCase *tc, void *data)
518
513
  frt_lazy_doc_close(lazy_doc);
519
514
  }
520
515
 
521
- TestSuite *ts_fields(TestSuite *suite)
522
- {
516
+ TestSuite *ts_fields(TestSuite *suite) {
523
517
  suite = ADD_SUITE(suite);
524
518
  tst_run_test(suite, test_fi_new, NULL);
525
519
  tst_run_test(suite, test_fis_basic, NULL);