ferret 0.11.6 → 0.11.8.4
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.
- data/README +10 -22
- data/RELEASE_CHANGES +137 -0
- data/RELEASE_NOTES +60 -0
- data/Rakefile +379 -274
- data/TODO +100 -8
- data/bin/ferret-browser +0 -0
- data/ext/BZLIB_blocksort.c +1094 -0
- data/ext/BZLIB_bzlib.c +1578 -0
- data/ext/BZLIB_compress.c +672 -0
- data/ext/BZLIB_crctable.c +104 -0
- data/ext/BZLIB_decompress.c +626 -0
- data/ext/BZLIB_huffman.c +205 -0
- data/ext/BZLIB_randtable.c +84 -0
- data/ext/{api.c → STEMMER_api.c} +7 -10
- data/ext/{libstemmer.c → STEMMER_libstemmer.c} +3 -2
- data/ext/{stem_ISO_8859_1_danish.c → STEMMER_stem_ISO_8859_1_danish.c} +123 -124
- data/ext/{stem_ISO_8859_1_dutch.c → STEMMER_stem_ISO_8859_1_dutch.c} +177 -188
- data/ext/STEMMER_stem_ISO_8859_1_english.c +1117 -0
- data/ext/{stem_ISO_8859_1_finnish.c → STEMMER_stem_ISO_8859_1_finnish.c} +276 -306
- data/ext/STEMMER_stem_ISO_8859_1_french.c +1246 -0
- data/ext/{stem_ISO_8859_1_german.c → STEMMER_stem_ISO_8859_1_german.c} +161 -170
- data/ext/STEMMER_stem_ISO_8859_1_hungarian.c +1230 -0
- data/ext/STEMMER_stem_ISO_8859_1_italian.c +1065 -0
- data/ext/STEMMER_stem_ISO_8859_1_norwegian.c +297 -0
- data/ext/{stem_ISO_8859_1_porter.c → STEMMER_stem_ISO_8859_1_porter.c} +263 -290
- data/ext/{stem_ISO_8859_1_portuguese.c → STEMMER_stem_ISO_8859_1_portuguese.c} +362 -380
- data/ext/STEMMER_stem_ISO_8859_1_spanish.c +1093 -0
- data/ext/STEMMER_stem_ISO_8859_1_swedish.c +307 -0
- data/ext/STEMMER_stem_ISO_8859_2_romanian.c +998 -0
- data/ext/{stem_KOI8_R_russian.c → STEMMER_stem_KOI8_R_russian.c} +244 -245
- data/ext/STEMMER_stem_UTF_8_danish.c +339 -0
- data/ext/{stem_UTF_8_dutch.c → STEMMER_stem_UTF_8_dutch.c} +192 -211
- data/ext/STEMMER_stem_UTF_8_english.c +1125 -0
- data/ext/{stem_UTF_8_finnish.c → STEMMER_stem_UTF_8_finnish.c} +284 -324
- data/ext/STEMMER_stem_UTF_8_french.c +1256 -0
- data/ext/{stem_UTF_8_german.c → STEMMER_stem_UTF_8_german.c} +170 -187
- data/ext/STEMMER_stem_UTF_8_hungarian.c +1234 -0
- data/ext/STEMMER_stem_UTF_8_italian.c +1073 -0
- data/ext/STEMMER_stem_UTF_8_norwegian.c +299 -0
- data/ext/{stem_UTF_8_porter.c → STEMMER_stem_UTF_8_porter.c} +271 -310
- data/ext/STEMMER_stem_UTF_8_portuguese.c +1023 -0
- data/ext/STEMMER_stem_UTF_8_romanian.c +1004 -0
- data/ext/STEMMER_stem_UTF_8_russian.c +694 -0
- data/ext/STEMMER_stem_UTF_8_spanish.c +1097 -0
- data/ext/STEMMER_stem_UTF_8_swedish.c +309 -0
- data/ext/STEMMER_stem_UTF_8_turkish.c +2205 -0
- data/ext/{utilities.c → STEMMER_utilities.c} +100 -68
- data/ext/analysis.c +276 -121
- data/ext/analysis.h +190 -143
- data/ext/api.h +3 -4
- data/ext/array.c +5 -3
- data/ext/array.h +52 -43
- data/ext/bitvector.c +38 -482
- data/ext/bitvector.h +446 -124
- data/ext/bzlib.h +282 -0
- data/ext/bzlib_private.h +503 -0
- data/ext/compound_io.c +23 -22
- data/ext/config.h +21 -11
- data/ext/document.c +43 -40
- data/ext/document.h +31 -21
- data/ext/except.c +20 -38
- data/ext/except.h +89 -76
- data/ext/extconf.rb +3 -2
- data/ext/ferret.c +49 -35
- data/ext/ferret.h +14 -11
- data/ext/field_index.c +262 -0
- data/ext/field_index.h +52 -0
- data/ext/filter.c +11 -10
- data/ext/fs_store.c +65 -47
- data/ext/global.c +245 -165
- data/ext/global.h +252 -54
- data/ext/hash.c +200 -243
- data/ext/hash.h +205 -163
- data/ext/hashset.c +118 -96
- data/ext/hashset.h +110 -82
- data/ext/header.h +19 -19
- data/ext/helper.c +11 -10
- data/ext/helper.h +14 -6
- data/ext/index.c +745 -366
- data/ext/index.h +503 -529
- data/ext/internal.h +1020 -0
- data/ext/lang.c +10 -0
- data/ext/lang.h +35 -15
- data/ext/mempool.c +5 -4
- data/ext/mempool.h +30 -22
- data/ext/modules.h +35 -7
- data/ext/multimapper.c +43 -2
- data/ext/multimapper.h +32 -23
- data/ext/posh.c +0 -0
- data/ext/posh.h +4 -38
- data/ext/priorityqueue.c +10 -12
- data/ext/priorityqueue.h +33 -21
- data/ext/q_boolean.c +22 -9
- data/ext/q_const_score.c +3 -2
- data/ext/q_filtered_query.c +15 -12
- data/ext/q_fuzzy.c +147 -135
- data/ext/q_match_all.c +3 -2
- data/ext/q_multi_term.c +28 -32
- data/ext/q_parser.c +451 -173
- data/ext/q_phrase.c +158 -79
- data/ext/q_prefix.c +16 -18
- data/ext/q_range.c +363 -31
- data/ext/q_span.c +130 -141
- data/ext/q_term.c +21 -21
- data/ext/q_wildcard.c +19 -23
- data/ext/r_analysis.c +369 -242
- data/ext/r_index.c +421 -434
- data/ext/r_qparser.c +142 -92
- data/ext/r_search.c +790 -407
- data/ext/r_store.c +44 -44
- data/ext/r_utils.c +264 -96
- data/ext/ram_store.c +29 -23
- data/ext/scanner.c +895 -0
- data/ext/scanner.h +36 -0
- data/ext/scanner_mb.c +6701 -0
- data/ext/scanner_utf8.c +4415 -0
- data/ext/search.c +210 -87
- data/ext/search.h +556 -488
- data/ext/similarity.c +17 -16
- data/ext/similarity.h +51 -44
- data/ext/sort.c +157 -354
- data/ext/stem_ISO_8859_1_hungarian.h +16 -0
- data/ext/stem_ISO_8859_2_romanian.h +16 -0
- data/ext/stem_UTF_8_hungarian.h +16 -0
- data/ext/stem_UTF_8_romanian.h +16 -0
- data/ext/stem_UTF_8_turkish.h +16 -0
- data/ext/stopwords.c +287 -278
- data/ext/store.c +57 -51
- data/ext/store.h +308 -286
- data/ext/symbol.c +10 -0
- data/ext/symbol.h +23 -0
- data/ext/term_vectors.c +14 -293
- data/ext/threading.h +22 -22
- data/ext/win32.h +12 -4
- data/lib/ferret.rb +2 -1
- data/lib/ferret/browser.rb +1 -1
- data/lib/ferret/field_symbol.rb +94 -0
- data/lib/ferret/index.rb +221 -34
- data/lib/ferret/number_tools.rb +6 -6
- data/lib/ferret/version.rb +3 -0
- data/test/{unit → long_running}/largefile/tc_largefile.rb +1 -1
- data/test/test_helper.rb +7 -2
- data/test/test_installed.rb +1 -0
- data/test/threading/thread_safety_index_test.rb +10 -1
- data/test/threading/thread_safety_read_write_test.rb +4 -7
- data/test/threading/thread_safety_test.rb +0 -0
- data/test/unit/analysis/tc_analyzer.rb +29 -27
- data/test/unit/analysis/tc_token_stream.rb +23 -16
- data/test/unit/index/tc_index.rb +116 -11
- data/test/unit/index/tc_index_reader.rb +27 -27
- data/test/unit/index/tc_index_writer.rb +10 -0
- data/test/unit/index/th_doc.rb +38 -21
- data/test/unit/search/tc_filter.rb +31 -10
- data/test/unit/search/tc_index_searcher.rb +6 -0
- data/test/unit/search/tm_searcher.rb +53 -1
- data/test/unit/store/tc_fs_store.rb +40 -2
- data/test/unit/store/tc_ram_store.rb +0 -0
- data/test/unit/store/tm_store.rb +0 -0
- data/test/unit/store/tm_store_lock.rb +7 -6
- data/test/unit/tc_field_symbol.rb +26 -0
- data/test/unit/ts_analysis.rb +0 -0
- data/test/unit/ts_index.rb +0 -0
- data/test/unit/ts_store.rb +0 -0
- data/test/unit/ts_utils.rb +0 -0
- data/test/unit/utils/tc_number_tools.rb +0 -0
- data/test/utils/content_generator.rb +226 -0
- metadata +262 -221
- data/ext/inc/lang.h +0 -48
- data/ext/inc/threading.h +0 -31
- data/ext/stem_ISO_8859_1_english.c +0 -1156
- data/ext/stem_ISO_8859_1_french.c +0 -1276
- data/ext/stem_ISO_8859_1_italian.c +0 -1091
- data/ext/stem_ISO_8859_1_norwegian.c +0 -296
- data/ext/stem_ISO_8859_1_spanish.c +0 -1119
- data/ext/stem_ISO_8859_1_swedish.c +0 -307
- data/ext/stem_UTF_8_danish.c +0 -344
- data/ext/stem_UTF_8_english.c +0 -1176
- data/ext/stem_UTF_8_french.c +0 -1296
- data/ext/stem_UTF_8_italian.c +0 -1113
- data/ext/stem_UTF_8_norwegian.c +0 -302
- data/ext/stem_UTF_8_portuguese.c +0 -1055
- data/ext/stem_UTF_8_russian.c +0 -709
- data/ext/stem_UTF_8_spanish.c +0 -1137
- data/ext/stem_UTF_8_swedish.c +0 -313
- data/lib/ferret_version.rb +0 -3
data/ext/posh.c
CHANGED
File without changes
|
data/ext/posh.h
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/**
|
2
2
|
@file posh.h
|
3
3
|
@author Brian Hook
|
4
|
-
@version 1.3.
|
4
|
+
@version 1.3.002
|
5
5
|
|
6
6
|
Header file for POSH, the Portable Open Source Harness project.
|
7
7
|
|
@@ -62,6 +62,7 @@ REVISION:
|
|
62
62
|
I've been lax about revision histories, so this starts at, um, 1.3.001.
|
63
63
|
Sorry for any inconveniences.
|
64
64
|
|
65
|
+
1.3.002 - 8/29/2006 - Removed FORCE_DOXYGEN stuff
|
65
66
|
1.3.001 - 2/23/2006 - Incorporated fix for bug reported by Bill Cary,
|
66
67
|
where I was not detecting Visual Studio
|
67
68
|
compilation on x86-64 systems. Added check for
|
@@ -522,9 +523,7 @@ Metrowerks:
|
|
522
523
|
** -----------------------------------------------------------------------------
|
523
524
|
*/
|
524
525
|
#if !defined POSH_OS_STRING
|
525
|
-
#
|
526
|
-
# define POSH_OS_EMBEDDED 1
|
527
|
-
# endif
|
526
|
+
# define POSH_OS_EMBEDDED 1
|
528
527
|
# if defined _R5900
|
529
528
|
# define POSH_OS_STRING "Sony PS2(embedded)"
|
530
529
|
# else
|
@@ -617,13 +616,6 @@ Metrowerks:
|
|
617
616
|
# define POSH_IMPORTEXPORT
|
618
617
|
#endif
|
619
618
|
|
620
|
-
#if defined FORCE_DOXYGEN
|
621
|
-
# define POSH_DLL
|
622
|
-
# define POSH_BUILDING_LIB
|
623
|
-
# undef POSH_DLL
|
624
|
-
# undef POSH_BUILDING_LIB
|
625
|
-
#endif
|
626
|
-
|
627
619
|
/*
|
628
620
|
** ----------------------------------------------------------------------------
|
629
621
|
** (Re)define POSH_PUBLIC_API export signature
|
@@ -656,10 +648,6 @@ Metrowerks:
|
|
656
648
|
# define POSH_BIG_ENDIAN 1
|
657
649
|
#endif
|
658
650
|
|
659
|
-
#if defined FORCE_DOXYGEN
|
660
|
-
# define POSH_LITTLE_ENDIAN
|
661
|
-
#endif
|
662
|
-
|
663
651
|
/*
|
664
652
|
** ----------------------------------------------------------------------------
|
665
653
|
** Cross-platform compile time assertion macro
|
@@ -709,15 +697,6 @@ typedef unsigned long long posh_u64_t;
|
|
709
697
|
#define POSH_I64_PRINTF_PREFIX "I64"
|
710
698
|
#endif
|
711
699
|
|
712
|
-
#ifdef FORCE_DOXYGEN
|
713
|
-
typedef long long posh_i64_t;
|
714
|
-
typedef unsigned long posh_u64_t;
|
715
|
-
# define POSH_64BIT_INTEGER
|
716
|
-
# define POSH_I64_PRINTF_PREFIX
|
717
|
-
# define POSH_I64(x)
|
718
|
-
# define POSH_U64(x)
|
719
|
-
#endif
|
720
|
-
|
721
700
|
/** Minimum value for a 64-bit signed integer */
|
722
701
|
#define POSH_I64_MIN POSH_I64(0x8000000000000000)
|
723
702
|
/** Maximum value for a 64-bit signed integer */
|
@@ -810,8 +789,6 @@ typedef signed char posh_i8_t;
|
|
810
789
|
** Sanity checks on expected sizes
|
811
790
|
** ----------------------------------------------------------------------------
|
812
791
|
*/
|
813
|
-
#if !defined FORCE_DOXYGEN
|
814
|
-
|
815
792
|
POSH_COMPILE_TIME_ASSERT(posh_byte_t, sizeof(posh_byte_t) == 1);
|
816
793
|
POSH_COMPILE_TIME_ASSERT(posh_u8_t, sizeof(posh_u8_t) == 1);
|
817
794
|
POSH_COMPILE_TIME_ASSERT(posh_i8_t, sizeof(posh_i8_t) == 1);
|
@@ -830,8 +807,6 @@ POSH_COMPILE_TIME_ASSERT(posh_i32_t, sizeof(posh_i32_t) == 4);
|
|
830
807
|
POSH_COMPILE_TIME_ASSERT(posh_i64_t, sizeof(posh_i64_t) == 8);
|
831
808
|
#endif
|
832
809
|
|
833
|
-
#endif
|
834
|
-
|
835
810
|
/*
|
836
811
|
** ----------------------------------------------------------------------------
|
837
812
|
** 64-bit pointer support
|
@@ -851,7 +826,7 @@ POSH_COMPILE_TIME_ASSERT(posh_i32_t, sizeof(posh_i32_t) == 4);
|
|
851
826
|
|
852
827
|
#if defined POSH_64BIT_POINTER
|
853
828
|
POSH_COMPILE_TIME_ASSERT( posh_64bit_pointer, sizeof( void * ) == 8 );
|
854
|
-
#
|
829
|
+
#else
|
855
830
|
/* if this assertion is hit then you're on a system that either has 64-bit
|
856
831
|
addressing and we didn't catch it, or you're on a system with 16-bit
|
857
832
|
pointers. In the latter case, POSH doesn't actually care, we're just
|
@@ -863,10 +838,6 @@ POSH_COMPILE_TIME_ASSERT(posh_i32_t, sizeof(posh_i32_t) == 4);
|
|
863
838
|
POSH_COMPILE_TIME_ASSERT( posh_32bit_pointer, sizeof( void * ) == 4 );
|
864
839
|
#endif
|
865
840
|
|
866
|
-
#if defined FORCE_DOXYGEN
|
867
|
-
# define POSH_64BIT_POINTER
|
868
|
-
#endif
|
869
|
-
|
870
841
|
/*
|
871
842
|
** ----------------------------------------------------------------------------
|
872
843
|
** POSH Utility Functions
|
@@ -907,11 +878,6 @@ double POSH_ReadDoubleFromBig( const void *src );
|
|
907
878
|
*/
|
908
879
|
#endif /* !defined POSH_NO_FLOAT */
|
909
880
|
|
910
|
-
#if defined FORCE_DOXYGEN
|
911
|
-
# define POSH_NO_FLOAT
|
912
|
-
# undef POSH_NO_FLOAT
|
913
|
-
#endif
|
914
|
-
|
915
881
|
extern posh_u16_t POSH_SwapU16( posh_u16_t u );
|
916
882
|
extern posh_i16_t POSH_SwapI16( posh_i16_t u );
|
917
883
|
extern posh_u32_t POSH_SwapU32( posh_u32_t u );
|
data/ext/priorityqueue.c
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
#include <string.h>
|
2
2
|
#include "priorityqueue.h"
|
3
|
+
#include "internal.h"
|
3
4
|
|
4
5
|
#define START_CAPA 127
|
5
6
|
|
6
|
-
PriorityQueue *pq_new(int capa,
|
7
|
-
bool (*less_than)(const void *p1, const void *p2),
|
8
|
-
void (*free_elem)(void *elem))
|
7
|
+
PriorityQueue *pq_new(int capa, lt_ft less_than, free_ft free_elem)
|
9
8
|
{
|
10
9
|
PriorityQueue *pq = ALLOC(PriorityQueue);
|
11
10
|
pq->size = 0;
|
@@ -111,22 +110,23 @@ void pq_push(PriorityQueue *pq, void *elem)
|
|
111
110
|
pq_up(pq);
|
112
111
|
}
|
113
112
|
|
114
|
-
|
113
|
+
PriorityQueueInsertEnum pq_insert(PriorityQueue *pq,
|
114
|
+
void *elem)
|
115
115
|
{
|
116
116
|
if (pq->size < pq->capa) {
|
117
117
|
pq_push(pq, elem);
|
118
118
|
return PQ_ADDED;
|
119
119
|
}
|
120
|
-
|
120
|
+
|
121
|
+
if (pq->size > 0 && pq->less_than_i(pq->heap[1], elem)) {
|
121
122
|
pq->free_elem_i(pq->heap[1]);
|
122
123
|
pq->heap[1] = elem;
|
123
124
|
pq_down(pq);
|
124
125
|
return PQ_INSERTED;
|
125
126
|
}
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
}
|
127
|
+
|
128
|
+
pq->free_elem_i(elem);
|
129
|
+
return PQ_DROPPED;
|
130
130
|
}
|
131
131
|
|
132
132
|
void *pq_top(PriorityQueue *pq)
|
@@ -144,8 +144,6 @@ void *pq_pop(PriorityQueue *pq)
|
|
144
144
|
pq_down(pq); /* adjust heap */
|
145
145
|
return result;
|
146
146
|
}
|
147
|
-
|
148
|
-
return NULL;
|
149
|
-
}
|
147
|
+
return NULL;
|
150
148
|
}
|
151
149
|
|
data/ext/priorityqueue.h
CHANGED
@@ -1,23 +1,27 @@
|
|
1
1
|
#ifndef FRT_PRIORITYQUEUE_H
|
2
2
|
#define FRT_PRIORITYQUEUE_H
|
3
3
|
|
4
|
+
#ifdef __cplusplus
|
5
|
+
extern "C" {
|
6
|
+
#endif
|
7
|
+
|
4
8
|
#include "global.h"
|
5
9
|
|
6
|
-
typedef bool(*
|
10
|
+
typedef bool (*frt_lt_ft)(const void *p1, const void *p2);
|
7
11
|
|
8
12
|
/**
|
9
13
|
* A PriorityQueue has a fixed size and contains a less_than function and a
|
10
14
|
* free_elem function specific to the data type to be stored in the queue.
|
11
15
|
*/
|
12
|
-
typedef struct
|
16
|
+
typedef struct FrtPriorityQueue
|
13
17
|
{
|
14
18
|
int size;
|
15
19
|
int capa;
|
16
20
|
int mem_capa;
|
17
21
|
void **heap;
|
18
|
-
|
19
|
-
|
20
|
-
}
|
22
|
+
frt_lt_ft less_than_i;
|
23
|
+
frt_free_ft free_elem_i;
|
24
|
+
} FrtPriorityQueue;
|
21
25
|
|
22
26
|
/**
|
23
27
|
* Create a new PriorityQueue setting the less_than and free_elem for this
|
@@ -31,9 +35,9 @@ typedef struct PriorityQueue
|
|
31
35
|
* when it is destroyed or there is insertion overflow
|
32
36
|
* @return a newly allocated PriorityQueue
|
33
37
|
*/
|
34
|
-
extern
|
35
|
-
|
36
|
-
|
38
|
+
extern FrtPriorityQueue *frt_pq_new(int capa,
|
39
|
+
frt_lt_ft less_than,
|
40
|
+
frt_free_ft free_elem);
|
37
41
|
|
38
42
|
/**
|
39
43
|
* Allocate a clone of the PriorityQueue. This can be used if you want to scan
|
@@ -43,7 +47,7 @@ extern PriorityQueue *pq_new(int capa,
|
|
43
47
|
* @param pq the priority queue to clone
|
44
48
|
* @return a clone of the original priority queue
|
45
49
|
*/
|
46
|
-
extern
|
50
|
+
extern FrtPriorityQueue *frt_pq_clone(FrtPriorityQueue *pq);
|
47
51
|
|
48
52
|
/**
|
49
53
|
* Clear all elements from the PriorityQueue and reset the size to 0. When
|
@@ -52,7 +56,7 @@ extern PriorityQueue *pq_clone(PriorityQueue *pq);
|
|
52
56
|
*
|
53
57
|
* @param self the PriorityQueue to clear
|
54
58
|
*/
|
55
|
-
extern void
|
59
|
+
extern void frt_pq_clear(FrtPriorityQueue *self);
|
56
60
|
|
57
61
|
/**
|
58
62
|
* Free the memory allocated to the PriorityQueue. This function does nothing
|
@@ -61,7 +65,7 @@ extern void pq_clear(PriorityQueue *self);
|
|
61
65
|
*
|
62
66
|
* @param self the PriorityQueue to free
|
63
67
|
*/
|
64
|
-
extern void
|
68
|
+
extern void frt_pq_free(FrtPriorityQueue *self);
|
65
69
|
|
66
70
|
/**
|
67
71
|
* Destroy the PriorityQueue, freeing all memory allocated to it and also
|
@@ -70,7 +74,7 @@ extern void pq_free(PriorityQueue *self);
|
|
70
74
|
*
|
71
75
|
* @param the PriorityQueue to destroy
|
72
76
|
*/
|
73
|
-
extern void
|
77
|
+
extern void frt_pq_destroy(FrtPriorityQueue *self);
|
74
78
|
|
75
79
|
/**
|
76
80
|
* Reorder the PriorityQueue after the top element has been modified. This
|
@@ -80,7 +84,7 @@ extern void pq_destroy(PriorityQueue *self);
|
|
80
84
|
*
|
81
85
|
* @param self the PriorityQueue to reorder
|
82
86
|
*/
|
83
|
-
extern void
|
87
|
+
extern void frt_pq_down(FrtPriorityQueue *self);
|
84
88
|
|
85
89
|
/**
|
86
90
|
* Add another element to the PriorityQueue. This method should only be used
|
@@ -92,11 +96,14 @@ extern void pq_down(PriorityQueue *self);
|
|
92
96
|
* @param self the PriorityQueue to add the element to
|
93
97
|
* @param elem the element to add to the PriorityQueue
|
94
98
|
*/
|
95
|
-
extern void
|
99
|
+
extern void frt_pq_push(FrtPriorityQueue *self, void *elem);
|
100
|
+
|
101
|
+
typedef enum {
|
102
|
+
FRT_PQ_DROPPED = 0,
|
103
|
+
FRT_PQ_ADDED,
|
104
|
+
FRT_PQ_INSERTED
|
105
|
+
} FrtPriorityQueueInsertEnum;
|
96
106
|
|
97
|
-
#define PQ_DROPPED 0
|
98
|
-
#define PQ_ADDED 1
|
99
|
-
#define PQ_INSERTED 2
|
100
107
|
/**
|
101
108
|
* Add another element to the PriorityQueue. Unlike pq_push, this method
|
102
109
|
* handles insertion overflow. That is, when you insert more elements than the
|
@@ -114,7 +121,8 @@ extern void pq_push(PriorityQueue *self, void *elem);
|
|
114
121
|
* element was dropped and destroyed
|
115
122
|
* </pre>
|
116
123
|
*/
|
117
|
-
extern
|
124
|
+
extern FrtPriorityQueueInsertEnum frt_pq_insert(FrtPriorityQueue *self,
|
125
|
+
void *elem);
|
118
126
|
|
119
127
|
/**
|
120
128
|
* Get the top element in the PriorityQueue.
|
@@ -122,7 +130,7 @@ extern int pq_insert(PriorityQueue *self, void *elem);
|
|
122
130
|
* @param self the PriorityQueue to get the top from
|
123
131
|
* @return the top element in the PriorityQueue
|
124
132
|
*/
|
125
|
-
extern void *
|
133
|
+
extern void *frt_pq_top(FrtPriorityQueue *self);
|
126
134
|
|
127
135
|
/**
|
128
136
|
* Remove and return the top element in the PriorityQueue.
|
@@ -130,7 +138,7 @@ extern void *pq_top(PriorityQueue *self);
|
|
130
138
|
* @param self the PriorityQueue to get the top from
|
131
139
|
* @return the top element in the PriorityQueue
|
132
140
|
*/
|
133
|
-
extern void *
|
141
|
+
extern void *frt_pq_pop(FrtPriorityQueue *self);
|
134
142
|
|
135
143
|
/**
|
136
144
|
* Return true if the PriorityQueue is full.
|
@@ -138,6 +146,10 @@ extern void *pq_pop(PriorityQueue *self);
|
|
138
146
|
* @param self the PriorityQueue to test
|
139
147
|
* @return true if the PriorityQueue is full.
|
140
148
|
*/
|
141
|
-
#define
|
149
|
+
#define frt_pq_full(pq) ((pq)->size == (pq)->capa)
|
150
|
+
|
151
|
+
#ifdef __cplusplus
|
152
|
+
} // extern "C"
|
153
|
+
#endif
|
142
154
|
|
143
155
|
#endif
|
data/ext/q_boolean.c
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#include <string.h>
|
2
2
|
#include "search.h"
|
3
3
|
#include "array.h"
|
4
|
+
#include "internal.h"
|
4
5
|
|
5
6
|
#define BQ(query) ((BooleanQuery *)(query))
|
6
7
|
#define BW(weight) ((BooleanWeight *)(weight))
|
@@ -110,7 +111,7 @@ static bool dssc_advance_after_current(Scorer *self)
|
|
110
111
|
break;
|
111
112
|
}
|
112
113
|
}
|
113
|
-
top = pq_top(scorer_queue);
|
114
|
+
top = (Scorer *)pq_top(scorer_queue);
|
114
115
|
if (top->doc != self->doc) {
|
115
116
|
/* All remaining subscorers are after self->doc */
|
116
117
|
break;
|
@@ -161,7 +162,7 @@ static bool dssc_skip_to(Scorer *self, int doc_num)
|
|
161
162
|
doc_num = self->doc + 1;
|
162
163
|
}
|
163
164
|
while (true) {
|
164
|
-
Scorer *top = pq_top(scorer_queue);
|
165
|
+
Scorer *top = (Scorer *)pq_top(scorer_queue);
|
165
166
|
if (top->doc >= doc_num) {
|
166
167
|
return dssc_advance_after_current(self);
|
167
168
|
}
|
@@ -280,7 +281,19 @@ typedef struct ConjunctionScorer
|
|
280
281
|
|
281
282
|
static void csc_sort_scorers(ConjunctionScorer *csc)
|
282
283
|
{
|
283
|
-
|
284
|
+
int i;
|
285
|
+
Scorer *current = csc->sub_scorers[0], *previous;
|
286
|
+
for (i = 1; i < csc->ss_cnt; i++) {
|
287
|
+
previous = current;
|
288
|
+
current = csc->sub_scorers[i];
|
289
|
+
if (previous->doc > current->doc) {
|
290
|
+
if (!current->skip_to(current, previous->doc)) {
|
291
|
+
csc->more = false;
|
292
|
+
return;
|
293
|
+
}
|
294
|
+
}
|
295
|
+
}
|
296
|
+
/*qsort(csc->sub_scorers, csc->ss_cnt, sizeof(Scorer *), &scorer_doc_cmp);*/
|
284
297
|
csc->first_idx = 0;
|
285
298
|
}
|
286
299
|
|
@@ -371,7 +384,7 @@ static bool csc_skip_to(Scorer *self, int doc_num)
|
|
371
384
|
bool more = csc->more;
|
372
385
|
|
373
386
|
if (csc->first_time) {
|
374
|
-
csc_init(self,
|
387
|
+
csc_init(self, false);
|
375
388
|
}
|
376
389
|
|
377
390
|
for (i = 0; i < sub_sc_cnt; i++) {
|
@@ -1255,7 +1268,7 @@ static Weight *bw_new(Query *query, Searcher *searcher)
|
|
1255
1268
|
*
|
1256
1269
|
***************************************************************************/
|
1257
1270
|
|
1258
|
-
void bc_set_occur(BooleanClause *self,
|
1271
|
+
void bc_set_occur(BooleanClause *self, BCType occur)
|
1259
1272
|
{
|
1260
1273
|
self->occur = occur;
|
1261
1274
|
switch (occur) {
|
@@ -1295,7 +1308,7 @@ static int bc_eq(BooleanClause *self, BooleanClause *o)
|
|
1295
1308
|
return ((self->occur == o->occur) && q_eq(self->query, o->query));
|
1296
1309
|
}
|
1297
1310
|
|
1298
|
-
BooleanClause *bc_new(Query *query,
|
1311
|
+
BooleanClause *bc_new(Query *query, BCType occur)
|
1299
1312
|
{
|
1300
1313
|
BooleanClause *self = ALLOC(BooleanClause);
|
1301
1314
|
self->ref_cnt = 1;
|
@@ -1402,7 +1415,7 @@ static void bq_extract_terms(Query *self, HashSet *terms)
|
|
1402
1415
|
}
|
1403
1416
|
}
|
1404
1417
|
|
1405
|
-
static char *bq_to_s(Query *self,
|
1418
|
+
static char *bq_to_s(Query *self, Symbol field)
|
1406
1419
|
{
|
1407
1420
|
int i;
|
1408
1421
|
BooleanClause *clause;
|
@@ -1585,7 +1598,7 @@ BooleanClause *bq_add_clause(Query *self, BooleanClause *bc)
|
|
1585
1598
|
return bq_add_clause_nr(self, bc);
|
1586
1599
|
}
|
1587
1600
|
|
1588
|
-
BooleanClause *bq_add_query_nr(Query *self, Query *sub_query,
|
1601
|
+
BooleanClause *bq_add_query_nr(Query *self, Query *sub_query, BCType occur)
|
1589
1602
|
{
|
1590
1603
|
BooleanClause *bc;
|
1591
1604
|
if (BQ(self)->clause_cnt >= BQ(self)->max_clause_cnt) {
|
@@ -1600,7 +1613,7 @@ BooleanClause *bq_add_query_nr(Query *self, Query *sub_query, enum BC_TYPE occur
|
|
1600
1613
|
return bc;
|
1601
1614
|
}
|
1602
1615
|
|
1603
|
-
BooleanClause *bq_add_query(Query *self, Query *sub_query,
|
1616
|
+
BooleanClause *bq_add_query(Query *self, Query *sub_query, BCType occur)
|
1604
1617
|
{
|
1605
1618
|
REF(sub_query);
|
1606
1619
|
return bq_add_query_nr(self, sub_query, occur);
|
data/ext/q_const_score.c
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#include "search.h"
|
2
2
|
#include <string.h>
|
3
|
+
#include "internal.h"
|
3
4
|
|
4
5
|
/***************************************************************************
|
5
6
|
*
|
@@ -107,12 +108,12 @@ static Weight *csw_new(Query *query, Searcher *searcher)
|
|
107
108
|
*
|
108
109
|
***************************************************************************/
|
109
110
|
|
110
|
-
static char *csq_to_s(Query *self,
|
111
|
+
static char *csq_to_s(Query *self, Symbol default_field)
|
111
112
|
{
|
112
113
|
Filter *filter = CScQ(self)->filter;
|
113
114
|
char *filter_str = filter->to_s(filter);
|
114
115
|
char *buffer;
|
115
|
-
(void)
|
116
|
+
(void)default_field;
|
116
117
|
if (self->boost == 1.0) {
|
117
118
|
buffer = strfmt("ConstantScore(%s)", filter_str);
|
118
119
|
}
|
data/ext/q_filtered_query.c
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#include "search.h"
|
2
2
|
#include <string.h>
|
3
|
+
#include "internal.h"
|
3
4
|
|
4
5
|
/***************************************************************************
|
5
6
|
*
|
@@ -17,13 +18,13 @@ typedef struct FilteredQueryScorer
|
|
17
18
|
BitVector *bv;
|
18
19
|
} FilteredQueryScorer;
|
19
20
|
|
20
|
-
float fqsc_score(Scorer *self)
|
21
|
+
static float fqsc_score(Scorer *self)
|
21
22
|
{
|
22
23
|
Scorer *sub_sc = FQSc(self)->sub_scorer;
|
23
24
|
return sub_sc->score(sub_sc);
|
24
25
|
}
|
25
26
|
|
26
|
-
bool fqsc_next(Scorer *self)
|
27
|
+
static bool fqsc_next(Scorer *self)
|
27
28
|
{
|
28
29
|
Scorer *sub_sc = FQSc(self)->sub_scorer;
|
29
30
|
BitVector *bv = FQSc(self)->bv;
|
@@ -34,33 +35,35 @@ bool fqsc_next(Scorer *self)
|
|
34
35
|
return false;
|
35
36
|
}
|
36
37
|
|
37
|
-
bool fqsc_skip_to(Scorer *self, int doc_num)
|
38
|
+
static bool fqsc_skip_to(Scorer *self, int doc_num)
|
38
39
|
{
|
39
40
|
Scorer *sub_sc = FQSc(self)->sub_scorer;
|
40
41
|
BitVector *bv = FQSc(self)->bv;
|
41
42
|
if (sub_sc->skip_to(sub_sc, doc_num)) {
|
42
|
-
self->doc = sub_sc->doc;
|
43
43
|
do {
|
44
|
-
|
44
|
+
self->doc = sub_sc->doc;
|
45
|
+
if (bv_get(bv, self->doc)) {
|
46
|
+
return true;
|
47
|
+
}
|
45
48
|
} while (sub_sc->next(sub_sc));
|
46
49
|
}
|
47
50
|
return false;
|
48
51
|
}
|
49
52
|
|
50
|
-
Explanation *fqsc_explain(Scorer *self, int doc_num)
|
53
|
+
static Explanation *fqsc_explain(Scorer *self, int doc_num)
|
51
54
|
{
|
52
55
|
Scorer *sub_sc = FQSc(self)->sub_scorer;
|
53
56
|
return sub_sc->explain(sub_sc, doc_num);
|
54
57
|
}
|
55
58
|
|
56
|
-
void fqsc_destroy(Scorer *self)
|
59
|
+
static void fqsc_destroy(Scorer *self)
|
57
60
|
{
|
58
61
|
FilteredQueryScorer *fqsc = FQSc(self);
|
59
62
|
fqsc->sub_scorer->destroy(fqsc->sub_scorer);
|
60
63
|
scorer_destroy_i(self);
|
61
64
|
}
|
62
65
|
|
63
|
-
Scorer *fqsc_new(Scorer *scorer, BitVector *bv, Similarity *sim)
|
66
|
+
static Scorer *fqsc_new(Scorer *scorer, BitVector *bv, Similarity *sim)
|
64
67
|
{
|
65
68
|
Scorer *self = scorer_new(FilteredQueryScorer, sim);
|
66
69
|
|
@@ -161,11 +164,11 @@ static Weight *fqw_new(Query *query, Weight *sub_weight, Similarity *sim)
|
|
161
164
|
*
|
162
165
|
***************************************************************************/
|
163
166
|
|
164
|
-
static char *fq_to_s(Query *self,
|
167
|
+
static char *fq_to_s(Query *self, Symbol default_field)
|
165
168
|
{
|
166
169
|
FilteredQuery *fq = FQQ(self);
|
167
170
|
char *filter_str = fq->filter->to_s(fq->filter);
|
168
|
-
char *query_str = fq->query->to_s(fq->query,
|
171
|
+
char *query_str = fq->query->to_s(fq->query, default_field);
|
169
172
|
char *buffer;
|
170
173
|
if (self->boost == 1.0) {
|
171
174
|
buffer = strfmt("FilteredQuery(query:%s, filter:%s)",
|
@@ -179,14 +182,14 @@ static char *fq_to_s(Query *self, const char *field)
|
|
179
182
|
return buffer;;
|
180
183
|
}
|
181
184
|
|
182
|
-
void fq_destroy(Query *self)
|
185
|
+
static void fq_destroy(Query *self)
|
183
186
|
{
|
184
187
|
filt_deref(FQQ(self)->filter);
|
185
188
|
q_deref(FQQ(self)->query);
|
186
189
|
q_destroy_i(self);
|
187
190
|
}
|
188
191
|
|
189
|
-
Weight *fq_new_weight(Query *self, Searcher *searcher)
|
192
|
+
static Weight *fq_new_weight(Query *self, Searcher *searcher)
|
190
193
|
{
|
191
194
|
Query *sub_query = FQQ(self)->query;
|
192
195
|
return fqw_new(self, q_weight(sub_query, searcher),
|