isomorfeus-ferret 0.17.2 → 0.17.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) 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 +161 -187
  10. data/ext/isomorfeus_ferret_ext/frb_lazy_doc.c +14 -16
  11. data/ext/isomorfeus_ferret_ext/frb_search.c +77 -69
  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 +5 -33
  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 +14 -33
  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_filter.c +2 -2
  31. data/ext/isomorfeus_ferret_ext/frt_global.c +10 -4
  32. data/ext/isomorfeus_ferret_ext/frt_global.h +11 -15
  33. data/ext/isomorfeus_ferret_ext/frt_hash.c +8 -8
  34. data/ext/isomorfeus_ferret_ext/frt_hash.h +1 -2
  35. data/ext/isomorfeus_ferret_ext/frt_hashset.c +20 -40
  36. data/ext/isomorfeus_ferret_ext/frt_hashset.h +1 -2
  37. data/ext/isomorfeus_ferret_ext/frt_helper.c +7 -15
  38. data/ext/isomorfeus_ferret_ext/frt_in_stream.c +35 -45
  39. data/ext/isomorfeus_ferret_ext/frt_in_stream.h +3 -2
  40. data/ext/isomorfeus_ferret_ext/frt_ind.c +21 -39
  41. data/ext/isomorfeus_ferret_ext/frt_ind.h +1 -1
  42. data/ext/isomorfeus_ferret_ext/frt_index.c +334 -848
  43. data/ext/isomorfeus_ferret_ext/frt_index.h +4 -105
  44. data/ext/isomorfeus_ferret_ext/frt_lang.c +5 -10
  45. data/ext/isomorfeus_ferret_ext/frt_lazy_doc.c +3 -3
  46. data/ext/isomorfeus_ferret_ext/frt_lazy_doc.h +1 -1
  47. data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.c +18 -25
  48. data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.h +5 -5
  49. data/ext/isomorfeus_ferret_ext/frt_mdbx_store.c +102 -70
  50. data/ext/isomorfeus_ferret_ext/frt_mempool.c +8 -16
  51. data/ext/isomorfeus_ferret_ext/frt_multimapper.c +23 -46
  52. data/ext/isomorfeus_ferret_ext/frt_multimapper.h +4 -8
  53. data/ext/isomorfeus_ferret_ext/frt_out_stream.c +31 -43
  54. data/ext/isomorfeus_ferret_ext/frt_out_stream.h +2 -2
  55. data/ext/isomorfeus_ferret_ext/frt_posh.c +6 -819
  56. data/ext/isomorfeus_ferret_ext/frt_posh.h +0 -57
  57. data/ext/isomorfeus_ferret_ext/frt_priorityqueue.c +11 -22
  58. data/ext/isomorfeus_ferret_ext/frt_priorityqueue.h +1 -2
  59. data/ext/isomorfeus_ferret_ext/frt_q_boolean.c +131 -217
  60. data/ext/isomorfeus_ferret_ext/frt_q_const_score.c +2 -2
  61. data/ext/isomorfeus_ferret_ext/frt_q_filtered_query.c +4 -4
  62. data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +18 -26
  63. data/ext/isomorfeus_ferret_ext/frt_q_multi_term.c +27 -28
  64. data/ext/isomorfeus_ferret_ext/frt_q_parser.c +49 -98
  65. data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +64 -116
  66. data/ext/isomorfeus_ferret_ext/frt_q_range.c +8 -14
  67. data/ext/isomorfeus_ferret_ext/frt_q_span.c +251 -365
  68. data/ext/isomorfeus_ferret_ext/frt_q_term.c +9 -9
  69. data/ext/isomorfeus_ferret_ext/frt_q_wildcard.c +1 -2
  70. data/ext/isomorfeus_ferret_ext/frt_ram_store.c +134 -85
  71. data/ext/isomorfeus_ferret_ext/frt_search.c +109 -191
  72. data/ext/isomorfeus_ferret_ext/frt_search.h +6 -6
  73. data/ext/isomorfeus_ferret_ext/frt_similarity.c +12 -23
  74. data/ext/isomorfeus_ferret_ext/frt_similarity.h +1 -2
  75. data/ext/isomorfeus_ferret_ext/frt_sort.c +20 -20
  76. data/ext/isomorfeus_ferret_ext/frt_store.c +13 -25
  77. data/ext/isomorfeus_ferret_ext/frt_store.h +86 -52
  78. data/ext/isomorfeus_ferret_ext/frt_term_vectors.c +8 -16
  79. data/ext/isomorfeus_ferret_ext/frt_win32.h +5 -10
  80. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +12 -11
  81. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.h +11 -13
  82. data/ext/isomorfeus_ferret_ext/lz4.c +422 -195
  83. data/ext/isomorfeus_ferret_ext/lz4.h +114 -46
  84. data/ext/isomorfeus_ferret_ext/lz4frame.c +421 -242
  85. data/ext/isomorfeus_ferret_ext/lz4frame.h +122 -53
  86. data/ext/isomorfeus_ferret_ext/lz4hc.c +127 -111
  87. data/ext/isomorfeus_ferret_ext/lz4hc.h +14 -14
  88. data/ext/isomorfeus_ferret_ext/lz4xxhash.h +1 -1
  89. data/ext/isomorfeus_ferret_ext/mdbx.c +3762 -2526
  90. data/ext/isomorfeus_ferret_ext/mdbx.h +115 -70
  91. data/ext/isomorfeus_ferret_ext/test.c +41 -88
  92. data/ext/isomorfeus_ferret_ext/test.h +3 -6
  93. data/ext/isomorfeus_ferret_ext/test_1710.c +11 -13
  94. data/ext/isomorfeus_ferret_ext/test_analysis.c +32 -64
  95. data/ext/isomorfeus_ferret_ext/test_array.c +6 -12
  96. data/ext/isomorfeus_ferret_ext/test_bitvector.c +12 -24
  97. data/ext/isomorfeus_ferret_ext/test_document.c +23 -33
  98. data/ext/isomorfeus_ferret_ext/test_except.c +10 -21
  99. data/ext/isomorfeus_ferret_ext/test_fields.c +62 -68
  100. data/ext/isomorfeus_ferret_ext/test_file_deleter.c +16 -25
  101. data/ext/isomorfeus_ferret_ext/test_filter.c +22 -33
  102. data/ext/isomorfeus_ferret_ext/test_global.c +14 -29
  103. data/ext/isomorfeus_ferret_ext/test_hash.c +19 -38
  104. data/ext/isomorfeus_ferret_ext/test_hashset.c +8 -16
  105. data/ext/isomorfeus_ferret_ext/test_helper.c +4 -8
  106. data/ext/isomorfeus_ferret_ext/test_highlighter.c +16 -28
  107. data/ext/isomorfeus_ferret_ext/test_index.c +307 -519
  108. data/ext/isomorfeus_ferret_ext/test_lang.c +7 -14
  109. data/ext/isomorfeus_ferret_ext/test_mdbx_store.c +2 -5
  110. data/ext/isomorfeus_ferret_ext/test_mempool.c +5 -10
  111. data/ext/isomorfeus_ferret_ext/test_multimapper.c +3 -6
  112. data/ext/isomorfeus_ferret_ext/test_priorityqueue.c +9 -18
  113. data/ext/isomorfeus_ferret_ext/test_q_const_score.c +4 -6
  114. data/ext/isomorfeus_ferret_ext/test_q_filtered.c +3 -4
  115. data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +9 -15
  116. data/ext/isomorfeus_ferret_ext/test_q_parser.c +8 -16
  117. data/ext/isomorfeus_ferret_ext/test_q_span.c +19 -35
  118. data/ext/isomorfeus_ferret_ext/test_ram_store.c +14 -13
  119. data/ext/isomorfeus_ferret_ext/test_search.c +66 -115
  120. data/ext/isomorfeus_ferret_ext/test_segments.c +8 -13
  121. data/ext/isomorfeus_ferret_ext/test_similarity.c +2 -4
  122. data/ext/isomorfeus_ferret_ext/test_sort.c +17 -27
  123. data/ext/isomorfeus_ferret_ext/test_store.c +96 -115
  124. data/ext/isomorfeus_ferret_ext/test_term.c +9 -15
  125. data/ext/isomorfeus_ferret_ext/test_term_vectors.c +9 -14
  126. data/ext/isomorfeus_ferret_ext/test_test.c +4 -8
  127. data/ext/isomorfeus_ferret_ext/test_threading.c +15 -21
  128. data/ext/isomorfeus_ferret_ext/testhelper.c +11 -21
  129. data/ext/isomorfeus_ferret_ext/testhelper.h +1 -1
  130. data/ext/isomorfeus_ferret_ext/tests_all.h +1 -2
  131. data/lib/isomorfeus/ferret/index/index.rb +8 -8
  132. data/lib/isomorfeus/ferret/version.rb +1 -1
  133. metadata +32 -6
@@ -1,3 +1,8 @@
1
+ /* prevent warning: #warning Please include winsock2.h before windows.h [-Wcpp] */
2
+ #ifdef _WIN32
3
+ # include <winsock2.h>
4
+ #endif
5
+
1
6
  #include "brotli_decode.h"
2
7
  #include "brotli_encode.h"
3
8
  #include "bzlib.h"
@@ -12,6 +17,7 @@
12
17
  */
13
18
  FrtInStream *frt_is_new(void) {
14
19
  FrtInStream *is = FRT_ALLOC(FrtInStream);
20
+ is->folder_name = NULL;
15
21
  is->f = FRT_ALLOC_AND_ZERO(FrtInStreamFile);
16
22
  is->f->ref_cnt = 1;
17
23
  is->buf.start = 0;
@@ -28,8 +34,7 @@ FrtInStream *frt_is_new(void) {
28
34
  * @raise FRT_IO_ERROR if there is a error reading from the filesystem
29
35
  * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
30
36
  */
31
- static void frt_is_refill(FrtInStream *is)
32
- {
37
+ static void frt_is_refill(FrtInStream *is) {
33
38
  frt_off_t start = is->buf.start + is->buf.pos;
34
39
  frt_off_t last = start + FRT_BUFFER_SIZE;
35
40
  frt_off_t flen = is->m->length_i(is);
@@ -65,22 +70,18 @@ static void frt_is_refill(FrtInStream *is)
65
70
  * @raise FRT_IO_ERROR if there is a error reading from the filesystem
66
71
  * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
67
72
  */
68
- frt_uchar frt_is_read_byte(FrtInStream *is)
69
- {
73
+ frt_uchar frt_is_read_byte(FrtInStream *is) {
70
74
  if (is->buf.pos >= is->buf.len) {
71
75
  frt_is_refill(is);
72
76
  }
73
-
74
77
  return read_byte(is);
75
78
  }
76
79
 
77
- off_t frt_is_pos(FrtInStream *is)
78
- {
80
+ off_t frt_is_pos(FrtInStream *is) {
79
81
  return is->buf.start + is->buf.pos;
80
82
  }
81
83
 
82
- frt_uchar *frt_is_read_bytes(FrtInStream *is, frt_uchar *buf, int len)
83
- {
84
+ frt_uchar *frt_is_read_bytes(FrtInStream *is, frt_uchar *buf, int len) {
84
85
  int i;
85
86
  frt_off_t start;
86
87
 
@@ -88,8 +89,7 @@ frt_uchar *frt_is_read_bytes(FrtInStream *is, frt_uchar *buf, int len)
88
89
  for (i = 0; i < len; i++) {
89
90
  buf[i] = read_byte(is);
90
91
  }
91
- }
92
- else { /* read all-at-once */
92
+ } else { /* read all-at-once */
93
93
  start = frt_is_pos(is);
94
94
  is->m->seek_i(is, start);
95
95
  is->m->read_i(is, buf, len);
@@ -122,23 +122,27 @@ void frt_is_close(FrtInStream *is) {
122
122
  is->m->close_i(is);
123
123
  free(is->f);
124
124
  }
125
+ if (is->folder_name) {
126
+ free((void *)is->folder_name);
127
+ }
125
128
  free(is);
126
129
  }
127
130
  }
128
131
 
129
- FrtInStream *frt_is_clone(FrtInStream *is)
130
- {
132
+ FrtInStream *frt_is_clone(FrtInStream *is) {
131
133
  if (!(is->f))
132
134
  return NULL;
133
135
  FrtInStream *new_is = FRT_ALLOC(FrtInStream);
134
136
  memcpy(new_is, is, sizeof(FrtInStream));
137
+ if (is->folder_name) {
138
+ new_is->folder_name = frt_estrdup(is->folder_name);
139
+ }
135
140
  new_is->ref_cnt = 1;
136
141
  FRT_REF(new_is->f);
137
142
  return new_is;
138
143
  }
139
144
 
140
- frt_i32 frt_is_read_i32(FrtInStream *is)
141
- {
145
+ frt_i32 frt_is_read_i32(FrtInStream *is) {
142
146
  return ((frt_i32)frt_is_read_byte(is) << 24) |
143
147
  ((frt_i32)frt_is_read_byte(is) << 16) |
144
148
  ((frt_i32)frt_is_read_byte(is) << 8) |
@@ -146,8 +150,7 @@ frt_i32 frt_is_read_i32(FrtInStream *is)
146
150
  }
147
151
 
148
152
 
149
- frt_i64 frt_is_read_i64(FrtInStream *is)
150
- {
153
+ frt_i64 frt_is_read_i64(FrtInStream *is) {
151
154
  return ((frt_i64)frt_is_read_byte(is) << 56) |
152
155
  ((frt_i64)frt_is_read_byte(is) << 48) |
153
156
  ((frt_i64)frt_is_read_byte(is) << 40) |
@@ -159,16 +162,14 @@ frt_i64 frt_is_read_i64(FrtInStream *is)
159
162
  }
160
163
 
161
164
 
162
- frt_u32 frt_is_read_u32(FrtInStream *is)
163
- {
165
+ frt_u32 frt_is_read_u32(FrtInStream *is) {
164
166
  return ((frt_u32)frt_is_read_byte(is) << 24) |
165
167
  ((frt_u32)frt_is_read_byte(is) << 16) |
166
168
  ((frt_u32)frt_is_read_byte(is) << 8) |
167
169
  ((frt_u32)frt_is_read_byte(is));
168
170
  }
169
171
 
170
- frt_u64 frt_is_read_u64(FrtInStream *is)
171
- {
172
+ frt_u64 frt_is_read_u64(FrtInStream *is) {
172
173
  return ((frt_u64)frt_is_read_byte(is) << 56) |
173
174
  ((frt_u64)frt_is_read_byte(is) << 48) |
174
175
  ((frt_u64)frt_is_read_byte(is) << 40) |
@@ -181,8 +182,7 @@ frt_u64 frt_is_read_u64(FrtInStream *is)
181
182
 
182
183
 
183
184
  /* optimized to use unchecked read_byte if there is definitely space */
184
- unsigned int frt_is_read_vint(FrtInStream *is)
185
- {
185
+ unsigned int frt_is_read_vint(FrtInStream *is) {
186
186
  register unsigned int res, b;
187
187
  register int shift = 7;
188
188
 
@@ -195,8 +195,7 @@ unsigned int frt_is_read_vint(FrtInStream *is)
195
195
  res |= (b & 0x7F) << shift;
196
196
  shift += 7;
197
197
  }
198
- }
199
- else { /* unchecked optimization */
198
+ } else { /* unchecked optimization */
200
199
  b = read_byte(is);
201
200
  res = b & 0x7F; /* 0x7F = 0b01111111 */
202
201
 
@@ -212,8 +211,7 @@ unsigned int frt_is_read_vint(FrtInStream *is)
212
211
 
213
212
 
214
213
  /* optimized to use unchecked read_byte if there is definitely space */
215
- off_t frt_is_read_voff_t(FrtInStream *is)
216
- {
214
+ off_t frt_is_read_voff_t(FrtInStream *is) {
217
215
  register frt_off_t res, b;
218
216
  register int shift = 7;
219
217
 
@@ -226,8 +224,7 @@ off_t frt_is_read_voff_t(FrtInStream *is)
226
224
  res |= (b & 0x7F) << shift;
227
225
  shift += 7;
228
226
  }
229
- }
230
- else { /* unchecked optimization */
227
+ } else { /* unchecked optimization */
231
228
  b = read_byte(is);
232
229
  res = b & 0x7F; /* 0x7F = 0b01111111 */
233
230
 
@@ -242,8 +239,7 @@ off_t frt_is_read_voff_t(FrtInStream *is)
242
239
  }
243
240
 
244
241
  /* optimized to use unchecked read_byte if there is definitely space */
245
- frt_u64 frt_is_read_vll(FrtInStream *is)
246
- {
242
+ frt_u64 frt_is_read_vll(FrtInStream *is) {
247
243
  register frt_u64 res, b;
248
244
  register int shift = 7;
249
245
 
@@ -256,8 +252,7 @@ frt_u64 frt_is_read_vll(FrtInStream *is)
256
252
  res |= (b & 0x7F) << shift;
257
253
  shift += 7;
258
254
  }
259
- }
260
- else { /* unchecked optimization */
255
+ } else { /* unchecked optimization */
261
256
  b = read_byte(is);
262
257
  res = b & 0x7F; /* 0x7F = 0b01111111 */
263
258
 
@@ -271,16 +266,14 @@ frt_u64 frt_is_read_vll(FrtInStream *is)
271
266
  return res;
272
267
  }
273
268
 
274
- void frt_is_skip_vints(FrtInStream *is, register int cnt)
275
- {
269
+ void frt_is_skip_vints(FrtInStream *is, register int cnt) {
276
270
  for (; cnt > 0; cnt--) {
277
271
  while ((frt_is_read_byte(is) & 0x80) != 0) {
278
272
  }
279
273
  }
280
274
  }
281
275
 
282
- char *frt_is_read_string(FrtInStream *is)
283
- {
276
+ char *frt_is_read_string(FrtInStream *is) {
284
277
  register int length = (int) frt_is_read_vint(is);
285
278
  char *str = FRT_ALLOC_N(char, length + 1);
286
279
  str[length] = '\0';
@@ -290,8 +283,7 @@ char *frt_is_read_string(FrtInStream *is)
290
283
  for (i = 0; i < length; i++) {
291
284
  str[i] = frt_is_read_byte(is);
292
285
  }
293
- }
294
- else { /* unchecked optimization */
286
+ } else { /* unchecked optimization */
295
287
  memcpy(str, is->buf.buf + is->buf.pos, length);
296
288
  is->buf.pos += length;
297
289
  }
@@ -299,8 +291,7 @@ char *frt_is_read_string(FrtInStream *is)
299
291
  return str;
300
292
  }
301
293
 
302
- char *frt_is_read_string_safe(FrtInStream *is)
303
- {
294
+ char *frt_is_read_string_safe(FrtInStream *is) {
304
295
  register int length = (int) frt_is_read_vint(is);
305
296
  char *str = FRT_ALLOC_N(char, length + 1);
306
297
  str[length] = '\0';
@@ -311,8 +302,7 @@ char *frt_is_read_string_safe(FrtInStream *is)
311
302
  for (i = 0; i < length; i++) {
312
303
  str[i] = frt_is_read_byte(is);
313
304
  }
314
- }
315
- else { /* unchecked optimization */
305
+ } else { /* unchecked optimization */
316
306
  memcpy(str, is->buf.buf + is->buf.pos, length);
317
307
  is->buf.pos += length;
318
308
  }
@@ -478,8 +468,8 @@ static char *frt_is_read_lz4_compressed_bytes(FrtInStream *is, int compressed_le
478
468
  return buf_out;
479
469
  }
480
470
 
481
- char *frt_is_read_compressed_bytes(FrtInStream *is, int compressed_len, int *len, FrtCompressionType compression) {
482
- switch (compression) {
471
+ char *frt_is_read_compressed_bytes(FrtInStream *is, int compressed_len, int *len, FrtCompressionType compression_type) {
472
+ switch (compression_type) {
483
473
  case FRT_COMPRESSION_BROTLI:
484
474
  return frt_is_read_brotli_compressed_bytes(is, compressed_len, len);
485
475
  case FRT_COMPRESSION_BZ2:
@@ -56,6 +56,7 @@ typedef struct FrtInStreamFile {
56
56
  } FrtInStreamFile;
57
57
 
58
58
  struct FrtInStream {
59
+ const char *folder_name;
59
60
  FrtBuffer buf;
60
61
  struct FrtInStreamFile *f;
61
62
  union {
@@ -233,8 +234,8 @@ extern char *frt_is_read_string(FrtInStream *is);
233
234
  */
234
235
  extern char *frt_is_read_string_safe(FrtInStream *is);
235
236
 
236
- extern char *frt_is_read_compressed_bytes(FrtInStream *is, int compressed_len, int *len, FrtCompressionType compression);
237
+ extern char *frt_is_read_compressed_bytes(FrtInStream *is, int compressed_len, int *len, FrtCompressionType compression_type);
237
238
 
238
239
  #define frt_is_length(mis) mis->m->length_i(mis)
239
240
 
240
- #endif
241
+ #endif
@@ -44,6 +44,7 @@ FrtIndex *frt_index_new(FrtStore *store, FrtAnalyzer *analyzer, FrtHashSet *def_
44
44
  FRT_REF(store);
45
45
  } else {
46
46
  self->store = frt_open_ram_store(NULL);
47
+ self->store->create_folder(self->store, segm_idx_name);
47
48
  create = true;
48
49
  }
49
50
  if (analyzer) {
@@ -79,8 +80,7 @@ FrtIndex *frt_index_new(FrtStore *store, FrtAnalyzer *analyzer, FrtHashSet *def_
79
80
  return self;
80
81
  }
81
82
 
82
- void frt_index_destroy(FrtIndex *self)
83
- {
83
+ void frt_index_destroy(FrtIndex *self) {
84
84
  pthread_mutex_destroy(&self->mutex);
85
85
  INDEX_CLOSE_READER(self);
86
86
  if (self->iw) frt_iw_close(self->iw);
@@ -91,8 +91,7 @@ void frt_index_destroy(FrtIndex *self)
91
91
  free(self);
92
92
  }
93
93
 
94
- void frt_ensure_writer_open(FrtIndex *self)
95
- {
94
+ void frt_ensure_writer_open(FrtIndex *self) {
96
95
  if (!self->iw) {
97
96
  INDEX_CLOSE_READER(self);
98
97
 
@@ -102,8 +101,7 @@ void frt_ensure_writer_open(FrtIndex *self)
102
101
  }
103
102
  }
104
103
 
105
- void frt_ensure_reader_open(FrtIndex *self)
106
- {
104
+ void frt_ensure_reader_open(FrtIndex *self) {
107
105
  if (self->ir) {
108
106
  if (self->check_latest && !frt_ir_is_latest(self->ir)) {
109
107
  INDEX_CLOSE_READER(self);
@@ -118,16 +116,14 @@ void frt_ensure_reader_open(FrtIndex *self)
118
116
  self->ir = frt_ir_open(NULL, self->store);
119
117
  }
120
118
 
121
- void frt_ensure_searcher_open(FrtIndex *self)
122
- {
119
+ void frt_ensure_searcher_open(FrtIndex *self) {
123
120
  frt_ensure_reader_open(self);
124
121
  if (!self->sea) {
125
122
  self->sea = frt_isea_new(self->ir);
126
123
  }
127
124
  }
128
125
 
129
- int frt_index_size(FrtIndex *self)
130
- {
126
+ int frt_index_size(FrtIndex *self) {
131
127
  int size;
132
128
  pthread_mutex_lock(&self->mutex);
133
129
  {
@@ -138,8 +134,7 @@ int frt_index_size(FrtIndex *self)
138
134
  return size;
139
135
  }
140
136
 
141
- bool frt_index_is_deleted(FrtIndex *self, int doc_num)
142
- {
137
+ bool frt_index_is_deleted(FrtIndex *self, int doc_num) {
143
138
  bool is_del;
144
139
  pthread_mutex_lock(&self->mutex);
145
140
  {
@@ -151,8 +146,7 @@ bool frt_index_is_deleted(FrtIndex *self, int doc_num)
151
146
  }
152
147
 
153
148
  static void index_del_doc_with_key_i(FrtIndex *self, FrtDocument *doc,
154
- FrtHashSet *key)
155
- {
149
+ FrtHashSet *key) {
156
150
  FrtQuery *q;
157
151
  FrtTopDocs *td;
158
152
  FrtDocField *df;
@@ -182,14 +176,13 @@ static void index_del_doc_with_key_i(FrtIndex *self, FrtDocument *doc,
182
176
  frt_td_destroy(td);
183
177
  FRT_RAISE(FRT_ARG_ERROR, "%s", NON_UNIQUE_KEY_ERROR_MSG);
184
178
  } else if (td->total_hits == 1) {
185
- frt_ir_delete_doc(self->ir, td->hits[0]->doc);
179
+ frt_ir_delete_doc(self->ir, td->hits[0]->doc_num);
186
180
  }
187
181
  frt_q_deref(q);
188
182
  frt_td_destroy(td);
189
183
  }
190
184
 
191
- static void index_add_doc_i(FrtIndex *self, FrtDocument *doc)
192
- {
185
+ static void index_add_doc_i(FrtIndex *self, FrtDocument *doc) {
193
186
  if (self->key) {
194
187
  index_del_doc_with_key_i(self, doc, self->key);
195
188
  }
@@ -198,8 +191,7 @@ static void index_add_doc_i(FrtIndex *self, FrtDocument *doc)
198
191
  AUTOFLUSH_IW(self);
199
192
  }
200
193
 
201
- void frt_index_add_doc(FrtIndex *self, FrtDocument *doc)
202
- {
194
+ void frt_index_add_doc(FrtIndex *self, FrtDocument *doc) {
203
195
  pthread_mutex_lock(&self->mutex);
204
196
  {
205
197
  index_add_doc_i(self, doc);
@@ -207,8 +199,7 @@ void frt_index_add_doc(FrtIndex *self, FrtDocument *doc)
207
199
  pthread_mutex_unlock(&self->mutex);
208
200
  }
209
201
 
210
- FrtQuery *frt_index_get_query(FrtIndex *self, char *qstr, rb_encoding *encoding)
211
- {
202
+ FrtQuery *frt_index_get_query(FrtIndex *self, char *qstr, rb_encoding *encoding) {
212
203
  int i;
213
204
  FrtFieldInfos *fis;
214
205
  frt_ensure_searcher_open(self);
@@ -221,8 +212,7 @@ FrtQuery *frt_index_get_query(FrtIndex *self, char *qstr, rb_encoding *encoding)
221
212
 
222
213
  FrtTopDocs *frt_index_search_str(FrtIndex *self, char *qstr, int first_doc,
223
214
  int num_docs, FrtFilter *filter, FrtSort *sort,
224
- FrtPostFilter *post_filter, rb_encoding *encoding)
225
- {
215
+ FrtPostFilter *post_filter, rb_encoding *encoding) {
226
216
  FrtQuery *query;
227
217
  FrtTopDocs *td;
228
218
  query = frt_index_get_query(self, qstr, encoding); /* will ensure_searcher is open */
@@ -232,16 +222,14 @@ FrtTopDocs *frt_index_search_str(FrtIndex *self, char *qstr, int first_doc,
232
222
  return td;
233
223
  }
234
224
 
235
- FrtDocument *frt_index_get_doc(FrtIndex *self, int doc_num)
236
- {
225
+ FrtDocument *frt_index_get_doc(FrtIndex *self, int doc_num) {
237
226
  FrtDocument *doc;
238
227
  frt_ensure_reader_open(self);
239
228
  doc = self->ir->get_doc(self->ir, doc_num);
240
229
  return doc;
241
230
  }
242
231
 
243
- FrtDocument *frt_index_get_doc_ts(FrtIndex *self, int doc_num)
244
- {
232
+ FrtDocument *frt_index_get_doc_ts(FrtIndex *self, int doc_num) {
245
233
  FrtDocument *doc;
246
234
  pthread_mutex_lock(&self->mutex);
247
235
  {
@@ -267,13 +255,11 @@ FrtDocument *frt_index_get_doc_term(FrtIndex *self, ID field, const char *term)
267
255
  return doc;
268
256
  }
269
257
 
270
- FrtDocument *frt_index_get_doc_id(FrtIndex *self, const char *id)
271
- {
258
+ FrtDocument *frt_index_get_doc_num(FrtIndex *self, const char *id) {
272
259
  return frt_index_get_doc_term(self, self->id_field, id);
273
260
  }
274
261
 
275
- void frt_index_delete(FrtIndex *self, int doc_num)
276
- {
262
+ void frt_index_delete(FrtIndex *self, int doc_num) {
277
263
  pthread_mutex_lock(&self->mutex);
278
264
  {
279
265
  frt_ensure_reader_open(self);
@@ -305,20 +291,17 @@ void frt_index_delete_term(FrtIndex *self, ID field, const char *term) {
305
291
  pthread_mutex_unlock(&self->mutex);
306
292
  }
307
293
 
308
- void frt_index_delete_id(FrtIndex *self, const char *id)
309
- {
294
+ void frt_index_delete_id(FrtIndex *self, const char *id) {
310
295
  frt_index_delete_term(self, self->id_field, id);
311
296
  }
312
297
 
313
- static void index_qdel_i(FrtSearcher *sea, int doc_num, float score, void *arg)
314
- {
298
+ static void index_qdel_i(FrtSearcher *sea, int doc_num, float score, void *arg) {
315
299
  (void)score; (void)arg;
316
300
  frt_ir_delete_doc(((FrtIndexSearcher *)sea)->ir, doc_num);
317
301
  }
318
302
 
319
303
  void frt_index_delete_query(FrtIndex *self, FrtQuery *q, FrtFilter *f,
320
- FrtPostFilter *post_filter)
321
- {
304
+ FrtPostFilter *post_filter) {
322
305
  pthread_mutex_lock(&self->mutex);
323
306
  {
324
307
  frt_ensure_searcher_open(self);
@@ -329,8 +312,7 @@ void frt_index_delete_query(FrtIndex *self, FrtQuery *q, FrtFilter *f,
329
312
  }
330
313
 
331
314
  void frt_index_delete_query_str(FrtIndex *self, char *qstr, FrtFilter *f,
332
- FrtPostFilter *post_filter, rb_encoding *encoding)
333
- {
315
+ FrtPostFilter *post_filter, rb_encoding *encoding) {
334
316
  FrtQuery *q = frt_index_get_query(self, qstr, encoding);
335
317
  frt_index_delete_query(self, q, f, post_filter);
336
318
  frt_q_deref(q);
@@ -38,7 +38,7 @@ extern FrtTopDocs *frt_index_search_str(FrtIndex *self, char *query, int first_d
38
38
  extern FrtQuery *frt_index_get_query(FrtIndex *self, char *qstr, rb_encoding *encoding);
39
39
  extern FrtDocument *frt_index_get_doc(FrtIndex *self, int doc_num);
40
40
  extern FrtDocument *frt_index_get_doc_ts(FrtIndex *self, int doc_num);
41
- extern FrtDocument *frt_index_get_doc_id(FrtIndex *self, const char *id);
41
+ extern FrtDocument *frt_index_get_doc_num(FrtIndex *self, const char *id);
42
42
  extern FrtDocument *frt_index_get_doc_term(FrtIndex *self, ID field, const char *term);
43
43
  extern void frt_index_delete(FrtIndex *self, int doc_num);
44
44
  extern void frt_index_delete_term(FrtIndex *self, ID field, const char *term);