isomorfeus-ferret 0.17.2 → 0.17.3
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/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
@@ -24,11 +24,10 @@ static void with_lock_test(void *p) {
|
|
24
24
|
Assert(l->lock->is_locked(l->lock), "lock should be locked");
|
25
25
|
}
|
26
26
|
|
27
|
-
static void with_lock_name_test(void *p)
|
28
|
-
{
|
27
|
+
static void with_lock_name_test(void *p) {
|
29
28
|
WithLockNameTestArg *l = (WithLockNameTestArg *)p;
|
30
29
|
TestCase *tc = l->tc;
|
31
|
-
FrtLock *lock = frt_open_lock(l->store, l->lock_name);
|
30
|
+
FrtLock *lock = frt_open_lock(l->store, segm_idx_name, l->lock_name);
|
32
31
|
Assert(lock->is_locked(lock), "lock should be locked");
|
33
32
|
frt_close_lock(lock);
|
34
33
|
}
|
@@ -36,22 +35,21 @@ static void with_lock_name_test(void *p)
|
|
36
35
|
/**
|
37
36
|
* Test that the lock is created and deleted correctly
|
38
37
|
*/
|
39
|
-
static void test_lock(TestCase *tc, void *data)
|
40
|
-
{
|
38
|
+
static void test_lock(TestCase *tc, void *data) {
|
41
39
|
FrtStore *store = (FrtStore *)data;
|
42
40
|
FrtLock *lock, *lock1, *lock2;
|
43
41
|
bool handled;
|
44
42
|
WithLockTestArg wlta;
|
45
43
|
WithLockNameTestArg wlnta;
|
46
44
|
|
47
|
-
lock1 = frt_open_lock(store, TEST_LOCK_NAME);
|
45
|
+
lock1 = frt_open_lock(store, segm_idx_name, TEST_LOCK_NAME);
|
48
46
|
Aiequal(false, lock1->is_locked(lock1));
|
49
47
|
Aiequal(true, lock1->obtain(lock1));
|
50
48
|
Aiequal(true, lock1->is_locked(lock1));
|
51
49
|
lock1->release(lock1);
|
52
50
|
Aiequal(false, lock1->is_locked(lock1));
|
53
51
|
Aiequal(true, lock1->obtain(lock1));
|
54
|
-
lock2 = frt_open_lock(store, TEST_LOCK_NAME);
|
52
|
+
lock2 = frt_open_lock(store, segm_idx_name, TEST_LOCK_NAME);
|
55
53
|
Aiequal(true, lock2->is_locked(lock2));
|
56
54
|
lock1->release(lock1);
|
57
55
|
Aiequal(false, lock2->is_locked(lock2));
|
@@ -59,7 +57,7 @@ static void test_lock(TestCase *tc, void *data)
|
|
59
57
|
frt_close_lock(lock2);
|
60
58
|
|
61
59
|
/* test with_lock */
|
62
|
-
lock = frt_open_lock(store, TEST_LOCK_NAME);
|
60
|
+
lock = frt_open_lock(store, segm_idx_name, TEST_LOCK_NAME);
|
63
61
|
Assert(!lock->is_locked(lock), "lock shouldn't be locked yet");
|
64
62
|
wlta.lock = lock; wlta.tc = tc;
|
65
63
|
frt_with_lock(lock, &with_lock_test, &wlta);
|
@@ -85,15 +83,15 @@ static void test_lock(TestCase *tc, void *data)
|
|
85
83
|
frt_close_lock(lock);
|
86
84
|
|
87
85
|
/* test with_lock_name */
|
88
|
-
lock = frt_open_lock(store, TEST_LOCK_NAME);
|
86
|
+
lock = frt_open_lock(store, segm_idx_name, TEST_LOCK_NAME);
|
89
87
|
Assert(!lock->is_locked(lock), "lock shouldn't be locked yet");
|
90
88
|
wlnta.lock_name = TEST_LOCK_NAME; wlnta.tc = tc; wlnta.store = store;
|
91
|
-
frt_with_lock_name(store, TEST_LOCK_NAME, &with_lock_name_test, &wlnta);
|
89
|
+
frt_with_lock_name(store, segm_idx_name, TEST_LOCK_NAME, &with_lock_name_test, &wlnta);
|
92
90
|
Assert(!lock->is_locked(lock), "lock should be unlocked again");
|
93
91
|
Assert(lock->obtain(lock), "lock should be obtainable");
|
94
92
|
handled = false;
|
95
93
|
FRT_TRY
|
96
|
-
frt_with_lock_name(store, TEST_LOCK_NAME, &with_lock_name_test, &wlnta);
|
94
|
+
frt_with_lock_name(store, segm_idx_name, TEST_LOCK_NAME, &with_lock_name_test, &wlnta);
|
97
95
|
Assert(false, "A locking exception should have been raised");
|
98
96
|
break;
|
99
97
|
case FRT_LOCK_ERROR:
|
@@ -117,32 +115,31 @@ static void test_lock(TestCase *tc, void *data)
|
|
117
115
|
static void test_basic_file_ops(TestCase *tc, void *data) {
|
118
116
|
FrtStore *store = (FrtStore *)data;
|
119
117
|
|
120
|
-
store->clear_all(store); /* Make sure the test directory is empty. */
|
121
|
-
Assert(!store->exists(store, "_1.f1"), "File1 should not been created yet");
|
122
|
-
store->touch(store, "_1.f1");
|
123
|
-
Aiequal(1, store->count(store));
|
124
|
-
Assert(store->count(store) == 1, "The store now contains one file");
|
125
|
-
Assert(store->exists(store, "_1.f1"), "File1 should now been created");
|
126
|
-
store->touch(store, "_1.f2");
|
127
|
-
Assert(store->count(store) == 2, "The store now contains two files");
|
128
|
-
Assert(store->exists(store, "_1.f2"), "File2 should now been created");
|
129
|
-
store->remove(store, "_1.f1");
|
130
|
-
Assert(store->count(store) == 1, "The store now contains one file");
|
131
|
-
Assert(!store->exists(store, "_1.f1"), "File1 should have been removed");
|
132
|
-
Assert(store->exists(store, "_1.f2"), "File2 should still exist");
|
118
|
+
store->clear_all(store, segm_idx_name); /* Make sure the test directory is empty. */
|
119
|
+
Assert(!store->exists(store, segm_idx_name, "_1.f1"), "File1 should not been created yet");
|
120
|
+
store->touch(store, segm_idx_name, "_1.f1");
|
121
|
+
Aiequal(1, store->count(store, segm_idx_name));
|
122
|
+
Assert(store->count(store, segm_idx_name) == 1, "The store now contains one file");
|
123
|
+
Assert(store->exists(store, segm_idx_name, "_1.f1"), "File1 should now been created");
|
124
|
+
store->touch(store, segm_idx_name, "_1.f2");
|
125
|
+
Assert(store->count(store, segm_idx_name) == 2, "The store now contains two files");
|
126
|
+
Assert(store->exists(store, segm_idx_name, "_1.f2"), "File2 should now been created");
|
127
|
+
store->remove(store, segm_idx_name, "_1.f1");
|
128
|
+
Assert(store->count(store, segm_idx_name) == 1, "The store now contains one file");
|
129
|
+
Assert(!store->exists(store, segm_idx_name, "_1.f1"), "File1 should have been removed");
|
130
|
+
Assert(store->exists(store, segm_idx_name, "_1.f2"), "File2 should still exist");
|
133
131
|
|
134
132
|
/* test that lock files get deleted by clear_all */
|
135
|
-
store->touch(store, "ferret-write.lck");
|
136
|
-
Assert(store->exists(store, "ferret-write.lck"),"lock should still exist");
|
137
|
-
store->clear_all(store);
|
138
|
-
Assert(!store->exists(store, "ferret-write.lck"), "lock should be deleted");
|
133
|
+
store->touch(store, segm_idx_name, "ferret-write.lck");
|
134
|
+
Assert(store->exists(store, segm_idx_name, "ferret-write.lck"),"lock should still exist");
|
135
|
+
store->clear_all(store, segm_idx_name);
|
136
|
+
Assert(!store->exists(store, segm_idx_name, "ferret-write.lck"), "lock should be deleted");
|
139
137
|
}
|
140
138
|
|
141
139
|
/**
|
142
140
|
* Test argument used to test the store->each function
|
143
141
|
*/
|
144
|
-
struct EachArg
|
145
|
-
{
|
142
|
+
struct EachArg {
|
146
143
|
char str[100];
|
147
144
|
char *p;
|
148
145
|
};
|
@@ -150,8 +147,7 @@ struct EachArg
|
|
150
147
|
/**
|
151
148
|
* Test function used to test store->each function
|
152
149
|
*/
|
153
|
-
static void concat_filenames(const char *fname, struct EachArg *ea)
|
154
|
-
{
|
150
|
+
static void concat_filenames(const char *fname, struct EachArg *ea) {
|
155
151
|
strcpy(ea->p, fname);
|
156
152
|
ea->p += strlen(fname);
|
157
153
|
}
|
@@ -159,19 +155,18 @@ static void concat_filenames(const char *fname, struct EachArg *ea)
|
|
159
155
|
/**
|
160
156
|
* Test the store->each function
|
161
157
|
*/
|
162
|
-
static void test_each(TestCase *tc, void *data)
|
163
|
-
{
|
158
|
+
static void test_each(TestCase *tc, void *data) {
|
164
159
|
FrtStore *store = (FrtStore *)data;
|
165
160
|
|
166
161
|
struct EachArg ea;
|
167
162
|
ea.p = ea.str;
|
168
163
|
|
169
|
-
store->clear_all(store); /* Make sure the test directory is empty. */
|
170
|
-
store->touch(store, "_1.f1");
|
171
|
-
store->touch(store, "_1.f2");
|
172
|
-
store->touch(store, "_1.f3");
|
173
|
-
store->touch(store, "_1.f4");
|
174
|
-
store->each(store, (void(*)(const char *fname, void *arg))&concat_filenames, &ea);
|
164
|
+
store->clear_all(store, segm_idx_name); /* Make sure the test directory is empty. */
|
165
|
+
store->touch(store, segm_idx_name, "_1.f1");
|
166
|
+
store->touch(store, segm_idx_name, "_1.f2");
|
167
|
+
store->touch(store, segm_idx_name, "_1.f3");
|
168
|
+
store->touch(store, segm_idx_name, "_1.f4");
|
169
|
+
store->each(store, segm_idx_name, (void(*)(const char *fname, void *arg))&concat_filenames, &ea);
|
175
170
|
*(ea.p) = 0;
|
176
171
|
Assert(strstr(ea.str, "_1.f1") != NULL, "should contain this file");
|
177
172
|
Assert(strstr(ea.str, "_1.f2") != NULL, "should contain this file");
|
@@ -183,54 +178,52 @@ static void test_each(TestCase *tc, void *data)
|
|
183
178
|
/**
|
184
179
|
* Test the store->rename function
|
185
180
|
*/
|
186
|
-
static void test_rename(TestCase *tc, void *data)
|
187
|
-
{
|
181
|
+
static void test_rename(TestCase *tc, void *data) {
|
188
182
|
int cnt_before, cnt_after;
|
189
183
|
FrtStore *store = (FrtStore *)data;
|
190
|
-
store->touch(store, "_from.f1");
|
191
|
-
Assert(store->exists(store, "_from.f1"), "File should exist");
|
192
|
-
Assert(!store->exists(store, "_to.f1"), "File should not exist");
|
193
|
-
cnt_before = store->count(store);
|
194
|
-
store->rename(store, "_from.f1", "_to.f1");
|
195
|
-
cnt_after = store->count(store);
|
184
|
+
store->touch(store, segm_idx_name, "_from.f1");
|
185
|
+
Assert(store->exists(store, segm_idx_name, "_from.f1"), "File should exist");
|
186
|
+
Assert(!store->exists(store, segm_idx_name, "_to.f1"), "File should not exist");
|
187
|
+
cnt_before = store->count(store, segm_idx_name);
|
188
|
+
store->rename(store, segm_idx_name, "_from.f1", "_to.f1");
|
189
|
+
cnt_after = store->count(store, segm_idx_name);
|
196
190
|
Aiequal(cnt_before, cnt_after);
|
197
|
-
Assert(store->exists(store, "_to.f1"), "File should now exist");
|
198
|
-
Assert(!store->exists(store, "_from.f1"), "File should no longer exist");
|
191
|
+
Assert(store->exists(store, segm_idx_name, "_to.f1"), "File should now exist");
|
192
|
+
Assert(!store->exists(store, segm_idx_name, "_from.f1"), "File should no longer exist");
|
199
193
|
}
|
200
194
|
|
201
195
|
/**
|
202
196
|
* Test the reading and writing of bytes (8 bit)
|
203
197
|
*/
|
204
|
-
static void test_rw_bytes(TestCase *tc, void *data)
|
205
|
-
{
|
198
|
+
static void test_rw_bytes(TestCase *tc, void *data) {
|
206
199
|
int i;
|
207
200
|
FrtStore *store = (FrtStore *)data;
|
208
201
|
frt_uchar bytes[6] = { 0x34, 0x87, 0xF9, 0xEA, 0x00, 0xFF };
|
209
|
-
FrtOutStream *ostream = store->new_output(store, "_rw_byte.
|
202
|
+
FrtOutStream *ostream = store->new_output(store, segm_idx_name, "_rw_byte.fdt");
|
210
203
|
FrtInStream *istream;
|
211
|
-
|
204
|
+
|
212
205
|
for (i = 0; i < 6; i++) {
|
213
206
|
frt_os_write_byte(ostream, bytes[i]);
|
214
207
|
}
|
215
208
|
frt_os_close(ostream);
|
209
|
+
Assert(store->exists(store, segm_idx_name, "_rw_byte.fdt"), "File should now exist");
|
216
210
|
|
217
|
-
istream = store->open_input(store, "_rw_byte.
|
211
|
+
istream = store->open_input(store, segm_idx_name, "_rw_byte.fdt");
|
218
212
|
for (i = 0; i < 6; i++) {
|
219
213
|
Aiequal(bytes[i], frt_is_read_byte(istream));
|
220
214
|
}
|
221
215
|
frt_is_close(istream);
|
222
|
-
Aiequal(6, store->length(store, "_rw_byte.
|
223
|
-
Assert(store->exists(store, "_rw_byte.
|
216
|
+
Aiequal(6, store->length(store, segm_idx_name, "_rw_byte.fdt"));
|
217
|
+
Assert(store->exists(store, segm_idx_name, "_rw_byte.fdt"), "File should now exist");
|
224
218
|
}
|
225
219
|
|
226
220
|
/**
|
227
221
|
* Test the reading and writing of 32-bit integers
|
228
222
|
*/
|
229
|
-
static void test_rw_i32(TestCase *tc, void *data)
|
230
|
-
{
|
223
|
+
static void test_rw_i32(TestCase *tc, void *data) {
|
231
224
|
int i;
|
232
225
|
FrtStore *store = (FrtStore *)data;
|
233
|
-
FrtOutStream *ostream = store->new_output(store, "_rw_int.
|
226
|
+
FrtOutStream *ostream = store->new_output(store, segm_idx_name, "_rw_int.fdt");
|
234
227
|
FrtInStream *istream;
|
235
228
|
frt_i32 ints[4] = { POSH_I32_MAX, POSH_I32_MIN, -1, 0 };
|
236
229
|
|
@@ -239,25 +232,24 @@ static void test_rw_i32(TestCase *tc, void *data)
|
|
239
232
|
}
|
240
233
|
frt_os_close(ostream);
|
241
234
|
|
242
|
-
istream = store->open_input(store, "_rw_int.
|
235
|
+
istream = store->open_input(store, segm_idx_name, "_rw_int.fdt");
|
243
236
|
for (i = 0; i < 4; i++) {
|
244
237
|
Aiequal(ints[i], frt_is_read_i32(istream));
|
245
238
|
}
|
246
239
|
|
247
240
|
frt_is_close(istream);
|
248
|
-
Aiequal(16, store->length(store, "_rw_int.
|
241
|
+
Aiequal(16, store->length(store, segm_idx_name, "_rw_int.fdt"));
|
249
242
|
}
|
250
243
|
|
251
244
|
/**
|
252
245
|
* Test the reading and writing of 64-bit integers
|
253
246
|
*/
|
254
|
-
static void test_rw_i64(TestCase *tc, void *data)
|
255
|
-
{
|
247
|
+
static void test_rw_i64(TestCase *tc, void *data) {
|
256
248
|
int i;
|
257
249
|
FrtStore *store = (FrtStore *)data;
|
258
250
|
frt_u64 longs[4] =
|
259
251
|
{ POSH_I64_MIN, POSH_I64_MAX, POSH_I64(-1), POSH_I64(0) };
|
260
|
-
FrtOutStream *ostream = store->new_output(store, "_rw_long.
|
252
|
+
FrtOutStream *ostream = store->new_output(store, segm_idx_name, "_rw_long.fdt");
|
261
253
|
FrtInStream *istream;
|
262
254
|
|
263
255
|
for (i = 0; i < 4; i++) {
|
@@ -265,23 +257,22 @@ static void test_rw_i64(TestCase *tc, void *data)
|
|
265
257
|
}
|
266
258
|
frt_os_close(ostream);
|
267
259
|
|
268
|
-
istream = store->open_input(store, "_rw_long.
|
260
|
+
istream = store->open_input(store, segm_idx_name, "_rw_long.fdt");
|
269
261
|
for (i = 0; i < 4; i++) {
|
270
262
|
Aiequal(longs[i], frt_is_read_i64(istream));
|
271
263
|
}
|
272
264
|
frt_is_close(istream);
|
273
|
-
Aiequal(32, store->length(store, "_rw_long.
|
265
|
+
Aiequal(32, store->length(store, segm_idx_name, "_rw_long.fdt"));
|
274
266
|
}
|
275
267
|
|
276
268
|
/**
|
277
269
|
* Test the reading and writing of 32-bit unsigned integers
|
278
270
|
*/
|
279
|
-
static void test_rw_u32(TestCase *tc, void *data)
|
280
|
-
{
|
271
|
+
static void test_rw_u32(TestCase *tc, void *data) {
|
281
272
|
int i;
|
282
273
|
FrtStore *store = (FrtStore *)data;
|
283
274
|
frt_u32 uints[4] = { POSH_U32_MAX, POSH_U32_MIN, 100000, 1 };
|
284
|
-
FrtOutStream *ostream = store->new_output(store, "_rw_uint.
|
275
|
+
FrtOutStream *ostream = store->new_output(store, segm_idx_name, "_rw_uint.fdt");
|
285
276
|
FrtInStream *istream;
|
286
277
|
|
287
278
|
for (i = 0; i < 4; i++) {
|
@@ -289,24 +280,23 @@ static void test_rw_u32(TestCase *tc, void *data)
|
|
289
280
|
}
|
290
281
|
frt_os_close(ostream);
|
291
282
|
|
292
|
-
istream = store->open_input(store, "_rw_uint.
|
283
|
+
istream = store->open_input(store, segm_idx_name, "_rw_uint.fdt");
|
293
284
|
for (i = 0; i < 4; i++) {
|
294
285
|
Aiequal(uints[i], frt_is_read_u32(istream));
|
295
286
|
}
|
296
287
|
frt_is_close(istream);
|
297
|
-
Aiequal(16, store->length(store, "_rw_uint.
|
288
|
+
Aiequal(16, store->length(store, segm_idx_name, "_rw_uint.fdt"));
|
298
289
|
}
|
299
290
|
|
300
291
|
/**
|
301
292
|
* Test the reading and writing of 64-bit unsigned integers
|
302
293
|
*/
|
303
|
-
static void test_rw_u64(TestCase *tc, void *data)
|
304
|
-
{
|
294
|
+
static void test_rw_u64(TestCase *tc, void *data) {
|
305
295
|
int i;
|
306
296
|
FrtStore *store = (FrtStore *)data;
|
307
297
|
frt_u64 ulongs[4] =
|
308
298
|
{ POSH_U64_MAX, POSH_U64_MIN, POSH_U64(100000000000000), POSH_U64(1) };
|
309
|
-
FrtOutStream *ostream = store->new_output(store, "_rw_ulong.
|
299
|
+
FrtOutStream *ostream = store->new_output(store, segm_idx_name, "_rw_ulong.fdt");
|
310
300
|
FrtInStream *istream;
|
311
301
|
|
312
302
|
for (i = 0; i < 4; i++) {
|
@@ -314,23 +304,22 @@ static void test_rw_u64(TestCase *tc, void *data)
|
|
314
304
|
}
|
315
305
|
frt_os_close(ostream);
|
316
306
|
|
317
|
-
istream = store->open_input(store, "_rw_ulong.
|
307
|
+
istream = store->open_input(store, segm_idx_name, "_rw_ulong.fdt");
|
318
308
|
for (i = 0; i < 4; i++) {
|
319
309
|
Aiequal(ulongs[i], frt_is_read_u64(istream));
|
320
310
|
}
|
321
311
|
frt_is_close(istream);
|
322
|
-
Aiequal(32, store->length(store, "_rw_ulong.
|
312
|
+
Aiequal(32, store->length(store, segm_idx_name, "_rw_ulong.fdt"));
|
323
313
|
}
|
324
314
|
|
325
315
|
/**
|
326
316
|
* Test reading and writing of variable size integers
|
327
317
|
*/
|
328
|
-
static void test_rw_vints(TestCase *tc, void *data)
|
329
|
-
{
|
318
|
+
static void test_rw_vints(TestCase *tc, void *data) {
|
330
319
|
int i;
|
331
320
|
FrtStore *store = (FrtStore *)data;
|
332
321
|
unsigned int vints[4] = { UINT_MAX, 0, 10000, 1 };
|
333
|
-
FrtOutStream *ostream = store->new_output(store, "_rw_vint.
|
322
|
+
FrtOutStream *ostream = store->new_output(store, segm_idx_name, "_rw_vint.fdt");
|
334
323
|
FrtInStream *istream;
|
335
324
|
|
336
325
|
for (i = 0; i < 4; i++) {
|
@@ -338,7 +327,7 @@ static void test_rw_vints(TestCase *tc, void *data)
|
|
338
327
|
}
|
339
328
|
frt_os_close(ostream);
|
340
329
|
|
341
|
-
istream = store->open_input(store, "_rw_vint.
|
330
|
+
istream = store->open_input(store, segm_idx_name, "_rw_vint.fdt");
|
342
331
|
for (i = 0; i < 4; i++) {
|
343
332
|
Aiequal(vints[i], frt_is_read_vint(istream));
|
344
333
|
}
|
@@ -348,12 +337,11 @@ static void test_rw_vints(TestCase *tc, void *data)
|
|
348
337
|
/**
|
349
338
|
* Test reading and writing of variable size integers
|
350
339
|
*/
|
351
|
-
static void test_rw_vlls(TestCase *tc, void *data)
|
352
|
-
{
|
340
|
+
static void test_rw_vlls(TestCase *tc, void *data) {
|
353
341
|
int i;
|
354
342
|
FrtStore *store = (FrtStore *)data;
|
355
343
|
unsigned long long vlls[4] = { ULLONG_MAX, 0, 10000, 1 };
|
356
|
-
FrtOutStream *ostream = store->new_output(store, "_rw_vll.
|
344
|
+
FrtOutStream *ostream = store->new_output(store, segm_idx_name, "_rw_vll.fdt");
|
357
345
|
FrtInStream *istream;
|
358
346
|
|
359
347
|
for (i = 0; i < 4; i++) {
|
@@ -361,7 +349,7 @@ static void test_rw_vlls(TestCase *tc, void *data)
|
|
361
349
|
}
|
362
350
|
frt_os_close(ostream);
|
363
351
|
|
364
|
-
istream = store->open_input(store, "_rw_vll.
|
352
|
+
istream = store->open_input(store, segm_idx_name, "_rw_vll.fdt");
|
365
353
|
for (i = 0; i < 4; i++) {
|
366
354
|
Aiequal(vlls[i], frt_is_read_vll(istream));
|
367
355
|
}
|
@@ -371,8 +359,7 @@ static void test_rw_vlls(TestCase *tc, void *data)
|
|
371
359
|
/**
|
372
360
|
* Test reading and writing of variable size 64-bit integers
|
373
361
|
*/
|
374
|
-
static void test_rw_voff_ts(TestCase *tc, void *data)
|
375
|
-
{
|
362
|
+
static void test_rw_voff_ts(TestCase *tc, void *data) {
|
376
363
|
int i;
|
377
364
|
FrtStore *store = (FrtStore *)data;
|
378
365
|
FrtOutStream *ostream;
|
@@ -381,18 +368,17 @@ static void test_rw_voff_ts(TestCase *tc, void *data)
|
|
381
368
|
{ LONG_MAX, 0, 1000000, 1 };
|
382
369
|
if (sizeof(off_t) == 8) {
|
383
370
|
voff_ts[0] = POSH_I64_MAX;
|
384
|
-
}
|
385
|
-
else {
|
371
|
+
} else {
|
386
372
|
voff_ts[0] = POSH_I32_MAX;
|
387
373
|
}
|
388
|
-
ostream = store->new_output(store, "_rw_voff_t.
|
374
|
+
ostream = store->new_output(store, segm_idx_name, "_rw_voff_t.fdt");
|
389
375
|
|
390
376
|
for (i = 0; i < 4; i++) {
|
391
377
|
frt_os_write_voff_t(ostream, (off_t)voff_ts[i]);
|
392
378
|
}
|
393
379
|
frt_os_close(ostream);
|
394
380
|
|
395
|
-
istream = store->open_input(store, "_rw_voff_t.
|
381
|
+
istream = store->open_input(store, segm_idx_name, "_rw_voff_t.fdt");
|
396
382
|
for (i = 0; i < 4; i++) {
|
397
383
|
Aiequal(voff_ts[i], frt_is_read_voff_t(istream));
|
398
384
|
}
|
@@ -402,8 +388,7 @@ static void test_rw_voff_ts(TestCase *tc, void *data)
|
|
402
388
|
/**
|
403
389
|
* Test reading and writing of strings
|
404
390
|
*/
|
405
|
-
static void test_rw_strings(TestCase *tc, void *data)
|
406
|
-
{
|
391
|
+
static void test_rw_strings(TestCase *tc, void *data) {
|
407
392
|
int i;
|
408
393
|
char *tmp;
|
409
394
|
FrtStore *store = (FrtStore *)data;
|
@@ -417,12 +402,12 @@ static void test_rw_strings(TestCase *tc, void *data)
|
|
417
402
|
strcat(buf, str);
|
418
403
|
}
|
419
404
|
|
420
|
-
ostream = store->new_output(store, "_rw_string.
|
405
|
+
ostream = store->new_output(store, segm_idx_name, "_rw_string.fdt");
|
421
406
|
frt_os_write_string(ostream, str);
|
422
407
|
frt_os_write_string(ostream, buf);
|
423
408
|
frt_os_close(ostream);
|
424
409
|
|
425
|
-
istream = store->open_input(store, "_rw_string.
|
410
|
+
istream = store->open_input(store, segm_idx_name, "_rw_string.fdt");
|
426
411
|
|
427
412
|
tmp = frt_is_read_string(istream);
|
428
413
|
Asequal(str, tmp);
|
@@ -431,14 +416,13 @@ static void test_rw_strings(TestCase *tc, void *data)
|
|
431
416
|
Asequal(buf, tmp);
|
432
417
|
free(tmp);
|
433
418
|
frt_is_close(istream);
|
434
|
-
Aiequal(59063, store->length(store, "_rw_string.
|
419
|
+
Aiequal(59063, store->length(store, segm_idx_name, "_rw_string.fdt"));
|
435
420
|
}
|
436
421
|
|
437
422
|
/**
|
438
423
|
* Test reading and writing of non-ascii characters
|
439
424
|
*/
|
440
|
-
static void test_rw_funny_strings(TestCase *tc, void *data)
|
441
|
-
{
|
425
|
+
static void test_rw_funny_strings(TestCase *tc, void *data) {
|
442
426
|
int i;
|
443
427
|
char *tmp;
|
444
428
|
FrtStore *store = (FrtStore *)data;
|
@@ -451,12 +435,12 @@ static void test_rw_funny_strings(TestCase *tc, void *data)
|
|
451
435
|
strcat(buf, str);
|
452
436
|
}
|
453
437
|
|
454
|
-
ostream = store->new_output(store, "_funny_string.
|
438
|
+
ostream = store->new_output(store, segm_idx_name, "_funny_string.fdt");
|
455
439
|
frt_os_write_string(ostream, str);
|
456
440
|
frt_os_write_string(ostream, buf);
|
457
441
|
frt_os_close(ostream);
|
458
442
|
|
459
|
-
istream = store->open_input(store, "_funny_string.
|
443
|
+
istream = store->open_input(store, segm_idx_name, "_funny_string.fdt");
|
460
444
|
tmp = frt_is_read_string(istream);
|
461
445
|
Asequal(str, tmp);
|
462
446
|
free(tmp);
|
@@ -464,19 +448,18 @@ static void test_rw_funny_strings(TestCase *tc, void *data)
|
|
464
448
|
Asequal(buf, tmp);
|
465
449
|
free(tmp);
|
466
450
|
frt_is_close(istream);
|
467
|
-
Aiequal(17021, store->length(store, "_funny_string.
|
451
|
+
Aiequal(17021, store->length(store, segm_idx_name, "_funny_string.fdt"));
|
468
452
|
}
|
469
453
|
|
470
454
|
/**
|
471
455
|
* Test seek in both input stream and output stream, ie test the frt_os_seek and
|
472
456
|
* frt_is_seek functions
|
473
457
|
*/
|
474
|
-
static void test_buffer_seek(TestCase *tc, void *data)
|
475
|
-
{
|
458
|
+
static void test_buffer_seek(TestCase *tc, void *data) {
|
476
459
|
int i;
|
477
460
|
FrtStore *store = (FrtStore *)data;
|
478
461
|
|
479
|
-
FrtOutStream *ostream = store->new_output(store, "_rw_seek.
|
462
|
+
FrtOutStream *ostream = store->new_output(store, segm_idx_name, "_rw_seek.fdt");
|
480
463
|
char text[60] = "This is another int test string !@#$%#$%&%$*%^&*()(_";
|
481
464
|
FrtInStream *istream;
|
482
465
|
|
@@ -495,7 +478,7 @@ static void test_buffer_seek(TestCase *tc, void *data)
|
|
495
478
|
frt_os_write_voff_t(ostream, 98763210);
|
496
479
|
frt_os_close(ostream);
|
497
480
|
|
498
|
-
istream = store->open_input(store, "_rw_seek.
|
481
|
+
istream = store->open_input(store, segm_idx_name, "_rw_seek.fdt");
|
499
482
|
frt_is_seek(istream, 56);
|
500
483
|
Aiequal(56, frt_is_pos(istream));
|
501
484
|
Aiequal(12345, frt_is_read_vint(istream));
|
@@ -511,18 +494,17 @@ static void test_buffer_seek(TestCase *tc, void *data)
|
|
511
494
|
/**
|
512
495
|
* Test cloning of InputStream
|
513
496
|
*/
|
514
|
-
static void test_is_clone(TestCase *tc, void *data)
|
515
|
-
{
|
497
|
+
static void test_is_clone(TestCase *tc, void *data) {
|
516
498
|
int i;
|
517
499
|
FrtStore *store = (FrtStore *)data;
|
518
|
-
FrtOutStream *ostream = store->new_output(store, "_clone.
|
500
|
+
FrtOutStream *ostream = store->new_output(store, segm_idx_name, "_clone.fdt");
|
519
501
|
FrtInStream *istream, *alt_istream;
|
520
502
|
|
521
503
|
for (i = 0; i < 10; i++) {
|
522
504
|
frt_os_write_i64(ostream, i);
|
523
505
|
}
|
524
506
|
frt_os_close(ostream);
|
525
|
-
istream = store->open_input(store, "_clone.
|
507
|
+
istream = store->open_input(store, segm_idx_name, "_clone.fdt");
|
526
508
|
frt_is_seek(istream, 24);
|
527
509
|
alt_istream = frt_is_clone(istream);
|
528
510
|
Aiequal(frt_is_pos(istream), frt_is_pos(alt_istream));
|
@@ -542,16 +524,15 @@ static void test_is_clone(TestCase *tc, void *data)
|
|
542
524
|
* Test the read_bytes method. This method reads a number of bytes into a
|
543
525
|
* buffer.
|
544
526
|
*/
|
545
|
-
static void test_read_bytes(TestCase *tc, void *data)
|
546
|
-
{
|
527
|
+
static void test_read_bytes(TestCase *tc, void *data) {
|
547
528
|
char str[11] = "0000000000";
|
548
529
|
FrtStore *store = (FrtStore *)data;
|
549
|
-
FrtOutStream *ostream = store->new_output(store, "_read_bytes.
|
530
|
+
FrtOutStream *ostream = store->new_output(store, segm_idx_name, "_read_bytes.fdt");
|
550
531
|
FrtInStream *istream;
|
551
532
|
|
552
533
|
frt_os_write_bytes(ostream, (frt_uchar *)"how are you doing?", 18);
|
553
534
|
frt_os_close(ostream);
|
554
|
-
istream = store->open_input(store, "_read_bytes.
|
535
|
+
istream = store->open_input(store, segm_idx_name, "_read_bytes.fdt");
|
555
536
|
frt_is_read_bytes(istream, (frt_uchar *)(str + 2), 4);
|
556
537
|
Asequal("00how 0000", str);
|
557
538
|
frt_is_read_bytes(istream, (frt_uchar *)(str + 1), 8);
|
@@ -565,7 +546,7 @@ static void test_read_bytes(TestCase *tc, void *data)
|
|
565
546
|
* store that you might want to create.
|
566
547
|
*/
|
567
548
|
void create_test_store_suite(TestSuite *suite, FrtStore *store) {
|
568
|
-
store->clear_all(store);
|
549
|
+
store->clear_all(store, segm_idx_name);
|
569
550
|
|
570
551
|
tst_run_test(suite, test_basic_file_ops, store);
|
571
552
|
tst_run_test(suite, test_rename, store);
|
@@ -585,5 +566,5 @@ void create_test_store_suite(TestSuite *suite, FrtStore *store) {
|
|
585
566
|
tst_run_test(suite, test_read_bytes, store);
|
586
567
|
tst_run_test(suite, test_lock, store);
|
587
568
|
|
588
|
-
store->clear_all(store);
|
569
|
+
store->clear_all(store, segm_idx_name);
|
589
570
|
}
|
@@ -60,8 +60,7 @@ static const char *DICT[DICT_LEN] = {
|
|
60
60
|
};
|
61
61
|
|
62
62
|
/*
|
63
|
-
static char *rev(char *str)
|
64
|
-
{
|
63
|
+
static char *rev(char *str) {
|
65
64
|
char *rev = frt_estrdup(str);
|
66
65
|
int i, j;
|
67
66
|
for (i = 0, j = (int)strlen(str)-1; i < j; i++, j--) {
|
@@ -78,8 +77,7 @@ static char *rev(char *str)
|
|
78
77
|
*
|
79
78
|
*****************************************************************************/
|
80
79
|
|
81
|
-
static void test_segment_field_index_single_field(TestCase *tc, void *data)
|
82
|
-
{
|
80
|
+
static void test_segment_field_index_single_field(TestCase *tc, void *data) {
|
83
81
|
int i;
|
84
82
|
FrtStore *store = (FrtStore *)data;
|
85
83
|
FrtSegmentFieldIndex *sfi;
|
@@ -107,8 +105,7 @@ static void test_segment_field_index_single_field(TestCase *tc, void *data)
|
|
107
105
|
frt_sfi_close(sfi);
|
108
106
|
}
|
109
107
|
|
110
|
-
static void add_multi_field_terms(FrtStore *store)
|
111
|
-
{
|
108
|
+
static void add_multi_field_terms(FrtStore *store) {
|
112
109
|
int i;
|
113
110
|
int field_num = 0;
|
114
111
|
FrtTermInfosWriter *tiw = frt_tiw_open(store, "_0", 8, 8);
|
@@ -124,8 +121,7 @@ static void add_multi_field_terms(FrtStore *store)
|
|
124
121
|
frt_tiw_close(tiw);
|
125
122
|
}
|
126
123
|
|
127
|
-
static void test_segment_field_index_multi_field(TestCase *tc, void *data)
|
128
|
-
{
|
124
|
+
static void test_segment_field_index_multi_field(TestCase *tc, void *data) {
|
129
125
|
FrtStore *store = (FrtStore *)data;
|
130
126
|
FrtSegmentFieldIndex *sfi;
|
131
127
|
FrtSegmentTermIndex *sti;
|
@@ -153,8 +149,7 @@ static void test_segment_field_index_multi_field(TestCase *tc, void *data)
|
|
153
149
|
frt_sfi_close(sfi);
|
154
150
|
}
|
155
151
|
|
156
|
-
void test_segment_term_enum(TestCase *tc, void *data)
|
157
|
-
{
|
152
|
+
void test_segment_term_enum(TestCase *tc, void *data) {
|
158
153
|
int i;
|
159
154
|
FrtStore *store = (FrtStore *)data;
|
160
155
|
FrtSegmentFieldIndex *sfi;
|
@@ -163,7 +158,7 @@ void test_segment_term_enum(TestCase *tc, void *data)
|
|
163
158
|
add_multi_field_terms(store);
|
164
159
|
|
165
160
|
sfi = frt_sfi_open(store, "_0");
|
166
|
-
FrtInStream *is = store->open_input(store, "_0.tis");
|
161
|
+
FrtInStream *is = store->open_input(store, segm_idx_name, "_0.tis");
|
167
162
|
FRT_DEREF(is);
|
168
163
|
te = frt_ste_new(is, sfi);
|
169
164
|
te->set_field(te, 0);
|
@@ -284,8 +279,7 @@ void test_segment_term_enum(TestCase *tc, void *data)
|
|
284
279
|
frt_sfi_close(sfi);
|
285
280
|
}
|
286
281
|
|
287
|
-
static void test_term_infos_reader(TestCase *tc, void *data)
|
288
|
-
{
|
282
|
+
static void test_term_infos_reader(TestCase *tc, void *data) {
|
289
283
|
FrtStore *store = (FrtStore *)data;
|
290
284
|
FrtSegmentFieldIndex *sfi;
|
291
285
|
FrtTermInfosReader *tir;
|
@@ -338,9 +332,9 @@ static void test_term_infos_reader(TestCase *tc, void *data)
|
|
338
332
|
frt_sfi_close(sfi);
|
339
333
|
}
|
340
334
|
|
341
|
-
TestSuite *ts_term(TestSuite *suite)
|
342
|
-
{
|
335
|
+
TestSuite *ts_term(TestSuite *suite) {
|
343
336
|
FrtStore *store = frt_open_ram_store(NULL);
|
337
|
+
store->create_folder(store, segm_idx_name);
|
344
338
|
|
345
339
|
suite = ADD_SUITE(suite);
|
346
340
|
|