isomorfeus-ferret 0.15.0 → 0.16.0
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/frb_index.c +170 -48
- data/ext/isomorfeus_ferret_ext/frb_search.c +1 -1
- data/ext/isomorfeus_ferret_ext/frb_store.c +231 -108
- data/ext/isomorfeus_ferret_ext/frt_compound_io.c +1 -1
- data/ext/isomorfeus_ferret_ext/frt_index.c +6 -12
- data/ext/isomorfeus_ferret_ext/frt_mdbx_store.c +114 -56
- data/ext/isomorfeus_ferret_ext/frt_store.h +0 -9
- data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +2 -2
- data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.h +1 -1
- data/ext/isomorfeus_ferret_ext/mdbx.c +656 -613
- data/ext/isomorfeus_ferret_ext/test.c +26 -28
- data/ext/isomorfeus_ferret_ext/test_index.c +3 -3
- data/ext/isomorfeus_ferret_ext/test_ram_store.c +1 -1
- data/ext/isomorfeus_ferret_ext/test_segments.c +1 -1
- data/ext/isomorfeus_ferret_ext/test_sort.c +2 -2
- data/ext/isomorfeus_ferret_ext/test_threading.c +2 -2
- data/ext/isomorfeus_ferret_ext/tests_all.h +0 -3
- data/lib/isomorfeus/ferret/index/index.rb +8 -9
- data/lib/isomorfeus/ferret/version.rb +1 -1
- metadata +4 -6
- data/ext/isomorfeus_ferret_ext/frt_fs_store.c +0 -479
- data/ext/isomorfeus_ferret_ext/test_fs_store.c +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0910e1e8d9cb68f71275b885c83ac427fd06163d19c9d3353a5eac3899bf91a8'
|
4
|
+
data.tar.gz: b057b640008ef4384a7d118bb97ad6644c51b2fef0986bb02bc3ac296a423f8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8437a6d16ff08ebc05f78169a0ca1bfa6627b3994ecae09b25a1373a7cfd41c8836ee21cf0485f0b1008d34488da8f4e781a50e92f9847527f5f6c2b8729d3df
|
7
|
+
data.tar.gz: 7742111e748ba8adb135d50a8d676eb57c63e2bd723b5099a000f01f6e17dd0e3d1bfdd9e47bf7a5af67ad7ead75b6241b660af094f6b7e673115dd07e0abe7b
|
@@ -291,7 +291,7 @@ static VALUE frb_fis_create_index(VALUE self, VALUE rdir) {
|
|
291
291
|
} else {
|
292
292
|
StringValue(rdir);
|
293
293
|
frb_create_dir(rdir);
|
294
|
-
store =
|
294
|
+
store = frt_open_mdbx_store(rs2s(rdir));
|
295
295
|
frt_index_create(store, fis);
|
296
296
|
frt_store_close(store);
|
297
297
|
}
|
@@ -983,7 +983,7 @@ static VALUE frb_iw_close(VALUE self) {
|
|
983
983
|
* dir = RAMDirectory.new()
|
984
984
|
* iw = IndexWriter.new(:dir => dir)
|
985
985
|
*
|
986
|
-
* dir =
|
986
|
+
* dir = MDBXDirectory.new("/path/to/index")
|
987
987
|
* iw = IndexWriter.new(:dir => dir)
|
988
988
|
*
|
989
989
|
* iw = IndexWriter.new(:path => "/path/to/index")
|
@@ -1039,7 +1039,7 @@ static VALUE frb_iw_init(int argc, VALUE *argv, VALUE self) {
|
|
1039
1039
|
} else if ((rval = rb_hash_aref(roptions, sym_path)) != Qnil) {
|
1040
1040
|
StringValue(rval);
|
1041
1041
|
frb_create_dir(rval);
|
1042
|
-
store =
|
1042
|
+
store = frt_open_mdbx_store(rs2s(rval));
|
1043
1043
|
}
|
1044
1044
|
/* use_compound_file defaults to true */
|
1045
1045
|
config.use_compound_file =
|
@@ -1112,10 +1112,25 @@ static VALUE frb_iw_init(int argc, VALUE *argv, VALUE self) {
|
|
1112
1112
|
* taken into account until the FrtIndexWriter has been committed.
|
1113
1113
|
*/
|
1114
1114
|
static VALUE
|
1115
|
-
frb_iw_get_doc_count(VALUE self)
|
1116
|
-
|
1115
|
+
frb_iw_get_doc_count(VALUE self) {
|
1116
|
+
int ex_code = 0;
|
1117
|
+
const char *msg = NULL;
|
1118
|
+
int cnt = 0;
|
1117
1119
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1118
|
-
|
1120
|
+
|
1121
|
+
FRT_TRY
|
1122
|
+
cnt = frt_iw_doc_count(iw);
|
1123
|
+
FRT_XCATCHALL
|
1124
|
+
ex_code = xcontext.excode;
|
1125
|
+
msg = xcontext.msg;
|
1126
|
+
FRT_HANDLED();
|
1127
|
+
FRT_XENDTRY
|
1128
|
+
|
1129
|
+
if (ex_code && msg) {
|
1130
|
+
frb_raise(ex_code, msg);
|
1131
|
+
}
|
1132
|
+
|
1133
|
+
return INT2FIX(cnt);
|
1119
1134
|
}
|
1120
1135
|
|
1121
1136
|
static int
|
@@ -1224,12 +1239,26 @@ frb_get_doc(VALUE rdoc)
|
|
1224
1239
|
* hash object.
|
1225
1240
|
*/
|
1226
1241
|
static VALUE
|
1227
|
-
frb_iw_add_doc(VALUE self, VALUE rdoc)
|
1228
|
-
|
1242
|
+
frb_iw_add_doc(VALUE self, VALUE rdoc) {
|
1243
|
+
int ex_code = 0;
|
1244
|
+
const char *msg = NULL;
|
1245
|
+
|
1229
1246
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1247
|
+
|
1248
|
+
FRT_TRY
|
1249
|
+
FrtDocument *doc = frb_get_doc(rdoc);
|
1250
|
+
frt_iw_add_doc(iw, doc);
|
1251
|
+
frt_doc_destroy(doc);
|
1252
|
+
FRT_XCATCHALL
|
1253
|
+
ex_code = xcontext.excode;
|
1254
|
+
msg = xcontext.msg;
|
1255
|
+
FRT_HANDLED();
|
1256
|
+
FRT_XENDTRY
|
1257
|
+
|
1258
|
+
if (ex_code && msg) {
|
1259
|
+
frb_raise(ex_code, msg);
|
1260
|
+
}
|
1261
|
+
|
1233
1262
|
return self;
|
1234
1263
|
}
|
1235
1264
|
|
@@ -1246,10 +1275,24 @@ frb_iw_add_doc(VALUE self, VALUE rdoc)
|
|
1246
1275
|
* process).
|
1247
1276
|
*/
|
1248
1277
|
static VALUE
|
1249
|
-
frb_iw_optimize(VALUE self)
|
1250
|
-
|
1278
|
+
frb_iw_optimize(VALUE self) {
|
1279
|
+
int ex_code = 0;
|
1280
|
+
const char *msg = NULL;
|
1281
|
+
|
1251
1282
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1252
|
-
|
1283
|
+
|
1284
|
+
FRT_TRY
|
1285
|
+
frt_iw_optimize(iw);
|
1286
|
+
FRT_XCATCHALL
|
1287
|
+
ex_code = xcontext.excode;
|
1288
|
+
msg = xcontext.msg;
|
1289
|
+
FRT_HANDLED();
|
1290
|
+
FRT_XENDTRY
|
1291
|
+
|
1292
|
+
if (ex_code && msg) {
|
1293
|
+
frb_raise(ex_code, msg);
|
1294
|
+
}
|
1295
|
+
|
1253
1296
|
return self;
|
1254
1297
|
}
|
1255
1298
|
|
@@ -1262,10 +1305,24 @@ frb_iw_optimize(VALUE self)
|
|
1262
1305
|
* with an IndexWriter.
|
1263
1306
|
*/
|
1264
1307
|
static VALUE
|
1265
|
-
frb_iw_commit(VALUE self)
|
1266
|
-
|
1308
|
+
frb_iw_commit(VALUE self) {
|
1309
|
+
int ex_code = 0;
|
1310
|
+
const char *msg = NULL;
|
1311
|
+
|
1267
1312
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1268
|
-
|
1313
|
+
|
1314
|
+
FRT_TRY
|
1315
|
+
frt_iw_commit(iw);
|
1316
|
+
FRT_XCATCHALL
|
1317
|
+
ex_code = xcontext.excode;
|
1318
|
+
msg = xcontext.msg;
|
1319
|
+
FRT_HANDLED();
|
1320
|
+
FRT_XENDTRY
|
1321
|
+
|
1322
|
+
if (ex_code && msg) {
|
1323
|
+
frb_raise(ex_code, msg);
|
1324
|
+
}
|
1325
|
+
|
1269
1326
|
return self;
|
1270
1327
|
}
|
1271
1328
|
|
@@ -1322,21 +1379,36 @@ const rb_data_type_t frb_index_reader_t = {
|
|
1322
1379
|
* index.
|
1323
1380
|
*/
|
1324
1381
|
static VALUE frb_iw_add_readers(VALUE self, VALUE rreaders) {
|
1382
|
+
int ex_code = 0;
|
1383
|
+
const char *msg = NULL;
|
1325
1384
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1326
|
-
int i;
|
1385
|
+
int i, l;
|
1327
1386
|
FrtIndexReader **irs;
|
1328
1387
|
Check_Type(rreaders, T_ARRAY);
|
1329
1388
|
|
1330
1389
|
irs = FRT_ALLOC_N(FrtIndexReader *, RARRAY_LEN(rreaders));
|
1331
|
-
i = RARRAY_LEN(rreaders);
|
1390
|
+
i = l = RARRAY_LEN(rreaders);
|
1332
1391
|
while (i-- > 0) {
|
1333
1392
|
FrtIndexReader *ir;
|
1334
1393
|
TypedData_Get_Struct(RARRAY_PTR(rreaders)[i], FrtIndexReader, &frb_index_reader_t, ir);
|
1335
1394
|
FRT_REF(ir);
|
1336
1395
|
irs[i] = ir;
|
1337
1396
|
}
|
1338
|
-
|
1397
|
+
|
1398
|
+
FRT_TRY
|
1399
|
+
frt_iw_add_readers(iw, irs, l);
|
1400
|
+
FRT_XCATCHALL
|
1401
|
+
ex_code = xcontext.excode;
|
1402
|
+
msg = xcontext.msg;
|
1403
|
+
FRT_HANDLED();
|
1404
|
+
FRT_XENDTRY
|
1405
|
+
|
1339
1406
|
free(irs);
|
1407
|
+
|
1408
|
+
if (ex_code && msg) {
|
1409
|
+
frb_raise(ex_code, msg);
|
1410
|
+
}
|
1411
|
+
|
1340
1412
|
return self;
|
1341
1413
|
}
|
1342
1414
|
|
@@ -1352,21 +1424,35 @@ static VALUE frb_iw_add_readers(VALUE self, VALUE rreaders) {
|
|
1352
1424
|
* want to delete all documents with the term "viagra" when deleting spam.
|
1353
1425
|
*/
|
1354
1426
|
static VALUE
|
1355
|
-
frb_iw_delete(VALUE self, VALUE rfield, VALUE rterm)
|
1356
|
-
|
1427
|
+
frb_iw_delete(VALUE self, VALUE rfield, VALUE rterm) {
|
1428
|
+
int ex_code = 0;
|
1429
|
+
const char *msg = NULL;
|
1430
|
+
|
1357
1431
|
FrtIndexWriter *iw = (FrtIndexWriter *)DATA_PTR(self);
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
terms
|
1432
|
+
|
1433
|
+
FRT_TRY
|
1434
|
+
if (TYPE(rterm) == T_ARRAY) {
|
1435
|
+
const int term_cnt = RARRAY_LEN(rterm);
|
1436
|
+
int i;
|
1437
|
+
char **terms = FRT_ALLOC_N(char *, term_cnt);
|
1438
|
+
for (i = 0; i < term_cnt; i++) {
|
1439
|
+
terms[i] = StringValuePtr(RARRAY_PTR(rterm)[i]);
|
1440
|
+
}
|
1441
|
+
frt_iw_delete_terms(iw, frb_field(rfield), terms, term_cnt);
|
1442
|
+
free(terms);
|
1443
|
+
} else {
|
1444
|
+
frt_iw_delete_term(iw, frb_field(rfield), StringValuePtr(rterm));
|
1364
1445
|
}
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1446
|
+
FRT_XCATCHALL
|
1447
|
+
ex_code = xcontext.excode;
|
1448
|
+
msg = xcontext.msg;
|
1449
|
+
FRT_HANDLED();
|
1450
|
+
FRT_XENDTRY
|
1451
|
+
|
1452
|
+
if (ex_code && msg) {
|
1453
|
+
frb_raise(ex_code, msg);
|
1369
1454
|
}
|
1455
|
+
|
1370
1456
|
return self;
|
1371
1457
|
}
|
1372
1458
|
|
@@ -1688,7 +1774,7 @@ frb_iw_set_use_compound_file(VALUE self, VALUE rval)
|
|
1688
1774
|
* dir = RAMDirectory.new()
|
1689
1775
|
* iw = IndexReader.new(dir)
|
1690
1776
|
*
|
1691
|
-
* dir =
|
1777
|
+
* dir = MDBXDirectory.new("/path/to/index")
|
1692
1778
|
* iw = IndexReader.new(dir)
|
1693
1779
|
*
|
1694
1780
|
* iw = IndexReader.new("/path/to/index")
|
@@ -1744,7 +1830,7 @@ static VALUE frb_ir_init(VALUE self, VALUE rdir) {
|
|
1744
1830
|
break;
|
1745
1831
|
case T_STRING:
|
1746
1832
|
frb_create_dir(rdir);
|
1747
|
-
store =
|
1833
|
+
store = frt_open_mdbx_store(rs2s(rdir));
|
1748
1834
|
break;
|
1749
1835
|
default:
|
1750
1836
|
FRT_RAISE(FRT_ARG_ERROR, "%s isn't a valid directory "
|
@@ -1765,7 +1851,7 @@ static VALUE frb_ir_init(VALUE self, VALUE rdir) {
|
|
1765
1851
|
break;
|
1766
1852
|
case T_STRING:
|
1767
1853
|
frb_create_dir(rdir);
|
1768
|
-
store =
|
1854
|
+
store = frt_open_mdbx_store(rs2s(rdir));
|
1769
1855
|
break;
|
1770
1856
|
default:
|
1771
1857
|
FRT_RAISE(FRT_ARG_ERROR, "%s isn't a valid directory argument. "
|
@@ -1810,10 +1896,23 @@ static VALUE frb_ir_init(VALUE self, VALUE rdir) {
|
|
1810
1896
|
* encoded float value.
|
1811
1897
|
*/
|
1812
1898
|
static VALUE
|
1813
|
-
frb_ir_set_norm(VALUE self, VALUE rdoc_id, VALUE rfield, VALUE rval)
|
1814
|
-
|
1899
|
+
frb_ir_set_norm(VALUE self, VALUE rdoc_id, VALUE rfield, VALUE rval) {
|
1900
|
+
int ex_code = 0;
|
1901
|
+
const char *msg = NULL;
|
1815
1902
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
1816
|
-
|
1903
|
+
|
1904
|
+
FRT_TRY
|
1905
|
+
frt_ir_set_norm(ir, FIX2INT(rdoc_id), frb_field(rfield), (frt_uchar)NUM2CHR(rval));
|
1906
|
+
FRT_XCATCHALL
|
1907
|
+
ex_code = xcontext.excode;
|
1908
|
+
msg = xcontext.msg;
|
1909
|
+
FRT_HANDLED();
|
1910
|
+
FRT_XENDTRY
|
1911
|
+
|
1912
|
+
if (ex_code && msg) {
|
1913
|
+
frb_raise(ex_code, msg);
|
1914
|
+
}
|
1915
|
+
|
1817
1916
|
return self;
|
1818
1917
|
}
|
1819
1918
|
|
@@ -1871,10 +1970,22 @@ frb_ir_get_norms_into(VALUE self, VALUE rfield, VALUE rnorms, VALUE roffset)
|
|
1871
1970
|
* will use open a Commit lock.
|
1872
1971
|
*/
|
1873
1972
|
static VALUE
|
1874
|
-
frb_ir_commit(VALUE self)
|
1875
|
-
|
1973
|
+
frb_ir_commit(VALUE self) {
|
1974
|
+
int ex_code = 0;
|
1975
|
+
const char *msg = NULL;
|
1876
1976
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
1877
|
-
|
1977
|
+
FRT_TRY
|
1978
|
+
frt_ir_commit(ir);
|
1979
|
+
FRT_XCATCHALL
|
1980
|
+
ex_code = xcontext.excode;
|
1981
|
+
msg = xcontext.msg;
|
1982
|
+
FRT_HANDLED();
|
1983
|
+
FRT_XENDTRY
|
1984
|
+
|
1985
|
+
if (ex_code && msg) {
|
1986
|
+
frb_raise(ex_code, msg);
|
1987
|
+
}
|
1988
|
+
|
1878
1989
|
return self;
|
1879
1990
|
}
|
1880
1991
|
|
@@ -1922,10 +2033,23 @@ frb_ir_has_deletions(VALUE self)
|
|
1922
2033
|
* returned by search methods.
|
1923
2034
|
*/
|
1924
2035
|
static VALUE
|
1925
|
-
frb_ir_delete(VALUE self, VALUE rdoc_id)
|
1926
|
-
|
2036
|
+
frb_ir_delete(VALUE self, VALUE rdoc_id) {
|
2037
|
+
int ex_code = 0;
|
2038
|
+
const char *msg = NULL;
|
1927
2039
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
1928
|
-
|
2040
|
+
|
2041
|
+
FRT_TRY
|
2042
|
+
frt_ir_delete_doc(ir, FIX2INT(rdoc_id));
|
2043
|
+
FRT_XCATCHALL
|
2044
|
+
ex_code = xcontext.excode;
|
2045
|
+
msg = xcontext.msg;
|
2046
|
+
FRT_HANDLED();
|
2047
|
+
FRT_XENDTRY
|
2048
|
+
|
2049
|
+
if (ex_code && msg) {
|
2050
|
+
frb_raise(ex_code, msg);
|
2051
|
+
}
|
2052
|
+
|
1929
2053
|
return self;
|
1930
2054
|
}
|
1931
2055
|
|
@@ -2014,8 +2138,7 @@ frb_get_doc_range(FrtIndexReader *ir, int pos, int len, int max)
|
|
2014
2138
|
* which are returned by the Searchers search methods.
|
2015
2139
|
*/
|
2016
2140
|
static VALUE
|
2017
|
-
frb_ir_get_doc(int argc, VALUE *argv, VALUE self)
|
2018
|
-
{
|
2141
|
+
frb_ir_get_doc(int argc, VALUE *argv, VALUE self) {
|
2019
2142
|
FrtIndexReader *ir = (FrtIndexReader *)DATA_PTR(self);
|
2020
2143
|
VALUE arg1, arg2;
|
2021
2144
|
long pos, len;
|
@@ -2044,8 +2167,7 @@ frb_ir_get_doc(int argc, VALUE *argv, VALUE self)
|
|
2044
2167
|
default:
|
2045
2168
|
return frb_get_doc_range(ir, pos, len, max);
|
2046
2169
|
}
|
2047
|
-
}
|
2048
|
-
else {
|
2170
|
+
} else {
|
2049
2171
|
pos = FIX2LONG(arg1);
|
2050
2172
|
len = FIX2LONG(arg2);
|
2051
2173
|
return frb_get_doc_range(ir, pos, len, max);
|
@@ -3604,7 +3604,7 @@ static VALUE frb_sea_init(VALUE self, VALUE obj) {
|
|
3604
3604
|
FrtSearcher *sea;
|
3605
3605
|
if (TYPE(obj) == T_STRING) {
|
3606
3606
|
frb_create_dir(obj);
|
3607
|
-
store =
|
3607
|
+
store = frt_open_mdbx_store(rs2s(obj));
|
3608
3608
|
ir = frt_ir_open(NULL, store);
|
3609
3609
|
ir->rir = TypedData_Wrap_Struct(cIndexReader, &frb_index_reader_t, ir);
|
3610
3610
|
} else {
|