isomorfeus-ferret 0.12.7 → 0.13.2
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 +101 -19
- data/README.md +85 -13
- data/ext/isomorfeus_ferret_ext/bm_bitvector.c +22 -30
- data/ext/isomorfeus_ferret_ext/bm_hash.c +6 -12
- data/ext/isomorfeus_ferret_ext/bm_micro_string.c +3 -6
- data/ext/isomorfeus_ferret_ext/bm_store.c +11 -22
- data/ext/isomorfeus_ferret_ext/brotli_common_dictionary.c +1 -1
- data/ext/isomorfeus_ferret_ext/brotli_dec_decode.c +1 -1
- data/ext/isomorfeus_ferret_ext/bzlib.c +1572 -0
- data/ext/isomorfeus_ferret_ext/bzlib.h +282 -0
- data/ext/isomorfeus_ferret_ext/bzlib_blocksort.c +1094 -0
- data/ext/isomorfeus_ferret_ext/bzlib_compress.c +672 -0
- data/ext/isomorfeus_ferret_ext/bzlib_crctable.c +104 -0
- data/ext/isomorfeus_ferret_ext/bzlib_decompress.c +652 -0
- data/ext/isomorfeus_ferret_ext/bzlib_huffman.c +205 -0
- data/ext/isomorfeus_ferret_ext/bzlib_private.h +509 -0
- data/ext/isomorfeus_ferret_ext/bzlib_randtable.c +84 -0
- data/ext/isomorfeus_ferret_ext/fio_tmpfile.h +53 -53
- data/ext/isomorfeus_ferret_ext/frb_analysis.c +785 -1192
- data/ext/isomorfeus_ferret_ext/frb_index.c +497 -495
- data/ext/isomorfeus_ferret_ext/frb_qparser.c +48 -60
- data/ext/isomorfeus_ferret_ext/frb_search.c +1520 -1002
- data/ext/isomorfeus_ferret_ext/frb_store.c +96 -96
- data/ext/isomorfeus_ferret_ext/frb_threading.h +0 -1
- data/ext/isomorfeus_ferret_ext/frb_utils.c +147 -196
- data/ext/isomorfeus_ferret_ext/frt_analysis.c +695 -1090
- data/ext/isomorfeus_ferret_ext/frt_analysis.h +174 -170
- data/ext/isomorfeus_ferret_ext/frt_array.c +2 -4
- data/ext/isomorfeus_ferret_ext/frt_bitvector.c +9 -16
- data/ext/isomorfeus_ferret_ext/frt_bitvector.h +32 -81
- data/ext/isomorfeus_ferret_ext/frt_document.c +15 -20
- data/ext/isomorfeus_ferret_ext/frt_document.h +10 -10
- data/ext/isomorfeus_ferret_ext/frt_except.c +5 -12
- data/ext/isomorfeus_ferret_ext/frt_field_index.c +3 -3
- data/ext/isomorfeus_ferret_ext/frt_field_index.h +6 -7
- data/ext/isomorfeus_ferret_ext/frt_filter.c +35 -46
- data/ext/isomorfeus_ferret_ext/frt_fs_store.c +1 -0
- data/ext/isomorfeus_ferret_ext/frt_global.c +91 -200
- data/ext/isomorfeus_ferret_ext/frt_global.h +7 -18
- data/ext/isomorfeus_ferret_ext/frt_hash.c +1 -2
- data/ext/isomorfeus_ferret_ext/frt_ind.c +32 -35
- data/ext/isomorfeus_ferret_ext/frt_ind.h +9 -9
- data/ext/isomorfeus_ferret_ext/frt_index.c +603 -410
- data/ext/isomorfeus_ferret_ext/frt_index.h +272 -291
- data/ext/isomorfeus_ferret_ext/frt_lang.c +0 -2
- data/ext/isomorfeus_ferret_ext/frt_mempool.c +1 -2
- data/ext/isomorfeus_ferret_ext/frt_multimapper.c +4 -7
- data/ext/isomorfeus_ferret_ext/frt_q_boolean.c +68 -91
- data/ext/isomorfeus_ferret_ext/frt_q_const_score.c +35 -38
- data/ext/isomorfeus_ferret_ext/frt_q_filtered_query.c +53 -72
- data/ext/isomorfeus_ferret_ext/frt_q_fuzzy.c +25 -32
- data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +21 -23
- data/ext/isomorfeus_ferret_ext/frt_q_multi_term.c +66 -103
- data/ext/isomorfeus_ferret_ext/frt_q_parser.c +207 -195
- data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +20 -16
- data/ext/isomorfeus_ferret_ext/frt_q_prefix.c +17 -14
- data/ext/isomorfeus_ferret_ext/frt_q_range.c +102 -131
- data/ext/isomorfeus_ferret_ext/frt_q_span.c +179 -178
- data/ext/isomorfeus_ferret_ext/frt_q_term.c +47 -60
- data/ext/isomorfeus_ferret_ext/frt_q_wildcard.c +18 -16
- data/ext/isomorfeus_ferret_ext/frt_ram_store.c +45 -84
- data/ext/isomorfeus_ferret_ext/frt_search.c +105 -146
- data/ext/isomorfeus_ferret_ext/frt_search.h +331 -320
- data/ext/isomorfeus_ferret_ext/frt_similarity.c +5 -13
- data/ext/isomorfeus_ferret_ext/frt_similarity.h +7 -12
- data/ext/isomorfeus_ferret_ext/frt_sort.c +105 -149
- data/ext/isomorfeus_ferret_ext/frt_store.c +13 -7
- data/ext/isomorfeus_ferret_ext/frt_store.h +10 -2
- data/ext/isomorfeus_ferret_ext/frt_threading.h +0 -1
- data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +22 -112
- data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.h +2 -32
- data/ext/isomorfeus_ferret_ext/lz4.c +2495 -0
- data/ext/isomorfeus_ferret_ext/lz4.h +774 -0
- data/ext/isomorfeus_ferret_ext/lz4frame.c +1899 -0
- data/ext/isomorfeus_ferret_ext/lz4frame.h +623 -0
- data/ext/isomorfeus_ferret_ext/lz4hc.c +1615 -0
- data/ext/isomorfeus_ferret_ext/lz4hc.h +413 -0
- data/ext/isomorfeus_ferret_ext/lz4xxhash.c +1030 -0
- data/ext/isomorfeus_ferret_ext/lz4xxhash.h +328 -0
- data/ext/isomorfeus_ferret_ext/stem_modules.h +0 -86
- data/ext/isomorfeus_ferret_ext/test.c +0 -17
- data/ext/isomorfeus_ferret_ext/test_1710.c +11 -12
- data/ext/isomorfeus_ferret_ext/test_analysis.c +590 -583
- data/ext/isomorfeus_ferret_ext/test_compound_io.c +1 -1
- data/ext/isomorfeus_ferret_ext/test_document.c +19 -15
- data/ext/isomorfeus_ferret_ext/test_except.c +1 -2
- data/ext/isomorfeus_ferret_ext/test_fields.c +59 -60
- data/ext/isomorfeus_ferret_ext/test_file_deleter.c +10 -27
- data/ext/isomorfeus_ferret_ext/test_filter.c +11 -8
- data/ext/isomorfeus_ferret_ext/test_global.c +0 -46
- data/ext/isomorfeus_ferret_ext/test_hash.c +2 -2
- data/ext/isomorfeus_ferret_ext/test_hashset.c +1 -1
- data/ext/isomorfeus_ferret_ext/test_highlighter.c +15 -11
- data/ext/isomorfeus_ferret_ext/test_index.c +372 -365
- data/ext/isomorfeus_ferret_ext/test_q_const_score.c +5 -3
- data/ext/isomorfeus_ferret_ext/test_q_filtered.c +5 -3
- data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +13 -10
- data/ext/isomorfeus_ferret_ext/test_q_parser.c +45 -7
- data/ext/isomorfeus_ferret_ext/test_q_span.c +15 -12
- data/ext/isomorfeus_ferret_ext/test_ram_store.c +3 -3
- data/ext/isomorfeus_ferret_ext/test_search.c +60 -64
- data/ext/isomorfeus_ferret_ext/test_segments.c +5 -4
- data/ext/isomorfeus_ferret_ext/test_sort.c +17 -14
- data/ext/isomorfeus_ferret_ext/test_store.c +2 -0
- data/ext/isomorfeus_ferret_ext/test_term.c +3 -1
- data/ext/isomorfeus_ferret_ext/test_term_vectors.c +9 -10
- data/ext/isomorfeus_ferret_ext/test_test.c +1 -2
- data/ext/isomorfeus_ferret_ext/test_threading.c +9 -10
- data/ext/isomorfeus_ferret_ext/testhelper.c +1 -2
- data/lib/isomorfeus/ferret/version.rb +1 -1
- metadata +27 -57
- data/ext/isomorfeus_ferret_ext/email.rl +0 -21
- data/ext/isomorfeus_ferret_ext/frt_scanner.c +0 -900
- data/ext/isomorfeus_ferret_ext/frt_scanner.h +0 -28
- data/ext/isomorfeus_ferret_ext/frt_scanner_mb.c +0 -6706
- data/ext/isomorfeus_ferret_ext/frt_scanner_utf8.c +0 -4420
- data/ext/isomorfeus_ferret_ext/scanner.h +0 -28
- data/ext/isomorfeus_ferret_ext/scanner.in +0 -43
- data/ext/isomorfeus_ferret_ext/scanner.rl +0 -84
- data/ext/isomorfeus_ferret_ext/scanner_mb.rl +0 -200
- data/ext/isomorfeus_ferret_ext/scanner_utf8.rl +0 -85
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_basque.c +0 -1167
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_basque.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_catalan.c +0 -1433
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_catalan.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_danish.c +0 -301
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_danish.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_dutch.c +0 -590
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_dutch.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_english.c +0 -1049
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_english.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_finnish.c +0 -705
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_finnish.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_french.c +0 -1239
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_french.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_german.c +0 -477
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_german.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_hungarian.c +0 -1217
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_hungarian.h +0 -7
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_indonesian.c +0 -394
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_indonesian.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_irish.c +0 -457
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_irish.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_italian.c +0 -1009
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_italian.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_norwegian.c +0 -259
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_norwegian.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_porter.c +0 -704
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_porter.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_portuguese.c +0 -948
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_portuguese.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_spanish.c +0 -1028
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_spanish.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_swedish.c +0 -275
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_swedish.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_hungarian.c +0 -849
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_hungarian.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_romanian.c +0 -952
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_romanian.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_KOI8_R_russian.c +0 -669
- data/ext/isomorfeus_ferret_ext/stem_KOI8_R_russian.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_modules.txt +0 -63
- data/ext/isomorfeus_ferret_ext/uchar-ucs4.rl +0 -1854
- data/ext/isomorfeus_ferret_ext/uchar-utf8.rl +0 -1999
- data/ext/isomorfeus_ferret_ext/url.rl +0 -27
@@ -150,6 +150,7 @@ struct FrtLock
|
|
150
150
|
int (*obtain)(FrtLock *lock);
|
151
151
|
int (*is_locked)(FrtLock *lock);
|
152
152
|
void (*release)(FrtLock *lock);
|
153
|
+
VALUE rlock;
|
153
154
|
};
|
154
155
|
|
155
156
|
typedef struct FrtCompoundStore
|
@@ -320,6 +321,11 @@ struct FrtStore
|
|
320
321
|
* @param store self
|
321
322
|
*/
|
322
323
|
void (*close_i)(FrtStore *store);
|
324
|
+
|
325
|
+
/**
|
326
|
+
* Reference to be used within ruby realm.
|
327
|
+
*/
|
328
|
+
VALUE rstore;
|
323
329
|
};
|
324
330
|
|
325
331
|
/**
|
@@ -336,7 +342,7 @@ extern FrtStore *frt_open_fs_store(const char *pathname);
|
|
336
342
|
*
|
337
343
|
* @return a newly allocated RAM FrtStore.
|
338
344
|
*/
|
339
|
-
extern FrtStore *frt_open_ram_store();
|
345
|
+
extern FrtStore *frt_open_ram_store(FrtStore *new_store);
|
340
346
|
|
341
347
|
/**
|
342
348
|
* Create a newly allocated in-memory or RAM FrtStore. Copy the contents of
|
@@ -349,7 +355,7 @@ extern FrtStore *frt_open_ram_store();
|
|
349
355
|
* @param close_store close the store whose contents where copied
|
350
356
|
* @return a newly allocated RAM FrtStore.
|
351
357
|
*/
|
352
|
-
extern FrtStore *frt_open_ram_store_and_copy(FrtStore *store, bool close_store);
|
358
|
+
extern FrtStore *frt_open_ram_store_and_copy(FrtStore *store, FrtStore *from_store, bool close_store);
|
353
359
|
|
354
360
|
/**
|
355
361
|
* Open a compound store. This is basically store which is stored within a
|
@@ -779,6 +785,8 @@ extern void frt_close_lock(FrtLock *lock);
|
|
779
785
|
|
780
786
|
/* required by submodules
|
781
787
|
* FIXME document. Perhaps include in different header?? */
|
788
|
+
extern FrtStore *frt_store_alloc();
|
789
|
+
extern FrtStore *frt_store_init(FrtStore *store);
|
782
790
|
extern FrtStore *frt_store_new();
|
783
791
|
extern void frt_store_destroy(FrtStore *store);
|
784
792
|
extern FrtOutStream *frt_os_new();
|
@@ -17,7 +17,6 @@ typedef pthread_once_t frt_thread_once_t;
|
|
17
17
|
#define frt_thread_key_delete(a) pthread_key_delete(a)
|
18
18
|
#define frt_thread_setspecific(a, b) pthread_setspecific(a, b)
|
19
19
|
#define frt_thread_getspecific(a) pthread_getspecific(a)
|
20
|
-
#define frt_thread_exit(a) pthread_exit(a)
|
21
20
|
#define frt_thread_once(a, b) pthread_once(a, b)
|
22
21
|
|
23
22
|
#endif
|
@@ -7,10 +7,6 @@
|
|
7
7
|
#include "frb_threading.h"
|
8
8
|
#include "frb_lang.h"
|
9
9
|
|
10
|
-
|
11
|
-
/* Object Map */
|
12
|
-
static FrtHash *object_map;
|
13
|
-
|
14
10
|
/* IDs */
|
15
11
|
ID id_new;
|
16
12
|
ID id_call;
|
@@ -50,104 +46,44 @@ VALUE cStateError;
|
|
50
46
|
void Init_Benchmark(void);
|
51
47
|
void Init_Test(void);
|
52
48
|
|
53
|
-
unsigned long long value_hash(const void *key)
|
54
|
-
{
|
49
|
+
unsigned long long value_hash(const void *key) {
|
55
50
|
return (unsigned long long)key;
|
56
51
|
}
|
57
52
|
|
58
|
-
int value_eq(const void *key1, const void *key2)
|
59
|
-
{
|
53
|
+
int value_eq(const void *key1, const void *key2) {
|
60
54
|
return key1 == key2;
|
61
55
|
}
|
62
56
|
|
63
|
-
|
64
|
-
{
|
65
|
-
VALUE val = (VALUE)frt_h_get(object_map, key);
|
66
|
-
if (!val) val = Qnil;
|
67
|
-
return val;
|
68
|
-
}
|
69
|
-
|
70
|
-
//static int hash_cnt = 0;
|
71
|
-
void
|
72
|
-
//object_add(void *key, VALUE obj)
|
73
|
-
object_add2(void *key, VALUE obj, const char *file, int line)
|
74
|
-
{
|
75
|
-
if (frt_h_get(object_map, key))
|
76
|
-
printf("failed adding %lx to %lld; already contains %llx. %s:%d\n",
|
77
|
-
(long)obj, (long long)key, (long long)frt_h_get(object_map, key), file, line);
|
78
|
-
frt_h_set(object_map, key, (void *)obj);
|
79
|
-
}
|
80
|
-
|
81
|
-
void
|
82
|
-
//object_set(void *key, VALUE obj)
|
83
|
-
object_set2(void *key, VALUE obj, const char *file, int line)
|
84
|
-
{
|
85
|
-
frt_h_set(object_map, key, (void *)obj);
|
86
|
-
}
|
87
|
-
|
88
|
-
void
|
89
|
-
//object_del(void *key)
|
90
|
-
object_del2(void *key, const char *file, int line)
|
91
|
-
{
|
92
|
-
if (object_get(key) == Qnil)
|
93
|
-
printf("failed deleting %lld. %s:%d\n", (long long)key, file, line);
|
94
|
-
frt_h_del(object_map, key);
|
95
|
-
}
|
96
|
-
|
97
|
-
void frb_gc_mark(void *key)
|
98
|
-
{
|
99
|
-
VALUE val = (VALUE)frt_h_get(object_map, key);
|
100
|
-
if (val)
|
101
|
-
rb_gc_mark(val);
|
102
|
-
}
|
103
|
-
|
104
|
-
VALUE frb_data_alloc(VALUE klass)
|
105
|
-
{
|
106
|
-
return Frt_Make_Struct(klass);
|
107
|
-
}
|
108
|
-
|
109
|
-
void frb_deref_free(void *p)
|
110
|
-
{
|
111
|
-
object_del(p);
|
112
|
-
}
|
113
|
-
|
114
|
-
void frb_thread_once(int *once_control, void (*init_routine) (void))
|
115
|
-
{
|
57
|
+
void frb_thread_once(int *once_control, void (*init_routine) (void)) {
|
116
58
|
if (*once_control) {
|
117
59
|
init_routine();
|
118
60
|
*once_control = 0;
|
119
61
|
}
|
120
62
|
}
|
121
63
|
|
122
|
-
void frb_thread_key_create(frt_thread_key_t *key, void (*destr_function)(void *))
|
123
|
-
{
|
64
|
+
void frb_thread_key_create(frt_thread_key_t *key, void (*destr_function)(void *)) {
|
124
65
|
*key = frt_h_new(&value_hash, &value_eq, NULL, destr_function);
|
125
66
|
}
|
126
67
|
|
127
|
-
void frb_thread_key_delete(frt_thread_key_t key)
|
128
|
-
{
|
68
|
+
void frb_thread_key_delete(frt_thread_key_t key) {
|
129
69
|
frt_h_destroy(key);
|
130
70
|
}
|
131
71
|
|
132
|
-
void frb_thread_setspecific(frt_thread_key_t key, const void *pointer)
|
133
|
-
{
|
72
|
+
void frb_thread_setspecific(frt_thread_key_t key, const void *pointer) {
|
134
73
|
frt_h_set(key, (void *)rb_thread_current(), (void *)pointer);
|
135
74
|
}
|
136
75
|
|
137
|
-
void *frb_thread_getspecific(frt_thread_key_t key)
|
138
|
-
{
|
76
|
+
void *frb_thread_getspecific(frt_thread_key_t key) {
|
139
77
|
return frt_h_get(key, (void *)rb_thread_current());
|
140
78
|
}
|
141
79
|
|
142
|
-
void frb_create_dir(VALUE rpath)
|
143
|
-
{
|
80
|
+
void frb_create_dir(VALUE rpath) {
|
144
81
|
VALUE mFileUtils;
|
145
82
|
mFileUtils = rb_define_module("FileUtils");
|
146
83
|
rb_funcall(mFileUtils, id_mkdir_p, 1, rpath);
|
147
84
|
}
|
148
85
|
|
149
|
-
VALUE frb_hs_to_rb_ary(FrtHashSet *hs)
|
150
|
-
{
|
86
|
+
VALUE frb_hs_to_rb_ary(FrtHashSet *hs) {
|
151
87
|
FrtHashSetEntry *hse;
|
152
88
|
VALUE ary = rb_ary_new();
|
153
89
|
|
@@ -157,31 +93,21 @@ VALUE frb_hs_to_rb_ary(FrtHashSet *hs)
|
|
157
93
|
return ary;
|
158
94
|
}
|
159
95
|
|
160
|
-
void *frb_rb_data_ptr(VALUE val)
|
161
|
-
{
|
96
|
+
void *frb_rb_data_ptr(VALUE val) {
|
162
97
|
Check_Type(val, T_DATA);
|
163
98
|
return DATA_PTR(val);
|
164
99
|
}
|
165
100
|
|
166
|
-
char *
|
167
|
-
rs2s(VALUE rstr)
|
168
|
-
{
|
101
|
+
char *rs2s(VALUE rstr) {
|
169
102
|
return (char *)(RSTRING_PTR(rstr) ? RSTRING_PTR(rstr) : FRT_EMPTY_STRING);
|
170
103
|
}
|
171
104
|
|
172
|
-
char *
|
173
|
-
rstrdup(VALUE rstr)
|
174
|
-
{
|
105
|
+
char *rstrdup(VALUE rstr) {
|
175
106
|
char *old = rs2s(rstr);
|
176
|
-
//int len = RSTRING_LEN(rstr);
|
177
|
-
//char *new = FRT_ALLOC_N(char, len + 1);
|
178
|
-
//memcpy(new, old, len);
|
179
107
|
return frt_estrdup(old);
|
180
108
|
}
|
181
109
|
|
182
|
-
|
183
|
-
frb_field(VALUE rfield)
|
184
|
-
{
|
110
|
+
ID frb_field(VALUE rfield) {
|
185
111
|
switch (TYPE(rfield)) {
|
186
112
|
case T_SYMBOL:
|
187
113
|
return rb_to_id(rfield);
|
@@ -200,9 +126,7 @@ frb_field(VALUE rfield)
|
|
200
126
|
* Jeremie 'ahFeel' BORDIER
|
201
127
|
* ahFeel@rift.Fr
|
202
128
|
*/
|
203
|
-
char *
|
204
|
-
json_concat_string(char *s, char *field)
|
205
|
-
{
|
129
|
+
char *json_concat_string(char *s, char *field) {
|
206
130
|
*(s++) = '"';
|
207
131
|
while (*field) {
|
208
132
|
if (*field == '"') {
|
@@ -220,8 +144,7 @@ json_concat_string(char *s, char *field)
|
|
220
144
|
|
221
145
|
static VALUE error_map;
|
222
146
|
|
223
|
-
VALUE frb_get_error(const char *err_type)
|
224
|
-
{
|
147
|
+
VALUE frb_get_error(const char *err_type) {
|
225
148
|
VALUE error_class;
|
226
149
|
if (Qnil != (error_class = rb_hash_aref(error_map, rb_intern(err_type)))) {
|
227
150
|
return error_class;
|
@@ -283,16 +206,11 @@ void FRT_EXIT(const char *err_type, const char *fmt, ...)
|
|
283
206
|
static ID id_field;
|
284
207
|
static ID id_text;
|
285
208
|
|
286
|
-
VALUE frb_get_term(
|
287
|
-
|
288
|
-
return rb_struct_new(cTerm,
|
289
|
-
ID2SYM(field),
|
290
|
-
rb_str_new_cstr(text),
|
291
|
-
NULL);
|
209
|
+
VALUE frb_get_term(ID field, const char *text) {
|
210
|
+
return rb_struct_new(cTerm, ID2SYM(field), rb_str_new_cstr(text), NULL);
|
292
211
|
}
|
293
212
|
|
294
|
-
static VALUE frb_term_to_s(VALUE self)
|
295
|
-
{
|
213
|
+
static VALUE frb_term_to_s(VALUE self) {
|
296
214
|
VALUE rstr;
|
297
215
|
VALUE rfield = rb_funcall(self, id_field, 0);
|
298
216
|
VALUE rtext = rb_funcall(self, id_text, 0);
|
@@ -311,8 +229,7 @@ static VALUE frb_term_to_s(VALUE self)
|
|
311
229
|
*
|
312
230
|
* A Term holds a term from a document and its field name (as a Symbol).
|
313
231
|
*/
|
314
|
-
void Init_Term(void)
|
315
|
-
{
|
232
|
+
void Init_Term(void) {
|
316
233
|
const char *term_class = "Term";
|
317
234
|
cTerm = rb_struct_define(term_class, "field", "text", NULL);
|
318
235
|
rb_set_class_path(cTerm, mFerret, term_class);
|
@@ -327,20 +244,13 @@ void Init_Term(void)
|
|
327
244
|
*
|
328
245
|
* See the README
|
329
246
|
*/
|
330
|
-
void Init_Ferret(void)
|
331
|
-
{
|
247
|
+
void Init_Ferret(void) {
|
332
248
|
Init_Term();
|
333
249
|
rb_require("fileutils");
|
334
250
|
}
|
335
251
|
|
336
|
-
void Init_isomorfeus_ferret_ext(void)
|
337
|
-
|
338
|
-
const char *const progname[] = {"ruby"};
|
339
|
-
|
340
|
-
frt_init(1, progname);
|
341
|
-
|
342
|
-
/* initialize object map */
|
343
|
-
object_map = frt_h_new(&value_hash, &value_eq, NULL, NULL);
|
252
|
+
void Init_isomorfeus_ferret_ext(void) {
|
253
|
+
frt_init(0, NULL);
|
344
254
|
|
345
255
|
/* IDs */
|
346
256
|
id_new = rb_intern("new");
|
@@ -50,45 +50,15 @@ extern void Init_Search();
|
|
50
50
|
extern void Init_QueryParser();
|
51
51
|
|
52
52
|
extern void frb_raise(int excode, const char *msg);
|
53
|
-
//extern void object_add(void *key, VALUE obj);
|
54
|
-
#define object_add(key, obj) object_add2(key, obj, __FILE__, __LINE__)
|
55
|
-
extern void object_add2(void *key, VALUE obj, const char *file, int line);
|
56
|
-
//extern void object_set(void *key, VALUE obj);
|
57
|
-
#define object_set(key, obj) object_set2(key, obj, __FILE__, __LINE__)
|
58
|
-
extern void object_set2(void *key, VALUE obj, const char *file, int line);
|
59
|
-
//extern void object_del(void *key);
|
60
|
-
#define object_del(key) object_del2(key, __FILE__, __LINE__)
|
61
|
-
extern void object_del2(void *key, const char *file, int line);
|
62
|
-
extern void frb_gc_mark(void *key);
|
63
|
-
extern VALUE object_get(void *key);
|
64
|
-
extern VALUE frb_data_alloc(VALUE klass);
|
65
|
-
extern void frb_deref_free(void *p);
|
66
53
|
extern void frb_create_dir(VALUE rpath);
|
67
54
|
extern VALUE frb_hs_to_rb_ary(FrtHashSet *hs);
|
68
55
|
extern void *frb_rb_data_ptr(VALUE val);
|
69
|
-
extern
|
70
|
-
extern VALUE frb_get_term(
|
56
|
+
extern ID frb_field(VALUE rfield);
|
57
|
+
extern VALUE frb_get_term(ID field, const char *term);
|
71
58
|
extern char *json_concat_string(char *s, char *field);
|
72
59
|
extern char *rs2s(VALUE rstr);
|
73
60
|
extern char *rstrdup(VALUE rstr);
|
74
61
|
|
75
|
-
#define Frt_Make_Struct(klass)\
|
76
|
-
rb_data_object_wrap(klass,NULL,(RUBY_DATA_FUNC)NULL,(RUBY_DATA_FUNC)NULL)
|
77
|
-
|
78
|
-
#define Frt_Wrap_Struct(self,mmark,mfree,mdata)\
|
79
|
-
do {\
|
80
|
-
((struct RData *)(self))->data = mdata;\
|
81
|
-
((struct RData *)(self))->dmark = (RUBY_DATA_FUNC)mmark;\
|
82
|
-
((struct RData *)(self))->dfree = (RUBY_DATA_FUNC)mfree;\
|
83
|
-
} while (0)
|
84
|
-
|
85
|
-
#define Frt_Unwrap_Struct(self)\
|
86
|
-
do {\
|
87
|
-
((struct RData *)(self))->data = NULL;\
|
88
|
-
((struct RData *)(self))->dmark = NULL;\
|
89
|
-
((struct RData *)(self))->dfree = NULL;\
|
90
|
-
} while (0)
|
91
|
-
|
92
62
|
#endif
|
93
63
|
|
94
64
|
#define frb_mark_cclass(klass) rb_ivar_set(klass, id_cclass, Qtrue)
|