isomorfeus-ferret 0.12.7 → 0.13.2
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -4,6 +4,8 @@
|
|
4
4
|
#include "frt_search.h"
|
5
5
|
#include "frt_hashset.h"
|
6
6
|
|
7
|
+
#undef close
|
8
|
+
|
7
9
|
#define CLAUSE_INIT_CAPA 4
|
8
10
|
|
9
11
|
/*****************************************************************************
|
@@ -24,8 +26,7 @@ static int spanq_eq(FrtQuery *self, FrtQuery *o)
|
|
24
26
|
return SpQ(self)->field == SpQ(o)->field;
|
25
27
|
}
|
26
28
|
|
27
|
-
static void spanq_destroy_i(FrtQuery *self)
|
28
|
-
{
|
29
|
+
static void spanq_destroy_i(FrtQuery *self) {
|
29
30
|
frt_q_destroy_i(self);
|
30
31
|
}
|
31
32
|
|
@@ -143,25 +144,20 @@ static FrtTermDocEnum *spanq_ir_term_positions(FrtIndexReader *ir)
|
|
143
144
|
return tde;
|
144
145
|
}
|
145
146
|
|
146
|
-
static FrtMatchVector *spanq_get_matchv_i(FrtQuery *self, FrtMatchVector *mv,
|
147
|
-
FrtTermVector *tv)
|
148
|
-
{
|
147
|
+
static FrtMatchVector *spanq_get_matchv_i(FrtQuery *self, FrtMatchVector *mv, FrtTermVector *tv) {
|
149
148
|
if (SpQ(self)->field == tv->field) {
|
150
149
|
FrtSpanEnum *sp_enum;
|
151
150
|
FrtIndexReader *ir = FRT_ALLOC(FrtIndexReader);
|
152
151
|
FrtMatchVector *full_mv = frt_matchv_new();
|
153
152
|
FrtHashSet *terms = SpQ(self)->get_terms(self);
|
154
153
|
/* FIXME What is going on here? Need to document this! */
|
155
|
-
ir->fis = frt_fis_new(FRT_STORE_NO, FRT_INDEX_NO, FRT_TERM_VECTOR_NO);
|
156
|
-
frt_fis_add_field(ir->fis,
|
157
|
-
frt_fi_new(tv->field, FRT_STORE_NO, FRT_INDEX_NO, FRT_TERM_VECTOR_NO));
|
154
|
+
ir->fis = frt_fis_new(FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_NO, FRT_TERM_VECTOR_NO);
|
155
|
+
frt_fis_add_field(ir->fis, frt_fi_new(tv->field, FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_NO, FRT_TERM_VECTOR_NO));
|
158
156
|
ir->store = (FrtStore *)tv;
|
159
157
|
ir->term_positions = &spanq_ir_term_positions;
|
160
158
|
sp_enum = SpQ(self)->get_spans(self, ir);
|
161
159
|
while (sp_enum->next(sp_enum)) {
|
162
|
-
frt_matchv_add(full_mv,
|
163
|
-
sp_enum->start(sp_enum),
|
164
|
-
sp_enum->end(sp_enum) - 1);
|
160
|
+
frt_matchv_add(full_mv, sp_enum->start(sp_enum), sp_enum->end(sp_enum) - 1);
|
165
161
|
}
|
166
162
|
sp_enum->destroy(sp_enum);
|
167
163
|
|
@@ -385,9 +381,8 @@ static int spante_end(FrtSpanEnum *self)
|
|
385
381
|
return SpTEn(self)->position + 1;
|
386
382
|
}
|
387
383
|
|
388
|
-
static char *spante_to_s(FrtSpanEnum *self)
|
389
|
-
|
390
|
-
char *query_str = self->query->to_s(self->query, (FrtSymbol)NULL);
|
384
|
+
static char *spante_to_s(FrtSpanEnum *self) {
|
385
|
+
char *query_str = self->query->to_s(self->query, (ID)NULL);
|
391
386
|
char pos_str[20];
|
392
387
|
size_t len = strlen(query_str);
|
393
388
|
int pos;
|
@@ -704,9 +699,8 @@ static int spanfe_end(FrtSpanEnum *self)
|
|
704
699
|
return sub_enum->end(sub_enum);
|
705
700
|
}
|
706
701
|
|
707
|
-
static char *spanfe_to_s(FrtSpanEnum *self)
|
708
|
-
|
709
|
-
char *query_str = self->query->to_s(self->query, (FrtSymbol)NULL);
|
702
|
+
static char *spanfe_to_s(FrtSpanEnum *self) {
|
703
|
+
char *query_str = self->query->to_s(self->query, (ID)NULL);
|
710
704
|
char *res = frt_strfmt("SpanFirstEnum(%s)", query_str);
|
711
705
|
free(query_str);
|
712
706
|
return res;
|
@@ -857,10 +851,9 @@ static int spanoe_end(FrtSpanEnum *self)
|
|
857
851
|
return se->end(se);
|
858
852
|
}
|
859
853
|
|
860
|
-
static char *spanoe_to_s(FrtSpanEnum *self)
|
861
|
-
{
|
854
|
+
static char *spanoe_to_s(FrtSpanEnum *self) {
|
862
855
|
SpanOrEnum *soe = SpOEn(self);
|
863
|
-
char *query_str = self->query->to_s(self->query, (
|
856
|
+
char *query_str = self->query->to_s(self->query, (ID)NULL);
|
864
857
|
char doc_str[62];
|
865
858
|
size_t len = strlen(query_str);
|
866
859
|
char *str = FRT_ALLOC_N(char, len + 80);
|
@@ -1169,10 +1162,9 @@ static int spanne_end(FrtSpanEnum *self)
|
|
1169
1162
|
return SpNEn(self)->end;
|
1170
1163
|
}
|
1171
1164
|
|
1172
|
-
static char *spanne_to_s(FrtSpanEnum *self)
|
1173
|
-
{
|
1165
|
+
static char *spanne_to_s(FrtSpanEnum *self) {
|
1174
1166
|
SpanNearEnum *sne = SpNEn(self);
|
1175
|
-
char *query_str = self->query->to_s(self->query, (
|
1167
|
+
char *query_str = self->query->to_s(self->query, (ID)NULL);
|
1176
1168
|
char doc_str[62];
|
1177
1169
|
size_t len = strlen(query_str);
|
1178
1170
|
char *str = FRT_ALLOC_N(char, len + 80);
|
@@ -1333,9 +1325,8 @@ static int spanxe_end(FrtSpanEnum *self)
|
|
1333
1325
|
return inc->end(inc);
|
1334
1326
|
}
|
1335
1327
|
|
1336
|
-
static char *spanxe_to_s(FrtSpanEnum *self)
|
1337
|
-
|
1338
|
-
char *query_str = self->query->to_s(self->query, (FrtSymbol)NULL);
|
1328
|
+
static char *spanxe_to_s(FrtSpanEnum *self) {
|
1329
|
+
char *query_str = self->query->to_s(self->query, (ID)NULL);
|
1339
1330
|
char *res = frt_strfmt("SpanNotEnum(%s)", query_str);
|
1340
1331
|
free(query_str);
|
1341
1332
|
return res;
|
@@ -1379,14 +1370,12 @@ static FrtSpanEnum *spanxe_new(FrtQuery *query, FrtIndexReader *ir)
|
|
1379
1370
|
*****************************************************************************/
|
1380
1371
|
|
1381
1372
|
#define SpW(weight) ((SpanWeight *)(weight))
|
1382
|
-
typedef struct SpanWeight
|
1383
|
-
|
1384
|
-
|
1385
|
-
FrtHashSet *terms;
|
1373
|
+
typedef struct SpanWeight {
|
1374
|
+
FrtWeight super;
|
1375
|
+
FrtHashSet *terms;
|
1386
1376
|
} SpanWeight;
|
1387
1377
|
|
1388
|
-
static FrtExplanation *spanw_explain(FrtWeight *self, FrtIndexReader *ir, int target)
|
1389
|
-
{
|
1378
|
+
static FrtExplanation *spanw_explain(FrtWeight *self, FrtIndexReader *ir, int target) {
|
1390
1379
|
FrtExplanation *expl;
|
1391
1380
|
FrtExplanation *idf_expl1;
|
1392
1381
|
FrtExplanation *idf_expl2;
|
@@ -1411,7 +1400,7 @@ static FrtExplanation *spanw_explain(FrtWeight *self, FrtIndexReader *ir, int ta
|
|
1411
1400
|
return frt_expl_new(0.0, "field \"%s\" does not exist in the index", field_name);
|
1412
1401
|
}
|
1413
1402
|
|
1414
|
-
query_str = self->query->to_s(self->query, (
|
1403
|
+
query_str = self->query->to_s(self->query, (ID)NULL);
|
1415
1404
|
|
1416
1405
|
for (hse = terms->first; hse; hse = hse->next) {
|
1417
1406
|
char *term = (char *)hse->elem;
|
@@ -1525,8 +1514,7 @@ static FrtWeight *spanw_new(FrtQuery *query, FrtSearcher *searcher)
|
|
1525
1514
|
* FrtSpanTermQuery
|
1526
1515
|
*****************************************************************************/
|
1527
1516
|
|
1528
|
-
static char *spantq_to_s(FrtQuery *self,
|
1529
|
-
{
|
1517
|
+
static char *spantq_to_s(FrtQuery *self, ID default_field) {
|
1530
1518
|
if (default_field && default_field == SpQ(self)->field) {
|
1531
1519
|
return frt_strfmt("span_terms(%s)", SpTQ(self)->term);
|
1532
1520
|
} else {
|
@@ -1534,38 +1522,34 @@ static char *spantq_to_s(FrtQuery *self, FrtSymbol default_field)
|
|
1534
1522
|
}
|
1535
1523
|
}
|
1536
1524
|
|
1537
|
-
static void spantq_destroy_i(FrtQuery *self)
|
1538
|
-
{
|
1525
|
+
static void spantq_destroy_i(FrtQuery *self) {
|
1539
1526
|
free(SpTQ(self)->term);
|
1540
1527
|
spanq_destroy_i(self);
|
1541
1528
|
}
|
1542
1529
|
|
1543
|
-
static void spantq_extract_terms(FrtQuery *self, FrtHashSet *terms)
|
1544
|
-
{
|
1530
|
+
static void spantq_extract_terms(FrtQuery *self, FrtHashSet *terms) {
|
1545
1531
|
frt_hs_add(terms, frt_term_new(SpQ(self)->field, SpTQ(self)->term));
|
1546
1532
|
}
|
1547
1533
|
|
1548
|
-
static FrtHashSet *spantq_get_terms(FrtQuery *self)
|
1549
|
-
{
|
1534
|
+
static FrtHashSet *spantq_get_terms(FrtQuery *self) {
|
1550
1535
|
FrtHashSet *terms = frt_hs_new_str(&free);
|
1551
1536
|
frt_hs_add(terms, frt_estrdup(SpTQ(self)->term));
|
1552
1537
|
return terms;
|
1553
1538
|
}
|
1554
1539
|
|
1555
|
-
static unsigned long long spantq_hash(FrtQuery *self)
|
1556
|
-
{
|
1540
|
+
static unsigned long long spantq_hash(FrtQuery *self) {
|
1557
1541
|
return spanq_hash(self) ^ frt_str_hash(SpTQ(self)->term);
|
1558
1542
|
}
|
1559
1543
|
|
1560
|
-
static int spantq_eq(FrtQuery *self, FrtQuery *o)
|
1561
|
-
{
|
1544
|
+
static int spantq_eq(FrtQuery *self, FrtQuery *o) {
|
1562
1545
|
return spanq_eq(self, o) && strcmp(SpTQ(self)->term, SpTQ(o)->term) == 0;
|
1563
1546
|
}
|
1564
1547
|
|
1565
|
-
FrtQuery *
|
1566
|
-
|
1567
|
-
|
1548
|
+
FrtQuery *frt_spantq_alloc(void) {
|
1549
|
+
return frt_q_new(FrtSpanTermQuery);
|
1550
|
+
}
|
1568
1551
|
|
1552
|
+
FrtQuery *frt_spantq_init(FrtQuery *self, ID field, const char *term) {
|
1569
1553
|
SpTQ(self)->term = frt_estrdup(term);
|
1570
1554
|
SpQ(self)->field = field;
|
1571
1555
|
SpQ(self)->get_spans = &spante_new;
|
@@ -1582,12 +1566,16 @@ FrtQuery *frt_spantq_new(FrtSymbol field, const char *term)
|
|
1582
1566
|
return self;
|
1583
1567
|
}
|
1584
1568
|
|
1569
|
+
FrtQuery *frt_spantq_new(ID field, const char *term) {
|
1570
|
+
FrtQuery *self = frt_spantq_alloc();
|
1571
|
+
return frt_spantq_init(self, field, term);
|
1572
|
+
}
|
1573
|
+
|
1585
1574
|
/*****************************************************************************
|
1586
1575
|
* SpanMultiTermQuery
|
1587
1576
|
*****************************************************************************/
|
1588
1577
|
|
1589
|
-
static char *spanmtq_to_s(FrtQuery *self,
|
1590
|
-
{
|
1578
|
+
static char *spanmtq_to_s(FrtQuery *self, ID field) {
|
1591
1579
|
char *terms = NULL, *p;
|
1592
1580
|
int len = 3, i;
|
1593
1581
|
FrtSpanMultiTermQuery *smtq = SpMTQ(self);
|
@@ -1606,16 +1594,14 @@ static char *spanmtq_to_s(FrtQuery *self, FrtSymbol field)
|
|
1606
1594
|
|
1607
1595
|
if (field == SpQ(self)->field) {
|
1608
1596
|
p = frt_strfmt("span_terms(%s)", terms);
|
1609
|
-
}
|
1610
|
-
else {
|
1597
|
+
} else {
|
1611
1598
|
p = frt_strfmt("span_terms(%s:%s)", rb_id2name(SpQ(self)->field), terms);
|
1612
1599
|
}
|
1613
1600
|
free(terms);
|
1614
1601
|
return p;
|
1615
1602
|
}
|
1616
1603
|
|
1617
|
-
static void spanmtq_destroy_i(FrtQuery *self)
|
1618
|
-
{
|
1604
|
+
static void spanmtq_destroy_i(FrtQuery *self) {
|
1619
1605
|
FrtSpanMultiTermQuery *smtq = SpMTQ(self);
|
1620
1606
|
int i;
|
1621
1607
|
for (i = 0; i < smtq->term_cnt; i++) {
|
@@ -1625,8 +1611,7 @@ static void spanmtq_destroy_i(FrtQuery *self)
|
|
1625
1611
|
spanq_destroy_i(self);
|
1626
1612
|
}
|
1627
1613
|
|
1628
|
-
static void spanmtq_extract_terms(FrtQuery *self, FrtHashSet *terms)
|
1629
|
-
{
|
1614
|
+
static void spanmtq_extract_terms(FrtQuery *self, FrtHashSet *terms) {
|
1630
1615
|
FrtSpanMultiTermQuery *smtq = SpMTQ(self);
|
1631
1616
|
int i;
|
1632
1617
|
for (i = 0; i < smtq->term_cnt; i++) {
|
@@ -1634,8 +1619,7 @@ static void spanmtq_extract_terms(FrtQuery *self, FrtHashSet *terms)
|
|
1634
1619
|
}
|
1635
1620
|
}
|
1636
1621
|
|
1637
|
-
static FrtHashSet *spanmtq_get_terms(FrtQuery *self)
|
1638
|
-
{
|
1622
|
+
static FrtHashSet *spanmtq_get_terms(FrtQuery *self) {
|
1639
1623
|
FrtHashSet *terms = frt_hs_new_str(&free);
|
1640
1624
|
FrtSpanMultiTermQuery *smtq = SpMTQ(self);
|
1641
1625
|
int i;
|
@@ -1645,8 +1629,7 @@ static FrtHashSet *spanmtq_get_terms(FrtQuery *self)
|
|
1645
1629
|
return terms;
|
1646
1630
|
}
|
1647
1631
|
|
1648
|
-
static unsigned long long spanmtq_hash(FrtQuery *self)
|
1649
|
-
{
|
1632
|
+
static unsigned long long spanmtq_hash(FrtQuery *self) {
|
1650
1633
|
unsigned long long hash = spanq_hash(self);
|
1651
1634
|
FrtSpanMultiTermQuery *smtq = SpMTQ(self);
|
1652
1635
|
int i;
|
@@ -1656,8 +1639,7 @@ static unsigned long long spanmtq_hash(FrtQuery *self)
|
|
1656
1639
|
return hash;
|
1657
1640
|
}
|
1658
1641
|
|
1659
|
-
static int spanmtq_eq(FrtQuery *self, FrtQuery *o)
|
1660
|
-
{
|
1642
|
+
static int spanmtq_eq(FrtQuery *self, FrtQuery *o) {
|
1661
1643
|
FrtSpanMultiTermQuery *smtq = SpMTQ(self);
|
1662
1644
|
FrtSpanMultiTermQuery *smtqo = SpMTQ(o);
|
1663
1645
|
int i;
|
@@ -1669,10 +1651,11 @@ static int spanmtq_eq(FrtQuery *self, FrtQuery *o)
|
|
1669
1651
|
return true;;
|
1670
1652
|
}
|
1671
1653
|
|
1672
|
-
FrtQuery *
|
1673
|
-
|
1674
|
-
|
1654
|
+
FrtQuery *frt_spanmtq_alloc(void) {
|
1655
|
+
return frt_q_new(FrtSpanMultiTermQuery);
|
1656
|
+
}
|
1675
1657
|
|
1658
|
+
FrtQuery *frt_spanmtq_init_conf(FrtQuery *self, ID field, int max_terms) {
|
1676
1659
|
SpMTQ(self)->terms = FRT_ALLOC_N(char *, max_terms);
|
1677
1660
|
SpMTQ(self)->term_cnt = 0;
|
1678
1661
|
SpMTQ(self)->term_capa = max_terms;
|
@@ -1693,13 +1676,20 @@ FrtQuery *frt_spanmtq_new_conf(FrtSymbol field, int max_terms)
|
|
1693
1676
|
return self;
|
1694
1677
|
}
|
1695
1678
|
|
1696
|
-
FrtQuery *
|
1697
|
-
|
1679
|
+
FrtQuery *frt_spanmtq_new_conf(ID field, int max_terms) {
|
1680
|
+
FrtQuery *self = frt_spanmtq_alloc();
|
1681
|
+
return frt_spanmtq_init_conf(self, field, max_terms);
|
1682
|
+
}
|
1683
|
+
|
1684
|
+
FrtQuery *frt_spanmtq_init(FrtQuery *self, ID field) {
|
1685
|
+
return frt_spanmtq_init_conf(self, field, SPAN_MULTI_TERM_QUERY_CAPA);
|
1686
|
+
}
|
1687
|
+
|
1688
|
+
FrtQuery *frt_spanmtq_new(ID field) {
|
1698
1689
|
return frt_spanmtq_new_conf(field, SPAN_MULTI_TERM_QUERY_CAPA);
|
1699
1690
|
}
|
1700
1691
|
|
1701
|
-
void frt_spanmtq_add_term(FrtQuery *self, const char *term)
|
1702
|
-
{
|
1692
|
+
void frt_spanmtq_add_term(FrtQuery *self, const char *term) {
|
1703
1693
|
FrtSpanMultiTermQuery *smtq = SpMTQ(self);
|
1704
1694
|
if (smtq->term_cnt < smtq->term_capa) {
|
1705
1695
|
smtq->terms[smtq->term_cnt++] = frt_estrdup(term);
|
@@ -1712,8 +1702,7 @@ void frt_spanmtq_add_term(FrtQuery *self, const char *term)
|
|
1712
1702
|
*
|
1713
1703
|
*****************************************************************************/
|
1714
1704
|
|
1715
|
-
static char *spanfq_to_s(FrtQuery *self,
|
1716
|
-
{
|
1705
|
+
static char *spanfq_to_s(FrtQuery *self, ID field) {
|
1717
1706
|
FrtQuery *match = SpFQ(self)->match;
|
1718
1707
|
char *q_str = match->to_s(match, field);
|
1719
1708
|
char *res = frt_strfmt("span_first(%s, %d)", q_str, SpFQ(self)->end);
|
@@ -1721,19 +1710,16 @@ static char *spanfq_to_s(FrtQuery *self, FrtSymbol field)
|
|
1721
1710
|
return res;
|
1722
1711
|
}
|
1723
1712
|
|
1724
|
-
static void spanfq_extract_terms(FrtQuery *self, FrtHashSet *terms)
|
1725
|
-
{
|
1713
|
+
static void spanfq_extract_terms(FrtQuery *self, FrtHashSet *terms) {
|
1726
1714
|
SpFQ(self)->match->extract_terms(SpFQ(self)->match, terms);
|
1727
1715
|
}
|
1728
1716
|
|
1729
|
-
static FrtHashSet *spanfq_get_terms(FrtQuery *self)
|
1730
|
-
{
|
1717
|
+
static FrtHashSet *spanfq_get_terms(FrtQuery *self) {
|
1731
1718
|
FrtSpanFirstQuery *sfq = SpFQ(self);
|
1732
1719
|
return SpQ(sfq->match)->get_terms(sfq->match);
|
1733
1720
|
}
|
1734
1721
|
|
1735
|
-
static FrtQuery *spanfq_rewrite(FrtQuery *self, FrtIndexReader *ir)
|
1736
|
-
{
|
1722
|
+
static FrtQuery *spanfq_rewrite(FrtQuery *self, FrtIndexReader *ir) {
|
1737
1723
|
FrtQuery *q, *rq;
|
1738
1724
|
|
1739
1725
|
q = SpFQ(self)->match;
|
@@ -1745,30 +1731,28 @@ static FrtQuery *spanfq_rewrite(FrtQuery *self, FrtIndexReader *ir)
|
|
1745
1731
|
return self; /* no clauses rewrote */
|
1746
1732
|
}
|
1747
1733
|
|
1748
|
-
static void spanfq_destroy_i(FrtQuery *self)
|
1749
|
-
{
|
1734
|
+
static void spanfq_destroy_i(FrtQuery *self) {
|
1750
1735
|
frt_q_deref(SpFQ(self)->match);
|
1751
1736
|
spanq_destroy_i(self);
|
1752
1737
|
}
|
1753
1738
|
|
1754
|
-
static unsigned long long spanfq_hash(FrtQuery *self)
|
1755
|
-
{
|
1739
|
+
static unsigned long long spanfq_hash(FrtQuery *self) {
|
1756
1740
|
return spanq_hash(self) ^ SpFQ(self)->match->hash(SpFQ(self)->match)
|
1757
1741
|
^ SpFQ(self)->end;
|
1758
1742
|
}
|
1759
1743
|
|
1760
|
-
static int spanfq_eq(FrtQuery *self, FrtQuery *o)
|
1761
|
-
{
|
1744
|
+
static int spanfq_eq(FrtQuery *self, FrtQuery *o) {
|
1762
1745
|
FrtSpanFirstQuery *sfq1 = SpFQ(self);
|
1763
1746
|
FrtSpanFirstQuery *sfq2 = SpFQ(o);
|
1764
1747
|
return spanq_eq(self, o) && sfq1->match->eq(sfq1->match, sfq2->match)
|
1765
1748
|
&& (sfq1->end == sfq2->end);
|
1766
1749
|
}
|
1767
1750
|
|
1768
|
-
FrtQuery *
|
1769
|
-
|
1770
|
-
|
1751
|
+
FrtQuery *frt_spanfq_alloc(void) {
|
1752
|
+
return frt_q_new(FrtSpanFirstQuery);
|
1753
|
+
}
|
1771
1754
|
|
1755
|
+
FrtQuery *frt_spanfq_init_nr(FrtQuery *self, FrtQuery *match, int end) {
|
1772
1756
|
SpFQ(self)->match = match;
|
1773
1757
|
SpFQ(self)->end = end;
|
1774
1758
|
|
@@ -1789,8 +1773,17 @@ FrtQuery *frt_spanfq_new_nr(FrtQuery *match, int end)
|
|
1789
1773
|
return self;
|
1790
1774
|
}
|
1791
1775
|
|
1792
|
-
FrtQuery *
|
1793
|
-
|
1776
|
+
FrtQuery *frt_spanfq_new_nr(FrtQuery *match, int end) {
|
1777
|
+
FrtQuery *self = frt_spanfq_alloc();
|
1778
|
+
return frt_spanfq_init_nr(self, match, end);
|
1779
|
+
}
|
1780
|
+
|
1781
|
+
FrtQuery *frt_spanfq_init(FrtQuery *self, FrtQuery *match, int end) {
|
1782
|
+
FRT_REF(match);
|
1783
|
+
return frt_spanfq_init_nr(self, match, end);
|
1784
|
+
}
|
1785
|
+
|
1786
|
+
FrtQuery *frt_spanfq_new(FrtQuery *match, int end) {
|
1794
1787
|
FRT_REF(match);
|
1795
1788
|
return frt_spanfq_new_nr(match, end);
|
1796
1789
|
}
|
@@ -1801,8 +1794,7 @@ FrtQuery *frt_spanfq_new(FrtQuery *match, int end)
|
|
1801
1794
|
*
|
1802
1795
|
*****************************************************************************/
|
1803
1796
|
|
1804
|
-
static char *spanoq_to_s(FrtQuery *self,
|
1805
|
-
{
|
1797
|
+
static char *spanoq_to_s(FrtQuery *self, ID field) {
|
1806
1798
|
int i;
|
1807
1799
|
FrtSpanOrQuery *soq = SpOQ(self);
|
1808
1800
|
char *res, *res_p;
|
@@ -1828,8 +1820,7 @@ static char *spanoq_to_s(FrtQuery *self, FrtSymbol field)
|
|
1828
1820
|
return res;
|
1829
1821
|
}
|
1830
1822
|
|
1831
|
-
static void spanoq_extract_terms(FrtQuery *self, FrtHashSet *terms)
|
1832
|
-
{
|
1823
|
+
static void spanoq_extract_terms(FrtQuery *self, FrtHashSet *terms) {
|
1833
1824
|
FrtSpanOrQuery *soq = SpOQ(self);
|
1834
1825
|
int i;
|
1835
1826
|
for (i = 0; i < soq->c_cnt; i++) {
|
@@ -1838,8 +1829,7 @@ static void spanoq_extract_terms(FrtQuery *self, FrtHashSet *terms)
|
|
1838
1829
|
}
|
1839
1830
|
}
|
1840
1831
|
|
1841
|
-
static FrtHashSet *spanoq_get_terms(FrtQuery *self)
|
1842
|
-
{
|
1832
|
+
static FrtHashSet *spanoq_get_terms(FrtQuery *self) {
|
1843
1833
|
FrtSpanOrQuery *soq = SpOQ(self);
|
1844
1834
|
FrtHashSet *terms = frt_hs_new_str(&free);
|
1845
1835
|
int i;
|
@@ -1852,8 +1842,7 @@ static FrtHashSet *spanoq_get_terms(FrtQuery *self)
|
|
1852
1842
|
return terms;
|
1853
1843
|
}
|
1854
1844
|
|
1855
|
-
static FrtSpanEnum *spanoq_get_spans(FrtQuery *self, FrtIndexReader *ir)
|
1856
|
-
{
|
1845
|
+
static FrtSpanEnum *spanoq_get_spans(FrtQuery *self, FrtIndexReader *ir) {
|
1857
1846
|
FrtSpanOrQuery *soq = SpOQ(self);
|
1858
1847
|
if (soq->c_cnt == 1) {
|
1859
1848
|
FrtQuery *q = soq->clauses[0];
|
@@ -1863,8 +1852,7 @@ static FrtSpanEnum *spanoq_get_spans(FrtQuery *self, FrtIndexReader *ir)
|
|
1863
1852
|
return spanoe_new(self, ir);
|
1864
1853
|
}
|
1865
1854
|
|
1866
|
-
static FrtQuery *spanoq_rewrite(FrtQuery *self, FrtIndexReader *ir)
|
1867
|
-
{
|
1855
|
+
static FrtQuery *spanoq_rewrite(FrtQuery *self, FrtIndexReader *ir) {
|
1868
1856
|
FrtSpanOrQuery *soq = SpOQ(self);
|
1869
1857
|
int i;
|
1870
1858
|
|
@@ -1880,8 +1868,7 @@ static FrtQuery *spanoq_rewrite(FrtQuery *self, FrtIndexReader *ir)
|
|
1880
1868
|
return self;
|
1881
1869
|
}
|
1882
1870
|
|
1883
|
-
static void spanoq_destroy_i(FrtQuery *self)
|
1884
|
-
{
|
1871
|
+
static void spanoq_destroy_i(FrtQuery *self) {
|
1885
1872
|
FrtSpanOrQuery *soq = SpOQ(self);
|
1886
1873
|
|
1887
1874
|
int i;
|
@@ -1894,8 +1881,7 @@ static void spanoq_destroy_i(FrtQuery *self)
|
|
1894
1881
|
spanq_destroy_i(self);
|
1895
1882
|
}
|
1896
1883
|
|
1897
|
-
static unsigned long long spanoq_hash(FrtQuery *self)
|
1898
|
-
{
|
1884
|
+
static unsigned long long spanoq_hash(FrtQuery *self) {
|
1899
1885
|
int i;
|
1900
1886
|
unsigned long long hash = spanq_hash(self);
|
1901
1887
|
FrtSpanOrQuery *soq = SpOQ(self);
|
@@ -1907,8 +1893,7 @@ static unsigned long long spanoq_hash(FrtQuery *self)
|
|
1907
1893
|
return hash;
|
1908
1894
|
}
|
1909
1895
|
|
1910
|
-
static int spanoq_eq(FrtQuery *self, FrtQuery *o)
|
1911
|
-
{
|
1896
|
+
static int spanoq_eq(FrtQuery *self, FrtQuery *o) {
|
1912
1897
|
int i;
|
1913
1898
|
FrtQuery *q1, *q2;
|
1914
1899
|
FrtSpanOrQuery *soq1 = SpOQ(self);
|
@@ -1927,29 +1912,36 @@ static int spanoq_eq(FrtQuery *self, FrtQuery *o)
|
|
1927
1912
|
return true;
|
1928
1913
|
}
|
1929
1914
|
|
1930
|
-
FrtQuery *
|
1931
|
-
|
1932
|
-
|
1933
|
-
SpOQ(self)->clauses = FRT_ALLOC_N(FrtQuery *, CLAUSE_INIT_CAPA);
|
1934
|
-
SpOQ(self)->c_capa = CLAUSE_INIT_CAPA;
|
1915
|
+
FrtQuery *frt_spanoq_alloc(void) {
|
1916
|
+
return frt_q_new(FrtSpanOrQuery);
|
1917
|
+
}
|
1935
1918
|
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1919
|
+
FrtQuery *frt_spanoq_init(FrtQuery *self) {
|
1920
|
+
SpOQ(self)->clauses = FRT_ALLOC_N(FrtQuery *, CLAUSE_INIT_CAPA);
|
1921
|
+
SpOQ(self)->c_capa = CLAUSE_INIT_CAPA;
|
1939
1922
|
|
1940
|
-
self->
|
1941
|
-
self->
|
1942
|
-
self->
|
1943
|
-
|
1944
|
-
self->
|
1945
|
-
self->
|
1946
|
-
self->
|
1947
|
-
self->
|
1948
|
-
self->
|
1923
|
+
SpQ(self)->field = (ID)NULL;
|
1924
|
+
SpQ(self)->get_spans = &spanoq_get_spans;
|
1925
|
+
SpQ(self)->get_terms = &spanoq_get_terms;
|
1926
|
+
|
1927
|
+
self->type = SPAN_OR_QUERY;
|
1928
|
+
self->rewrite = &spanoq_rewrite;
|
1929
|
+
self->extract_terms = &spanoq_extract_terms;
|
1930
|
+
self->to_s = &spanoq_to_s;
|
1931
|
+
self->hash = &spanoq_hash;
|
1932
|
+
self->eq = &spanoq_eq;
|
1933
|
+
self->destroy_i = &spanoq_destroy_i;
|
1934
|
+
self->create_weight_i = &spanw_new;
|
1935
|
+
self->get_matchv_i = &spanq_get_matchv_i;
|
1949
1936
|
|
1950
1937
|
return self;
|
1951
1938
|
}
|
1952
1939
|
|
1940
|
+
FrtQuery *frt_spanoq_new(void) {
|
1941
|
+
FrtQuery *self = frt_spanoq_alloc();
|
1942
|
+
return frt_spanoq_init(self);
|
1943
|
+
}
|
1944
|
+
|
1953
1945
|
FrtQuery *frt_spanoq_add_clause_nr(FrtQuery *self, FrtQuery *clause)
|
1954
1946
|
{
|
1955
1947
|
const int curr_index = SpOQ(self)->c_cnt++;
|
@@ -1985,8 +1977,7 @@ FrtQuery *frt_spanoq_add_clause(FrtQuery *self, FrtQuery *clause)
|
|
1985
1977
|
*
|
1986
1978
|
*****************************************************************************/
|
1987
1979
|
|
1988
|
-
static char *spannq_to_s(FrtQuery *self,
|
1989
|
-
{
|
1980
|
+
static char *spannq_to_s(FrtQuery *self, ID field) {
|
1990
1981
|
int i;
|
1991
1982
|
FrtSpanNearQuery *snq = SpNQ(self);
|
1992
1983
|
char *res, *res_p;
|
@@ -2114,32 +2105,38 @@ static int spannq_eq(FrtQuery *self, FrtQuery *o)
|
|
2114
2105
|
return true;
|
2115
2106
|
}
|
2116
2107
|
|
2117
|
-
FrtQuery *
|
2118
|
-
|
2119
|
-
|
2108
|
+
FrtQuery *frt_spannq_alloc(void) {
|
2109
|
+
return frt_q_new(FrtSpanNearQuery);
|
2110
|
+
}
|
2120
2111
|
|
2121
|
-
|
2122
|
-
SpNQ(self)->
|
2123
|
-
SpNQ(self)->
|
2124
|
-
SpNQ(self)->
|
2112
|
+
FrtQuery *frt_spannq_init(FrtQuery *self, int slop, bool in_order) {
|
2113
|
+
SpNQ(self)->clauses = FRT_ALLOC_N(FrtQuery *, CLAUSE_INIT_CAPA);
|
2114
|
+
SpNQ(self)->c_capa = CLAUSE_INIT_CAPA;
|
2115
|
+
SpNQ(self)->slop = slop;
|
2116
|
+
SpNQ(self)->in_order = in_order;
|
2125
2117
|
|
2126
|
-
SpQ(self)->get_spans
|
2127
|
-
SpQ(self)->get_terms
|
2128
|
-
SpQ(self)->field
|
2118
|
+
SpQ(self)->get_spans = &spannq_get_spans;
|
2119
|
+
SpQ(self)->get_terms = &spannq_get_terms;
|
2120
|
+
SpQ(self)->field = (ID)NULL;
|
2129
2121
|
|
2130
|
-
self->type
|
2131
|
-
self->rewrite
|
2132
|
-
self->extract_terms
|
2133
|
-
self->to_s
|
2134
|
-
self->hash
|
2135
|
-
self->eq
|
2136
|
-
self->destroy_i
|
2137
|
-
self->create_weight_i
|
2138
|
-
self->get_matchv_i
|
2122
|
+
self->type = SPAN_NEAR_QUERY;
|
2123
|
+
self->rewrite = &spannq_rewrite;
|
2124
|
+
self->extract_terms = &spannq_extract_terms;
|
2125
|
+
self->to_s = &spannq_to_s;
|
2126
|
+
self->hash = &spannq_hash;
|
2127
|
+
self->eq = &spannq_eq;
|
2128
|
+
self->destroy_i = &spannq_destroy;
|
2129
|
+
self->create_weight_i = &spanw_new;
|
2130
|
+
self->get_matchv_i = &spanq_get_matchv_i;
|
2139
2131
|
|
2140
2132
|
return self;
|
2141
2133
|
}
|
2142
2134
|
|
2135
|
+
FrtQuery *frt_spannq_new(int slop, bool in_order) {
|
2136
|
+
FrtQuery *self = frt_spannq_alloc();
|
2137
|
+
return frt_spannq_init(self, slop, in_order);
|
2138
|
+
}
|
2139
|
+
|
2143
2140
|
FrtQuery *frt_spannq_add_clause_nr(FrtQuery *self, FrtQuery *clause)
|
2144
2141
|
{
|
2145
2142
|
const int curr_index = SpNQ(self)->c_cnt++;
|
@@ -2175,8 +2172,7 @@ FrtQuery *frt_spannq_add_clause(FrtQuery *self, FrtQuery *clause)
|
|
2175
2172
|
*
|
2176
2173
|
*****************************************************************************/
|
2177
2174
|
|
2178
|
-
static char *spanxq_to_s(FrtQuery *self,
|
2179
|
-
{
|
2175
|
+
static char *spanxq_to_s(FrtQuery *self, ID field) {
|
2180
2176
|
FrtSpanNotQuery *sxq = SpXQ(self);
|
2181
2177
|
char *inc_s = sxq->inc->to_s(sxq->inc, field);
|
2182
2178
|
char *exc_s = sxq->exc->to_s(sxq->exc, field);
|
@@ -2187,18 +2183,15 @@ static char *spanxq_to_s(FrtQuery *self, FrtSymbol field)
|
|
2187
2183
|
return res;
|
2188
2184
|
}
|
2189
2185
|
|
2190
|
-
static void spanxq_extract_terms(FrtQuery *self, FrtHashSet *terms)
|
2191
|
-
{
|
2186
|
+
static void spanxq_extract_terms(FrtQuery *self, FrtHashSet *terms) {
|
2192
2187
|
SpXQ(self)->inc->extract_terms(SpXQ(self)->inc, terms);
|
2193
2188
|
}
|
2194
2189
|
|
2195
|
-
static FrtHashSet *spanxq_get_terms(FrtQuery *self)
|
2196
|
-
{
|
2190
|
+
static FrtHashSet *spanxq_get_terms(FrtQuery *self) {
|
2197
2191
|
return SpQ(SpXQ(self)->inc)->get_terms(SpXQ(self)->inc);
|
2198
2192
|
}
|
2199
2193
|
|
2200
|
-
static FrtQuery *spanxq_rewrite(FrtQuery *self, FrtIndexReader *ir)
|
2201
|
-
{
|
2194
|
+
static FrtQuery *spanxq_rewrite(FrtQuery *self, FrtIndexReader *ir) {
|
2202
2195
|
FrtSpanNotQuery *sxq = SpXQ(self);
|
2203
2196
|
FrtQuery *q, *rq;
|
2204
2197
|
|
@@ -2218,8 +2211,7 @@ static FrtQuery *spanxq_rewrite(FrtQuery *self, FrtIndexReader *ir)
|
|
2218
2211
|
return self;
|
2219
2212
|
}
|
2220
2213
|
|
2221
|
-
static void spanxq_destroy(FrtQuery *self)
|
2222
|
-
{
|
2214
|
+
static void spanxq_destroy(FrtQuery *self) {
|
2223
2215
|
FrtSpanNotQuery *sxq = SpXQ(self);
|
2224
2216
|
|
2225
2217
|
frt_q_deref(sxq->inc);
|
@@ -2228,32 +2220,31 @@ static void spanxq_destroy(FrtQuery *self)
|
|
2228
2220
|
spanq_destroy_i(self);
|
2229
2221
|
}
|
2230
2222
|
|
2231
|
-
static unsigned long long spanxq_hash(FrtQuery *self)
|
2232
|
-
{
|
2223
|
+
static unsigned long long spanxq_hash(FrtQuery *self) {
|
2233
2224
|
FrtSpanNotQuery *sxq = SpXQ(self);
|
2234
2225
|
return spanq_hash(self) ^ sxq->inc->hash(sxq->inc)
|
2235
2226
|
^ sxq->exc->hash(sxq->exc);
|
2236
2227
|
}
|
2237
2228
|
|
2238
|
-
static int spanxq_eq(FrtQuery *self, FrtQuery *o)
|
2239
|
-
{
|
2229
|
+
static int spanxq_eq(FrtQuery *self, FrtQuery *o) {
|
2240
2230
|
FrtSpanNotQuery *sxq1 = SpXQ(self);
|
2241
2231
|
FrtSpanNotQuery *sxq2 = SpXQ(o);
|
2242
2232
|
return spanq_eq(self, o) && sxq1->inc->eq(sxq1->inc, sxq2->inc)
|
2243
2233
|
&& sxq1->exc->eq(sxq1->exc, sxq2->exc);
|
2244
2234
|
}
|
2245
2235
|
|
2236
|
+
FrtQuery *frt_spanxq_alloc(void) {
|
2237
|
+
return frt_q_new(FrtSpanNotQuery);
|
2238
|
+
}
|
2246
2239
|
|
2247
|
-
FrtQuery *
|
2248
|
-
{
|
2249
|
-
FrtQuery *self;
|
2240
|
+
FrtQuery *frt_spanxq_init_nr(FrtQuery *self, FrtQuery *inc, FrtQuery *exc) {
|
2250
2241
|
if (SpQ(inc)->field != SpQ(exc)->field) {
|
2242
|
+
free(self);
|
2251
2243
|
FRT_RAISE(FRT_ARG_ERROR, "All clauses in a SpanQuery must have the same field. "
|
2252
2244
|
"Attempted to add a SpanQuery with field \"%s\" along with a "
|
2253
2245
|
"SpanQuery with field \"%s\" to an SpanNotQuery",
|
2254
2246
|
rb_id2name(SpQ(inc)->field), rb_id2name(SpQ(exc)->field));
|
2255
2247
|
}
|
2256
|
-
self = frt_q_new(FrtSpanNotQuery);
|
2257
2248
|
|
2258
2249
|
SpXQ(self)->inc = inc;
|
2259
2250
|
SpXQ(self)->exc = exc;
|
@@ -2275,13 +2266,22 @@ FrtQuery *frt_spanxq_new_nr(FrtQuery *inc, FrtQuery *exc)
|
|
2275
2266
|
return self;
|
2276
2267
|
}
|
2277
2268
|
|
2278
|
-
FrtQuery *
|
2279
|
-
|
2269
|
+
FrtQuery *frt_spanxq_new_nr(FrtQuery *inc, FrtQuery *exc) {
|
2270
|
+
FrtQuery *self = frt_spanxq_alloc();
|
2271
|
+
return frt_spanxq_init_nr(self, inc, exc);
|
2272
|
+
}
|
2273
|
+
|
2274
|
+
FrtQuery *frt_spanxq_init(FrtQuery *self, FrtQuery *inc, FrtQuery *exc) {
|
2280
2275
|
FRT_REF(inc);
|
2281
2276
|
FRT_REF(exc);
|
2282
|
-
return
|
2277
|
+
return frt_spanxq_init_nr(self, inc, exc);
|
2283
2278
|
}
|
2284
2279
|
|
2280
|
+
FrtQuery *frt_spanxq_new(FrtQuery *inc, FrtQuery *exc) {
|
2281
|
+
FRT_REF(inc);
|
2282
|
+
FRT_REF(exc);
|
2283
|
+
return frt_spanxq_new_nr(inc, exc);
|
2284
|
+
}
|
2285
2285
|
|
2286
2286
|
/*****************************************************************************
|
2287
2287
|
*
|
@@ -2297,19 +2297,18 @@ FrtQuery *frt_spanxq_new(FrtQuery *inc, FrtQuery *exc)
|
|
2297
2297
|
|
2298
2298
|
#define SpPfxQ(query) ((FrtSpanPrefixQuery *)(query))
|
2299
2299
|
|
2300
|
-
static char *spanprq_to_s(FrtQuery *self,
|
2301
|
-
{
|
2300
|
+
static char *spanprq_to_s(FrtQuery *self, ID default_field) {
|
2302
2301
|
char *buffer, *bptr;
|
2303
2302
|
const char *prefix = SpPfxQ(self)->prefix;
|
2304
2303
|
size_t plen = strlen(prefix);
|
2305
|
-
|
2304
|
+
ID field = SpQ(self)->field;
|
2306
2305
|
const char *field_name = rb_id2name(field);
|
2307
2306
|
size_t flen = strlen(field_name);
|
2308
2307
|
|
2309
2308
|
|
2310
2309
|
bptr = buffer = FRT_ALLOC_N(char, plen + flen + 35);
|
2311
2310
|
|
2312
|
-
if (default_field == (
|
2311
|
+
if (default_field == (ID)NULL || (field != default_field)) {
|
2313
2312
|
bptr += sprintf(bptr, "%s:", field_name);
|
2314
2313
|
}
|
2315
2314
|
|
@@ -2322,8 +2321,7 @@ static char *spanprq_to_s(FrtQuery *self, FrtSymbol default_field)
|
|
2322
2321
|
return buffer;
|
2323
2322
|
}
|
2324
2323
|
|
2325
|
-
static FrtQuery *spanprq_rewrite(FrtQuery *self, FrtIndexReader *ir)
|
2326
|
-
{
|
2324
|
+
static FrtQuery *spanprq_rewrite(FrtQuery *self, FrtIndexReader *ir) {
|
2327
2325
|
const int field_num = frt_fis_get_field_num(ir->fis, SpQ(self)->field);
|
2328
2326
|
FrtQuery *volatile q = frt_spanmtq_new_conf(SpQ(self)->field, SpPfxQ(self)->max_terms);
|
2329
2327
|
q->boost = self->boost; /* set the boost */
|
@@ -2349,27 +2347,25 @@ static FrtQuery *spanprq_rewrite(FrtQuery *self, FrtIndexReader *ir)
|
|
2349
2347
|
return q;
|
2350
2348
|
}
|
2351
2349
|
|
2352
|
-
static void spanprq_destroy(FrtQuery *self)
|
2353
|
-
{
|
2350
|
+
static void spanprq_destroy(FrtQuery *self) {
|
2354
2351
|
free(SpPfxQ(self)->prefix);
|
2355
2352
|
spanq_destroy_i(self);
|
2356
2353
|
}
|
2357
2354
|
|
2358
|
-
static unsigned long long spanprq_hash(FrtQuery *self)
|
2359
|
-
{
|
2355
|
+
static unsigned long long spanprq_hash(FrtQuery *self) {
|
2360
2356
|
return frt_str_hash(rb_id2name(SpQ(self)->field)) ^ frt_str_hash(SpPfxQ(self)->prefix);
|
2361
2357
|
}
|
2362
2358
|
|
2363
|
-
static int spanprq_eq(FrtQuery *self, FrtQuery *o)
|
2364
|
-
{
|
2359
|
+
static int spanprq_eq(FrtQuery *self, FrtQuery *o) {
|
2365
2360
|
return (strcmp(SpPfxQ(self)->prefix, SpPfxQ(o)->prefix) == 0)
|
2366
2361
|
&& (SpQ(self)->field == SpQ(o)->field);
|
2367
2362
|
}
|
2368
2363
|
|
2369
|
-
FrtQuery *
|
2370
|
-
|
2371
|
-
|
2364
|
+
FrtQuery *frt_spanprq_alloc(void) {
|
2365
|
+
return frt_q_new(FrtSpanPrefixQuery);
|
2366
|
+
}
|
2372
2367
|
|
2368
|
+
FrtQuery *frt_spanprq_init(FrtQuery *self, ID field, const char *prefix) {
|
2373
2369
|
SpQ(self)->field = field;
|
2374
2370
|
SpPfxQ(self)->prefix = frt_estrdup(prefix);
|
2375
2371
|
SpPfxQ(self)->max_terms = FRT_SPAN_PREFIX_QUERY_MAX_TERMS;
|
@@ -2384,3 +2380,8 @@ FrtQuery *frt_spanprq_new(FrtSymbol field, const char *prefix)
|
|
2384
2380
|
|
2385
2381
|
return self;
|
2386
2382
|
}
|
2383
|
+
|
2384
|
+
FrtQuery *frt_spanprq_new(ID field, const char *prefix) {
|
2385
|
+
FrtQuery *self = frt_spanprq_alloc();
|
2386
|
+
return frt_spanprq_init(self, field, prefix);
|
2387
|
+
}
|