isomorfeus-ferret 0.17.1 → 0.17.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) 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/bm_store.c +2 -0
  6. data/ext/isomorfeus_ferret_ext/brotli_dec_decode.c +4 -2
  7. data/ext/isomorfeus_ferret_ext/brotli_enc_encode.c +3 -2
  8. data/ext/isomorfeus_ferret_ext/frb_analysis.c +4 -5
  9. data/ext/isomorfeus_ferret_ext/frb_field_info.c +3 -4
  10. data/ext/isomorfeus_ferret_ext/frb_index.c +118 -160
  11. data/ext/isomorfeus_ferret_ext/frb_lazy_doc.c +14 -16
  12. data/ext/isomorfeus_ferret_ext/frb_search.c +31 -23
  13. data/ext/isomorfeus_ferret_ext/frb_store.c +27 -13
  14. data/ext/isomorfeus_ferret_ext/frb_utils.c +3 -6
  15. data/ext/isomorfeus_ferret_ext/frt_analysis.c +39 -46
  16. data/ext/isomorfeus_ferret_ext/frt_analysis.h +9 -9
  17. data/ext/isomorfeus_ferret_ext/frt_array.c +11 -22
  18. data/ext/isomorfeus_ferret_ext/frt_bitvector.h +3 -6
  19. data/ext/isomorfeus_ferret_ext/frt_doc_field.c +87 -0
  20. data/ext/isomorfeus_ferret_ext/frt_doc_field.h +26 -0
  21. data/ext/isomorfeus_ferret_ext/frt_document.c +4 -97
  22. data/ext/isomorfeus_ferret_ext/frt_document.h +2 -27
  23. data/ext/isomorfeus_ferret_ext/frt_except.c +50 -6
  24. data/ext/isomorfeus_ferret_ext/frt_except.h +3 -2
  25. data/ext/isomorfeus_ferret_ext/frt_field_index.c +13 -32
  26. data/ext/isomorfeus_ferret_ext/frt_field_index.h +0 -6
  27. data/ext/isomorfeus_ferret_ext/frt_field_info.c +69 -0
  28. data/ext/isomorfeus_ferret_ext/frt_field_info.h +49 -0
  29. data/ext/isomorfeus_ferret_ext/frt_field_infos.c +196 -0
  30. data/ext/isomorfeus_ferret_ext/frt_field_infos.h +35 -0
  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 +482 -0
  39. data/ext/isomorfeus_ferret_ext/frt_in_stream.h +241 -0
  40. data/ext/isomorfeus_ferret_ext/frt_ind.c +20 -49
  41. data/ext/isomorfeus_ferret_ext/frt_ind.h +0 -1
  42. data/ext/isomorfeus_ferret_ext/frt_index.c +296 -1857
  43. data/ext/isomorfeus_ferret_ext/frt_index.h +2 -145
  44. data/ext/isomorfeus_ferret_ext/frt_lang.c +5 -10
  45. data/ext/isomorfeus_ferret_ext/frt_lazy_doc.c +29 -0
  46. data/ext/isomorfeus_ferret_ext/frt_lazy_doc.h +19 -0
  47. data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.c +93 -0
  48. data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.h +33 -0
  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 +334 -0
  54. data/ext/isomorfeus_ferret_ext/frt_out_stream.h +198 -0
  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 +85 -171
  60. data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +8 -16
  61. data/ext/isomorfeus_ferret_ext/frt_q_multi_term.c +1 -2
  62. data/ext/isomorfeus_ferret_ext/frt_q_parser.c +49 -98
  63. data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +52 -104
  64. data/ext/isomorfeus_ferret_ext/frt_q_range.c +6 -12
  65. data/ext/isomorfeus_ferret_ext/frt_q_span.c +113 -226
  66. data/ext/isomorfeus_ferret_ext/frt_q_wildcard.c +1 -2
  67. data/ext/isomorfeus_ferret_ext/frt_ram_store.c +134 -85
  68. data/ext/isomorfeus_ferret_ext/frt_ram_store.h +12 -0
  69. data/ext/isomorfeus_ferret_ext/frt_search.c +82 -164
  70. data/ext/isomorfeus_ferret_ext/frt_similarity.c +11 -22
  71. data/ext/isomorfeus_ferret_ext/frt_similarity.h +1 -2
  72. data/ext/isomorfeus_ferret_ext/frt_store.c +13 -536
  73. data/ext/isomorfeus_ferret_ext/frt_store.h +90 -495
  74. data/ext/isomorfeus_ferret_ext/frt_stream.h +18 -0
  75. data/ext/isomorfeus_ferret_ext/frt_term_vectors.c +8 -16
  76. data/ext/isomorfeus_ferret_ext/frt_win32.h +5 -10
  77. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +12 -11
  78. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.h +11 -13
  79. data/ext/isomorfeus_ferret_ext/lz4.c +422 -195
  80. data/ext/isomorfeus_ferret_ext/lz4.h +114 -46
  81. data/ext/isomorfeus_ferret_ext/lz4frame.c +421 -242
  82. data/ext/isomorfeus_ferret_ext/lz4frame.h +122 -53
  83. data/ext/isomorfeus_ferret_ext/lz4hc.c +127 -111
  84. data/ext/isomorfeus_ferret_ext/lz4hc.h +14 -14
  85. data/ext/isomorfeus_ferret_ext/lz4xxhash.h +1 -1
  86. data/ext/isomorfeus_ferret_ext/mdbx.c +3762 -2526
  87. data/ext/isomorfeus_ferret_ext/mdbx.h +115 -70
  88. data/ext/isomorfeus_ferret_ext/test.c +40 -87
  89. data/ext/isomorfeus_ferret_ext/test.h +3 -6
  90. data/ext/isomorfeus_ferret_ext/test_1710.c +11 -13
  91. data/ext/isomorfeus_ferret_ext/test_analysis.c +32 -64
  92. data/ext/isomorfeus_ferret_ext/test_array.c +6 -12
  93. data/ext/isomorfeus_ferret_ext/test_bitvector.c +12 -24
  94. data/ext/isomorfeus_ferret_ext/test_document.c +23 -33
  95. data/ext/isomorfeus_ferret_ext/test_except.c +10 -21
  96. data/ext/isomorfeus_ferret_ext/test_fields.c +62 -68
  97. data/ext/isomorfeus_ferret_ext/test_file_deleter.c +15 -24
  98. data/ext/isomorfeus_ferret_ext/test_filter.c +17 -27
  99. data/ext/isomorfeus_ferret_ext/test_global.c +14 -29
  100. data/ext/isomorfeus_ferret_ext/test_hash.c +19 -38
  101. data/ext/isomorfeus_ferret_ext/test_hashset.c +8 -16
  102. data/ext/isomorfeus_ferret_ext/test_helper.c +4 -8
  103. data/ext/isomorfeus_ferret_ext/test_highlighter.c +16 -28
  104. data/ext/isomorfeus_ferret_ext/test_index.c +277 -495
  105. data/ext/isomorfeus_ferret_ext/test_lang.c +7 -14
  106. data/ext/isomorfeus_ferret_ext/test_mdbx_store.c +2 -5
  107. data/ext/isomorfeus_ferret_ext/test_mempool.c +5 -10
  108. data/ext/isomorfeus_ferret_ext/test_multimapper.c +3 -6
  109. data/ext/isomorfeus_ferret_ext/test_priorityqueue.c +9 -18
  110. data/ext/isomorfeus_ferret_ext/test_q_const_score.c +4 -6
  111. data/ext/isomorfeus_ferret_ext/test_q_filtered.c +3 -4
  112. data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +9 -15
  113. data/ext/isomorfeus_ferret_ext/test_q_parser.c +8 -16
  114. data/ext/isomorfeus_ferret_ext/test_q_span.c +19 -35
  115. data/ext/isomorfeus_ferret_ext/test_ram_store.c +14 -13
  116. data/ext/isomorfeus_ferret_ext/test_search.c +60 -109
  117. data/ext/isomorfeus_ferret_ext/test_segments.c +8 -13
  118. data/ext/isomorfeus_ferret_ext/test_similarity.c +2 -4
  119. data/ext/isomorfeus_ferret_ext/test_sort.c +14 -24
  120. data/ext/isomorfeus_ferret_ext/test_store.c +96 -115
  121. data/ext/isomorfeus_ferret_ext/test_term.c +9 -15
  122. data/ext/isomorfeus_ferret_ext/test_term_vectors.c +9 -14
  123. data/ext/isomorfeus_ferret_ext/test_test.c +4 -8
  124. data/ext/isomorfeus_ferret_ext/test_threading.c +15 -30
  125. data/ext/isomorfeus_ferret_ext/testhelper.c +11 -21
  126. data/ext/isomorfeus_ferret_ext/testhelper.h +1 -1
  127. data/ext/isomorfeus_ferret_ext/tests_all.h +1 -2
  128. data/lib/isomorfeus/ferret/index/index.rb +1 -12
  129. data/lib/isomorfeus/ferret/version.rb +1 -1
  130. metadata +43 -4
@@ -0,0 +1,241 @@
1
+ #ifndef FRT_IN_STREAM_H
2
+ #define FRT_IN_STREAM_H
3
+
4
+ #include "frt_config.h"
5
+ #include "frt_global.h"
6
+ #include "frt_stream.h"
7
+ #include "frt_ram_store.h"
8
+
9
+ typedef struct FrtInStream FrtInStream;
10
+
11
+ struct FrtInStreamMethods {
12
+ /**
13
+ * Read +len+ characters from the input stream into the +offset+ position in
14
+ * +buf+, an array of unsigned characters.
15
+ *
16
+ * @param is self
17
+ * @param buf an array of characters which must be allocated with at least
18
+ * +offset+ + +len+ bytes
19
+ * @param len the number of bytes to read
20
+ * @raise FRT_IO_ERROR if there is an error reading from the input stream
21
+ */
22
+ void (*read_i)(struct FrtInStream *is, frt_uchar *buf, int len);
23
+
24
+ /**
25
+ * Seek position +pos+ in input stream +is+
26
+ *
27
+ * @param is self
28
+ * @param pos the position to seek
29
+ * @raise FRT_IO_ERROR if the seek fails
30
+ */
31
+ void (*seek_i)(struct FrtInStream *is, frt_off_t pos);
32
+
33
+ /**
34
+ * Returns the length of the input stream +is+
35
+ *
36
+ * @param is self
37
+ * @raise FRT_IO_ERROR if there is an error getting the file length
38
+ */
39
+ frt_off_t (*length_i)(struct FrtInStream *is);
40
+
41
+ /**
42
+ * Close the resources allocated to the inputstream +is+
43
+ *
44
+ * @param is self
45
+ * @raise FRT_IO_ERROR if the close fails
46
+ */
47
+ void (*close_i)(struct FrtInStream *is);
48
+ };
49
+
50
+ typedef struct FrtInStreamFile {
51
+ _Atomic unsigned int ref_cnt;
52
+ union {
53
+ int fd;
54
+ FrtRAMFile *rf;
55
+ } file;
56
+ } FrtInStreamFile;
57
+
58
+ struct FrtInStream {
59
+ const char *folder_name;
60
+ FrtBuffer buf;
61
+ struct FrtInStreamFile *f;
62
+ union {
63
+ frt_off_t pointer; /* only used by RAMIn */
64
+ char *path; /* only used by FSIn */
65
+ } d;
66
+ _Atomic unsigned int ref_cnt;
67
+ const struct FrtInStreamMethods *m;
68
+ };
69
+
70
+ /**
71
+ * Get the current position within an FrtInStream.
72
+ *
73
+ * @param is the FrtInStream to get the current position from
74
+ * @return the current position within the FrtInStream +is+
75
+ */
76
+ extern frt_off_t frt_is_pos(FrtInStream *is);
77
+
78
+ /**
79
+ * Set the current position in FrtInStream +is+ to +pos+.
80
+ *
81
+ * @param is the FrtInStream to set the current position in
82
+ * @param pos the position in FrtInStream to seek
83
+ * @raise FRT_IO_ERROR if there is a error seeking from the file-system
84
+ * @raise FRT_EOF_ERROR if there is an attempt to seek past the end of the file
85
+ */
86
+ extern void frt_is_seek(FrtInStream *is, frt_off_t pos);
87
+
88
+ /**
89
+ * Close the FrtInStream freeing all allocated resources.
90
+ *
91
+ * @param is the FrtInStream to close
92
+ * @raise FRT_IO_ERROR if there is an error closing the associated file
93
+ */
94
+ extern void frt_is_close(FrtInStream *is);
95
+
96
+ /**
97
+ * Clone the FrtInStream allocating a new FrtInStream structure
98
+ *
99
+ * @param is the FrtInStream to clone
100
+ * @return a newly allocated FrtInStream which is a clone of +is+
101
+ */
102
+ extern FrtInStream *frt_is_clone(FrtInStream *is);
103
+
104
+ /**
105
+ * Read a singly byte (unsigned char) from the FrtInStream +is+.
106
+ *
107
+ * @param is the Instream to read from
108
+ * @return a single unsigned char read from the FrtInStream +is+
109
+ * @raise FRT_IO_ERROR if there is a error reading from the file-system
110
+ * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
111
+ */
112
+ extern frt_uchar frt_is_read_byte(FrtInStream *is);
113
+
114
+ /**
115
+ * Read +len+ bytes from FrtInStream +is+ and write them to buffer +buf+
116
+ *
117
+ * @param is the FrtInStream to read from
118
+ * @param buf the buffer to read into, that is copy the bytes read to
119
+ * @param len the number of bytes to read
120
+ * @return the resultant buffer +buf+
121
+ * @raise FRT_IO_ERROR if there is a error reading from the file-system
122
+ * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
123
+ */
124
+ extern frt_uchar *frt_is_read_bytes(FrtInStream *is, frt_uchar *buf, int len);
125
+
126
+ /**
127
+ * Read a 32-bit unsigned integer from the FrtInStream.
128
+ *
129
+ * @param is the FrtInStream to read from
130
+ * @return a 32-bit unsigned integer
131
+ * @raise FRT_IO_ERROR if there is a error reading from the file-system
132
+ * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
133
+ */
134
+ extern frt_i32 frt_is_read_i32(FrtInStream *is);
135
+
136
+ /**
137
+ * Read a 64-bit unsigned integer from the FrtInStream.
138
+ *
139
+ * @param is the FrtInStream to read from
140
+ * @return a 64-bit unsigned integer
141
+ * @raise FRT_IO_ERROR if there is a error reading from the file-system
142
+ * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
143
+ */
144
+ extern frt_i64 frt_is_read_i64(FrtInStream *is);
145
+
146
+ /**
147
+ * Read a 32-bit signed integer from the FrtInStream.
148
+ *
149
+ * @param is the FrtInStream to read from
150
+ * @return a 32-bit signed integer
151
+ * @raise FRT_IO_ERROR if there is a error reading from the file-system
152
+ * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
153
+ */
154
+ extern frt_u32 frt_is_read_u32(FrtInStream *is);
155
+
156
+ /**
157
+ * Read a 64-bit signed integer from the FrtInStream.
158
+ *
159
+ * @param is the FrtInStream to read from
160
+ * @return a 64-bit signed integer
161
+ * @raise FRT_IO_ERROR if there is a error reading from the file-system
162
+ * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
163
+ */
164
+ extern frt_u64 frt_is_read_u64(FrtInStream *is);
165
+
166
+ /**
167
+ * Read a compressed (VINT) unsigned integer from the FrtInStream.
168
+ * TODO: describe VINT format
169
+ *
170
+ * @param is the FrtInStream to read from
171
+ * @return an int
172
+ * @raise FRT_IO_ERROR if there is a error reading from the file-system
173
+ * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
174
+ */
175
+ extern unsigned int frt_is_read_vint(FrtInStream *is);
176
+
177
+ /**
178
+ * Skip _cnt_ vints. This is a convenience method used for performance reasons
179
+ * to skip large numbers of vints. It is mostly used by TermDocEnums. When
180
+ * skipping positions os the proximity index file.
181
+ *
182
+ * @param is the FrtInStream to read from
183
+ * @param cnt the number of vints to skip
184
+ * @raise FRT_IO_ERROR if there is a error reading from the file-system
185
+ * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
186
+ */
187
+ extern void frt_is_skip_vints(FrtInStream *is, register int cnt);
188
+
189
+ /**
190
+ * Read a compressed (VINT) unsigned frt_off_t from the FrtInStream.
191
+ * TODO: describe VINT format
192
+ *
193
+ * @param is the FrtInStream to read from
194
+ * @return a frt_off_t
195
+ * @raise FRT_IO_ERROR if there is a error reading from the file-system
196
+ * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
197
+ */
198
+ extern frt_off_t frt_is_read_voff_t(FrtInStream *is);
199
+
200
+ /**
201
+ * Read a compressed (VINT) unsigned 64bit int from the FrtInStream.
202
+ * TODO: describe VINT format
203
+ *
204
+ * @param is the FrtInStream to read from
205
+ * @return a 64bit int
206
+ * @raise FRT_IO_ERROR if there is a error reading from the file-system
207
+ * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
208
+ */
209
+ extern frt_u64 frt_is_read_vll(FrtInStream *is);
210
+
211
+ /**
212
+ * Read a string from the FrtInStream. A string is an integer +length+ in vint
213
+ * format (see frt_is_read_vint) followed by +length+ bytes. This is the format
214
+ * used by frt_os_write_string.
215
+ *
216
+ * @param is the FrtInStream to read from
217
+ * @return a null byte delimited string
218
+ * @raise FRT_IO_ERROR if there is a error reading from the file-system
219
+ * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
220
+ */
221
+ extern char *frt_is_read_string(FrtInStream *is);
222
+
223
+ /**
224
+ * Read a string from the FrtInStream. A string is an integer +length+ in vint
225
+ * format (see frt_is_read_vint) followed by +length+ bytes. This is the format
226
+ * used by frt_os_write_string. This method is similar to +frt_is_read_string+ except
227
+ * that it will safely free all memory if there is an error reading the
228
+ * string.
229
+ *
230
+ * @param is the FrtInStream to read from
231
+ * @return a null byte delimited string
232
+ * @raise FRT_IO_ERROR if there is a error reading from the file-system
233
+ * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
234
+ */
235
+ extern char *frt_is_read_string_safe(FrtInStream *is);
236
+
237
+ extern char *frt_is_read_compressed_bytes(FrtInStream *is, int compressed_len, int *len, FrtCompressionType compression_type);
238
+
239
+ #define frt_is_length(mis) mis->m->length_i(mis)
240
+
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,19 +134,7 @@ int frt_index_size(FrtIndex *self)
138
134
  return size;
139
135
  }
140
136
 
141
- void frt_index_optimize(FrtIndex *self)
142
- {
143
- pthread_mutex_lock(&self->mutex);
144
- {
145
- frt_ensure_writer_open(self);
146
- frt_iw_optimize(self->iw);
147
- AUTOFLUSH_IW(self);
148
- }
149
- pthread_mutex_unlock(&self->mutex);
150
- }
151
-
152
- bool frt_index_is_deleted(FrtIndex *self, int doc_num)
153
- {
137
+ bool frt_index_is_deleted(FrtIndex *self, int doc_num) {
154
138
  bool is_del;
155
139
  pthread_mutex_lock(&self->mutex);
156
140
  {
@@ -162,8 +146,7 @@ bool frt_index_is_deleted(FrtIndex *self, int doc_num)
162
146
  }
163
147
 
164
148
  static void index_del_doc_with_key_i(FrtIndex *self, FrtDocument *doc,
165
- FrtHashSet *key)
166
- {
149
+ FrtHashSet *key) {
167
150
  FrtQuery *q;
168
151
  FrtTopDocs *td;
169
152
  FrtDocField *df;
@@ -199,8 +182,7 @@ static void index_del_doc_with_key_i(FrtIndex *self, FrtDocument *doc,
199
182
  frt_td_destroy(td);
200
183
  }
201
184
 
202
- static void index_add_doc_i(FrtIndex *self, FrtDocument *doc)
203
- {
185
+ static void index_add_doc_i(FrtIndex *self, FrtDocument *doc) {
204
186
  if (self->key) {
205
187
  index_del_doc_with_key_i(self, doc, self->key);
206
188
  }
@@ -209,8 +191,7 @@ static void index_add_doc_i(FrtIndex *self, FrtDocument *doc)
209
191
  AUTOFLUSH_IW(self);
210
192
  }
211
193
 
212
- void frt_index_add_doc(FrtIndex *self, FrtDocument *doc)
213
- {
194
+ void frt_index_add_doc(FrtIndex *self, FrtDocument *doc) {
214
195
  pthread_mutex_lock(&self->mutex);
215
196
  {
216
197
  index_add_doc_i(self, doc);
@@ -218,8 +199,7 @@ void frt_index_add_doc(FrtIndex *self, FrtDocument *doc)
218
199
  pthread_mutex_unlock(&self->mutex);
219
200
  }
220
201
 
221
- FrtQuery *frt_index_get_query(FrtIndex *self, char *qstr, rb_encoding *encoding)
222
- {
202
+ FrtQuery *frt_index_get_query(FrtIndex *self, char *qstr, rb_encoding *encoding) {
223
203
  int i;
224
204
  FrtFieldInfos *fis;
225
205
  frt_ensure_searcher_open(self);
@@ -232,8 +212,7 @@ FrtQuery *frt_index_get_query(FrtIndex *self, char *qstr, rb_encoding *encoding)
232
212
 
233
213
  FrtTopDocs *frt_index_search_str(FrtIndex *self, char *qstr, int first_doc,
234
214
  int num_docs, FrtFilter *filter, FrtSort *sort,
235
- FrtPostFilter *post_filter, rb_encoding *encoding)
236
- {
215
+ FrtPostFilter *post_filter, rb_encoding *encoding) {
237
216
  FrtQuery *query;
238
217
  FrtTopDocs *td;
239
218
  query = frt_index_get_query(self, qstr, encoding); /* will ensure_searcher is open */
@@ -243,16 +222,14 @@ FrtTopDocs *frt_index_search_str(FrtIndex *self, char *qstr, int first_doc,
243
222
  return td;
244
223
  }
245
224
 
246
- FrtDocument *frt_index_get_doc(FrtIndex *self, int doc_num)
247
- {
225
+ FrtDocument *frt_index_get_doc(FrtIndex *self, int doc_num) {
248
226
  FrtDocument *doc;
249
227
  frt_ensure_reader_open(self);
250
228
  doc = self->ir->get_doc(self->ir, doc_num);
251
229
  return doc;
252
230
  }
253
231
 
254
- FrtDocument *frt_index_get_doc_ts(FrtIndex *self, int doc_num)
255
- {
232
+ FrtDocument *frt_index_get_doc_ts(FrtIndex *self, int doc_num) {
256
233
  FrtDocument *doc;
257
234
  pthread_mutex_lock(&self->mutex);
258
235
  {
@@ -278,13 +255,11 @@ FrtDocument *frt_index_get_doc_term(FrtIndex *self, ID field, const char *term)
278
255
  return doc;
279
256
  }
280
257
 
281
- FrtDocument *frt_index_get_doc_id(FrtIndex *self, const char *id)
282
- {
258
+ FrtDocument *frt_index_get_doc_id(FrtIndex *self, const char *id) {
283
259
  return frt_index_get_doc_term(self, self->id_field, id);
284
260
  }
285
261
 
286
- void frt_index_delete(FrtIndex *self, int doc_num)
287
- {
262
+ void frt_index_delete(FrtIndex *self, int doc_num) {
288
263
  pthread_mutex_lock(&self->mutex);
289
264
  {
290
265
  frt_ensure_reader_open(self);
@@ -316,20 +291,17 @@ void frt_index_delete_term(FrtIndex *self, ID field, const char *term) {
316
291
  pthread_mutex_unlock(&self->mutex);
317
292
  }
318
293
 
319
- void frt_index_delete_id(FrtIndex *self, const char *id)
320
- {
294
+ void frt_index_delete_id(FrtIndex *self, const char *id) {
321
295
  frt_index_delete_term(self, self->id_field, id);
322
296
  }
323
297
 
324
- static void index_qdel_i(FrtSearcher *sea, int doc_num, float score, void *arg)
325
- {
298
+ static void index_qdel_i(FrtSearcher *sea, int doc_num, float score, void *arg) {
326
299
  (void)score; (void)arg;
327
300
  frt_ir_delete_doc(((FrtIndexSearcher *)sea)->ir, doc_num);
328
301
  }
329
302
 
330
303
  void frt_index_delete_query(FrtIndex *self, FrtQuery *q, FrtFilter *f,
331
- FrtPostFilter *post_filter)
332
- {
304
+ FrtPostFilter *post_filter) {
333
305
  pthread_mutex_lock(&self->mutex);
334
306
  {
335
307
  frt_ensure_searcher_open(self);
@@ -340,8 +312,7 @@ void frt_index_delete_query(FrtIndex *self, FrtQuery *q, FrtFilter *f,
340
312
  }
341
313
 
342
314
  void frt_index_delete_query_str(FrtIndex *self, char *qstr, FrtFilter *f,
343
- FrtPostFilter *post_filter, rb_encoding *encoding)
344
- {
315
+ FrtPostFilter *post_filter, rb_encoding *encoding) {
345
316
  FrtQuery *q = frt_index_get_query(self, qstr, encoding);
346
317
  frt_index_delete_query(self, q, f, post_filter);
347
318
  frt_q_deref(q);
@@ -32,7 +32,6 @@ typedef struct FrtIndex {
32
32
  extern FrtIndex *frt_index_new(FrtStore *store, FrtAnalyzer *analyzer, FrtHashSet *def_fields, bool create);
33
33
  extern void frt_index_destroy(FrtIndex *self);
34
34
  extern int frt_index_size(FrtIndex *self);
35
- extern void frt_index_optimize(FrtIndex *self);
36
35
  extern bool frt_index_is_deleted(FrtIndex *self, int doc_num);
37
36
  extern void frt_index_add_doc(FrtIndex *self, FrtDocument *doc);
38
37
  extern FrtTopDocs *frt_index_search_str(FrtIndex *self, char *query, int first_doc, int num_docs, FrtFilter *filter, FrtSort *sort, FrtPostFilter *post_filter, rb_encoding *encoding);