isomorfeus-ferret 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +612 -0
- data/README.md +44 -0
- data/ext/isomorfeus_ferret_ext/benchmark.c +223 -0
- data/ext/isomorfeus_ferret_ext/benchmark.h +45 -0
- data/ext/isomorfeus_ferret_ext/benchmarks_all.h +25 -0
- data/ext/isomorfeus_ferret_ext/bm_bitvector.c +123 -0
- data/ext/isomorfeus_ferret_ext/bm_hash.c +118 -0
- data/ext/isomorfeus_ferret_ext/bm_micro_string.c +40 -0
- data/ext/isomorfeus_ferret_ext/bm_store.c +93 -0
- data/ext/isomorfeus_ferret_ext/email.rl +21 -0
- data/ext/isomorfeus_ferret_ext/extconf.rb +5 -0
- data/ext/isomorfeus_ferret_ext/fio_tmpfile.h +53 -0
- data/ext/isomorfeus_ferret_ext/frb_analysis.c +2577 -0
- data/ext/isomorfeus_ferret_ext/frb_index.c +3457 -0
- data/ext/isomorfeus_ferret_ext/frb_lang.c +9 -0
- data/ext/isomorfeus_ferret_ext/frb_lang.h +17 -0
- data/ext/isomorfeus_ferret_ext/frb_qparser.c +629 -0
- data/ext/isomorfeus_ferret_ext/frb_search.c +4460 -0
- data/ext/isomorfeus_ferret_ext/frb_store.c +515 -0
- data/ext/isomorfeus_ferret_ext/frb_threading.h +30 -0
- data/ext/isomorfeus_ferret_ext/frb_utils.c +1127 -0
- data/ext/isomorfeus_ferret_ext/frt_analysis.c +1644 -0
- data/ext/isomorfeus_ferret_ext/frt_analysis.h +247 -0
- data/ext/isomorfeus_ferret_ext/frt_array.c +124 -0
- data/ext/isomorfeus_ferret_ext/frt_array.h +54 -0
- data/ext/isomorfeus_ferret_ext/frt_bitvector.c +95 -0
- data/ext/isomorfeus_ferret_ext/frt_bitvector.h +586 -0
- data/ext/isomorfeus_ferret_ext/frt_compound_io.c +374 -0
- data/ext/isomorfeus_ferret_ext/frt_config.h +44 -0
- data/ext/isomorfeus_ferret_ext/frt_document.c +134 -0
- data/ext/isomorfeus_ferret_ext/frt_document.h +52 -0
- data/ext/isomorfeus_ferret_ext/frt_except.c +95 -0
- data/ext/isomorfeus_ferret_ext/frt_except.h +188 -0
- data/ext/isomorfeus_ferret_ext/frt_field_index.c +233 -0
- data/ext/isomorfeus_ferret_ext/frt_field_index.h +42 -0
- data/ext/isomorfeus_ferret_ext/frt_filter.c +157 -0
- data/ext/isomorfeus_ferret_ext/frt_fs_store.c +502 -0
- data/ext/isomorfeus_ferret_ext/frt_global.c +427 -0
- data/ext/isomorfeus_ferret_ext/frt_global.h +290 -0
- data/ext/isomorfeus_ferret_ext/frt_hash.c +518 -0
- data/ext/isomorfeus_ferret_ext/frt_hash.h +466 -0
- data/ext/isomorfeus_ferret_ext/frt_hashset.c +191 -0
- data/ext/isomorfeus_ferret_ext/frt_hashset.h +206 -0
- data/ext/isomorfeus_ferret_ext/frt_helper.c +62 -0
- data/ext/isomorfeus_ferret_ext/frt_helper.h +13 -0
- data/ext/isomorfeus_ferret_ext/frt_ind.c +353 -0
- data/ext/isomorfeus_ferret_ext/frt_ind.h +54 -0
- data/ext/isomorfeus_ferret_ext/frt_index.c +6377 -0
- data/ext/isomorfeus_ferret_ext/frt_index.h +880 -0
- data/ext/isomorfeus_ferret_ext/frt_lang.c +104 -0
- data/ext/isomorfeus_ferret_ext/frt_lang.h +44 -0
- data/ext/isomorfeus_ferret_ext/frt_mempool.c +87 -0
- data/ext/isomorfeus_ferret_ext/frt_mempool.h +33 -0
- data/ext/isomorfeus_ferret_ext/frt_multimapper.c +349 -0
- data/ext/isomorfeus_ferret_ext/frt_multimapper.h +52 -0
- data/ext/isomorfeus_ferret_ext/frt_posh.c +1006 -0
- data/ext/isomorfeus_ferret_ext/frt_posh.h +973 -0
- data/ext/isomorfeus_ferret_ext/frt_priorityqueue.c +147 -0
- data/ext/isomorfeus_ferret_ext/frt_priorityqueue.h +147 -0
- data/ext/isomorfeus_ferret_ext/frt_q_boolean.c +1612 -0
- data/ext/isomorfeus_ferret_ext/frt_q_const_score.c +157 -0
- data/ext/isomorfeus_ferret_ext/frt_q_filtered_query.c +209 -0
- data/ext/isomorfeus_ferret_ext/frt_q_fuzzy.c +281 -0
- data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +147 -0
- data/ext/isomorfeus_ferret_ext/frt_q_multi_term.c +672 -0
- data/ext/isomorfeus_ferret_ext/frt_q_parser.c +3084 -0
- data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +1182 -0
- data/ext/isomorfeus_ferret_ext/frt_q_prefix.c +98 -0
- data/ext/isomorfeus_ferret_ext/frt_q_range.c +665 -0
- data/ext/isomorfeus_ferret_ext/frt_q_span.c +2386 -0
- data/ext/isomorfeus_ferret_ext/frt_q_term.c +311 -0
- data/ext/isomorfeus_ferret_ext/frt_q_wildcard.c +166 -0
- data/ext/isomorfeus_ferret_ext/frt_ram_store.c +460 -0
- data/ext/isomorfeus_ferret_ext/frt_scanner.c +899 -0
- data/ext/isomorfeus_ferret_ext/frt_scanner.h +28 -0
- data/ext/isomorfeus_ferret_ext/frt_scanner_mb.c +6705 -0
- data/ext/isomorfeus_ferret_ext/frt_scanner_utf8.c +4419 -0
- data/ext/isomorfeus_ferret_ext/frt_search.c +1824 -0
- data/ext/isomorfeus_ferret_ext/frt_search.h +924 -0
- data/ext/isomorfeus_ferret_ext/frt_similarity.c +150 -0
- data/ext/isomorfeus_ferret_ext/frt_similarity.h +79 -0
- data/ext/isomorfeus_ferret_ext/frt_sort.c +796 -0
- data/ext/isomorfeus_ferret_ext/frt_stopwords.c +395 -0
- data/ext/isomorfeus_ferret_ext/frt_store.c +680 -0
- data/ext/isomorfeus_ferret_ext/frt_store.h +789 -0
- data/ext/isomorfeus_ferret_ext/frt_term_vectors.c +72 -0
- data/ext/isomorfeus_ferret_ext/frt_threading.h +23 -0
- data/ext/isomorfeus_ferret_ext/frt_win32.h +54 -0
- data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +409 -0
- data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.h +95 -0
- data/ext/isomorfeus_ferret_ext/libstemmer.c +93 -0
- data/ext/isomorfeus_ferret_ext/libstemmer.h +73 -0
- data/ext/isomorfeus_ferret_ext/q_parser.y +1366 -0
- data/ext/isomorfeus_ferret_ext/scanner.h +28 -0
- data/ext/isomorfeus_ferret_ext/scanner.in +43 -0
- data/ext/isomorfeus_ferret_ext/scanner.rl +84 -0
- data/ext/isomorfeus_ferret_ext/scanner_mb.rl +200 -0
- data/ext/isomorfeus_ferret_ext/scanner_utf8.rl +85 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_danish.c +324 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_danish.h +7 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_dutch.c +610 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_dutch.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_english.c +1104 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_english.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_finnish.c +749 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_finnish.h +7 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_french.c +1233 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_french.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_german.c +490 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_german.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_hungarian.c +1217 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_hungarian.h +7 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_italian.c +1052 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_italian.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_norwegian.c +283 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_norwegian.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_porter.c +735 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_porter.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_portuguese.c +1003 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_portuguese.h +7 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_spanish.c +1079 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_spanish.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_swedish.c +293 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_swedish.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_romanian.c +984 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_romanian.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_KOI8_R_russian.c +686 -0
- data/ext/isomorfeus_ferret_ext/stem_KOI8_R_russian.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_danish.c +325 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_danish.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_dutch.c +620 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_dutch.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_english.c +1111 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_english.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_finnish.c +754 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_finnish.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_french.c +1242 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_french.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_german.c +495 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_german.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_hungarian.c +1220 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_hungarian.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_italian.c +1059 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_italian.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_norwegian.c +285 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_norwegian.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_porter.c +741 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_porter.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_portuguese.c +1009 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_portuguese.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_romanian.c +990 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_romanian.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_russian.c +680 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_russian.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_spanish.c +1083 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_spanish.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_swedish.c +294 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_swedish.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_turkish.c +2191 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_turkish.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_api.c +66 -0
- data/ext/isomorfeus_ferret_ext/stem_api.h +26 -0
- data/ext/isomorfeus_ferret_ext/stem_header.h +57 -0
- data/ext/isomorfeus_ferret_ext/stem_modules.h +190 -0
- data/ext/isomorfeus_ferret_ext/stem_modules.txt +50 -0
- data/ext/isomorfeus_ferret_ext/stem_utilities.c +478 -0
- data/ext/isomorfeus_ferret_ext/test.c +850 -0
- data/ext/isomorfeus_ferret_ext/test.h +416 -0
- data/ext/isomorfeus_ferret_ext/test_1710.c +63 -0
- data/ext/isomorfeus_ferret_ext/test_analysis.c +1221 -0
- data/ext/isomorfeus_ferret_ext/test_array.c +272 -0
- data/ext/isomorfeus_ferret_ext/test_bitvector.c +600 -0
- data/ext/isomorfeus_ferret_ext/test_compound_io.c +170 -0
- data/ext/isomorfeus_ferret_ext/test_document.c +156 -0
- data/ext/isomorfeus_ferret_ext/test_except.c +244 -0
- data/ext/isomorfeus_ferret_ext/test_fields.c +522 -0
- data/ext/isomorfeus_ferret_ext/test_file_deleter.c +185 -0
- data/ext/isomorfeus_ferret_ext/test_filter.c +331 -0
- data/ext/isomorfeus_ferret_ext/test_fs_store.c +25 -0
- data/ext/isomorfeus_ferret_ext/test_global.c +299 -0
- data/ext/isomorfeus_ferret_ext/test_hash.c +485 -0
- data/ext/isomorfeus_ferret_ext/test_hashset.c +288 -0
- data/ext/isomorfeus_ferret_ext/test_helper.c +47 -0
- data/ext/isomorfeus_ferret_ext/test_highlighter.c +548 -0
- data/ext/isomorfeus_ferret_ext/test_index.c +2323 -0
- data/ext/isomorfeus_ferret_ext/test_lang.c +74 -0
- data/ext/isomorfeus_ferret_ext/test_mempool.c +102 -0
- data/ext/isomorfeus_ferret_ext/test_multimapper.c +64 -0
- data/ext/isomorfeus_ferret_ext/test_priorityqueue.c +213 -0
- data/ext/isomorfeus_ferret_ext/test_q_const_score.c +84 -0
- data/ext/isomorfeus_ferret_ext/test_q_filtered.c +61 -0
- data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +241 -0
- data/ext/isomorfeus_ferret_ext/test_q_parser.c +464 -0
- data/ext/isomorfeus_ferret_ext/test_q_span.c +575 -0
- data/ext/isomorfeus_ferret_ext/test_ram_store.c +77 -0
- data/ext/isomorfeus_ferret_ext/test_search.c +1874 -0
- data/ext/isomorfeus_ferret_ext/test_segments.c +167 -0
- data/ext/isomorfeus_ferret_ext/test_similarity.c +25 -0
- data/ext/isomorfeus_ferret_ext/test_sort.c +333 -0
- data/ext/isomorfeus_ferret_ext/test_store.c +591 -0
- data/ext/isomorfeus_ferret_ext/test_store.h +3 -0
- data/ext/isomorfeus_ferret_ext/test_term.c +351 -0
- data/ext/isomorfeus_ferret_ext/test_term_vectors.c +373 -0
- data/ext/isomorfeus_ferret_ext/test_test.c +83 -0
- data/ext/isomorfeus_ferret_ext/test_threading.c +188 -0
- data/ext/isomorfeus_ferret_ext/testhelper.c +561 -0
- data/ext/isomorfeus_ferret_ext/testhelper.h +25 -0
- data/ext/isomorfeus_ferret_ext/tests_all.h +87 -0
- data/ext/isomorfeus_ferret_ext/uchar-ucs4.rl +1854 -0
- data/ext/isomorfeus_ferret_ext/uchar-utf8.rl +1999 -0
- data/ext/isomorfeus_ferret_ext/url.rl +27 -0
- data/ext/isomorfeus_ferret_ext/word_list.h +15156 -0
- data/lib/isomorfeus/ferret/document.rb +132 -0
- data/lib/isomorfeus/ferret/field_symbol.rb +85 -0
- data/lib/isomorfeus/ferret/index/field_infos.rb +48 -0
- data/lib/isomorfeus/ferret/index/index.rb +970 -0
- data/lib/isomorfeus/ferret/monitor.rb +323 -0
- data/lib/isomorfeus/ferret/stdlib_patches.rb +151 -0
- data/lib/isomorfeus/ferret/version.rb +5 -0
- data/lib/isomorfeus-ferret.rb +8 -0
- metadata +307 -0
@@ -0,0 +1,74 @@
|
|
1
|
+
#include "test.h"
|
2
|
+
#include "frt_lang.h"
|
3
|
+
|
4
|
+
typedef void *(*alloc_ft)(size_t);
|
5
|
+
|
6
|
+
static void huge_emalloc(void *data)
|
7
|
+
{
|
8
|
+
(void)data;
|
9
|
+
frt_emalloc((size_t)-1);
|
10
|
+
}
|
11
|
+
|
12
|
+
static void huge_ecalloc(void *data)
|
13
|
+
{
|
14
|
+
(void)data;
|
15
|
+
frt_ecalloc((size_t)-1);
|
16
|
+
}
|
17
|
+
|
18
|
+
static void huge_erealloc(void *data)
|
19
|
+
{
|
20
|
+
char *p = NULL;
|
21
|
+
(void)data;
|
22
|
+
frt_erealloc(p, (size_t)-1);
|
23
|
+
}
|
24
|
+
|
25
|
+
static void test_emalloc(TestCase *tc, void *data)
|
26
|
+
{
|
27
|
+
char *p;
|
28
|
+
(void)data; /* suppress warning */
|
29
|
+
|
30
|
+
p = (char *)frt_emalloc(100);
|
31
|
+
Apnotnull(p);
|
32
|
+
free(p);
|
33
|
+
|
34
|
+
Araise(FRT_MEM_ERROR, huge_emalloc, NULL);
|
35
|
+
}
|
36
|
+
|
37
|
+
static void test_ecalloc(TestCase *tc, void *data)
|
38
|
+
{
|
39
|
+
int i;
|
40
|
+
char *p;
|
41
|
+
(void)data; /* suppress warning */
|
42
|
+
|
43
|
+
p = (char *)frt_ecalloc(100);
|
44
|
+
Apnotnull(p);
|
45
|
+
for (i = 0; i < 100; ++i) {
|
46
|
+
Aiequal(p[i], 0);
|
47
|
+
}
|
48
|
+
free(p);
|
49
|
+
|
50
|
+
Araise(FRT_MEM_ERROR, huge_ecalloc, NULL);
|
51
|
+
}
|
52
|
+
|
53
|
+
static void test_erealloc(TestCase *tc, void *data)
|
54
|
+
{
|
55
|
+
char *p = NULL;
|
56
|
+
(void)data; /* suppress warning */
|
57
|
+
|
58
|
+
p = (char *)frt_erealloc(p, 100);
|
59
|
+
Apnotnull(p);
|
60
|
+
free(p);
|
61
|
+
|
62
|
+
Araise(FRT_MEM_ERROR, huge_erealloc, NULL);
|
63
|
+
}
|
64
|
+
|
65
|
+
TestSuite *ts_lang(TestSuite *suite)
|
66
|
+
{
|
67
|
+
suite = ADD_SUITE(suite);
|
68
|
+
|
69
|
+
tst_run_test(suite, test_emalloc, NULL);
|
70
|
+
tst_run_test(suite, test_ecalloc, NULL);
|
71
|
+
tst_run_test(suite, test_erealloc, NULL);
|
72
|
+
|
73
|
+
return suite;
|
74
|
+
}
|
@@ -0,0 +1,102 @@
|
|
1
|
+
#include <stdlib.h>
|
2
|
+
#include "test.h"
|
3
|
+
#include "frt_mempool.h"
|
4
|
+
|
5
|
+
|
6
|
+
static void test_mp_default_capa(TestCase *tc, void *data)
|
7
|
+
{
|
8
|
+
FrtMemoryPool *mp = frt_mp_new();
|
9
|
+
(void)data;
|
10
|
+
Aiequal(FRT_MP_INIT_CAPA, mp->buf_capa);
|
11
|
+
frt_mp_destroy(mp);
|
12
|
+
}
|
13
|
+
|
14
|
+
struct MemChecker {
|
15
|
+
int size;
|
16
|
+
char vals[1];
|
17
|
+
};
|
18
|
+
|
19
|
+
#define NUM_ALLOCS 10000
|
20
|
+
#define MAX_SIZE 100
|
21
|
+
|
22
|
+
static void do_mp_test(TestCase *tc, FrtMemoryPool *mp)
|
23
|
+
{
|
24
|
+
int i, j;
|
25
|
+
int max_necessary;
|
26
|
+
int total_bytes = 0;
|
27
|
+
struct MemChecker *mem_checkers[NUM_ALLOCS];
|
28
|
+
|
29
|
+
for (i = 0; i < NUM_ALLOCS; i++) {
|
30
|
+
int size = rand() % MAX_SIZE;
|
31
|
+
total_bytes += size + sizeof(int);
|
32
|
+
mem_checkers[i] = (struct MemChecker *)frt_mp_alloc(mp, size + sizeof(int));
|
33
|
+
mem_checkers[i]->size = size;
|
34
|
+
}
|
35
|
+
for (i = 0; i < NUM_ALLOCS; i++) {
|
36
|
+
for (j = 0; j < mem_checkers[i]->size; j++) {
|
37
|
+
mem_checkers[i]->vals[j] = (char)(i & 0xFF);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
for (i = 0; i < NUM_ALLOCS; i++) {
|
41
|
+
for (j = 0; j < mem_checkers[i]->size; j++) {
|
42
|
+
if (mem_checkers[i]->vals[j] != (char)(i & 0xFF)) {
|
43
|
+
Aiequal(i & 0xFF, mem_checkers[i]->vals[j]);
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
if (!Atrue(total_bytes < (mp->buf_alloc * mp->chunk_size))) {
|
48
|
+
Tmsg("total bytes allocated <%d> > memory used <%d>",
|
49
|
+
total_bytes, mp->buf_alloc * mp->chunk_size);
|
50
|
+
}
|
51
|
+
|
52
|
+
max_necessary =
|
53
|
+
(mp->buf_alloc - 1) * (mp->chunk_size - (MAX_SIZE+sizeof(int)));
|
54
|
+
if (!Atrue(total_bytes > max_necessary)) {
|
55
|
+
Tmsg("total bytes allocated <%d> < max memory needed <%d>",
|
56
|
+
total_bytes, max_necessary);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
static void test_mp_dup(TestCase *tc, void *data)
|
61
|
+
{
|
62
|
+
FrtMemoryPool *mp = frt_mp_new_capa(2000, 16);
|
63
|
+
(void)data;
|
64
|
+
|
65
|
+
do_mp_test(tc, mp);
|
66
|
+
frt_mp_reset(mp);
|
67
|
+
do_mp_test(tc, mp);
|
68
|
+
frt_mp_destroy(mp);
|
69
|
+
}
|
70
|
+
|
71
|
+
static void test_mp_alloc(TestCase *tc, void *data)
|
72
|
+
{
|
73
|
+
FrtMemoryPool *mp = frt_mp_new_capa(20, 16);
|
74
|
+
char *t;
|
75
|
+
(void)data;
|
76
|
+
|
77
|
+
t = frt_mp_strdup(mp, "012345678901234");
|
78
|
+
|
79
|
+
Asequal("012345678901234", t);
|
80
|
+
Aiequal(strlen(t) + 1, frt_mp_used(mp));
|
81
|
+
|
82
|
+
t = (char *)frt_mp_memdup(mp, "012345678901234", 10);
|
83
|
+
Asnequal("012345678901234", t, 10);
|
84
|
+
Aiequal(30, frt_mp_used(mp));
|
85
|
+
|
86
|
+
t = (char *)frt_mp_strndup(mp, "012345678", 9);
|
87
|
+
Asequal("012345678", t);
|
88
|
+
Aiequal(40, frt_mp_used(mp)); /* Stays in the same chunk */
|
89
|
+
|
90
|
+
frt_mp_destroy(mp);
|
91
|
+
}
|
92
|
+
|
93
|
+
TestSuite *ts_mem_pool(TestSuite *suite)
|
94
|
+
{
|
95
|
+
suite = ADD_SUITE(suite);
|
96
|
+
|
97
|
+
tst_run_test(suite, test_mp_default_capa, NULL);
|
98
|
+
tst_run_test(suite, test_mp_alloc, NULL);
|
99
|
+
tst_run_test(suite, test_mp_dup, NULL);
|
100
|
+
|
101
|
+
return suite;
|
102
|
+
}
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#include "testhelper.h"
|
2
|
+
#include "frt_multimapper.h"
|
3
|
+
#include "test.h"
|
4
|
+
|
5
|
+
static void test_multimapper(TestCase *tc, void *data)
|
6
|
+
{
|
7
|
+
char text[] = "abc cabc abd cabcd";
|
8
|
+
char dest[1000];
|
9
|
+
FrtMultiMapper *mapper = frt_mulmap_new();
|
10
|
+
(void)data;
|
11
|
+
|
12
|
+
frt_mulmap_add_mapping(mapper, "abc", "hello");
|
13
|
+
|
14
|
+
frt_mulmap_compile(mapper);
|
15
|
+
Aiequal(24, frt_mulmap_map_len(mapper, dest, text, 1000));
|
16
|
+
Asequal("hello chello abd chellod", frt_mulmap_map(mapper, dest, text, 1000));
|
17
|
+
Asequal("hello chello abd chel", frt_mulmap_map(mapper, dest, text, 22));
|
18
|
+
Aiequal(21, frt_mulmap_map_len(mapper, dest, text, 22));
|
19
|
+
Asequal("hello chello a", frt_mulmap_map(mapper, dest, text, 15));
|
20
|
+
|
21
|
+
frt_mulmap_add_mapping(mapper, "abcd", "hello");
|
22
|
+
frt_mulmap_compile(mapper);
|
23
|
+
Asequal("hello chello abd chellod", frt_mulmap_map(mapper, dest, text, 1000));
|
24
|
+
|
25
|
+
frt_mulmap_add_mapping(mapper, "cab", "taxi");
|
26
|
+
frt_mulmap_compile(mapper);
|
27
|
+
Asequal("hello taxic abd taxicd", frt_mulmap_map(mapper, dest, text, 1000));
|
28
|
+
|
29
|
+
frt_mulmap_destroy(mapper);
|
30
|
+
}
|
31
|
+
|
32
|
+
static void test_multimapper_utf8(TestCase *tc, void *data)
|
33
|
+
{
|
34
|
+
char text[] = "zàáâãäåāăz";
|
35
|
+
char dest[1000];
|
36
|
+
char *dest_dynamic;
|
37
|
+
FrtMultiMapper *mapper = frt_mulmap_new();
|
38
|
+
(void)data;
|
39
|
+
|
40
|
+
frt_mulmap_add_mapping(mapper, "à", "a");
|
41
|
+
frt_mulmap_add_mapping(mapper, "á", "a");
|
42
|
+
frt_mulmap_add_mapping(mapper, "â", "a");
|
43
|
+
frt_mulmap_add_mapping(mapper, "ã", "a");
|
44
|
+
frt_mulmap_add_mapping(mapper, "ä", "a");
|
45
|
+
frt_mulmap_add_mapping(mapper, "å", "a");
|
46
|
+
frt_mulmap_add_mapping(mapper, "ā", "a");
|
47
|
+
frt_mulmap_add_mapping(mapper, "ă", "a");
|
48
|
+
frt_mulmap_compile(mapper);
|
49
|
+
Asequal("zaaaaaaaaz", frt_mulmap_map(mapper, dest, text, 1000));
|
50
|
+
dest_dynamic = frt_mulmap_dynamic_map(mapper, text);
|
51
|
+
Asequal("zaaaaaaaaz", dest_dynamic);
|
52
|
+
free(dest_dynamic);
|
53
|
+
frt_mulmap_destroy(mapper);
|
54
|
+
}
|
55
|
+
|
56
|
+
TestSuite *ts_multimapper(TestSuite *suite)
|
57
|
+
{
|
58
|
+
suite = ADD_SUITE(suite);
|
59
|
+
|
60
|
+
tst_run_test(suite, test_multimapper, NULL);
|
61
|
+
tst_run_test(suite, test_multimapper_utf8, NULL);
|
62
|
+
|
63
|
+
return suite;
|
64
|
+
}
|
@@ -0,0 +1,213 @@
|
|
1
|
+
#include "frt_priorityqueue.h"
|
2
|
+
#include "frt_global.h"
|
3
|
+
#include <string.h>
|
4
|
+
#include "test.h"
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Simple string less than function used for testing adding of strings to the
|
8
|
+
* priority queue.
|
9
|
+
*/
|
10
|
+
static bool str_lt(void *p1, void *p2)
|
11
|
+
{
|
12
|
+
return (strcmp((char *) p1, (char *) p2) < 0);
|
13
|
+
}
|
14
|
+
|
15
|
+
static bool str_lt_rev(void *p1, void *p2)
|
16
|
+
{
|
17
|
+
return (strcmp((char *) p1, (char *) p2) > 0);
|
18
|
+
}
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Test basic FrtPriorityQueue functions.
|
22
|
+
*/
|
23
|
+
static void test_pq(TestCase *tc, void *data)
|
24
|
+
{
|
25
|
+
char *tmp;
|
26
|
+
FrtPriorityQueue *pq = frt_pq_new(4, (frt_lt_ft)&str_lt, &free);
|
27
|
+
(void)data; /* suppress unused argument warning */
|
28
|
+
|
29
|
+
Aiequal(0, pq->size);
|
30
|
+
Aiequal(4, pq->capa);
|
31
|
+
frt_pq_push(pq, frt_estrdup("bword"));
|
32
|
+
Aiequal(1, pq->size);
|
33
|
+
Asequal("bword", (char *) frt_pq_top(pq));
|
34
|
+
frt_pq_push(pq, frt_estrdup("cword"));
|
35
|
+
Aiequal(2, pq->size);
|
36
|
+
Asequal("bword", (char *) frt_pq_top(pq));
|
37
|
+
frt_pq_push(pq, frt_estrdup("aword"));
|
38
|
+
Aiequal(3, pq->size);
|
39
|
+
Asequal("aword", (char *) frt_pq_top(pq));
|
40
|
+
frt_pq_push(pq, frt_estrdup("dword"));
|
41
|
+
Aiequal(4, pq->size);
|
42
|
+
Asequal("aword", (char *) frt_pq_top(pq));
|
43
|
+
Asequal("aword", tmp = (char *) frt_pq_pop(pq));
|
44
|
+
Aiequal(3, pq->size);
|
45
|
+
free(tmp);
|
46
|
+
Asequal("bword", tmp = (char *) frt_pq_pop(pq));
|
47
|
+
Aiequal(2, pq->size);
|
48
|
+
free(tmp);
|
49
|
+
Asequal("cword", tmp = (char *) frt_pq_pop(pq));
|
50
|
+
Aiequal(1, pq->size);
|
51
|
+
free(tmp);
|
52
|
+
Asequal("dword", tmp = (char *) frt_pq_pop(pq));
|
53
|
+
Aiequal(0, pq->size);
|
54
|
+
free(tmp);
|
55
|
+
frt_pq_destroy(pq);
|
56
|
+
}
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Test basic FrtPriorityQueue functions.
|
60
|
+
*/
|
61
|
+
static void test_pq_reverse(TestCase *tc, void *data)
|
62
|
+
{
|
63
|
+
char *tmp;
|
64
|
+
FrtPriorityQueue *pq = frt_pq_new(4, (frt_lt_ft)&str_lt_rev, &free);
|
65
|
+
(void)data; /* suppress unused argument warning */
|
66
|
+
|
67
|
+
Aiequal(0, pq->size);
|
68
|
+
Aiequal(4, pq->capa);
|
69
|
+
frt_pq_push(pq, frt_estrdup("bword"));
|
70
|
+
Aiequal(1, pq->size);
|
71
|
+
Asequal("bword", (char *) frt_pq_top(pq));
|
72
|
+
frt_pq_push(pq, frt_estrdup("cword"));
|
73
|
+
Aiequal(2, pq->size);
|
74
|
+
Asequal("cword", (char *) frt_pq_top(pq));
|
75
|
+
frt_pq_push(pq, frt_estrdup("aword"));
|
76
|
+
Aiequal(3, pq->size);
|
77
|
+
Asequal("cword", (char *) frt_pq_top(pq));
|
78
|
+
frt_pq_push(pq, frt_estrdup("dword"));
|
79
|
+
Aiequal(4, pq->size);
|
80
|
+
Asequal("dword", (char *) frt_pq_top(pq));
|
81
|
+
Asequal("dword", tmp = (char *) frt_pq_pop(pq));
|
82
|
+
Aiequal(3, pq->size);
|
83
|
+
free(tmp);
|
84
|
+
Asequal("cword", tmp = (char *) frt_pq_pop(pq));
|
85
|
+
Aiequal(2, pq->size);
|
86
|
+
free(tmp);
|
87
|
+
Asequal("bword", tmp = (char *) frt_pq_pop(pq));
|
88
|
+
Aiequal(1, pq->size);
|
89
|
+
free(tmp);
|
90
|
+
Asequal("aword", tmp = (char *) frt_pq_pop(pq));
|
91
|
+
Aiequal(0, pq->size);
|
92
|
+
free(tmp);
|
93
|
+
frt_pq_destroy(pq);
|
94
|
+
}
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Free mock used to test that the FrtPriorityQueue is being destroyed correctly
|
98
|
+
* including it's elements
|
99
|
+
*/
|
100
|
+
static void pq_free_mock(void *p)
|
101
|
+
{
|
102
|
+
char *str = (char *) p;
|
103
|
+
strcpy(str, "free");
|
104
|
+
}
|
105
|
+
|
106
|
+
/**
|
107
|
+
* Test pq_clear function
|
108
|
+
*/
|
109
|
+
static void test_pq_clear(TestCase *tc, void *data)
|
110
|
+
{
|
111
|
+
char word1[10] = "word1";
|
112
|
+
char word2[10] = "word2";
|
113
|
+
char word3[10] = "word3";
|
114
|
+
FrtPriorityQueue *pq = frt_pq_new(3, (frt_lt_ft)&str_lt, &pq_free_mock);
|
115
|
+
(void)data; /* suppress unused argument warning */
|
116
|
+
|
117
|
+
frt_pq_push(pq, word1);
|
118
|
+
frt_pq_push(pq, word2);
|
119
|
+
frt_pq_push(pq, word3);
|
120
|
+
Aiequal(3, pq->size);
|
121
|
+
frt_pq_clear(pq);
|
122
|
+
Aiequal(0, pq->size);
|
123
|
+
Asequal("free", word1);
|
124
|
+
Asequal("free", word2);
|
125
|
+
Asequal("free", word3);
|
126
|
+
frt_pq_destroy(pq);
|
127
|
+
}
|
128
|
+
|
129
|
+
/**
|
130
|
+
* Test that FrtPriorityQueue will handle insert overflow. That is, when you
|
131
|
+
* insert more than the PriorityQueue's capacity, the extra elements that drop
|
132
|
+
* off the bottom are destroyed.
|
133
|
+
*/
|
134
|
+
static void test_pq_insert_overflow(TestCase *tc, void *data)
|
135
|
+
{
|
136
|
+
char word1[10] = "word1";
|
137
|
+
char word2[10] = "word2";
|
138
|
+
char word3[10] = "word3";
|
139
|
+
char word4[10] = "word4";
|
140
|
+
char word5[10] = "word5";
|
141
|
+
char word6[10] = "word6";
|
142
|
+
FrtPriorityQueue *pq = frt_pq_new(3, (frt_lt_ft)&str_lt, &pq_free_mock);
|
143
|
+
(void)data; /* suppress unused argument warning */
|
144
|
+
|
145
|
+
Aiequal(FRT_PQ_ADDED, frt_pq_insert(pq, word2));
|
146
|
+
Aiequal(FRT_PQ_ADDED, frt_pq_insert(pq, word3));
|
147
|
+
Aiequal(FRT_PQ_ADDED, frt_pq_insert(pq, word4));
|
148
|
+
Aiequal(FRT_PQ_INSERTED, frt_pq_insert(pq, word5));
|
149
|
+
Aiequal(FRT_PQ_INSERTED, frt_pq_insert(pq, word6));
|
150
|
+
Aiequal(FRT_PQ_DROPPED, frt_pq_insert(pq, word1));
|
151
|
+
Aiequal(3, pq->size);
|
152
|
+
Asequal("free", word1);
|
153
|
+
Asequal("free", word2);
|
154
|
+
Asequal("free", word3);
|
155
|
+
Asequal("word4", word4);
|
156
|
+
Asequal("word5", word5);
|
157
|
+
Asequal("word6", word6);
|
158
|
+
frt_pq_clear(pq);
|
159
|
+
Aiequal(0, pq->size);
|
160
|
+
Asequal("free", word4);
|
161
|
+
Asequal("free", word5);
|
162
|
+
Asequal("free", word6);
|
163
|
+
frt_pq_destroy(pq);
|
164
|
+
}
|
165
|
+
|
166
|
+
/**
|
167
|
+
* Stress test the PriorityQueue. Make PQ_STRESS_SIZE much larger if you want
|
168
|
+
* to really stress test PriorityQueue.
|
169
|
+
*/
|
170
|
+
#define PQ_STRESS_SIZE 1000
|
171
|
+
static void stress_pq(TestCase *tc, void *data)
|
172
|
+
{
|
173
|
+
int i;
|
174
|
+
char buf[100], *prev, *curr;
|
175
|
+
FrtPriorityQueue *pq = frt_pq_new(PQ_STRESS_SIZE, (frt_lt_ft)&str_lt, &free);
|
176
|
+
(void)data; /* suppress unused argument warning */
|
177
|
+
|
178
|
+
for (i = 0; i < PQ_STRESS_SIZE; i++) {
|
179
|
+
sprintf(buf, "<%d>", rand());
|
180
|
+
frt_pq_push(pq, frt_estrdup(buf));
|
181
|
+
}
|
182
|
+
Aiequal(PQ_STRESS_SIZE, pq->size);
|
183
|
+
|
184
|
+
prev = (char *) frt_pq_pop(pq);
|
185
|
+
for (i = 0; i < PQ_STRESS_SIZE - 1; i++) {
|
186
|
+
curr = (char *) frt_pq_pop(pq);
|
187
|
+
if (str_lt(curr, prev) == true) {
|
188
|
+
Assert(false, "previous should be less than or equal to current");
|
189
|
+
Tmsg("%d: %s, %s\n", i, prev, curr);
|
190
|
+
}
|
191
|
+
free(prev);
|
192
|
+
prev = curr;
|
193
|
+
}
|
194
|
+
free(prev);
|
195
|
+
frt_pq_clear(pq);
|
196
|
+
frt_pq_destroy(pq);
|
197
|
+
}
|
198
|
+
|
199
|
+
/**
|
200
|
+
* PriorityQueue's test suite
|
201
|
+
*/
|
202
|
+
TestSuite *ts_priorityqueue(TestSuite *suite)
|
203
|
+
{
|
204
|
+
suite = ADD_SUITE(suite);
|
205
|
+
|
206
|
+
tst_run_test(suite, test_pq, NULL);
|
207
|
+
tst_run_test(suite, test_pq_reverse, NULL);
|
208
|
+
tst_run_test(suite, test_pq_clear, NULL);
|
209
|
+
tst_run_test(suite, test_pq_insert_overflow, NULL);
|
210
|
+
tst_run_test(suite, stress_pq, NULL);
|
211
|
+
|
212
|
+
return suite;
|
213
|
+
}
|
@@ -0,0 +1,84 @@
|
|
1
|
+
#include "frt_search.h"
|
2
|
+
#include "test.h"
|
3
|
+
|
4
|
+
static FrtSymbol num;
|
5
|
+
|
6
|
+
extern void prepare_filter_index(FrtStore *store);
|
7
|
+
|
8
|
+
static void test_const_score_query(TestCase *tc, void *data)
|
9
|
+
{
|
10
|
+
FrtSearcher *searcher = (FrtSearcher *)data;
|
11
|
+
FrtQuery *q;
|
12
|
+
q = frt_csq_new_nr(frt_rfilt_new(num, "2", "6", true, true));
|
13
|
+
tst_check_hits(tc, searcher, q, "2,3,4,5,6", -1);
|
14
|
+
frt_q_deref(q);
|
15
|
+
q = frt_csq_new_nr(frt_rfilt_new(num, "2", "6", true, false));
|
16
|
+
tst_check_hits(tc, searcher, q, "2,3,4,5", -1);
|
17
|
+
frt_q_deref(q);
|
18
|
+
q = frt_csq_new_nr(frt_rfilt_new(num, "2", "6", false, true));
|
19
|
+
tst_check_hits(tc, searcher, q, "3,4,5,6", -1);
|
20
|
+
frt_q_deref(q);
|
21
|
+
q = frt_csq_new_nr(frt_rfilt_new(num, "2", "6", false, false));
|
22
|
+
tst_check_hits(tc, searcher, q, "3,4,5", -1);
|
23
|
+
frt_q_deref(q);
|
24
|
+
q = frt_csq_new_nr(frt_rfilt_new(num, "6", NULL, true, false));
|
25
|
+
tst_check_hits(tc, searcher, q, "6,7,8,9", -1);
|
26
|
+
frt_q_deref(q);
|
27
|
+
q = frt_csq_new_nr(frt_rfilt_new(num, "6", NULL, false, false));
|
28
|
+
tst_check_hits(tc, searcher, q, "7,8,9", -1);
|
29
|
+
frt_q_deref(q);
|
30
|
+
q = frt_csq_new_nr(frt_rfilt_new(num, NULL, "2", false, true));
|
31
|
+
tst_check_hits(tc, searcher, q, "0,1,2", -1);
|
32
|
+
frt_q_deref(q);
|
33
|
+
q = frt_csq_new_nr(frt_rfilt_new(num, NULL, "2", false, false));
|
34
|
+
tst_check_hits(tc, searcher, q, "0,1", -1);
|
35
|
+
frt_q_deref(q);
|
36
|
+
}
|
37
|
+
|
38
|
+
static void test_const_score_query_hash(TestCase *tc, void *data)
|
39
|
+
{
|
40
|
+
FrtFilter *f;
|
41
|
+
FrtQuery *q1, *q2;
|
42
|
+
(void)data;
|
43
|
+
f = frt_rfilt_new(num, "2", "6", true, true);
|
44
|
+
q1 = frt_csq_new_nr(f);
|
45
|
+
q2 = frt_csq_new(f);
|
46
|
+
|
47
|
+
Assert(frt_q_eq(q1, q1), "Test same queries are equal");
|
48
|
+
Aiequal(frt_q_hash(q1), frt_q_hash(q2));
|
49
|
+
Assert(frt_q_eq(q1, q2), "Queries are equal");
|
50
|
+
frt_q_deref(q2);
|
51
|
+
|
52
|
+
q2 = frt_csq_new_nr(frt_rfilt_new(num, "2", "6", true, true));
|
53
|
+
Aiequal(frt_q_hash(q1), frt_q_hash(q2));
|
54
|
+
Assert(frt_q_eq(q1, q2), "Queries are equal");
|
55
|
+
frt_q_deref(q2);
|
56
|
+
|
57
|
+
q2 = frt_csq_new_nr(frt_rfilt_new(num, "3", "6", true, true));
|
58
|
+
Assert(frt_q_hash(q1) != frt_q_hash(q2), "Queries are not equal");
|
59
|
+
Assert(!frt_q_eq(q1, q2), "Queries are not equal");
|
60
|
+
frt_q_deref(q2);
|
61
|
+
frt_q_deref(q1);
|
62
|
+
}
|
63
|
+
|
64
|
+
TestSuite *ts_q_const_score(TestSuite *suite)
|
65
|
+
{
|
66
|
+
FrtStore *store = frt_open_ram_store();
|
67
|
+
FrtIndexReader *ir;
|
68
|
+
FrtSearcher *searcher;
|
69
|
+
|
70
|
+
num = rb_intern("num");
|
71
|
+
|
72
|
+
suite = ADD_SUITE(suite);
|
73
|
+
|
74
|
+
prepare_filter_index(store);
|
75
|
+
ir = frt_ir_open(store);
|
76
|
+
searcher = frt_isea_new(ir);
|
77
|
+
|
78
|
+
tst_run_test(suite, test_const_score_query, (void *)searcher);
|
79
|
+
tst_run_test(suite, test_const_score_query_hash, NULL);
|
80
|
+
|
81
|
+
frt_store_deref(store);
|
82
|
+
frt_searcher_close(searcher);
|
83
|
+
return suite;
|
84
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
#include "frt_search.h"
|
2
|
+
#include "test.h"
|
3
|
+
|
4
|
+
static FrtSymbol num, flipflop;
|
5
|
+
|
6
|
+
extern void prepare_filter_index(FrtStore *store);
|
7
|
+
|
8
|
+
static void test_filtered_query(TestCase *tc, void *data)
|
9
|
+
{
|
10
|
+
FrtSearcher *searcher = (FrtSearcher *)data;
|
11
|
+
FrtQuery *q;
|
12
|
+
q = frt_fq_new(frt_maq_new(), frt_rfilt_new(num, "2", "6", true, true));
|
13
|
+
tst_check_hits(tc, searcher, q, "2,3,4,5,6", -1);
|
14
|
+
frt_q_deref(q);
|
15
|
+
q = frt_fq_new(frt_tq_new(flipflop, "on"), frt_rfilt_new(num, "2", "6", true, true));
|
16
|
+
tst_check_hits(tc, searcher, q, "2,4,6", -1);
|
17
|
+
frt_q_deref(q);
|
18
|
+
q = frt_fq_new(frt_maq_new(), frt_rfilt_new(num, "2", "6", true, false));
|
19
|
+
tst_check_hits(tc, searcher, q, "2,3,4,5", -1);
|
20
|
+
frt_q_deref(q);
|
21
|
+
q = frt_fq_new(frt_maq_new(), frt_rfilt_new(num, "2", "6", false, true));
|
22
|
+
tst_check_hits(tc, searcher, q, "3,4,5,6", -1);
|
23
|
+
frt_q_deref(q);
|
24
|
+
q = frt_fq_new(frt_maq_new(), frt_rfilt_new(num, "2", "6", false, false));
|
25
|
+
tst_check_hits(tc, searcher, q, "3,4,5", -1);
|
26
|
+
frt_q_deref(q);
|
27
|
+
q = frt_fq_new(frt_maq_new(), frt_rfilt_new(num, "6", NULL, true, false));
|
28
|
+
tst_check_hits(tc, searcher, q, "6,7,8,9", -1);
|
29
|
+
frt_q_deref(q);
|
30
|
+
q = frt_fq_new(frt_maq_new(), frt_rfilt_new(num, "6", NULL, false, false));
|
31
|
+
tst_check_hits(tc, searcher, q, "7,8,9", -1);
|
32
|
+
frt_q_deref(q);
|
33
|
+
q = frt_fq_new(frt_maq_new(), frt_rfilt_new(num, NULL, "2", false, true));
|
34
|
+
tst_check_hits(tc, searcher, q, "0,1,2", -1);
|
35
|
+
frt_q_deref(q);
|
36
|
+
q = frt_fq_new(frt_maq_new(), frt_rfilt_new(num, NULL, "2", false, false));
|
37
|
+
tst_check_hits(tc, searcher, q, "0,1", -1);
|
38
|
+
frt_q_deref(q);
|
39
|
+
}
|
40
|
+
|
41
|
+
TestSuite *ts_q_filtered(TestSuite *suite)
|
42
|
+
{
|
43
|
+
FrtStore *store = frt_open_ram_store();
|
44
|
+
FrtIndexReader *ir;
|
45
|
+
FrtSearcher *searcher;
|
46
|
+
|
47
|
+
num = rb_intern("num");
|
48
|
+
flipflop = rb_intern("flipflop");
|
49
|
+
|
50
|
+
suite = ADD_SUITE(suite);
|
51
|
+
|
52
|
+
prepare_filter_index(store);
|
53
|
+
ir = frt_ir_open(store);
|
54
|
+
searcher = frt_isea_new(ir);
|
55
|
+
|
56
|
+
tst_run_test(suite, test_filtered_query, (void *)searcher);
|
57
|
+
|
58
|
+
frt_store_deref(store);
|
59
|
+
searcher->close(searcher);
|
60
|
+
return suite;
|
61
|
+
}
|