ferret 0.11.6 → 0.11.8.4
Sign up to get free protection for your applications and to get access to all the features.
- 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/index.h
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
#ifndef FRT_INDEX_H
|
2
2
|
#define FRT_INDEX_H
|
3
3
|
|
4
|
+
#ifdef __cplusplus
|
5
|
+
extern "C" {
|
6
|
+
#endif
|
7
|
+
|
4
8
|
#include "global.h"
|
5
9
|
#include "document.h"
|
6
10
|
#include "analysis.h"
|
@@ -12,17 +16,19 @@
|
|
12
16
|
#include "bitvector.h"
|
13
17
|
#include "priorityqueue.h"
|
14
18
|
|
15
|
-
typedef struct
|
16
|
-
typedef struct
|
17
|
-
typedef struct
|
19
|
+
typedef struct FrtIndexReader FrtIndexReader;
|
20
|
+
typedef struct FrtMultiReader FrtMultiReader;
|
21
|
+
typedef struct FrtDeleter FrtDeleter;
|
22
|
+
|
23
|
+
extern bool frt_file_name_filter_is_index_file(const char *file_name, bool include_locks);
|
18
24
|
|
19
25
|
/****************************************************************************
|
20
26
|
*
|
21
|
-
*
|
27
|
+
* FrtConfig
|
22
28
|
*
|
23
29
|
****************************************************************************/
|
24
30
|
|
25
|
-
typedef struct
|
31
|
+
typedef struct FrtConfig
|
26
32
|
{
|
27
33
|
int chunk_size;
|
28
34
|
int max_buffer_memory;
|
@@ -33,205 +39,209 @@ typedef struct Config
|
|
33
39
|
int max_merge_docs;
|
34
40
|
int max_field_length;
|
35
41
|
bool use_compound_file;
|
36
|
-
}
|
42
|
+
} FrtConfig;
|
37
43
|
|
38
|
-
extern const
|
44
|
+
extern const FrtConfig frt_default_config;
|
39
45
|
|
40
46
|
/***************************************************************************
|
41
47
|
*
|
42
|
-
*
|
48
|
+
* FrtCacheObject
|
43
49
|
*
|
44
50
|
***************************************************************************/
|
45
51
|
|
46
|
-
typedef struct
|
47
|
-
|
48
|
-
|
52
|
+
typedef struct FrtCacheObject {
|
53
|
+
FrtHash *ref_tab1;
|
54
|
+
FrtHash *ref_tab2;
|
49
55
|
void *ref1;
|
50
56
|
void *ref2;
|
51
57
|
void *obj;
|
52
58
|
void (*destroy)(void *p);
|
53
|
-
}
|
59
|
+
} FrtCacheObject;
|
54
60
|
|
55
|
-
extern void
|
56
|
-
extern
|
57
|
-
|
58
|
-
|
61
|
+
extern void frt_cache_destroy(FrtCacheObject *co);
|
62
|
+
extern FrtCacheObject *frt_co_create(FrtHash *ref_tab1,
|
63
|
+
FrtHash *ref_tab2,
|
64
|
+
void *ref1, void *ref2, frt_free_ft destroy, void *obj);
|
65
|
+
extern FrtHash *frt_co_hash_create();
|
59
66
|
|
60
67
|
/****************************************************************************
|
61
68
|
*
|
62
|
-
*
|
69
|
+
* FrtFieldInfo
|
63
70
|
*
|
64
71
|
****************************************************************************/
|
65
72
|
|
66
|
-
enum
|
73
|
+
typedef enum
|
67
74
|
{
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
};
|
75
|
+
FRT_STORE_NO = 0,
|
76
|
+
FRT_STORE_YES = 1,
|
77
|
+
FRT_STORE_COMPRESS = 2
|
78
|
+
} FrtStoreValue;
|
72
79
|
|
73
|
-
enum
|
80
|
+
typedef enum
|
74
81
|
{
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
};
|
82
|
+
FRT_INDEX_NO = 0,
|
83
|
+
FRT_INDEX_UNTOKENIZED = 1,
|
84
|
+
FRT_INDEX_YES = 3,
|
85
|
+
FRT_INDEX_UNTOKENIZED_OMIT_NORMS = 5,
|
86
|
+
FRT_INDEX_YES_OMIT_NORMS = 7
|
87
|
+
} FrtIndexValue;
|
81
88
|
|
82
|
-
enum
|
89
|
+
typedef enum
|
83
90
|
{
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
};
|
91
|
+
FRT_TERM_VECTOR_NO = 0,
|
92
|
+
FRT_TERM_VECTOR_YES = 1,
|
93
|
+
FRT_TERM_VECTOR_WITH_POSITIONS = 3,
|
94
|
+
FRT_TERM_VECTOR_WITH_OFFSETS = 5,
|
95
|
+
FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS = 7
|
96
|
+
} FrtTermVectorValue;
|
90
97
|
|
91
|
-
#define
|
92
|
-
#define
|
93
|
-
#define
|
94
|
-
#define
|
95
|
-
#define
|
96
|
-
#define
|
97
|
-
#define
|
98
|
-
#define
|
98
|
+
#define FRT_FI_IS_STORED_BM 0x001
|
99
|
+
#define FRT_FI_IS_COMPRESSED_BM 0x002
|
100
|
+
#define FRT_FI_IS_INDEXED_BM 0x004
|
101
|
+
#define FRT_FI_IS_TOKENIZED_BM 0x008
|
102
|
+
#define FRT_FI_OMIT_NORMS_BM 0x010
|
103
|
+
#define FRT_FI_STORE_TERM_VECTOR_BM 0x020
|
104
|
+
#define FRT_FI_STORE_POSITIONS_BM 0x040
|
105
|
+
#define FRT_FI_STORE_OFFSETS_BM 0x080
|
99
106
|
|
100
|
-
typedef struct
|
107
|
+
typedef struct FrtFieldInfo
|
101
108
|
{
|
102
|
-
|
109
|
+
FrtSymbol name;
|
103
110
|
float boost;
|
104
111
|
unsigned int bits;
|
105
112
|
int number;
|
106
113
|
int ref_cnt;
|
107
|
-
}
|
108
|
-
|
109
|
-
extern
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
extern char *
|
114
|
-
extern void
|
115
|
-
|
116
|
-
#define fi_is_stored(fi) (((fi)->bits &
|
117
|
-
#define fi_is_compressed(fi) (((fi)->bits &
|
118
|
-
#define fi_is_indexed(fi) (((fi)->bits &
|
119
|
-
#define fi_is_tokenized(fi) (((fi)->bits &
|
120
|
-
#define fi_omit_norms(fi) (((fi)->bits &
|
121
|
-
#define fi_store_term_vector(fi) (((fi)->bits &
|
122
|
-
#define fi_store_positions(fi) (((fi)->bits &
|
123
|
-
#define fi_store_offsets(fi) (((fi)->bits &
|
114
|
+
} FrtFieldInfo;
|
115
|
+
|
116
|
+
extern FrtFieldInfo *frt_fi_new(FrtSymbol name,
|
117
|
+
FrtStoreValue store,
|
118
|
+
FrtIndexValue index,
|
119
|
+
FrtTermVectorValue term_vector);
|
120
|
+
extern char *frt_fi_to_s(FrtFieldInfo *fi);
|
121
|
+
extern void frt_fi_deref(FrtFieldInfo *fi);
|
122
|
+
|
123
|
+
#define fi_is_stored(fi) (((fi)->bits & FRT_FI_IS_STORED_BM) != 0)
|
124
|
+
#define fi_is_compressed(fi) (((fi)->bits & FRT_FI_IS_COMPRESSED_BM) != 0)
|
125
|
+
#define fi_is_indexed(fi) (((fi)->bits & FRT_FI_IS_INDEXED_BM) != 0)
|
126
|
+
#define fi_is_tokenized(fi) (((fi)->bits & FRT_FI_IS_TOKENIZED_BM) != 0)
|
127
|
+
#define fi_omit_norms(fi) (((fi)->bits & FRT_FI_OMIT_NORMS_BM) != 0)
|
128
|
+
#define fi_store_term_vector(fi) (((fi)->bits & FRT_FI_STORE_TERM_VECTOR_BM) != 0)
|
129
|
+
#define fi_store_positions(fi) (((fi)->bits & FRT_FI_STORE_POSITIONS_BM) != 0)
|
130
|
+
#define fi_store_offsets(fi) (((fi)->bits & FRT_FI_STORE_OFFSETS_BM) != 0)
|
124
131
|
#define fi_has_norms(fi)\
|
125
|
-
(((fi)->bits & (
|
132
|
+
(((fi)->bits & (FRT_FI_OMIT_NORMS_BM|FRT_FI_IS_INDEXED_BM)) == FRT_FI_IS_INDEXED_BM)
|
126
133
|
|
127
134
|
/****************************************************************************
|
128
135
|
*
|
129
|
-
*
|
136
|
+
* FrtFieldInfos
|
130
137
|
*
|
131
138
|
****************************************************************************/
|
132
139
|
|
133
140
|
#define FIELD_INFOS_INIT_CAPA 4
|
134
141
|
/* carry changes over to dummy_fis in test/test_segments.c */
|
135
|
-
typedef struct
|
142
|
+
typedef struct FrtFieldInfos
|
136
143
|
{
|
137
|
-
|
138
|
-
|
139
|
-
|
144
|
+
FrtStoreValue store;
|
145
|
+
FrtIndexValue index;
|
146
|
+
FrtTermVectorValue term_vector;
|
140
147
|
int size;
|
141
148
|
int capa;
|
142
|
-
|
143
|
-
|
149
|
+
FrtFieldInfo **fields;
|
150
|
+
FrtHash *field_dict;
|
144
151
|
int ref_cnt;
|
145
|
-
}
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
extern
|
150
|
-
extern
|
151
|
-
extern
|
152
|
-
extern
|
153
|
-
extern
|
154
|
-
|
155
|
-
extern void
|
152
|
+
} FrtFieldInfos;
|
153
|
+
|
154
|
+
FrtFieldInfos *frt_fis_new(FrtStoreValue store, FrtIndexValue index,
|
155
|
+
FrtTermVectorValue term_vector);
|
156
|
+
extern FrtFieldInfo *frt_fis_add_field(FrtFieldInfos *fis, FrtFieldInfo *fi);
|
157
|
+
extern FrtFieldInfo *frt_fis_get_field(FrtFieldInfos *fis, FrtSymbol name);
|
158
|
+
extern int frt_fis_get_field_num(FrtFieldInfos *fis, FrtSymbol name);
|
159
|
+
extern FrtFieldInfo *frt_fis_by_number(FrtFieldInfos *fis, int num);
|
160
|
+
extern FrtFieldInfo *frt_fis_get_or_add_field(FrtFieldInfos *fis,
|
161
|
+
FrtSymbol name);
|
162
|
+
extern void frt_fis_write(FrtFieldInfos *fis, FrtOutStream *os);
|
163
|
+
extern FrtFieldInfos *frt_fis_read(FrtInStream *is);
|
164
|
+
extern char *frt_fis_to_s(FrtFieldInfos *fis);
|
165
|
+
extern void frt_fis_deref(FrtFieldInfos *fis);
|
156
166
|
|
157
167
|
/****************************************************************************
|
158
168
|
*
|
159
|
-
*
|
169
|
+
* FrtSegmentInfo
|
160
170
|
*
|
161
171
|
****************************************************************************/
|
162
172
|
|
163
|
-
#define
|
164
|
-
#define
|
173
|
+
#define FRT_SEGMENT_NAME_MAX_LENGTH 100
|
174
|
+
#define FRT_SEGMENTS_FILE_NAME "segments"
|
165
175
|
|
166
|
-
typedef struct
|
176
|
+
typedef struct FrtSegmentInfo
|
167
177
|
{
|
168
178
|
int ref_cnt;
|
169
179
|
char *name;
|
170
|
-
|
180
|
+
FrtStore *store;
|
171
181
|
int doc_cnt;
|
172
182
|
int del_gen;
|
173
183
|
int *norm_gens;
|
174
184
|
int norm_gens_size;
|
175
185
|
bool use_compound_file;
|
176
|
-
}
|
186
|
+
} FrtSegmentInfo;
|
177
187
|
|
178
|
-
extern
|
179
|
-
extern void
|
180
|
-
extern bool
|
181
|
-
extern bool
|
182
|
-
extern bool
|
183
|
-
extern void
|
188
|
+
extern FrtSegmentInfo *frt_si_new(char *name, int doc_cnt, FrtStore *store);
|
189
|
+
extern void frt_si_deref(FrtSegmentInfo *si);
|
190
|
+
extern bool frt_si_has_deletions(FrtSegmentInfo *si);
|
191
|
+
extern bool frt_si_uses_compound_file(FrtSegmentInfo *si);
|
192
|
+
extern bool frt_si_has_separate_norms(FrtSegmentInfo *si);
|
193
|
+
extern void frt_si_advance_norm_gen(FrtSegmentInfo *si, int field_num);
|
184
194
|
|
185
195
|
/****************************************************************************
|
186
196
|
*
|
187
|
-
*
|
197
|
+
* FrtSegmentInfos
|
188
198
|
*
|
189
199
|
****************************************************************************/
|
190
200
|
|
191
|
-
typedef struct
|
201
|
+
typedef struct FrtSegmentInfos
|
192
202
|
{
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
203
|
+
FrtFieldInfos *fis;
|
204
|
+
frt_u64 counter;
|
205
|
+
frt_u64 version;
|
206
|
+
frt_i64 generation;
|
207
|
+
frt_i32 format;
|
208
|
+
FrtStore *store;
|
209
|
+
FrtSegmentInfo **segs;
|
200
210
|
int size;
|
201
211
|
int capa;
|
202
|
-
}
|
203
|
-
|
204
|
-
extern char *
|
205
|
-
|
206
|
-
extern
|
207
|
-
extern
|
208
|
-
extern
|
209
|
-
extern void
|
210
|
-
extern void
|
211
|
-
extern void
|
212
|
-
extern
|
213
|
-
extern void
|
214
|
-
extern
|
215
|
-
extern void
|
216
|
-
extern
|
217
|
-
extern char *
|
218
|
-
extern void
|
212
|
+
} FrtSegmentInfos;
|
213
|
+
|
214
|
+
extern char *frt_fn_for_generation(char *buf, char *base, char *ext, frt_i64 gen);
|
215
|
+
|
216
|
+
extern FrtSegmentInfos *frt_sis_new(FrtFieldInfos *fis);
|
217
|
+
extern FrtSegmentInfo *frt_sis_new_segment(FrtSegmentInfos *sis, int dcnt, FrtStore *store);
|
218
|
+
extern FrtSegmentInfo *frt_sis_add_si(FrtSegmentInfos *sis, FrtSegmentInfo *si);
|
219
|
+
extern void frt_sis_del_at(FrtSegmentInfos *sis, int at);
|
220
|
+
extern void frt_sis_del_from_to(FrtSegmentInfos *sis, int from, int to);
|
221
|
+
extern void frt_sis_clear(FrtSegmentInfos *sis);
|
222
|
+
extern FrtSegmentInfos *frt_sis_read(FrtStore *store);
|
223
|
+
extern void frt_sis_write(FrtSegmentInfos *sis, FrtStore *store, FrtDeleter *deleter);
|
224
|
+
extern frt_u64 frt_sis_read_current_version(FrtStore *store);
|
225
|
+
extern void frt_sis_destroy(FrtSegmentInfos *sis);
|
226
|
+
extern frt_i64 frt_sis_current_segment_generation(FrtStore *store);
|
227
|
+
extern char *frt_sis_curr_seg_file_name(char *buf, FrtStore *store);
|
228
|
+
extern void frt_sis_put(FrtSegmentInfos *sis, FILE *stream);
|
219
229
|
|
220
230
|
/****************************************************************************
|
221
231
|
*
|
222
|
-
*
|
232
|
+
* FrtTermInfo
|
223
233
|
*
|
224
234
|
****************************************************************************/
|
225
235
|
|
226
|
-
typedef struct
|
236
|
+
typedef struct FrtTermInfo
|
227
237
|
{
|
228
238
|
int doc_freq;
|
229
239
|
off_t frq_ptr;
|
230
240
|
off_t prx_ptr;
|
231
241
|
off_t skip_offset;
|
232
|
-
}
|
242
|
+
} FrtTermInfo;
|
233
243
|
|
234
|
-
#define
|
244
|
+
#define frt_ti_set(ti, mdf, mfp, mpp, mso) do {\
|
235
245
|
(ti).doc_freq = mdf;\
|
236
246
|
(ti).frq_ptr = mfp;\
|
237
247
|
(ti).prx_ptr = mpp;\
|
@@ -240,183 +250,183 @@ typedef struct TermInfo
|
|
240
250
|
|
241
251
|
/****************************************************************************
|
242
252
|
*
|
243
|
-
*
|
253
|
+
* FrtTermEnum
|
244
254
|
*
|
245
255
|
****************************************************************************/
|
246
256
|
|
247
|
-
typedef struct
|
257
|
+
typedef struct FrtTermEnum FrtTermEnum;
|
248
258
|
|
249
|
-
struct
|
259
|
+
struct FrtTermEnum
|
250
260
|
{
|
251
|
-
char curr_term[
|
252
|
-
char prev_term[
|
253
|
-
|
261
|
+
char curr_term[FRT_MAX_WORD_SIZE];
|
262
|
+
char prev_term[FRT_MAX_WORD_SIZE];
|
263
|
+
FrtTermInfo curr_ti;
|
254
264
|
int curr_term_len;
|
255
265
|
int field_num;
|
256
|
-
|
257
|
-
char *(*next)(
|
258
|
-
char *(*skip_to)(
|
259
|
-
void (*close)(
|
260
|
-
|
266
|
+
FrtTermEnum *(*set_field)(FrtTermEnum *te, int field_num);
|
267
|
+
char *(*next)(FrtTermEnum *te);
|
268
|
+
char *(*skip_to)(FrtTermEnum *te, const char *term);
|
269
|
+
void (*close)(FrtTermEnum *te);
|
270
|
+
FrtTermEnum *(*clone)(FrtTermEnum *te);
|
261
271
|
};
|
262
272
|
|
263
|
-
char *
|
264
|
-
|
273
|
+
char *frt_te_get_term(struct FrtTermEnum *te);
|
274
|
+
FrtTermInfo *frt_te_get_ti(struct FrtTermEnum *te);
|
265
275
|
|
266
276
|
/****************************************************************************
|
267
277
|
*
|
268
|
-
*
|
278
|
+
* FrtSegmentTermEnum
|
269
279
|
*
|
270
280
|
****************************************************************************/
|
271
281
|
|
272
|
-
/* *
|
282
|
+
/* * FrtSegmentTermIndex * */
|
273
283
|
|
274
|
-
typedef struct
|
284
|
+
typedef struct FrtSegmentTermIndex
|
275
285
|
{
|
276
286
|
off_t index_ptr;
|
277
287
|
off_t ptr;
|
278
|
-
int
|
288
|
+
int index_cnt;
|
279
289
|
int size;
|
280
290
|
char **index_terms;
|
281
291
|
int *index_term_lens;
|
282
|
-
|
292
|
+
FrtTermInfo *index_term_infos;
|
283
293
|
off_t *index_ptrs;
|
284
|
-
}
|
294
|
+
} FrtSegmentTermIndex;
|
285
295
|
|
286
|
-
/* *
|
296
|
+
/* * FrtSegmentFieldIndex * */
|
287
297
|
|
288
|
-
typedef struct
|
298
|
+
typedef struct FrtSegmentTermEnum FrtSegmentTermEnum;
|
289
299
|
|
290
|
-
typedef struct
|
300
|
+
typedef struct FrtSegmentFieldIndex
|
291
301
|
{
|
292
|
-
|
302
|
+
frt_mutex_t mutex;
|
293
303
|
int skip_interval;
|
294
304
|
int index_interval;
|
295
305
|
off_t index_ptr;
|
296
|
-
|
297
|
-
|
298
|
-
}
|
306
|
+
FrtTermEnum *index_te;
|
307
|
+
FrtHash *field_dict;
|
308
|
+
} FrtSegmentFieldIndex;
|
299
309
|
|
300
|
-
extern
|
301
|
-
extern void
|
310
|
+
extern FrtSegmentFieldIndex *frt_sfi_open(FrtStore *store, const char *segment);
|
311
|
+
extern void frt_sfi_close(FrtSegmentFieldIndex *sfi);
|
302
312
|
|
303
313
|
|
304
|
-
/* *
|
305
|
-
struct
|
314
|
+
/* * FrtSegmentTermEnum * */
|
315
|
+
struct FrtSegmentTermEnum
|
306
316
|
{
|
307
|
-
|
308
|
-
|
317
|
+
FrtTermEnum te;
|
318
|
+
FrtInStream *is;
|
309
319
|
int size;
|
310
320
|
int pos;
|
311
321
|
int skip_interval;
|
312
|
-
|
322
|
+
FrtSegmentFieldIndex *sfi;
|
313
323
|
};
|
314
324
|
|
315
|
-
extern void
|
316
|
-
extern
|
317
|
-
extern
|
325
|
+
extern void frt_ste_close(FrtTermEnum *te);
|
326
|
+
extern FrtTermEnum *frt_ste_clone(FrtTermEnum *te);
|
327
|
+
extern FrtTermEnum *frt_ste_new(FrtInStream *is, FrtSegmentFieldIndex *sfi);
|
318
328
|
|
319
329
|
/* * MultiTermEnum * */
|
320
330
|
|
321
|
-
extern
|
331
|
+
extern FrtTermEnum *frt_mte_new(FrtMultiReader *mr, int field_num, const char *term);
|
322
332
|
|
323
333
|
/****************************************************************************
|
324
334
|
*
|
325
|
-
*
|
335
|
+
* FrtTermInfosReader
|
326
336
|
*
|
327
337
|
****************************************************************************/
|
328
338
|
|
329
|
-
#define
|
339
|
+
#define FRT_TE_BUCKET_INIT_CAPA 1
|
330
340
|
|
331
|
-
typedef struct
|
341
|
+
typedef struct FrtTermInfosReader
|
332
342
|
{
|
333
|
-
|
343
|
+
frt_thread_key_t thread_te;
|
334
344
|
void **te_bucket;
|
335
|
-
|
345
|
+
FrtTermEnum *orig_te;
|
336
346
|
int field_num;
|
337
|
-
}
|
347
|
+
} FrtTermInfosReader;
|
338
348
|
|
339
|
-
extern
|
340
|
-
|
349
|
+
extern FrtTermInfosReader *frt_tir_open(FrtStore *store,
|
350
|
+
FrtSegmentFieldIndex *sfi,
|
341
351
|
const char *segment);
|
342
|
-
extern
|
343
|
-
extern
|
344
|
-
extern char *
|
345
|
-
extern void
|
352
|
+
extern FrtTermInfosReader *frt_tir_set_field(FrtTermInfosReader *tir, int field_num);
|
353
|
+
extern FrtTermInfo *frt_tir_get_ti(FrtTermInfosReader *tir, const char *term);
|
354
|
+
extern char *frt_tir_get_term(FrtTermInfosReader *tir, int pos);
|
355
|
+
extern void frt_tir_close(FrtTermInfosReader *tir);
|
346
356
|
|
347
357
|
/****************************************************************************
|
348
358
|
*
|
349
|
-
*
|
359
|
+
* FrtTermInfosWriter
|
350
360
|
*
|
351
361
|
****************************************************************************/
|
352
362
|
|
353
|
-
#define
|
354
|
-
#define
|
363
|
+
#define FRT_INDEX_INTERVAL 128
|
364
|
+
#define FRT_SKIP_INTERVAL 16
|
355
365
|
|
356
|
-
typedef struct
|
366
|
+
typedef struct FrtTermWriter
|
357
367
|
{
|
358
368
|
int counter;
|
359
369
|
const char *last_term;
|
360
|
-
|
361
|
-
|
362
|
-
}
|
370
|
+
FrtTermInfo last_term_info;
|
371
|
+
FrtOutStream *os;
|
372
|
+
} FrtTermWriter;
|
363
373
|
|
364
|
-
typedef struct
|
374
|
+
typedef struct FrtTermInfosWriter
|
365
375
|
{
|
366
376
|
int field_count;
|
367
377
|
int index_interval;
|
368
378
|
int skip_interval;
|
369
379
|
off_t last_index_ptr;
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
}
|
380
|
+
FrtOutStream *tfx_out;
|
381
|
+
FrtTermWriter *tix_writer;
|
382
|
+
FrtTermWriter *tis_writer;
|
383
|
+
} FrtTermInfosWriter;
|
374
384
|
|
375
|
-
extern
|
385
|
+
extern FrtTermInfosWriter *frt_tiw_open(FrtStore *store,
|
376
386
|
const char *segment,
|
377
387
|
int index_interval,
|
378
388
|
int skip_interval);
|
379
|
-
extern void
|
380
|
-
extern void
|
389
|
+
extern void frt_tiw_start_field(FrtTermInfosWriter *tiw, int field_num);
|
390
|
+
extern void frt_tiw_add(FrtTermInfosWriter *tiw,
|
381
391
|
const char *term,
|
382
392
|
int t_len,
|
383
|
-
|
384
|
-
extern void
|
393
|
+
FrtTermInfo *ti);
|
394
|
+
extern void frt_tiw_close(FrtTermInfosWriter *tiw);
|
385
395
|
|
386
396
|
/****************************************************************************
|
387
397
|
*
|
388
|
-
*
|
398
|
+
* FrtTermDocEnum
|
389
399
|
*
|
390
400
|
****************************************************************************/
|
391
401
|
|
392
|
-
typedef struct
|
393
|
-
struct
|
394
|
-
{
|
395
|
-
void (*seek)(
|
396
|
-
void (*seek_te)(
|
397
|
-
void (*seek_ti)(
|
398
|
-
int (*doc_num)(
|
399
|
-
int (*freq)(
|
400
|
-
bool (*next)(
|
401
|
-
int (*read)(
|
402
|
-
bool (*skip_to)(
|
403
|
-
int (*next_position)(
|
404
|
-
void (*close)(
|
402
|
+
typedef struct FrtTermDocEnum FrtTermDocEnum;
|
403
|
+
struct FrtTermDocEnum
|
404
|
+
{
|
405
|
+
void (*seek)(FrtTermDocEnum *tde, int field_num, const char *term);
|
406
|
+
void (*seek_te)(FrtTermDocEnum *tde, FrtTermEnum *te);
|
407
|
+
void (*seek_ti)(FrtTermDocEnum *tde, FrtTermInfo *ti);
|
408
|
+
int (*doc_num)(FrtTermDocEnum *tde);
|
409
|
+
int (*freq)(FrtTermDocEnum *tde);
|
410
|
+
bool (*next)(FrtTermDocEnum *tde);
|
411
|
+
int (*read)(FrtTermDocEnum *tde, int *docs, int *freqs, int req_num);
|
412
|
+
bool (*skip_to)(FrtTermDocEnum *tde, int target);
|
413
|
+
int (*next_position)(FrtTermDocEnum *tde);
|
414
|
+
void (*close)(FrtTermDocEnum *tde);
|
405
415
|
};
|
406
416
|
|
407
|
-
/* *
|
417
|
+
/* * FrtSegmentTermDocEnum * */
|
408
418
|
|
409
|
-
typedef struct
|
410
|
-
struct
|
419
|
+
typedef struct FrtSegmentTermDocEnum FrtSegmentTermDocEnum;
|
420
|
+
struct FrtSegmentTermDocEnum
|
411
421
|
{
|
412
|
-
|
413
|
-
void (*seek_prox)(
|
414
|
-
void (*skip_prox)(
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
422
|
+
FrtTermDocEnum tde;
|
423
|
+
void (*seek_prox)(FrtSegmentTermDocEnum *stde, off_t prx_ptr);
|
424
|
+
void (*skip_prox)(FrtSegmentTermDocEnum *stde);
|
425
|
+
FrtTermInfosReader *tir;
|
426
|
+
FrtInStream *frq_in;
|
427
|
+
FrtInStream *prx_in;
|
428
|
+
FrtInStream *skip_in;
|
429
|
+
FrtBitVector *deleted_docs;
|
420
430
|
int count; /* number of docs for this term skipped */
|
421
431
|
int doc_freq; /* number of doc this term appears in */
|
422
432
|
int doc_num;
|
@@ -433,451 +443,404 @@ struct SegmentTermDocEnum
|
|
433
443
|
bool have_skipped : 1;
|
434
444
|
};
|
435
445
|
|
436
|
-
extern
|
437
|
-
|
446
|
+
extern FrtTermDocEnum *frt_stde_new(FrtTermInfosReader *tir, FrtInStream *frq_in,
|
447
|
+
FrtBitVector *deleted_docs, int skip_interval);
|
438
448
|
|
439
|
-
/* *
|
440
|
-
extern
|
441
|
-
|
449
|
+
/* * FrtSegmentTermDocEnum * */
|
450
|
+
extern FrtTermDocEnum *frt_stpe_new(FrtTermInfosReader *tir, FrtInStream *frq_in,
|
451
|
+
FrtInStream *prx_in, FrtBitVector *deleted_docs,
|
442
452
|
int skip_interval);
|
443
453
|
|
444
454
|
/****************************************************************************
|
445
455
|
* MultipleTermDocPosEnum
|
446
456
|
****************************************************************************/
|
447
457
|
|
448
|
-
extern
|
458
|
+
extern FrtTermDocEnum *frt_mtdpe_new(FrtIndexReader *ir, int field_num, char **terms,
|
449
459
|
int t_cnt);
|
450
460
|
|
451
461
|
/****************************************************************************
|
452
462
|
*
|
453
|
-
*
|
463
|
+
* FrtOffset
|
454
464
|
*
|
455
465
|
****************************************************************************/
|
456
466
|
|
457
|
-
typedef struct
|
467
|
+
typedef struct FrtOffset
|
458
468
|
{
|
459
469
|
off_t start;
|
460
470
|
off_t end;
|
461
|
-
}
|
471
|
+
} FrtOffset;
|
462
472
|
|
463
|
-
extern
|
473
|
+
extern FrtOffset *frt_offset_new(off_t start, off_t end);
|
464
474
|
|
465
475
|
/****************************************************************************
|
466
476
|
*
|
467
|
-
*
|
477
|
+
* FrtOccurence
|
468
478
|
*
|
469
479
|
****************************************************************************/
|
470
480
|
|
471
|
-
typedef struct
|
481
|
+
typedef struct FrtOccurence
|
472
482
|
{
|
473
|
-
struct
|
483
|
+
struct FrtOccurence *next;
|
474
484
|
int pos;
|
475
|
-
}
|
485
|
+
} FrtOccurence;
|
476
486
|
|
477
487
|
/****************************************************************************
|
478
488
|
*
|
479
|
-
*
|
489
|
+
* FrtPosting
|
480
490
|
*
|
481
491
|
****************************************************************************/
|
482
492
|
|
483
|
-
typedef struct
|
493
|
+
typedef struct FrtPosting
|
484
494
|
{
|
485
495
|
int freq;
|
486
496
|
int doc_num;
|
487
|
-
|
488
|
-
struct
|
489
|
-
}
|
497
|
+
FrtOccurence *first_occ;
|
498
|
+
struct FrtPosting *next;
|
499
|
+
} FrtPosting;
|
490
500
|
|
491
|
-
extern
|
501
|
+
extern FrtPosting *frt_p_new(FrtMemoryPool *mp, int doc_num, int pos);
|
492
502
|
|
493
503
|
/****************************************************************************
|
494
504
|
*
|
495
|
-
*
|
505
|
+
* FrtPostingList
|
496
506
|
*
|
497
507
|
****************************************************************************/
|
498
508
|
|
499
|
-
typedef struct
|
509
|
+
typedef struct FrtPostingList
|
500
510
|
{
|
501
511
|
const char *term;
|
502
512
|
int term_len;
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
}
|
513
|
+
FrtPosting *first;
|
514
|
+
FrtPosting *last;
|
515
|
+
FrtOccurence *last_occ;
|
516
|
+
} FrtPostingList;
|
507
517
|
|
508
|
-
extern
|
509
|
-
int term_len,
|
510
|
-
extern void
|
518
|
+
extern FrtPostingList *frt_pl_new(FrtMemoryPool *mp, const char *term,
|
519
|
+
int term_len, FrtPosting *p);
|
520
|
+
extern void frt_pl_add_occ(FrtMemoryPool *mp, FrtPostingList *pl, int pos);
|
521
|
+
extern int frt_pl_cmp(const FrtPostingList **pl1, const FrtPostingList **pl2);
|
511
522
|
|
512
523
|
/****************************************************************************
|
513
524
|
*
|
514
|
-
*
|
525
|
+
* FrtTVField
|
515
526
|
*
|
516
527
|
****************************************************************************/
|
517
528
|
|
518
|
-
typedef struct
|
529
|
+
typedef struct FrtTVField
|
519
530
|
{
|
520
531
|
int field_num;
|
521
532
|
int size;
|
522
|
-
}
|
533
|
+
} FrtTVField;
|
523
534
|
|
524
535
|
/****************************************************************************
|
525
536
|
*
|
526
|
-
*
|
537
|
+
* FrtTVTerm
|
527
538
|
*
|
528
539
|
****************************************************************************/
|
529
540
|
|
530
|
-
typedef struct
|
541
|
+
typedef struct FrtTVTerm
|
531
542
|
{
|
532
543
|
char *text;
|
533
544
|
int freq;
|
534
545
|
int *positions;
|
535
|
-
}
|
546
|
+
} FrtTVTerm;
|
536
547
|
|
537
548
|
/****************************************************************************
|
538
549
|
*
|
539
|
-
*
|
550
|
+
* FrtTermVector
|
540
551
|
*
|
541
552
|
****************************************************************************/
|
542
553
|
|
543
|
-
|
554
|
+
#define FRT_TV_FIELD_INIT_CAPA 8
|
555
|
+
typedef struct FrtTermVector
|
544
556
|
{
|
545
|
-
int
|
546
|
-
|
547
|
-
int
|
548
|
-
|
549
|
-
int
|
550
|
-
|
551
|
-
}
|
557
|
+
int field_num;
|
558
|
+
FrtSymbol field;
|
559
|
+
int term_cnt;
|
560
|
+
FrtTVTerm *terms;
|
561
|
+
int offset_cnt;
|
562
|
+
FrtOffset *offsets;
|
563
|
+
} FrtTermVector;
|
552
564
|
|
553
|
-
extern void
|
554
|
-
extern int
|
555
|
-
extern
|
565
|
+
extern void frt_tv_destroy(FrtTermVector *tv);
|
566
|
+
extern int frt_tv_get_term_index(FrtTermVector *tv, const char *term);
|
567
|
+
extern int frt_tv_scan_to_term_index(FrtTermVector *tv, const char *term);
|
568
|
+
extern FrtTVTerm *frt_tv_get_tv_term(FrtTermVector *tv, const char *term);
|
556
569
|
|
557
570
|
/****************************************************************************
|
558
571
|
*
|
559
|
-
*
|
572
|
+
* FrtLazyDoc
|
560
573
|
*
|
561
574
|
****************************************************************************/
|
562
575
|
|
563
|
-
|
564
|
-
|
565
|
-
typedef struct TermVectorsWriter
|
566
|
-
{
|
567
|
-
OutStream *tvx_out;
|
568
|
-
OutStream *tvd_out;
|
569
|
-
FieldInfos *fis;
|
570
|
-
TVField *fields;
|
571
|
-
off_t tvd_ptr;
|
572
|
-
} TermVectorsWriter;
|
573
|
-
|
574
|
-
extern TermVectorsWriter *tvw_open(Store *store,
|
575
|
-
const char *segment,
|
576
|
-
FieldInfos *fis);
|
577
|
-
extern void tvw_open_doc(TermVectorsWriter *tvw);
|
578
|
-
extern void tvw_close_doc(TermVectorsWriter *tvw);
|
579
|
-
extern void tvw_add_postings(TermVectorsWriter *tvw,
|
580
|
-
int field_num,
|
581
|
-
PostingList **plists,
|
582
|
-
int posting_count,
|
583
|
-
Offset *offsets,
|
584
|
-
int offset_count);
|
585
|
-
extern void tvw_close(TermVectorsWriter *tvw);
|
586
|
-
|
587
|
-
/****************************************************************************
|
588
|
-
*
|
589
|
-
* TermVectorsReader
|
590
|
-
*
|
591
|
-
****************************************************************************/
|
592
|
-
|
593
|
-
typedef struct TermVectorsReader
|
594
|
-
{
|
595
|
-
int size;
|
596
|
-
InStream *tvx_in;
|
597
|
-
InStream *tvd_in;
|
598
|
-
FieldInfos *fis;
|
599
|
-
} TermVectorsReader;
|
600
|
-
|
601
|
-
extern TermVectorsReader *tvr_open(Store *store,
|
602
|
-
const char *segment,
|
603
|
-
FieldInfos *fis);
|
604
|
-
extern TermVectorsReader *tvr_clone(TermVectorsReader *orig);
|
605
|
-
extern void tvr_close(TermVectorsReader *tvr);
|
606
|
-
extern HashTable *tvr_get_tv(TermVectorsReader *tvr, int doc_num);
|
607
|
-
extern TermVector *tvr_get_field_tv(TermVectorsReader *tvr,
|
608
|
-
int doc_num,
|
609
|
-
int field_num);
|
610
|
-
|
611
|
-
/****************************************************************************
|
612
|
-
*
|
613
|
-
* LazyDoc
|
614
|
-
*
|
615
|
-
****************************************************************************/
|
616
|
-
|
617
|
-
/* * * LazyDocField * * */
|
618
|
-
typedef struct LazyDocFieldData
|
576
|
+
/* * * FrtLazyDocField * * */
|
577
|
+
typedef struct FrtLazyDocFieldData
|
619
578
|
{
|
620
579
|
off_t start;
|
621
580
|
int length;
|
622
581
|
char *text;
|
623
|
-
}
|
582
|
+
} FrtLazyDocFieldData;
|
624
583
|
|
625
|
-
typedef struct
|
626
|
-
typedef struct
|
584
|
+
typedef struct FrtLazyDoc FrtLazyDoc;
|
585
|
+
typedef struct FrtLazyDocField
|
627
586
|
{
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
int
|
632
|
-
|
633
|
-
|
587
|
+
FrtSymbol name;
|
588
|
+
FrtLazyDocFieldData *data;
|
589
|
+
FrtLazyDoc *doc;
|
590
|
+
int size; /* number of data elements */
|
591
|
+
int len; /* length of data elements concatenated */
|
592
|
+
bool is_compressed : 2; /* set to 2 after all data is loaded */
|
593
|
+
} FrtLazyDocField;
|
634
594
|
|
635
|
-
extern char *
|
636
|
-
extern void
|
595
|
+
extern char *frt_lazy_df_get_data(FrtLazyDocField *self, int i);
|
596
|
+
extern void frt_lazy_df_get_bytes(FrtLazyDocField *self, char *buf,
|
637
597
|
int start, int len);
|
638
598
|
|
639
|
-
/* * *
|
640
|
-
struct
|
599
|
+
/* * * FrtLazyDoc * * */
|
600
|
+
struct FrtLazyDoc
|
641
601
|
{
|
642
|
-
|
602
|
+
FrtHash *field_dictionary;
|
643
603
|
int size;
|
644
|
-
|
645
|
-
|
604
|
+
FrtLazyDocField **fields;
|
605
|
+
FrtInStream *fields_in;
|
646
606
|
};
|
647
607
|
|
648
|
-
extern void
|
608
|
+
extern void frt_lazy_doc_close(FrtLazyDoc *self);
|
609
|
+
extern FrtLazyDocField *frt_lazy_doc_get(FrtLazyDoc *self, FrtSymbol field);
|
649
610
|
|
650
611
|
/****************************************************************************
|
651
612
|
*
|
652
|
-
*
|
613
|
+
* FrtFieldsReader
|
653
614
|
*
|
654
615
|
****************************************************************************/
|
655
616
|
|
656
|
-
typedef struct
|
617
|
+
typedef struct FrtFieldsReader
|
657
618
|
{
|
658
|
-
int
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
}
|
664
|
-
|
665
|
-
extern
|
666
|
-
const char *segment,
|
667
|
-
extern
|
668
|
-
extern void
|
669
|
-
extern
|
670
|
-
extern
|
671
|
-
extern
|
672
|
-
extern
|
673
|
-
|
619
|
+
int size;
|
620
|
+
FrtFieldInfos *fis;
|
621
|
+
FrtStore *store;
|
622
|
+
FrtInStream *fdx_in;
|
623
|
+
FrtInStream *fdt_in;
|
624
|
+
} FrtFieldsReader;
|
625
|
+
|
626
|
+
extern FrtFieldsReader *frt_fr_open(FrtStore *store,
|
627
|
+
const char *segment, FrtFieldInfos *fis);
|
628
|
+
extern FrtFieldsReader *frt_fr_clone(FrtFieldsReader *orig);
|
629
|
+
extern void frt_fr_close(FrtFieldsReader *fr);
|
630
|
+
extern FrtDocument *frt_fr_get_doc(FrtFieldsReader *fr, int doc_num);
|
631
|
+
extern FrtLazyDoc *frt_fr_get_lazy_doc(FrtFieldsReader *fr, int doc_num);
|
632
|
+
extern FrtHash *frt_fr_get_tv(FrtFieldsReader *fr, int doc_num);
|
633
|
+
extern FrtTermVector *frt_fr_get_field_tv(FrtFieldsReader *fr, int doc_num,
|
634
|
+
int field_num);
|
674
635
|
|
675
636
|
/****************************************************************************
|
676
637
|
*
|
677
|
-
*
|
638
|
+
* FrtFieldsWriter
|
678
639
|
*
|
679
640
|
****************************************************************************/
|
680
641
|
|
681
|
-
typedef struct
|
642
|
+
typedef struct FrtFieldsWriter
|
682
643
|
{
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
644
|
+
FrtFieldInfos *fis;
|
645
|
+
FrtOutStream *fdt_out;
|
646
|
+
FrtOutStream *fdx_out;
|
647
|
+
FrtOutStream *buffer;
|
648
|
+
FrtTVField *tv_fields;
|
687
649
|
off_t start_ptr;
|
688
|
-
}
|
650
|
+
} FrtFieldsWriter;
|
689
651
|
|
690
|
-
extern
|
691
|
-
const char *segment,
|
692
|
-
extern void
|
693
|
-
extern void
|
694
|
-
extern void
|
652
|
+
extern FrtFieldsWriter *frt_fw_open(FrtStore *store,
|
653
|
+
const char *segment, FrtFieldInfos *fis);
|
654
|
+
extern void frt_fw_close(FrtFieldsWriter *fw);
|
655
|
+
extern void frt_fw_add_doc(FrtFieldsWriter *fw, FrtDocument *doc);
|
656
|
+
extern void frt_fw_add_postings(FrtFieldsWriter *fw,
|
695
657
|
int field_num,
|
696
|
-
|
658
|
+
FrtPostingList **plists,
|
697
659
|
int posting_count,
|
698
|
-
|
660
|
+
FrtOffset *offsets,
|
699
661
|
int offset_count);
|
700
|
-
extern void
|
662
|
+
extern void frt_fw_write_tv_index(FrtFieldsWriter *fw);
|
701
663
|
|
702
664
|
/****************************************************************************
|
703
665
|
*
|
704
|
-
*
|
666
|
+
* FrtDeleter
|
705
667
|
*
|
706
|
-
* A utility class (used by both
|
668
|
+
* A utility class (used by both FrtIndexReader and FrtIndexWriter) to keep track of
|
707
669
|
* files that need to be deleted because they are no longer referenced by the
|
708
670
|
* index.
|
709
671
|
*
|
710
672
|
****************************************************************************/
|
711
673
|
|
712
|
-
struct
|
674
|
+
struct FrtDeleter
|
713
675
|
{
|
714
|
-
|
715
|
-
|
716
|
-
|
676
|
+
FrtStore *store;
|
677
|
+
FrtSegmentInfos *sis;
|
678
|
+
FrtHashSet *pending;
|
717
679
|
};
|
718
680
|
|
719
|
-
extern
|
720
|
-
extern void
|
721
|
-
extern void
|
722
|
-
extern void
|
723
|
-
extern void
|
724
|
-
extern void
|
725
|
-
extern void
|
681
|
+
extern FrtDeleter *frt_deleter_new(FrtSegmentInfos *sis, FrtStore *store);
|
682
|
+
extern void frt_deleter_destroy(FrtDeleter *dlr);
|
683
|
+
extern void frt_deleter_clear_pending_files(FrtDeleter *dlr);
|
684
|
+
extern void frt_deleter_delete_file(FrtDeleter *dlr, char *file_name);
|
685
|
+
extern void frt_deleter_find_deletable_files(FrtDeleter *dlr);
|
686
|
+
extern void frt_deleter_commit_pending_files(FrtDeleter *dlr);
|
687
|
+
extern void frt_deleter_delete_files(FrtDeleter *dlr, char **files, int file_cnt);
|
726
688
|
|
727
689
|
/****************************************************************************
|
728
690
|
*
|
729
|
-
*
|
691
|
+
* FrtIndexReader
|
730
692
|
*
|
731
693
|
****************************************************************************/
|
732
694
|
|
733
|
-
#define
|
734
|
-
#define
|
735
|
-
|
736
|
-
struct
|
737
|
-
{
|
738
|
-
int
|
739
|
-
int
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
int
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
bool
|
756
|
-
bool
|
757
|
-
void
|
758
|
-
void
|
759
|
-
|
760
|
-
void
|
761
|
-
void
|
762
|
-
void
|
763
|
-
bool
|
764
|
-
void
|
765
|
-
void
|
766
|
-
int
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
bool
|
778
|
-
bool
|
695
|
+
#define FRT_WRITE_LOCK_NAME "write"
|
696
|
+
#define FRT_COMMIT_LOCK_NAME "commit"
|
697
|
+
|
698
|
+
struct FrtIndexReader
|
699
|
+
{
|
700
|
+
int (*num_docs)(FrtIndexReader *ir);
|
701
|
+
int (*max_doc)(FrtIndexReader *ir);
|
702
|
+
FrtDocument *(*get_doc)(FrtIndexReader *ir, int doc_num);
|
703
|
+
FrtLazyDoc *(*get_lazy_doc)(FrtIndexReader *ir, int doc_num);
|
704
|
+
frt_uchar *(*get_norms)(FrtIndexReader *ir, int field_num);
|
705
|
+
frt_uchar *(*get_norms_into)(FrtIndexReader *ir, int field_num,
|
706
|
+
frt_uchar *buf);
|
707
|
+
FrtTermEnum *(*terms)(FrtIndexReader *ir, int field_num);
|
708
|
+
FrtTermEnum *(*terms_from)(FrtIndexReader *ir, int field_num,
|
709
|
+
const char *term);
|
710
|
+
int (*doc_freq)(FrtIndexReader *ir, int field_num,
|
711
|
+
const char *term);
|
712
|
+
FrtTermDocEnum *(*term_docs)(FrtIndexReader *ir);
|
713
|
+
FrtTermDocEnum *(*term_positions)(FrtIndexReader *ir);
|
714
|
+
FrtTermVector *(*term_vector)(FrtIndexReader *ir, int doc_num,
|
715
|
+
FrtSymbol field);
|
716
|
+
FrtHash *(*term_vectors)(FrtIndexReader *ir, int doc_num);
|
717
|
+
bool (*is_deleted)(FrtIndexReader *ir, int doc_num);
|
718
|
+
bool (*has_deletions)(FrtIndexReader *ir);
|
719
|
+
void (*acquire_write_lock)(FrtIndexReader *ir);
|
720
|
+
void (*set_norm_i)(FrtIndexReader *ir, int doc_num,
|
721
|
+
int field_num, frt_uchar val);
|
722
|
+
void (*delete_doc_i)(FrtIndexReader *ir, int doc_num);
|
723
|
+
void (*undelete_all_i)(FrtIndexReader *ir);
|
724
|
+
void (*set_deleter_i)(FrtIndexReader *ir, FrtDeleter *dlr);
|
725
|
+
bool (*is_latest_i)(FrtIndexReader *ir);
|
726
|
+
void (*commit_i)(FrtIndexReader *ir);
|
727
|
+
void (*close_i)(FrtIndexReader *ir);
|
728
|
+
int ref_cnt;
|
729
|
+
FrtDeleter *deleter;
|
730
|
+
FrtStore *store;
|
731
|
+
FrtLock *write_lock;
|
732
|
+
FrtSegmentInfos *sis;
|
733
|
+
FrtFieldInfos *fis;
|
734
|
+
FrtHash *cache;
|
735
|
+
FrtHash *field_index_cache;
|
736
|
+
frt_mutex_t field_index_mutex;
|
737
|
+
frt_uchar *fake_norms;
|
738
|
+
frt_mutex_t mutex;
|
739
|
+
bool has_changes : 1;
|
740
|
+
bool is_stale : 1;
|
741
|
+
bool is_owner : 1;
|
779
742
|
};
|
780
743
|
|
781
|
-
extern
|
782
|
-
extern
|
783
|
-
extern int
|
784
|
-
extern bool
|
785
|
-
extern void
|
786
|
-
extern void
|
787
|
-
extern void
|
788
|
-
extern void
|
789
|
-
extern int
|
790
|
-
extern void
|
791
|
-
|
792
|
-
extern
|
793
|
-
extern
|
794
|
-
extern
|
795
|
-
extern void
|
796
|
-
extern
|
744
|
+
extern FrtIndexReader *frt_ir_create(FrtStore *store, FrtSegmentInfos *sis, int is_owner);
|
745
|
+
extern FrtIndexReader *frt_ir_open(FrtStore *store);
|
746
|
+
extern int frt_ir_get_field_num(FrtIndexReader *ir, FrtSymbol field);
|
747
|
+
extern bool frt_ir_index_exists(FrtStore *store);
|
748
|
+
extern void frt_ir_close(FrtIndexReader *ir);
|
749
|
+
extern void frt_ir_commit(FrtIndexReader *ir);
|
750
|
+
extern void frt_ir_delete_doc(FrtIndexReader *ir, int doc_num);
|
751
|
+
extern void frt_ir_undelete_all(FrtIndexReader *ir);
|
752
|
+
extern int frt_ir_doc_freq(FrtIndexReader *ir, FrtSymbol field, const char *term);
|
753
|
+
extern void frt_ir_set_norm(FrtIndexReader *ir, int doc_num, FrtSymbol field,
|
754
|
+
frt_uchar val);
|
755
|
+
extern frt_uchar *frt_ir_get_norms_i(FrtIndexReader *ir, int field_num);
|
756
|
+
extern frt_uchar *frt_ir_get_norms(FrtIndexReader *ir, FrtSymbol field);
|
757
|
+
extern frt_uchar *frt_ir_get_norms_into(FrtIndexReader *ir, FrtSymbol field, frt_uchar *buf);
|
758
|
+
extern void frt_ir_destroy(FrtIndexReader *self);
|
759
|
+
extern FrtDocument *frt_ir_get_doc_with_term(FrtIndexReader *ir, FrtSymbol field,
|
797
760
|
const char *term);
|
798
|
-
extern
|
799
|
-
extern
|
761
|
+
extern FrtTermEnum *frt_ir_terms(FrtIndexReader *ir, FrtSymbol field);
|
762
|
+
extern FrtTermEnum *frt_ir_terms_from(FrtIndexReader *ir, FrtSymbol field,
|
800
763
|
const char *t);
|
801
|
-
extern
|
764
|
+
extern FrtTermDocEnum *frt_ir_term_docs_for(FrtIndexReader *ir, FrtSymbol field,
|
802
765
|
const char *term);
|
803
|
-
extern
|
804
|
-
|
805
|
-
|
806
|
-
extern
|
766
|
+
extern FrtTermDocEnum *frt_ir_term_positions_for(FrtIndexReader *ir,
|
767
|
+
FrtSymbol field,
|
768
|
+
const char *t);
|
769
|
+
extern void frt_ir_add_cache(FrtIndexReader *ir);
|
770
|
+
extern bool frt_ir_is_latest(FrtIndexReader *ir);
|
807
771
|
|
808
772
|
/****************************************************************************
|
809
|
-
*
|
773
|
+
* FrtMultiReader
|
810
774
|
****************************************************************************/
|
811
775
|
|
812
|
-
struct
|
813
|
-
|
776
|
+
struct FrtMultiReader {
|
777
|
+
FrtIndexReader ir;
|
814
778
|
int max_doc;
|
815
779
|
int num_docs_cache;
|
816
780
|
int r_cnt;
|
817
781
|
int *starts;
|
818
|
-
|
819
|
-
|
782
|
+
FrtIndexReader **sub_readers;
|
783
|
+
FrtHash *norms_cache;
|
820
784
|
bool has_deletions : 1;
|
821
785
|
int **field_num_map;
|
822
786
|
};
|
823
787
|
|
824
|
-
extern int
|
825
|
-
extern
|
788
|
+
extern int frt_mr_get_field_num(FrtMultiReader *mr, int ir_num, int f_num);
|
789
|
+
extern FrtIndexReader *frt_mr_open(FrtIndexReader **sub_readers, const int r_cnt);
|
826
790
|
|
827
791
|
|
828
792
|
/****************************************************************************
|
829
793
|
*
|
830
|
-
*
|
794
|
+
* FrtBoost
|
831
795
|
*
|
832
796
|
****************************************************************************/
|
833
797
|
|
834
|
-
typedef struct
|
798
|
+
typedef struct FrtBoost
|
835
799
|
{
|
836
800
|
float val;
|
837
801
|
int doc_num;
|
838
|
-
struct
|
839
|
-
}
|
802
|
+
struct FrtBoost *next;
|
803
|
+
} FrtBoost;
|
840
804
|
|
841
805
|
/****************************************************************************
|
842
806
|
*
|
843
|
-
*
|
807
|
+
* FrtFieldInverter
|
844
808
|
*
|
845
809
|
****************************************************************************/
|
846
810
|
|
847
|
-
typedef struct
|
811
|
+
typedef struct FrtFieldInverter
|
848
812
|
{
|
849
|
-
|
850
|
-
|
851
|
-
|
813
|
+
FrtHash *plists;
|
814
|
+
frt_uchar *norms;
|
815
|
+
FrtFieldInfo *fi;
|
852
816
|
int length;
|
853
817
|
bool is_tokenized : 1;
|
854
818
|
bool store_term_vector : 1;
|
855
819
|
bool store_offsets : 1;
|
856
820
|
bool has_norms : 1;
|
857
|
-
}
|
821
|
+
} FrtFieldInverter;
|
858
822
|
|
859
823
|
/****************************************************************************
|
860
824
|
*
|
861
|
-
*
|
825
|
+
* FrtDocWriter
|
862
826
|
*
|
863
827
|
****************************************************************************/
|
864
828
|
|
865
829
|
#define DW_OFFSET_INIT_CAPA 512
|
866
|
-
typedef struct
|
867
|
-
|
868
|
-
typedef struct
|
869
|
-
{
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
Offset *offsets;
|
830
|
+
typedef struct FrtIndexWriter FrtIndexWriter;
|
831
|
+
|
832
|
+
typedef struct FrtDocWriter
|
833
|
+
{
|
834
|
+
FrtStore *store;
|
835
|
+
FrtSegmentInfo *si;
|
836
|
+
FrtFieldInfos *fis;
|
837
|
+
FrtFieldsWriter *fw;
|
838
|
+
FrtMemoryPool *mp;
|
839
|
+
FrtAnalyzer *analyzer;
|
840
|
+
FrtHash *curr_plists;
|
841
|
+
FrtHash *fields;
|
842
|
+
FrtSimilarity *similarity;
|
843
|
+
FrtOffset *offsets;
|
881
844
|
int offsets_size;
|
882
845
|
int offsets_capa;
|
883
846
|
int doc_num;
|
@@ -885,77 +848,88 @@ typedef struct DocWriter
|
|
885
848
|
int skip_interval;
|
886
849
|
int max_field_length;
|
887
850
|
int max_buffered_docs;
|
888
|
-
}
|
851
|
+
} FrtDocWriter;
|
889
852
|
|
890
|
-
extern
|
891
|
-
extern void
|
892
|
-
extern void
|
893
|
-
extern void
|
853
|
+
extern FrtDocWriter *frt_dw_open(FrtIndexWriter *is, FrtSegmentInfo *si);
|
854
|
+
extern void frt_dw_close(FrtDocWriter *dw);
|
855
|
+
extern void frt_dw_add_doc(FrtDocWriter *dw, FrtDocument *doc);
|
856
|
+
extern void frt_dw_new_segment(FrtDocWriter *dw, FrtSegmentInfo *si);
|
857
|
+
/* For testing. need to remove somehow. FIXME */
|
858
|
+
extern FrtHash *frt_dw_invert_field(FrtDocWriter *dw,
|
859
|
+
FrtFieldInverter *fld_inv,
|
860
|
+
FrtDocField *df);
|
861
|
+
extern FrtFieldInverter *frt_dw_get_fld_inv(FrtDocWriter *dw, FrtFieldInfo *fi);
|
862
|
+
extern void frt_dw_reset_postings(FrtHash *postings);
|
894
863
|
|
895
864
|
/****************************************************************************
|
896
865
|
*
|
897
|
-
*
|
866
|
+
* FrtIndexWriter
|
898
867
|
*
|
899
868
|
****************************************************************************/
|
900
869
|
|
901
|
-
typedef struct
|
870
|
+
typedef struct FrtDelTerm
|
902
871
|
{
|
903
872
|
int field_num;
|
904
873
|
char *term;
|
905
|
-
}
|
906
|
-
|
907
|
-
struct
|
908
|
-
{
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
874
|
+
} FrtDelTerm;
|
875
|
+
|
876
|
+
struct FrtIndexWriter
|
877
|
+
{
|
878
|
+
FrtConfig config;
|
879
|
+
frt_mutex_t mutex;
|
880
|
+
FrtStore *store;
|
881
|
+
FrtAnalyzer *analyzer;
|
882
|
+
FrtSegmentInfos *sis;
|
883
|
+
FrtFieldInfos *fis;
|
884
|
+
FrtDocWriter *dw;
|
885
|
+
FrtSimilarity *similarity;
|
886
|
+
FrtLock *write_lock;
|
887
|
+
FrtDeleter *deleter;
|
919
888
|
};
|
920
889
|
|
921
|
-
extern void
|
922
|
-
extern bool
|
923
|
-
extern
|
924
|
-
const
|
925
|
-
extern void
|
890
|
+
extern void frt_index_create(FrtStore *store, FrtFieldInfos *fis);
|
891
|
+
extern bool frt_index_is_locked(FrtStore *store);
|
892
|
+
extern FrtIndexWriter *frt_iw_open(FrtStore *store, FrtAnalyzer *analyzer,
|
893
|
+
const FrtConfig *config);
|
894
|
+
extern void frt_iw_delete_term(FrtIndexWriter *iw, FrtSymbol field,
|
926
895
|
const char *term);
|
927
|
-
extern void
|
928
|
-
|
929
|
-
extern
|
930
|
-
extern void
|
931
|
-
extern
|
932
|
-
extern void
|
896
|
+
extern void frt_iw_delete_terms(FrtIndexWriter *iw, FrtSymbol field,
|
897
|
+
char **terms, const int term_cnt);
|
898
|
+
extern void frt_iw_close(FrtIndexWriter *iw);
|
899
|
+
extern void frt_iw_add_doc(FrtIndexWriter *iw, FrtDocument *doc);
|
900
|
+
extern int frt_iw_doc_count(FrtIndexWriter *iw);
|
901
|
+
extern void frt_iw_commit(FrtIndexWriter *iw);
|
902
|
+
extern void frt_iw_optimize(FrtIndexWriter *iw);
|
903
|
+
extern void frt_iw_add_readers(FrtIndexWriter *iw, FrtIndexReader **readers,
|
933
904
|
const int r_cnt);
|
934
905
|
|
935
906
|
/****************************************************************************
|
936
907
|
*
|
937
|
-
*
|
908
|
+
* FrtCompoundWriter
|
938
909
|
*
|
939
910
|
****************************************************************************/
|
940
911
|
|
941
|
-
#define
|
942
|
-
typedef struct
|
912
|
+
#define FRT_CW_INIT_CAPA 16
|
913
|
+
typedef struct FrtCWFileEntry
|
943
914
|
{
|
944
915
|
char *name;
|
945
916
|
off_t dir_offset;
|
946
917
|
off_t data_offset;
|
947
|
-
}
|
918
|
+
} FrtCWFileEntry;
|
948
919
|
|
949
|
-
typedef struct
|
950
|
-
|
920
|
+
typedef struct FrtCompoundWriter {
|
921
|
+
FrtStore *store;
|
951
922
|
const char *name;
|
952
|
-
|
953
|
-
|
954
|
-
}
|
923
|
+
FrtHashSet *ids;
|
924
|
+
FrtCWFileEntry *file_entries;
|
925
|
+
} FrtCompoundWriter;
|
955
926
|
|
956
|
-
extern
|
957
|
-
extern void
|
958
|
-
extern void
|
927
|
+
extern FrtCompoundWriter *frt_open_cw(FrtStore *store, char *name);
|
928
|
+
extern void frt_cw_add_file(FrtCompoundWriter *cw, char *id);
|
929
|
+
extern void frt_cw_close(FrtCompoundWriter *cw);
|
959
930
|
|
931
|
+
#ifdef __cplusplus
|
932
|
+
} // extern "C"
|
933
|
+
#endif
|
960
934
|
|
961
935
|
#endif
|