isomorfeus-ferret 0.13.11 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +2 -2
- data/README.md +43 -22
- data/ext/isomorfeus_ferret_ext/frb_field_info.c +539 -0
- data/ext/isomorfeus_ferret_ext/frb_index.c +59 -687
- data/ext/isomorfeus_ferret_ext/frb_lazy_doc.c +705 -0
- data/ext/isomorfeus_ferret_ext/frb_qparser.c +1 -1
- data/ext/isomorfeus_ferret_ext/frb_search.c +0 -10
- data/ext/isomorfeus_ferret_ext/frb_store.c +1 -1
- data/ext/isomorfeus_ferret_ext/frt_hash.h +6 -8
- data/ext/isomorfeus_ferret_ext/frt_index.c +5 -2
- data/ext/isomorfeus_ferret_ext/frt_index.h +3 -1
- data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +8 -6
- data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.h +6 -6
- data/lib/isomorfeus/ferret/index/index.rb +13 -13
- data/lib/isomorfeus/ferret/version.rb +1 -1
- metadata +4 -2
@@ -3789,10 +3789,6 @@ VALUE frb_get_q(FrtQuery *q) {
|
|
3789
3789
|
*
|
3790
3790
|
****************************************************************************/
|
3791
3791
|
|
3792
|
-
/* rdochack
|
3793
|
-
cTopDocs = rb_define_class_under(mSearch, "TopDocs", rb_cObject);
|
3794
|
-
*/
|
3795
|
-
|
3796
3792
|
/*
|
3797
3793
|
* Document-class: Ferret::Search::Hit
|
3798
3794
|
*
|
@@ -3806,9 +3802,6 @@ cTopDocs = rb_define_class_under(mSearch, "TopDocs", rb_cObject);
|
|
3806
3802
|
*/
|
3807
3803
|
static void Init_Hit(void) {
|
3808
3804
|
const char *hit_class = "Hit";
|
3809
|
-
/* rdochack
|
3810
|
-
cHit = rb_define_class_under(mSearch, "Hit", rb_cObject);
|
3811
|
-
*/
|
3812
3805
|
cHit = rb_struct_define(hit_class, "doc", "score", NULL);
|
3813
3806
|
rb_set_class_path(cHit, mSearch, hit_class);
|
3814
3807
|
rb_const_set(mSearch, rb_intern(hit_class), cHit);
|
@@ -3836,9 +3829,6 @@ static void Init_Hit(void) {
|
|
3836
3829
|
*/
|
3837
3830
|
static void Init_TopDocs(void) {
|
3838
3831
|
const char *td_class = "TopDocs";
|
3839
|
-
/* rdochack
|
3840
|
-
cTopDocs = rb_define_class_under(mSearch, "TopDocs", rb_cObject);
|
3841
|
-
*/
|
3842
3832
|
cTopDocs = rb_struct_define(td_class,
|
3843
3833
|
"total_hits",
|
3844
3834
|
"hits",
|
@@ -402,7 +402,7 @@ static VALUE frb_fsdir_new(int argc, VALUE *argv, VALUE klass) {
|
|
402
402
|
frb_create_dir(rpath);
|
403
403
|
}
|
404
404
|
if (!rb_funcall(rb_cFile, id_is_directory, 1, rpath)) {
|
405
|
-
rb_raise(
|
405
|
+
rb_raise(cFileNotFoundError, "No directory <%s> found. Use :create => true to create one.", rs2s(rpath));
|
406
406
|
}
|
407
407
|
store = frt_open_fs_store(rs2s(rpath));
|
408
408
|
if (create) store->clear_all(store);
|
@@ -58,10 +58,10 @@ typedef struct FrtHash {
|
|
58
58
|
* used outside of the Hash methods */
|
59
59
|
FrtHashEntry *(*lookup_i)(struct FrtHash *self,
|
60
60
|
register const void *key);
|
61
|
-
unsigned long
|
62
|
-
int
|
63
|
-
void
|
64
|
-
void
|
61
|
+
unsigned long (*hash_i)(const void *key);
|
62
|
+
int (*eq_i)(const void *key1, const void *key2);
|
63
|
+
void (*free_key_i)(void *p);
|
64
|
+
void (*free_value_i)(void *p);
|
65
65
|
} FrtHash;
|
66
66
|
|
67
67
|
/**
|
@@ -140,8 +140,7 @@ extern FrtHash *frt_h_new(frt_hash_ft hash,
|
|
140
140
|
* pass NULL in place of this parameter the value will not be destroyed.
|
141
141
|
* @return A newly allocated Hash
|
142
142
|
*/
|
143
|
-
extern FrtHash *frt_h_new_str(frt_free_ft free_key,
|
144
|
-
frt_free_ft free_value);
|
143
|
+
extern FrtHash *frt_h_new_str(frt_free_ft free_key, frt_free_ft free_value);
|
145
144
|
|
146
145
|
/**
|
147
146
|
* Create a new Hash that uses integers as its keys. The Hash will store all
|
@@ -258,8 +257,7 @@ extern void *frt_h_rem(FrtHash *self, const void *key, bool del_key);
|
|
258
257
|
* the existing key so no key was freed
|
259
258
|
* </pre>
|
260
259
|
*/
|
261
|
-
extern FrtHashKeyStatus frt_h_set(FrtHash *self,
|
262
|
-
const void *key, void *value);
|
260
|
+
extern FrtHashKeyStatus frt_h_set(FrtHash *self, const void *key, void *value);
|
263
261
|
|
264
262
|
/**
|
265
263
|
* Add the value +value+ to the Hash referencing it with key +key+. If
|
@@ -170,9 +170,9 @@ static char *fn_for_gen_field(char *buf,
|
|
170
170
|
*
|
171
171
|
***************************************************************************/
|
172
172
|
|
173
|
-
static unsigned long
|
173
|
+
static unsigned long co_hash(const void *key)
|
174
174
|
{
|
175
|
-
return (unsigned long
|
175
|
+
return (unsigned long)key;
|
176
176
|
}
|
177
177
|
|
178
178
|
static int co_eq(const void *key1, const void *key2)
|
@@ -1163,6 +1163,7 @@ static FrtLazyDocField *lazy_df_new(ID name, const int size, FrtCompressionType
|
|
1163
1163
|
self->data = FRT_ALLOC_AND_ZERO_N(FrtLazyDocFieldData, size);
|
1164
1164
|
self->compression = compression;
|
1165
1165
|
self->decompressed = false;
|
1166
|
+
self->loaded = false;
|
1166
1167
|
return self;
|
1167
1168
|
}
|
1168
1169
|
|
@@ -1400,6 +1401,7 @@ char *frt_lazy_df_get_data(FrtLazyDocField *self, int i) {
|
|
1400
1401
|
frt_is_read_bytes(self->doc->fields_in, (frt_uchar *)text, read_len);
|
1401
1402
|
text[read_len - 1] = '\0';
|
1402
1403
|
}
|
1404
|
+
self->loaded = true;
|
1403
1405
|
}
|
1404
1406
|
}
|
1405
1407
|
|
@@ -1473,6 +1475,7 @@ static FrtLazyDoc *lazy_doc_new(int size, FrtInStream *fdt_in)
|
|
1473
1475
|
self->size = size;
|
1474
1476
|
self->fields = FRT_ALLOC_AND_ZERO_N(FrtLazyDocField *, size);
|
1475
1477
|
self->fields_in = frt_is_clone(fdt_in);
|
1478
|
+
self->loaded = false;
|
1476
1479
|
return self;
|
1477
1480
|
}
|
1478
1481
|
|
@@ -529,7 +529,7 @@ extern FrtTVTerm *frt_tv_get_tv_term(FrtTermVector *tv, const char *term);
|
|
529
529
|
|
530
530
|
/* * * FrtLazyDocField * * */
|
531
531
|
typedef struct FrtLazyDocFieldData {
|
532
|
-
frt_off_t
|
532
|
+
frt_off_t start;
|
533
533
|
int length;
|
534
534
|
rb_encoding *encoding;
|
535
535
|
FrtCompressionType compression; /* as stored */
|
@@ -545,6 +545,7 @@ typedef struct FrtLazyDocField {
|
|
545
545
|
int len; /* length of data elements concatenated */
|
546
546
|
FrtCompressionType compression; /* as configured */
|
547
547
|
bool decompressed;
|
548
|
+
bool loaded;
|
548
549
|
} FrtLazyDocField;
|
549
550
|
|
550
551
|
extern char *frt_lazy_df_get_data(FrtLazyDocField *self, int i);
|
@@ -556,6 +557,7 @@ struct FrtLazyDoc {
|
|
556
557
|
int size;
|
557
558
|
FrtLazyDocField **fields;
|
558
559
|
FrtInStream *fields_in;
|
560
|
+
bool loaded;
|
559
561
|
};
|
560
562
|
|
561
563
|
extern void frt_lazy_doc_close(FrtLazyDoc *self);
|
@@ -29,6 +29,7 @@ VALUE sym_true;
|
|
29
29
|
VALUE sym_false;
|
30
30
|
VALUE sym_path;
|
31
31
|
VALUE sym_dir;
|
32
|
+
VALUE sym_each;
|
32
33
|
|
33
34
|
/* Modules */
|
34
35
|
VALUE mIsomorfeus;
|
@@ -272,12 +273,13 @@ void Init_isomorfeus_ferret_ext(void) {
|
|
272
273
|
id_data = rb_intern("@data");
|
273
274
|
|
274
275
|
/* Symbols */
|
275
|
-
sym_yes = ID2SYM(rb_intern("yes"))
|
276
|
-
sym_no = ID2SYM(rb_intern("no"))
|
277
|
-
sym_true = ID2SYM(rb_intern("true"))
|
278
|
-
sym_false = ID2SYM(rb_intern("false"))
|
279
|
-
sym_path = ID2SYM(rb_intern("path"))
|
280
|
-
sym_dir = ID2SYM(rb_intern("dir"))
|
276
|
+
sym_yes = ID2SYM(rb_intern("yes"));
|
277
|
+
sym_no = ID2SYM(rb_intern("no"));
|
278
|
+
sym_true = ID2SYM(rb_intern("true"));
|
279
|
+
sym_false = ID2SYM(rb_intern("false"));
|
280
|
+
sym_path = ID2SYM(rb_intern("path"));
|
281
|
+
sym_dir = ID2SYM(rb_intern("dir"));
|
282
|
+
sym_each = ID2SYM(rb_intern("each"));
|
281
283
|
|
282
284
|
mIsomorfeus = rb_define_module("Isomorfeus");
|
283
285
|
mFerret = rb_define_module_under(mIsomorfeus, "Ferret");
|
@@ -41,12 +41,12 @@ extern VALUE cLockError;
|
|
41
41
|
extern VALUE cTerm;
|
42
42
|
|
43
43
|
/* Ferret Inits */
|
44
|
-
extern void Init_Utils();
|
45
|
-
extern void Init_Analysis();
|
46
|
-
extern void Init_Store();
|
47
|
-
extern void Init_Index();
|
48
|
-
extern void Init_Search();
|
49
|
-
extern void Init_QueryParser();
|
44
|
+
extern void Init_Utils(void);
|
45
|
+
extern void Init_Analysis(void);
|
46
|
+
extern void Init_Store(void);
|
47
|
+
extern void Init_Index(void);
|
48
|
+
extern void Init_Search(void);
|
49
|
+
extern void Init_QueryParser(void);
|
50
50
|
|
51
51
|
extern void frb_raise(int excode, const char *msg);
|
52
52
|
extern void frb_create_dir(VALUE rpath);
|
@@ -5,6 +5,7 @@ module Isomorfeus
|
|
5
5
|
# information on how to use this class.
|
6
6
|
class Index
|
7
7
|
include MonitorMixin
|
8
|
+
include Enumerable
|
8
9
|
include Isomorfeus::Ferret::Store
|
9
10
|
include Isomorfeus::Ferret::Search
|
10
11
|
|
@@ -383,14 +384,11 @@ module Isomorfeus
|
|
383
384
|
# puts "hit document number #{doc} with a score of #{score}"
|
384
385
|
# end
|
385
386
|
#
|
386
|
-
def search_each(query, options = {}) # :yield: doc, score
|
387
|
+
def search_each(query, options = {}, &block) # :yield: doc, score
|
387
388
|
@dir.synchronize do
|
388
389
|
ensure_searcher_open()
|
389
390
|
query = do_process_query(query)
|
390
|
-
|
391
|
-
@searcher.search_each(query, options) do |doc, score|
|
392
|
-
yield doc, score
|
393
|
-
end
|
391
|
+
@searcher.search_each(query, options, &block)
|
394
392
|
end
|
395
393
|
end
|
396
394
|
|
@@ -485,15 +483,11 @@ module Isomorfeus
|
|
485
483
|
end
|
486
484
|
end
|
487
485
|
|
488
|
-
# iterate through all documents in the index.
|
489
|
-
|
490
|
-
# fields.
|
491
|
-
def each
|
486
|
+
# iterate through all documents in the index.
|
487
|
+
def each(&block)
|
492
488
|
@dir.synchronize do
|
493
489
|
ensure_reader_open
|
494
|
-
|
495
|
-
yield @reader[i].load unless @reader.deleted?(i)
|
496
|
-
end
|
490
|
+
@reader.each(&block)
|
497
491
|
end
|
498
492
|
end
|
499
493
|
|
@@ -679,7 +673,7 @@ module Isomorfeus
|
|
679
673
|
docs_to_add = []
|
680
674
|
query = do_process_query(query)
|
681
675
|
@searcher.search_each(query, :limit => :all) do |id, score|
|
682
|
-
document = @searcher[id].
|
676
|
+
document = @searcher[id].to_h
|
683
677
|
if new_val.is_a?(Hash)
|
684
678
|
document.merge!(new_val)
|
685
679
|
else new_val.is_a?(String) or new_val.is_a?(Symbol)
|
@@ -850,6 +844,12 @@ module Isomorfeus
|
|
850
844
|
end
|
851
845
|
end
|
852
846
|
|
847
|
+
def to_enum
|
848
|
+
@dir.synchronize do
|
849
|
+
ensure_reader_open
|
850
|
+
@reader.to_enum
|
851
|
+
end
|
852
|
+
end
|
853
853
|
|
854
854
|
protected
|
855
855
|
def ensure_writer_open()
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isomorfeus-ferret
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
@@ -180,7 +180,9 @@ files:
|
|
180
180
|
- ext/isomorfeus_ferret_ext/extconf.rb
|
181
181
|
- ext/isomorfeus_ferret_ext/fio_tmpfile.h
|
182
182
|
- ext/isomorfeus_ferret_ext/frb_analysis.c
|
183
|
+
- ext/isomorfeus_ferret_ext/frb_field_info.c
|
183
184
|
- ext/isomorfeus_ferret_ext/frb_index.c
|
185
|
+
- ext/isomorfeus_ferret_ext/frb_lazy_doc.c
|
184
186
|
- ext/isomorfeus_ferret_ext/frb_qparser.c
|
185
187
|
- ext/isomorfeus_ferret_ext/frb_search.c
|
186
188
|
- ext/isomorfeus_ferret_ext/frb_store.c
|