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.
- checksums.yaml +4 -4
- data/ext/isomorfeus_ferret_ext/benchmark.c +9 -20
- data/ext/isomorfeus_ferret_ext/benchmarks_all.h +1 -2
- data/ext/isomorfeus_ferret_ext/bm_hash.c +1 -2
- data/ext/isomorfeus_ferret_ext/brotli_dec_decode.c +4 -2
- data/ext/isomorfeus_ferret_ext/brotli_enc_encode.c +3 -2
- data/ext/isomorfeus_ferret_ext/frb_analysis.c +4 -5
- data/ext/isomorfeus_ferret_ext/frb_field_info.c +3 -4
- data/ext/isomorfeus_ferret_ext/frb_index.c +118 -125
- data/ext/isomorfeus_ferret_ext/frb_lazy_doc.c +14 -16
- data/ext/isomorfeus_ferret_ext/frb_search.c +31 -23
- data/ext/isomorfeus_ferret_ext/frb_store.c +27 -13
- data/ext/isomorfeus_ferret_ext/frb_utils.c +3 -6
- data/ext/isomorfeus_ferret_ext/frt_analysis.c +39 -46
- data/ext/isomorfeus_ferret_ext/frt_analysis.h +9 -9
- data/ext/isomorfeus_ferret_ext/frt_array.c +11 -22
- data/ext/isomorfeus_ferret_ext/frt_bitvector.h +3 -6
- data/ext/isomorfeus_ferret_ext/frt_doc_field.c +87 -0
- data/ext/isomorfeus_ferret_ext/frt_doc_field.h +26 -0
- data/ext/isomorfeus_ferret_ext/frt_document.c +4 -97
- data/ext/isomorfeus_ferret_ext/frt_document.h +2 -27
- data/ext/isomorfeus_ferret_ext/frt_except.c +8 -6
- data/ext/isomorfeus_ferret_ext/frt_except.h +1 -2
- data/ext/isomorfeus_ferret_ext/frt_field_index.c +13 -32
- data/ext/isomorfeus_ferret_ext/frt_field_index.h +0 -6
- data/ext/isomorfeus_ferret_ext/frt_field_info.c +69 -0
- data/ext/isomorfeus_ferret_ext/frt_field_info.h +49 -0
- data/ext/isomorfeus_ferret_ext/frt_field_infos.c +196 -0
- data/ext/isomorfeus_ferret_ext/frt_field_infos.h +35 -0
- data/ext/isomorfeus_ferret_ext/frt_global.c +10 -4
- data/ext/isomorfeus_ferret_ext/frt_global.h +11 -15
- data/ext/isomorfeus_ferret_ext/frt_hash.c +8 -8
- data/ext/isomorfeus_ferret_ext/frt_hash.h +1 -2
- data/ext/isomorfeus_ferret_ext/frt_hashset.c +20 -40
- data/ext/isomorfeus_ferret_ext/frt_hashset.h +1 -2
- data/ext/isomorfeus_ferret_ext/frt_helper.c +7 -15
- data/ext/isomorfeus_ferret_ext/frt_in_stream.c +35 -45
- data/ext/isomorfeus_ferret_ext/frt_in_stream.h +3 -2
- data/ext/isomorfeus_ferret_ext/frt_ind.c +20 -38
- data/ext/isomorfeus_ferret_ext/frt_index.c +292 -790
- data/ext/isomorfeus_ferret_ext/frt_index.h +1 -102
- data/ext/isomorfeus_ferret_ext/frt_lang.c +5 -10
- data/ext/isomorfeus_ferret_ext/frt_lazy_doc.c +3 -3
- data/ext/isomorfeus_ferret_ext/frt_lazy_doc.h +1 -1
- data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.c +18 -25
- data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.h +5 -5
- data/ext/isomorfeus_ferret_ext/frt_mdbx_store.c +102 -70
- data/ext/isomorfeus_ferret_ext/frt_mempool.c +8 -16
- data/ext/isomorfeus_ferret_ext/frt_multimapper.c +23 -46
- data/ext/isomorfeus_ferret_ext/frt_multimapper.h +4 -8
- data/ext/isomorfeus_ferret_ext/frt_out_stream.c +31 -43
- data/ext/isomorfeus_ferret_ext/frt_out_stream.h +2 -2
- data/ext/isomorfeus_ferret_ext/frt_posh.c +6 -819
- data/ext/isomorfeus_ferret_ext/frt_posh.h +0 -57
- data/ext/isomorfeus_ferret_ext/frt_priorityqueue.c +11 -22
- data/ext/isomorfeus_ferret_ext/frt_priorityqueue.h +1 -2
- data/ext/isomorfeus_ferret_ext/frt_q_boolean.c +85 -171
- data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +8 -16
- data/ext/isomorfeus_ferret_ext/frt_q_multi_term.c +1 -2
- data/ext/isomorfeus_ferret_ext/frt_q_parser.c +49 -98
- data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +52 -104
- data/ext/isomorfeus_ferret_ext/frt_q_range.c +6 -12
- data/ext/isomorfeus_ferret_ext/frt_q_span.c +113 -226
- data/ext/isomorfeus_ferret_ext/frt_q_wildcard.c +1 -2
- data/ext/isomorfeus_ferret_ext/frt_ram_store.c +134 -85
- data/ext/isomorfeus_ferret_ext/frt_search.c +82 -164
- data/ext/isomorfeus_ferret_ext/frt_similarity.c +11 -22
- data/ext/isomorfeus_ferret_ext/frt_similarity.h +1 -2
- data/ext/isomorfeus_ferret_ext/frt_store.c +13 -25
- data/ext/isomorfeus_ferret_ext/frt_store.h +86 -52
- data/ext/isomorfeus_ferret_ext/frt_term_vectors.c +8 -16
- data/ext/isomorfeus_ferret_ext/frt_win32.h +5 -10
- data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +12 -11
- data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.h +11 -13
- data/ext/isomorfeus_ferret_ext/lz4.c +422 -195
- data/ext/isomorfeus_ferret_ext/lz4.h +114 -46
- data/ext/isomorfeus_ferret_ext/lz4frame.c +421 -242
- data/ext/isomorfeus_ferret_ext/lz4frame.h +122 -53
- data/ext/isomorfeus_ferret_ext/lz4hc.c +127 -111
- data/ext/isomorfeus_ferret_ext/lz4hc.h +14 -14
- data/ext/isomorfeus_ferret_ext/lz4xxhash.h +1 -1
- data/ext/isomorfeus_ferret_ext/mdbx.c +3762 -2526
- data/ext/isomorfeus_ferret_ext/mdbx.h +115 -70
- data/ext/isomorfeus_ferret_ext/test.c +40 -87
- data/ext/isomorfeus_ferret_ext/test.h +3 -6
- data/ext/isomorfeus_ferret_ext/test_1710.c +11 -13
- data/ext/isomorfeus_ferret_ext/test_analysis.c +32 -64
- data/ext/isomorfeus_ferret_ext/test_array.c +6 -12
- data/ext/isomorfeus_ferret_ext/test_bitvector.c +12 -24
- data/ext/isomorfeus_ferret_ext/test_document.c +23 -33
- data/ext/isomorfeus_ferret_ext/test_except.c +10 -21
- data/ext/isomorfeus_ferret_ext/test_fields.c +62 -68
- data/ext/isomorfeus_ferret_ext/test_file_deleter.c +15 -23
- data/ext/isomorfeus_ferret_ext/test_filter.c +17 -27
- data/ext/isomorfeus_ferret_ext/test_global.c +14 -29
- data/ext/isomorfeus_ferret_ext/test_hash.c +19 -38
- data/ext/isomorfeus_ferret_ext/test_hashset.c +8 -16
- data/ext/isomorfeus_ferret_ext/test_helper.c +4 -8
- data/ext/isomorfeus_ferret_ext/test_highlighter.c +16 -28
- data/ext/isomorfeus_ferret_ext/test_index.c +277 -487
- data/ext/isomorfeus_ferret_ext/test_lang.c +7 -14
- data/ext/isomorfeus_ferret_ext/test_mdbx_store.c +2 -5
- data/ext/isomorfeus_ferret_ext/test_mempool.c +5 -10
- data/ext/isomorfeus_ferret_ext/test_multimapper.c +3 -6
- data/ext/isomorfeus_ferret_ext/test_priorityqueue.c +9 -18
- data/ext/isomorfeus_ferret_ext/test_q_const_score.c +4 -6
- data/ext/isomorfeus_ferret_ext/test_q_filtered.c +3 -4
- data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +9 -15
- data/ext/isomorfeus_ferret_ext/test_q_parser.c +8 -16
- data/ext/isomorfeus_ferret_ext/test_q_span.c +19 -35
- data/ext/isomorfeus_ferret_ext/test_ram_store.c +14 -13
- data/ext/isomorfeus_ferret_ext/test_search.c +60 -109
- data/ext/isomorfeus_ferret_ext/test_segments.c +8 -13
- data/ext/isomorfeus_ferret_ext/test_similarity.c +2 -4
- data/ext/isomorfeus_ferret_ext/test_sort.c +14 -24
- data/ext/isomorfeus_ferret_ext/test_store.c +96 -115
- data/ext/isomorfeus_ferret_ext/test_term.c +9 -15
- data/ext/isomorfeus_ferret_ext/test_term_vectors.c +9 -14
- data/ext/isomorfeus_ferret_ext/test_test.c +4 -8
- data/ext/isomorfeus_ferret_ext/test_threading.c +14 -20
- data/ext/isomorfeus_ferret_ext/testhelper.c +11 -21
- data/ext/isomorfeus_ferret_ext/testhelper.h +1 -1
- data/ext/isomorfeus_ferret_ext/tests_all.h +1 -2
- data/lib/isomorfeus/ferret/index/index.rb +1 -1
- data/lib/isomorfeus/ferret/version.rb +1 -1
- metadata +24 -4
@@ -208,8 +208,7 @@ static VALUE frb_fis_add(VALUE self, VALUE rfi) {
|
|
208
208
|
* of the available properties.
|
209
209
|
*/
|
210
210
|
static VALUE
|
211
|
-
frb_fis_add_field(int argc, VALUE *argv, VALUE self)
|
212
|
-
{
|
211
|
+
frb_fis_add_field(int argc, VALUE *argv, VALUE self) {
|
213
212
|
FrtFieldInfos *fis = (FrtFieldInfos *)DATA_PTR(self);
|
214
213
|
FrtFieldInfo *fi;
|
215
214
|
unsigned int bits = fis->bits;
|
@@ -233,8 +232,7 @@ frb_fis_add_field(int argc, VALUE *argv, VALUE self)
|
|
233
232
|
* Iterate through the FieldInfo objects.
|
234
233
|
*/
|
235
234
|
static VALUE
|
236
|
-
frb_fis_each(VALUE self)
|
237
|
-
{
|
235
|
+
frb_fis_each(VALUE self) {
|
238
236
|
int i;
|
239
237
|
FrtFieldInfos *fis = (FrtFieldInfos *)DATA_PTR(self);
|
240
238
|
|
@@ -251,8 +249,7 @@ frb_fis_each(VALUE self)
|
|
251
249
|
* Return a string representation of the FieldInfos object.
|
252
250
|
*/
|
253
251
|
static VALUE
|
254
|
-
frb_fis_to_s(VALUE self)
|
255
|
-
{
|
252
|
+
frb_fis_to_s(VALUE self) {
|
256
253
|
FrtFieldInfos *fis = (FrtFieldInfos *)DATA_PTR(self);
|
257
254
|
char *fis_s = frt_fis_to_s(fis);
|
258
255
|
VALUE rfis_s = rb_str_new2(fis_s);
|
@@ -291,6 +288,7 @@ static VALUE frb_fis_create_index(VALUE self, VALUE rdir) {
|
|
291
288
|
StringValue(rdir);
|
292
289
|
frb_create_dir(rdir);
|
293
290
|
store = frt_open_mdbx_store(rs2s(rdir));
|
291
|
+
store->create_folder(store, segm_idx_name);
|
294
292
|
frt_index_create(store, fis);
|
295
293
|
frt_store_close(store);
|
296
294
|
}
|
@@ -306,8 +304,7 @@ static VALUE frb_fis_create_index(VALUE self, VALUE rdir) {
|
|
306
304
|
* index.
|
307
305
|
*/
|
308
306
|
static VALUE
|
309
|
-
frb_fis_get_fields(VALUE self)
|
310
|
-
{
|
307
|
+
frb_fis_get_fields(VALUE self) {
|
311
308
|
FrtFieldInfos *fis = (FrtFieldInfos *)DATA_PTR(self);
|
312
309
|
VALUE rfield_names = rb_ary_new();
|
313
310
|
int i;
|
@@ -325,8 +322,7 @@ frb_fis_get_fields(VALUE self)
|
|
325
322
|
* in the index.
|
326
323
|
*/
|
327
324
|
static VALUE
|
328
|
-
frb_fis_get_tk_fields(VALUE self)
|
329
|
-
{
|
325
|
+
frb_fis_get_tk_fields(VALUE self) {
|
330
326
|
FrtFieldInfos *fis = (FrtFieldInfos *)DATA_PTR(self);
|
331
327
|
VALUE rfield_names = rb_ary_new();
|
332
328
|
int i;
|
@@ -777,16 +773,13 @@ static VALUE frb_tde_to_json(int argc, VALUE *argv, VALUE self) {
|
|
777
773
|
if (do_positions) {
|
778
774
|
if (argc == 0) {
|
779
775
|
format = "{\"document\":%d,\"frequency\":%d,\"positions\":[";
|
780
|
-
}
|
781
|
-
else {
|
776
|
+
} else {
|
782
777
|
format = "[%d,%d,[";
|
783
778
|
}
|
784
|
-
}
|
785
|
-
else {
|
779
|
+
} else {
|
786
780
|
if (argc == 0) {
|
787
781
|
format = "{\"document\":%d,\"frequency\":%d},";
|
788
|
-
}
|
789
|
-
else {
|
782
|
+
} else {
|
790
783
|
format = "[%d,%d],";
|
791
784
|
}
|
792
785
|
}
|
@@ -1039,6 +1032,7 @@ static VALUE frb_iw_init(int argc, VALUE *argv, VALUE self) {
|
|
1039
1032
|
StringValue(rval);
|
1040
1033
|
frb_create_dir(rval);
|
1041
1034
|
store = frt_open_mdbx_store(rs2s(rval));
|
1035
|
+
store->create_folder(store, segm_idx_name);
|
1042
1036
|
}
|
1043
1037
|
|
1044
1038
|
if ((rval = rb_hash_aref(roptions, sym_analyzer)) != Qnil) {
|
@@ -1060,8 +1054,9 @@ static VALUE frb_iw_init(int argc, VALUE *argv, VALUE self) {
|
|
1060
1054
|
}
|
1061
1055
|
if (NULL == store) {
|
1062
1056
|
store = frt_open_ram_store(NULL);
|
1057
|
+
store->create_folder(store, segm_idx_name);
|
1063
1058
|
}
|
1064
|
-
if (!create && create_if_missing && !store->exists(store, "segments")) {
|
1059
|
+
if (!create && create_if_missing && !store->exists(store, segm_idx_name, "segments")) {
|
1065
1060
|
create = true;
|
1066
1061
|
}
|
1067
1062
|
if (create) {
|
@@ -1130,8 +1125,7 @@ frb_iw_get_doc_count(VALUE self) {
|
|
1130
1125
|
}
|
1131
1126
|
|
1132
1127
|
static int
|
1133
|
-
frb_hash_to_doc_i(VALUE key, VALUE value, VALUE arg)
|
1134
|
-
{
|
1128
|
+
frb_hash_to_doc_i(VALUE key, VALUE value, VALUE arg) {
|
1135
1129
|
if (key == Qundef) {
|
1136
1130
|
return ST_CONTINUE;
|
1137
1131
|
} else {
|
@@ -1151,20 +1145,18 @@ frb_hash_to_doc_i(VALUE key, VALUE value, VALUE arg)
|
|
1151
1145
|
case T_ARRAY:
|
1152
1146
|
{
|
1153
1147
|
int i;
|
1154
|
-
df->destroy_data = true;
|
1155
1148
|
for (i = 0; i < RARRAY_LEN(value); i++) {
|
1156
1149
|
val = rb_obj_as_string(RARRAY_PTR(value)[i]);
|
1157
|
-
frt_df_add_data_len(df,
|
1150
|
+
frt_df_add_data_len(df, RSTRING_PTR(val), RSTRING_LEN(val), rb_enc_get(val));
|
1158
1151
|
}
|
1159
1152
|
}
|
1160
1153
|
break;
|
1161
1154
|
case T_STRING:
|
1162
|
-
frt_df_add_data_len(df,
|
1155
|
+
frt_df_add_data_len(df, RSTRING_PTR(value), RSTRING_LEN(value), rb_enc_get(value));
|
1163
1156
|
break;
|
1164
1157
|
default:
|
1165
1158
|
val = rb_obj_as_string(value);
|
1166
|
-
df
|
1167
|
-
frt_df_add_data_len(df, rstrdup(val), RSTRING_LEN(val), rb_enc_get(val));
|
1159
|
+
frt_df_add_data_len(df, RSTRING_PTR(val), RSTRING_LEN(val), rb_enc_get(val));
|
1168
1160
|
break;
|
1169
1161
|
}
|
1170
1162
|
FRT_TRY
|
@@ -1181,8 +1173,7 @@ frb_hash_to_doc_i(VALUE key, VALUE value, VALUE arg)
|
|
1181
1173
|
}
|
1182
1174
|
|
1183
1175
|
static FrtDocument *
|
1184
|
-
frb_get_doc(VALUE rdoc)
|
1185
|
-
{
|
1176
|
+
frb_get_doc(VALUE rdoc) {
|
1186
1177
|
VALUE val;
|
1187
1178
|
FrtDocument *doc = frt_doc_new();
|
1188
1179
|
FrtDocField *df;
|
@@ -1199,27 +1190,25 @@ frb_get_doc(VALUE rdoc)
|
|
1199
1190
|
{
|
1200
1191
|
int i;
|
1201
1192
|
df = frt_df_new(fsym_content);
|
1202
|
-
df->destroy_data = true;
|
1203
1193
|
for (i = 0; i < RARRAY_LEN(rdoc); i++) {
|
1204
1194
|
val = rb_obj_as_string(RARRAY_PTR(rdoc)[i]);
|
1205
|
-
frt_df_add_data_len(df,
|
1195
|
+
frt_df_add_data_len(df, RSTRING_PTR(val), RSTRING_LEN(val), rb_enc_get(val));
|
1206
1196
|
}
|
1207
1197
|
frt_doc_add_field(doc, df);
|
1208
1198
|
}
|
1209
1199
|
break;
|
1210
1200
|
case T_SYMBOL:
|
1211
1201
|
/* TODO: clean up this ugly cast */
|
1212
|
-
df = frt_df_add_data(frt_df_new(fsym_content),
|
1202
|
+
df = frt_df_add_data(frt_df_new(fsym_content), rb_id2name(SYM2ID(rdoc)), rb_enc_get(rdoc));
|
1213
1203
|
frt_doc_add_field(doc, df);
|
1214
1204
|
break;
|
1215
1205
|
case T_STRING:
|
1216
|
-
df = frt_df_add_data_len(frt_df_new(fsym_content),
|
1206
|
+
df = frt_df_add_data_len(frt_df_new(fsym_content), RSTRING_PTR(rdoc), RSTRING_LEN(rdoc), rb_enc_get(rdoc));
|
1217
1207
|
frt_doc_add_field(doc, df);
|
1218
1208
|
break;
|
1219
1209
|
default:
|
1220
1210
|
val = rb_obj_as_string(rdoc);
|
1221
|
-
df = frt_df_add_data_len(frt_df_new(fsym_content),
|
1222
|
-
df->destroy_data = true;
|
1211
|
+
df = frt_df_add_data_len(frt_df_new(fsym_content), RSTRING_PTR(val), RSTRING_LEN(val), rb_enc_get(val));
|
1223
1212
|
frt_doc_add_field(doc, df);
|
1224
1213
|
break;
|
1225
1214
|
}
|
@@ -1439,8 +1428,7 @@ static VALUE frb_iw_field_infos(VALUE self) {
|
|
1439
1428
|
* to use the same analyzer in a QueryParser.
|
1440
1429
|
*/
|
1441
1430
|
static VALUE
|
1442
|
-
frb_iw_get_analyzer(VALUE self)
|
1443
|
-
{
|
1431
|
+
frb_iw_get_analyzer(VALUE self) {
|
1444
1432
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1445
1433
|
return frb_get_analyzer(iw->analyzer);
|
1446
1434
|
}
|
@@ -1454,8 +1442,7 @@ frb_iw_get_analyzer(VALUE self)
|
|
1454
1442
|
* same analyzer will be used for all documents during search.
|
1455
1443
|
*/
|
1456
1444
|
static VALUE
|
1457
|
-
frb_iw_set_analyzer(VALUE self, VALUE ranalyzer)
|
1458
|
-
{
|
1445
|
+
frb_iw_set_analyzer(VALUE self, VALUE ranalyzer) {
|
1459
1446
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1460
1447
|
|
1461
1448
|
frt_a_deref(iw->analyzer);
|
@@ -1470,8 +1457,7 @@ frb_iw_set_analyzer(VALUE self, VALUE ranalyzer)
|
|
1470
1457
|
* Returns the current version of the index writer.
|
1471
1458
|
*/
|
1472
1459
|
static VALUE
|
1473
|
-
frb_iw_version(VALUE self)
|
1474
|
-
{
|
1460
|
+
frb_iw_version(VALUE self) {
|
1475
1461
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1476
1462
|
return ULL2NUM(iw->sis->version);
|
1477
1463
|
}
|
@@ -1483,8 +1469,7 @@ frb_iw_version(VALUE self)
|
|
1483
1469
|
* Return the current value of chunk_size
|
1484
1470
|
*/
|
1485
1471
|
static VALUE
|
1486
|
-
frb_iw_get_chunk_size(VALUE self)
|
1487
|
-
{
|
1472
|
+
frb_iw_get_chunk_size(VALUE self) {
|
1488
1473
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1489
1474
|
return INT2FIX(iw->config.chunk_size);
|
1490
1475
|
}
|
@@ -1496,8 +1481,7 @@ frb_iw_get_chunk_size(VALUE self)
|
|
1496
1481
|
* Set the chunk_size parameter
|
1497
1482
|
*/
|
1498
1483
|
static VALUE
|
1499
|
-
frb_iw_set_chunk_size(VALUE self, VALUE rval)
|
1500
|
-
{
|
1484
|
+
frb_iw_set_chunk_size(VALUE self, VALUE rval) {
|
1501
1485
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1502
1486
|
iw->config.chunk_size = FIX2INT(rval);
|
1503
1487
|
return rval;
|
@@ -1510,8 +1494,7 @@ frb_iw_set_chunk_size(VALUE self, VALUE rval)
|
|
1510
1494
|
* Return the current value of max_buffer_memory
|
1511
1495
|
*/
|
1512
1496
|
static VALUE
|
1513
|
-
frb_iw_get_max_buffer_memory(VALUE self)
|
1514
|
-
{
|
1497
|
+
frb_iw_get_max_buffer_memory(VALUE self) {
|
1515
1498
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1516
1499
|
return INT2FIX(iw->config.max_buffer_memory);
|
1517
1500
|
}
|
@@ -1523,8 +1506,7 @@ frb_iw_get_max_buffer_memory(VALUE self)
|
|
1523
1506
|
* Set the max_buffer_memory parameter
|
1524
1507
|
*/
|
1525
1508
|
static VALUE
|
1526
|
-
frb_iw_set_max_buffer_memory(VALUE self, VALUE rval)
|
1527
|
-
{
|
1509
|
+
frb_iw_set_max_buffer_memory(VALUE self, VALUE rval) {
|
1528
1510
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1529
1511
|
iw->config.max_buffer_memory = FIX2INT(rval);
|
1530
1512
|
return rval;
|
@@ -1537,8 +1519,7 @@ frb_iw_set_max_buffer_memory(VALUE self, VALUE rval)
|
|
1537
1519
|
* Return the current value of term_index_interval
|
1538
1520
|
*/
|
1539
1521
|
static VALUE
|
1540
|
-
frb_iw_get_index_interval(VALUE self)
|
1541
|
-
{
|
1522
|
+
frb_iw_get_index_interval(VALUE self) {
|
1542
1523
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1543
1524
|
return INT2FIX(iw->config.index_interval);
|
1544
1525
|
}
|
@@ -1550,8 +1531,7 @@ frb_iw_get_index_interval(VALUE self)
|
|
1550
1531
|
* Set the term_index_interval parameter
|
1551
1532
|
*/
|
1552
1533
|
static VALUE
|
1553
|
-
frb_iw_set_index_interval(VALUE self, VALUE rval)
|
1554
|
-
{
|
1534
|
+
frb_iw_set_index_interval(VALUE self, VALUE rval) {
|
1555
1535
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1556
1536
|
iw->config.index_interval = FIX2INT(rval);
|
1557
1537
|
return rval;
|
@@ -1564,8 +1544,7 @@ frb_iw_set_index_interval(VALUE self, VALUE rval)
|
|
1564
1544
|
* Return the current value of doc_skip_interval
|
1565
1545
|
*/
|
1566
1546
|
static VALUE
|
1567
|
-
frb_iw_get_skip_interval(VALUE self)
|
1568
|
-
{
|
1547
|
+
frb_iw_get_skip_interval(VALUE self) {
|
1569
1548
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1570
1549
|
return INT2FIX(iw->config.skip_interval);
|
1571
1550
|
}
|
@@ -1577,8 +1556,7 @@ frb_iw_get_skip_interval(VALUE self)
|
|
1577
1556
|
* Set the doc_skip_interval parameter
|
1578
1557
|
*/
|
1579
1558
|
static VALUE
|
1580
|
-
frb_iw_set_skip_interval(VALUE self, VALUE rval)
|
1581
|
-
{
|
1559
|
+
frb_iw_set_skip_interval(VALUE self, VALUE rval) {
|
1582
1560
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1583
1561
|
iw->config.skip_interval = FIX2INT(rval);
|
1584
1562
|
return rval;
|
@@ -1591,8 +1569,7 @@ frb_iw_set_skip_interval(VALUE self, VALUE rval)
|
|
1591
1569
|
* Return the current value of merge_factor
|
1592
1570
|
*/
|
1593
1571
|
static VALUE
|
1594
|
-
frb_iw_get_merge_factor(VALUE self)
|
1595
|
-
{
|
1572
|
+
frb_iw_get_merge_factor(VALUE self) {
|
1596
1573
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1597
1574
|
return INT2FIX(iw->config.merge_factor);
|
1598
1575
|
}
|
@@ -1604,8 +1581,7 @@ frb_iw_get_merge_factor(VALUE self)
|
|
1604
1581
|
* Set the merge_factor parameter
|
1605
1582
|
*/
|
1606
1583
|
static VALUE
|
1607
|
-
frb_iw_set_merge_factor(VALUE self, VALUE rval)
|
1608
|
-
{
|
1584
|
+
frb_iw_set_merge_factor(VALUE self, VALUE rval) {
|
1609
1585
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1610
1586
|
iw->config.merge_factor = FIX2INT(rval);
|
1611
1587
|
return rval;
|
@@ -1618,8 +1594,7 @@ frb_iw_set_merge_factor(VALUE self, VALUE rval)
|
|
1618
1594
|
* Return the current value of max_buffered_docs
|
1619
1595
|
*/
|
1620
1596
|
static VALUE
|
1621
|
-
frb_iw_get_max_buffered_docs(VALUE self)
|
1622
|
-
{
|
1597
|
+
frb_iw_get_max_buffered_docs(VALUE self) {
|
1623
1598
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1624
1599
|
return INT2FIX(iw->config.max_buffered_docs);
|
1625
1600
|
}
|
@@ -1631,8 +1606,7 @@ frb_iw_get_max_buffered_docs(VALUE self)
|
|
1631
1606
|
* Set the max_buffered_docs parameter
|
1632
1607
|
*/
|
1633
1608
|
static VALUE
|
1634
|
-
frb_iw_set_max_buffered_docs(VALUE self, VALUE rval)
|
1635
|
-
{
|
1609
|
+
frb_iw_set_max_buffered_docs(VALUE self, VALUE rval) {
|
1636
1610
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1637
1611
|
iw->config.max_buffered_docs = FIX2INT(rval);
|
1638
1612
|
return rval;
|
@@ -1645,8 +1619,7 @@ frb_iw_set_max_buffered_docs(VALUE self, VALUE rval)
|
|
1645
1619
|
* Return the current value of max_merge_docs
|
1646
1620
|
*/
|
1647
1621
|
static VALUE
|
1648
|
-
frb_iw_get_max_merge_docs(VALUE self)
|
1649
|
-
{
|
1622
|
+
frb_iw_get_max_merge_docs(VALUE self) {
|
1650
1623
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1651
1624
|
return INT2FIX(iw->config.max_merge_docs);
|
1652
1625
|
}
|
@@ -1658,8 +1631,7 @@ frb_iw_get_max_merge_docs(VALUE self)
|
|
1658
1631
|
* Set the max_merge_docs parameter
|
1659
1632
|
*/
|
1660
1633
|
static VALUE
|
1661
|
-
frb_iw_set_max_merge_docs(VALUE self, VALUE rval)
|
1662
|
-
{
|
1634
|
+
frb_iw_set_max_merge_docs(VALUE self, VALUE rval) {
|
1663
1635
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1664
1636
|
iw->config.max_merge_docs = FIX2INT(rval);
|
1665
1637
|
return rval;
|
@@ -1672,8 +1644,7 @@ frb_iw_set_max_merge_docs(VALUE self, VALUE rval)
|
|
1672
1644
|
* Return the current value of max_field_length
|
1673
1645
|
*/
|
1674
1646
|
static VALUE
|
1675
|
-
frb_iw_get_max_field_length(VALUE self)
|
1676
|
-
{
|
1647
|
+
frb_iw_get_max_field_length(VALUE self) {
|
1677
1648
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1678
1649
|
return INT2FIX(iw->config.max_field_length);
|
1679
1650
|
}
|
@@ -1685,8 +1656,7 @@ frb_iw_get_max_field_length(VALUE self)
|
|
1685
1656
|
* Set the max_field_length parameter
|
1686
1657
|
*/
|
1687
1658
|
static VALUE
|
1688
|
-
frb_iw_set_max_field_length(VALUE self, VALUE rval)
|
1689
|
-
{
|
1659
|
+
frb_iw_set_max_field_length(VALUE self, VALUE rval) {
|
1690
1660
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1691
1661
|
iw->config.max_field_length = FIX2INT(rval);
|
1692
1662
|
return rval;
|
@@ -1766,6 +1736,7 @@ static VALUE frb_ir_init(VALUE self, VALUE rdir) {
|
|
1766
1736
|
case T_STRING:
|
1767
1737
|
frb_create_dir(rdir);
|
1768
1738
|
store = frt_open_mdbx_store(rs2s(rdir));
|
1739
|
+
store->create_folder(store, segm_idx_name);
|
1769
1740
|
break;
|
1770
1741
|
default:
|
1771
1742
|
FRT_RAISE(FRT_ARG_ERROR, "%s isn't a valid directory "
|
@@ -1787,6 +1758,7 @@ static VALUE frb_ir_init(VALUE self, VALUE rdir) {
|
|
1787
1758
|
case T_STRING:
|
1788
1759
|
frb_create_dir(rdir);
|
1789
1760
|
store = frt_open_mdbx_store(rs2s(rdir));
|
1761
|
+
store->create_folder(store, segm_idx_name);
|
1790
1762
|
break;
|
1791
1763
|
default:
|
1792
1764
|
FRT_RAISE(FRT_ARG_ERROR, "%s isn't a valid directory argument. "
|
@@ -1860,8 +1832,7 @@ frb_ir_set_norm(VALUE self, VALUE rdoc_id, VALUE rfield, VALUE rval) {
|
|
1860
1832
|
* could have null bytes.
|
1861
1833
|
*/
|
1862
1834
|
static VALUE
|
1863
|
-
frb_ir_norms(VALUE self, VALUE rfield)
|
1864
|
-
{
|
1835
|
+
frb_ir_norms(VALUE self, VALUE rfield) {
|
1865
1836
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
1866
1837
|
frt_uchar *norms;
|
1867
1838
|
norms = frt_ir_get_norms(ir, frb_field(rfield));
|
@@ -1879,8 +1850,7 @@ frb_ir_norms(VALUE self, VALUE rfield)
|
|
1879
1850
|
* Expert: Get the norm values into a string +buffer+ starting at +offset+.
|
1880
1851
|
*/
|
1881
1852
|
static VALUE
|
1882
|
-
frb_ir_get_norms_into(VALUE self, VALUE rfield, VALUE rnorms, VALUE roffset)
|
1883
|
-
{
|
1853
|
+
frb_ir_get_norms_into(VALUE self, VALUE rfield, VALUE rnorms, VALUE roffset) {
|
1884
1854
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
1885
1855
|
int offset;
|
1886
1856
|
offset = FIX2INT(roffset);
|
@@ -1935,8 +1905,7 @@ frb_ir_commit(VALUE self) {
|
|
1935
1905
|
* errors.
|
1936
1906
|
*/
|
1937
1907
|
static VALUE
|
1938
|
-
frb_ir_close(VALUE self)
|
1939
|
-
{
|
1908
|
+
frb_ir_close(VALUE self) {
|
1940
1909
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
1941
1910
|
((struct RData *)(self))->data = NULL;
|
1942
1911
|
((struct RData *)(self))->dmark = NULL;
|
@@ -1953,8 +1922,7 @@ frb_ir_close(VALUE self)
|
|
1953
1922
|
* IndexReader or committed by any other IndexReader.
|
1954
1923
|
*/
|
1955
1924
|
static VALUE
|
1956
|
-
frb_ir_has_deletions(VALUE self)
|
1957
|
-
{
|
1925
|
+
frb_ir_has_deletions(VALUE self) {
|
1958
1926
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
1959
1927
|
return ir->has_deletions(ir) ? Qtrue : Qfalse;
|
1960
1928
|
}
|
@@ -1995,8 +1963,7 @@ frb_ir_delete(VALUE self, VALUE rdoc_id) {
|
|
1995
1963
|
* Returns true if the document at +doc_id+ has been deleted.
|
1996
1964
|
*/
|
1997
1965
|
static VALUE
|
1998
|
-
frb_ir_is_deleted(VALUE self, VALUE rdoc_id)
|
1999
|
-
{
|
1966
|
+
frb_ir_is_deleted(VALUE self, VALUE rdoc_id) {
|
2000
1967
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
2001
1968
|
return ir->is_deleted(ir, FIX2INT(rdoc_id)) ? Qtrue : Qfalse;
|
2002
1969
|
}
|
@@ -2011,8 +1978,7 @@ frb_ir_is_deleted(VALUE self, VALUE rdoc_id)
|
|
2011
1978
|
* in the index.
|
2012
1979
|
*/
|
2013
1980
|
static VALUE
|
2014
|
-
frb_ir_max_doc(VALUE self)
|
2015
|
-
{
|
1981
|
+
frb_ir_max_doc(VALUE self) {
|
2016
1982
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
2017
1983
|
return INT2FIX(ir->max_doc(ir));
|
2018
1984
|
}
|
@@ -2026,8 +1992,7 @@ frb_ir_max_doc(VALUE self)
|
|
2026
1992
|
* deleted from the index.
|
2027
1993
|
*/
|
2028
1994
|
static VALUE
|
2029
|
-
frb_ir_num_docs(VALUE self)
|
2030
|
-
{
|
1995
|
+
frb_ir_num_docs(VALUE self) {
|
2031
1996
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
2032
1997
|
return INT2FIX(ir->num_docs(ir));
|
2033
1998
|
}
|
@@ -2042,24 +2007,36 @@ frb_ir_num_docs(VALUE self)
|
|
2042
2007
|
* effect on these documents.
|
2043
2008
|
*/
|
2044
2009
|
static VALUE
|
2045
|
-
frb_ir_undelete_all(VALUE self)
|
2046
|
-
{
|
2010
|
+
frb_ir_undelete_all(VALUE self) {
|
2047
2011
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
2048
2012
|
frt_ir_undelete_all(ir);
|
2049
2013
|
return self;
|
2050
2014
|
}
|
2051
2015
|
|
2052
2016
|
static VALUE
|
2053
|
-
frb_get_doc_range(FrtIndexReader *ir, int pos, int len, int max)
|
2054
|
-
|
2017
|
+
frb_get_doc_range(FrtIndexReader *ir, int pos, int len, int max) {
|
2018
|
+
int ex_code = 0;
|
2019
|
+
const char *msg = NULL;
|
2055
2020
|
VALUE ary;
|
2056
2021
|
int i;
|
2057
2022
|
max = FRT_MIN(max, pos+len);
|
2058
2023
|
len = max - pos;
|
2059
2024
|
ary = rb_ary_new2(len);
|
2060
|
-
|
2061
|
-
|
2025
|
+
|
2026
|
+
FRT_TRY
|
2027
|
+
for (i = 0; i < len; i++) {
|
2028
|
+
rb_ary_store(ary, i, frb_get_lazy_doc(ir->get_lazy_doc(ir, i + pos)));
|
2029
|
+
}
|
2030
|
+
FRT_XCATCHALL
|
2031
|
+
ex_code = xcontext.excode;
|
2032
|
+
msg = xcontext.msg;
|
2033
|
+
FRT_HANDLED();
|
2034
|
+
FRT_XENDTRY
|
2035
|
+
|
2036
|
+
if (ex_code && msg) {
|
2037
|
+
frb_raise(ex_code, msg);
|
2062
2038
|
}
|
2039
|
+
|
2063
2040
|
return ary;
|
2064
2041
|
}
|
2065
2042
|
|
@@ -2087,7 +2064,24 @@ frb_ir_get_doc(int argc, VALUE *argv, VALUE self) {
|
|
2087
2064
|
rb_raise(rb_eArgError, "index %ld is out of range [%d..%ld] for "
|
2088
2065
|
"IndexReader#[]", pos, 0, max);
|
2089
2066
|
}
|
2090
|
-
|
2067
|
+
|
2068
|
+
int ex_code = 0;
|
2069
|
+
const char *msg = NULL;
|
2070
|
+
VALUE ld = Qnil;
|
2071
|
+
|
2072
|
+
FRT_TRY
|
2073
|
+
ld = frb_get_lazy_doc(ir->get_lazy_doc(ir, pos));
|
2074
|
+
FRT_XCATCHALL
|
2075
|
+
ex_code = xcontext.excode;
|
2076
|
+
msg = xcontext.msg;
|
2077
|
+
FRT_HANDLED();
|
2078
|
+
FRT_XENDTRY
|
2079
|
+
|
2080
|
+
if (ex_code && msg) {
|
2081
|
+
frb_raise(ex_code, msg);
|
2082
|
+
}
|
2083
|
+
|
2084
|
+
return ld;
|
2091
2085
|
}
|
2092
2086
|
|
2093
2087
|
/* check if idx is Range */
|
@@ -2118,8 +2112,7 @@ frb_ir_get_doc(int argc, VALUE *argv, VALUE self) {
|
|
2118
2112
|
* index to search the latest documents added to the index.
|
2119
2113
|
*/
|
2120
2114
|
static VALUE
|
2121
|
-
frb_ir_is_latest(VALUE self)
|
2122
|
-
{
|
2115
|
+
frb_ir_is_latest(VALUE self) {
|
2123
2116
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
2124
2117
|
return frt_ir_is_latest(ir) ? Qtrue : Qfalse;
|
2125
2118
|
}
|
@@ -2132,8 +2125,7 @@ frb_ir_is_latest(VALUE self)
|
|
2132
2125
|
* the index. Return nil if no such term_vector exists. See TermVector.
|
2133
2126
|
*/
|
2134
2127
|
static VALUE
|
2135
|
-
frb_ir_term_vector(VALUE self, VALUE rdoc_id, VALUE rfield)
|
2136
|
-
{
|
2128
|
+
frb_ir_term_vector(VALUE self, VALUE rdoc_id, VALUE rfield) {
|
2137
2129
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
2138
2130
|
FrtTermVector *tv;
|
2139
2131
|
VALUE rtv;
|
@@ -2142,15 +2134,13 @@ frb_ir_term_vector(VALUE self, VALUE rdoc_id, VALUE rfield)
|
|
2142
2134
|
rtv = frb_get_tv(tv);
|
2143
2135
|
frt_tv_destroy(tv);
|
2144
2136
|
return rtv;
|
2145
|
-
}
|
2146
|
-
else {
|
2137
|
+
} else {
|
2147
2138
|
return Qnil;
|
2148
2139
|
}
|
2149
2140
|
}
|
2150
2141
|
|
2151
2142
|
static void
|
2152
|
-
frb_add_each_tv(void *key, void *value, void *rtvs)
|
2153
|
-
{
|
2143
|
+
frb_add_each_tv(void *key, void *value, void *rtvs) {
|
2154
2144
|
rb_hash_aset((VALUE)rtvs, ID2SYM((ID)key), frb_get_tv(value));
|
2155
2145
|
}
|
2156
2146
|
|
@@ -2163,8 +2153,7 @@ frb_add_each_tv(void *key, void *value, void *rtvs)
|
|
2163
2153
|
* and they are referenced by field names (as symbols).
|
2164
2154
|
*/
|
2165
2155
|
static VALUE
|
2166
|
-
frb_ir_term_vectors(VALUE self, VALUE rdoc_id)
|
2167
|
-
{
|
2156
|
+
frb_ir_term_vectors(VALUE self, VALUE rdoc_id) {
|
2168
2157
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
2169
2158
|
FrtHash *tvs = ir->term_vectors(ir, FIX2INT(rdoc_id));
|
2170
2159
|
VALUE rtvs = rb_hash_new();
|
@@ -2182,8 +2171,7 @@ frb_ir_term_vectors(VALUE self, VALUE rdoc_id)
|
|
2182
2171
|
* See TermDocEnum for more info.
|
2183
2172
|
*/
|
2184
2173
|
static VALUE
|
2185
|
-
frb_ir_term_docs(VALUE self)
|
2186
|
-
{
|
2174
|
+
frb_ir_term_docs(VALUE self) {
|
2187
2175
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
2188
2176
|
return frb_get_tde(self, ir->term_docs(ir));
|
2189
2177
|
}
|
@@ -2196,8 +2184,7 @@ frb_ir_term_docs(VALUE self)
|
|
2196
2184
|
* term +term+ in the field +field+. See TermDocEnum for more info.
|
2197
2185
|
*/
|
2198
2186
|
static VALUE
|
2199
|
-
frb_ir_term_docs_for(VALUE self, VALUE rfield, VALUE rterm)
|
2200
|
-
{
|
2187
|
+
frb_ir_term_docs_for(VALUE self, VALUE rfield, VALUE rterm) {
|
2201
2188
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
2202
2189
|
return frb_get_tde(self, ir_term_docs_for(ir,
|
2203
2190
|
frb_field(rfield),
|
@@ -2213,8 +2200,7 @@ frb_ir_term_docs_for(VALUE self, VALUE rfield, VALUE rterm)
|
|
2213
2200
|
* more info.
|
2214
2201
|
*/
|
2215
2202
|
static VALUE
|
2216
|
-
frb_ir_term_positions(VALUE self)
|
2217
|
-
{
|
2203
|
+
frb_ir_term_positions(VALUE self) {
|
2218
2204
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
2219
2205
|
return frb_get_tde(self, ir->term_positions(ir));
|
2220
2206
|
}
|
@@ -2228,8 +2214,7 @@ frb_ir_term_positions(VALUE self)
|
|
2228
2214
|
* TermDocEnum for more info.
|
2229
2215
|
*/
|
2230
2216
|
static VALUE
|
2231
|
-
frb_ir_t_pos_for(VALUE self, VALUE rfield, VALUE rterm)
|
2232
|
-
{
|
2217
|
+
frb_ir_t_pos_for(VALUE self, VALUE rfield, VALUE rterm) {
|
2233
2218
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
2234
2219
|
return frb_get_tde(self, frt_ir_term_positions_for(ir,
|
2235
2220
|
frb_field(rfield),
|
@@ -2244,8 +2229,7 @@ frb_ir_t_pos_for(VALUE self, VALUE rfield, VALUE rterm)
|
|
2244
2229
|
* field +field+.
|
2245
2230
|
*/
|
2246
2231
|
static VALUE
|
2247
|
-
frb_ir_doc_freq(VALUE self, VALUE rfield, VALUE rterm)
|
2248
|
-
{
|
2232
|
+
frb_ir_doc_freq(VALUE self, VALUE rfield, VALUE rterm) {
|
2249
2233
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
2250
2234
|
return INT2FIX(frt_ir_doc_freq(ir,
|
2251
2235
|
frb_field(rfield),
|
@@ -2260,8 +2244,7 @@ frb_ir_doc_freq(VALUE self, VALUE rfield, VALUE rterm)
|
|
2260
2244
|
* terms in the field +field+ in the index.
|
2261
2245
|
*/
|
2262
2246
|
static VALUE
|
2263
|
-
frb_ir_terms(VALUE self, VALUE rfield)
|
2264
|
-
{
|
2247
|
+
frb_ir_terms(VALUE self, VALUE rfield) {
|
2265
2248
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
2266
2249
|
return frb_get_te(self, frt_ir_terms(ir, frb_field(rfield)));
|
2267
2250
|
}
|
@@ -2274,8 +2257,7 @@ frb_ir_terms(VALUE self, VALUE rfield)
|
|
2274
2257
|
* at term +term+.
|
2275
2258
|
*/
|
2276
2259
|
static VALUE
|
2277
|
-
frb_ir_terms_from(VALUE self, VALUE rfield, VALUE rterm)
|
2278
|
-
{
|
2260
|
+
frb_ir_terms_from(VALUE self, VALUE rfield, VALUE rterm) {
|
2279
2261
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
2280
2262
|
return frb_get_te(self, frt_ir_terms_from(ir,
|
2281
2263
|
frb_field(rfield),
|
@@ -2289,8 +2271,7 @@ frb_ir_terms_from(VALUE self, VALUE rfield, VALUE rterm)
|
|
2289
2271
|
* Same return a count of the number of terms in the field
|
2290
2272
|
*/
|
2291
2273
|
static VALUE
|
2292
|
-
frb_ir_term_count(VALUE self, VALUE rfield)
|
2293
|
-
{
|
2274
|
+
frb_ir_term_count(VALUE self, VALUE rfield) {
|
2294
2275
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
2295
2276
|
FrtTermEnum *te = frt_ir_terms(ir, frb_field(rfield));
|
2296
2277
|
int count = 0;
|
@@ -2311,8 +2292,7 @@ frb_ir_term_count(VALUE self, VALUE rfield)
|
|
2311
2292
|
* gathered from the FieldInfos object.
|
2312
2293
|
*/
|
2313
2294
|
static VALUE
|
2314
|
-
frb_ir_fields(VALUE self)
|
2315
|
-
{
|
2295
|
+
frb_ir_fields(VALUE self) {
|
2316
2296
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
2317
2297
|
FrtFieldInfos *fis = ir->fis;
|
2318
2298
|
VALUE rfield_names = rb_ary_new();
|
@@ -2345,8 +2325,7 @@ static VALUE frb_ir_field_infos(VALUE self) {
|
|
2345
2325
|
* of field names can also be gathered from the FieldInfos object.
|
2346
2326
|
*/
|
2347
2327
|
static VALUE
|
2348
|
-
frb_ir_tk_fields(VALUE self)
|
2349
|
-
{
|
2328
|
+
frb_ir_tk_fields(VALUE self) {
|
2350
2329
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
2351
2330
|
FrtFieldInfos *fis = ir->fis;
|
2352
2331
|
VALUE rfield_names = rb_ary_new();
|
@@ -2377,14 +2356,28 @@ static VALUE frb_ir_to_enum(VALUE self) {
|
|
2377
2356
|
static VALUE frb_ir_each(VALUE self) {
|
2378
2357
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
2379
2358
|
if (rb_block_given_p()) {
|
2359
|
+
int ex_code = 0;
|
2360
|
+
const char *msg = NULL;
|
2380
2361
|
long i;
|
2381
2362
|
long max_doc = ir->max_doc(ir);
|
2382
2363
|
VALUE rld;
|
2383
|
-
|
2384
|
-
|
2385
|
-
|
2386
|
-
|
2364
|
+
|
2365
|
+
FRT_TRY
|
2366
|
+
for (i = 0; i < max_doc; i++) {
|
2367
|
+
if (ir->is_deleted(ir, i)) continue;
|
2368
|
+
rld = frb_get_lazy_doc(ir->get_lazy_doc(ir, i));
|
2369
|
+
rb_yield(rld);
|
2370
|
+
}
|
2371
|
+
FRT_XCATCHALL
|
2372
|
+
ex_code = xcontext.excode;
|
2373
|
+
msg = xcontext.msg;
|
2374
|
+
FRT_HANDLED();
|
2375
|
+
FRT_XENDTRY
|
2376
|
+
|
2377
|
+
if (ex_code && msg) {
|
2378
|
+
frb_raise(ex_code, msg);
|
2387
2379
|
}
|
2380
|
+
|
2388
2381
|
return self;
|
2389
2382
|
} else {
|
2390
2383
|
return frb_ir_to_enum(self);
|