isomorfeus-ferret 0.17.1 → 0.17.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/isomorfeus_ferret_ext/benchmark.c +9 -20
- data/ext/isomorfeus_ferret_ext/benchmarks_all.h +1 -2
- data/ext/isomorfeus_ferret_ext/bm_hash.c +1 -2
- data/ext/isomorfeus_ferret_ext/bm_store.c +2 -0
- data/ext/isomorfeus_ferret_ext/brotli_dec_decode.c +4 -2
- data/ext/isomorfeus_ferret_ext/brotli_enc_encode.c +3 -2
- data/ext/isomorfeus_ferret_ext/frb_analysis.c +4 -5
- data/ext/isomorfeus_ferret_ext/frb_field_info.c +3 -4
- data/ext/isomorfeus_ferret_ext/frb_index.c +118 -160
- data/ext/isomorfeus_ferret_ext/frb_lazy_doc.c +14 -16
- data/ext/isomorfeus_ferret_ext/frb_search.c +31 -23
- data/ext/isomorfeus_ferret_ext/frb_store.c +27 -13
- data/ext/isomorfeus_ferret_ext/frb_utils.c +3 -6
- data/ext/isomorfeus_ferret_ext/frt_analysis.c +39 -46
- data/ext/isomorfeus_ferret_ext/frt_analysis.h +9 -9
- data/ext/isomorfeus_ferret_ext/frt_array.c +11 -22
- data/ext/isomorfeus_ferret_ext/frt_bitvector.h +3 -6
- data/ext/isomorfeus_ferret_ext/frt_doc_field.c +87 -0
- data/ext/isomorfeus_ferret_ext/frt_doc_field.h +26 -0
- data/ext/isomorfeus_ferret_ext/frt_document.c +4 -97
- data/ext/isomorfeus_ferret_ext/frt_document.h +2 -27
- data/ext/isomorfeus_ferret_ext/frt_except.c +50 -6
- data/ext/isomorfeus_ferret_ext/frt_except.h +3 -2
- data/ext/isomorfeus_ferret_ext/frt_field_index.c +13 -32
- data/ext/isomorfeus_ferret_ext/frt_field_index.h +0 -6
- data/ext/isomorfeus_ferret_ext/frt_field_info.c +69 -0
- data/ext/isomorfeus_ferret_ext/frt_field_info.h +49 -0
- data/ext/isomorfeus_ferret_ext/frt_field_infos.c +196 -0
- data/ext/isomorfeus_ferret_ext/frt_field_infos.h +35 -0
- data/ext/isomorfeus_ferret_ext/frt_global.c +10 -4
- data/ext/isomorfeus_ferret_ext/frt_global.h +11 -15
- data/ext/isomorfeus_ferret_ext/frt_hash.c +8 -8
- data/ext/isomorfeus_ferret_ext/frt_hash.h +1 -2
- data/ext/isomorfeus_ferret_ext/frt_hashset.c +20 -40
- data/ext/isomorfeus_ferret_ext/frt_hashset.h +1 -2
- data/ext/isomorfeus_ferret_ext/frt_helper.c +7 -15
- data/ext/isomorfeus_ferret_ext/frt_in_stream.c +482 -0
- data/ext/isomorfeus_ferret_ext/frt_in_stream.h +241 -0
- data/ext/isomorfeus_ferret_ext/frt_ind.c +20 -49
- data/ext/isomorfeus_ferret_ext/frt_ind.h +0 -1
- data/ext/isomorfeus_ferret_ext/frt_index.c +296 -1857
- data/ext/isomorfeus_ferret_ext/frt_index.h +2 -145
- data/ext/isomorfeus_ferret_ext/frt_lang.c +5 -10
- data/ext/isomorfeus_ferret_ext/frt_lazy_doc.c +29 -0
- data/ext/isomorfeus_ferret_ext/frt_lazy_doc.h +19 -0
- data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.c +93 -0
- data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.h +33 -0
- data/ext/isomorfeus_ferret_ext/frt_mdbx_store.c +102 -70
- data/ext/isomorfeus_ferret_ext/frt_mempool.c +8 -16
- data/ext/isomorfeus_ferret_ext/frt_multimapper.c +23 -46
- data/ext/isomorfeus_ferret_ext/frt_multimapper.h +4 -8
- data/ext/isomorfeus_ferret_ext/frt_out_stream.c +334 -0
- data/ext/isomorfeus_ferret_ext/frt_out_stream.h +198 -0
- data/ext/isomorfeus_ferret_ext/frt_posh.c +6 -819
- data/ext/isomorfeus_ferret_ext/frt_posh.h +0 -57
- data/ext/isomorfeus_ferret_ext/frt_priorityqueue.c +11 -22
- data/ext/isomorfeus_ferret_ext/frt_priorityqueue.h +1 -2
- data/ext/isomorfeus_ferret_ext/frt_q_boolean.c +85 -171
- data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +8 -16
- data/ext/isomorfeus_ferret_ext/frt_q_multi_term.c +1 -2
- data/ext/isomorfeus_ferret_ext/frt_q_parser.c +49 -98
- data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +52 -104
- data/ext/isomorfeus_ferret_ext/frt_q_range.c +6 -12
- data/ext/isomorfeus_ferret_ext/frt_q_span.c +113 -226
- data/ext/isomorfeus_ferret_ext/frt_q_wildcard.c +1 -2
- data/ext/isomorfeus_ferret_ext/frt_ram_store.c +134 -85
- data/ext/isomorfeus_ferret_ext/frt_ram_store.h +12 -0
- data/ext/isomorfeus_ferret_ext/frt_search.c +82 -164
- data/ext/isomorfeus_ferret_ext/frt_similarity.c +11 -22
- data/ext/isomorfeus_ferret_ext/frt_similarity.h +1 -2
- data/ext/isomorfeus_ferret_ext/frt_store.c +13 -536
- data/ext/isomorfeus_ferret_ext/frt_store.h +90 -495
- data/ext/isomorfeus_ferret_ext/frt_stream.h +18 -0
- data/ext/isomorfeus_ferret_ext/frt_term_vectors.c +8 -16
- data/ext/isomorfeus_ferret_ext/frt_win32.h +5 -10
- data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +12 -11
- data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.h +11 -13
- data/ext/isomorfeus_ferret_ext/lz4.c +422 -195
- data/ext/isomorfeus_ferret_ext/lz4.h +114 -46
- data/ext/isomorfeus_ferret_ext/lz4frame.c +421 -242
- data/ext/isomorfeus_ferret_ext/lz4frame.h +122 -53
- data/ext/isomorfeus_ferret_ext/lz4hc.c +127 -111
- data/ext/isomorfeus_ferret_ext/lz4hc.h +14 -14
- data/ext/isomorfeus_ferret_ext/lz4xxhash.h +1 -1
- data/ext/isomorfeus_ferret_ext/mdbx.c +3762 -2526
- data/ext/isomorfeus_ferret_ext/mdbx.h +115 -70
- data/ext/isomorfeus_ferret_ext/test.c +40 -87
- data/ext/isomorfeus_ferret_ext/test.h +3 -6
- data/ext/isomorfeus_ferret_ext/test_1710.c +11 -13
- data/ext/isomorfeus_ferret_ext/test_analysis.c +32 -64
- data/ext/isomorfeus_ferret_ext/test_array.c +6 -12
- data/ext/isomorfeus_ferret_ext/test_bitvector.c +12 -24
- data/ext/isomorfeus_ferret_ext/test_document.c +23 -33
- data/ext/isomorfeus_ferret_ext/test_except.c +10 -21
- data/ext/isomorfeus_ferret_ext/test_fields.c +62 -68
- data/ext/isomorfeus_ferret_ext/test_file_deleter.c +15 -24
- data/ext/isomorfeus_ferret_ext/test_filter.c +17 -27
- data/ext/isomorfeus_ferret_ext/test_global.c +14 -29
- data/ext/isomorfeus_ferret_ext/test_hash.c +19 -38
- data/ext/isomorfeus_ferret_ext/test_hashset.c +8 -16
- data/ext/isomorfeus_ferret_ext/test_helper.c +4 -8
- data/ext/isomorfeus_ferret_ext/test_highlighter.c +16 -28
- data/ext/isomorfeus_ferret_ext/test_index.c +277 -495
- data/ext/isomorfeus_ferret_ext/test_lang.c +7 -14
- data/ext/isomorfeus_ferret_ext/test_mdbx_store.c +2 -5
- data/ext/isomorfeus_ferret_ext/test_mempool.c +5 -10
- data/ext/isomorfeus_ferret_ext/test_multimapper.c +3 -6
- data/ext/isomorfeus_ferret_ext/test_priorityqueue.c +9 -18
- data/ext/isomorfeus_ferret_ext/test_q_const_score.c +4 -6
- data/ext/isomorfeus_ferret_ext/test_q_filtered.c +3 -4
- data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +9 -15
- data/ext/isomorfeus_ferret_ext/test_q_parser.c +8 -16
- data/ext/isomorfeus_ferret_ext/test_q_span.c +19 -35
- data/ext/isomorfeus_ferret_ext/test_ram_store.c +14 -13
- data/ext/isomorfeus_ferret_ext/test_search.c +60 -109
- data/ext/isomorfeus_ferret_ext/test_segments.c +8 -13
- data/ext/isomorfeus_ferret_ext/test_similarity.c +2 -4
- data/ext/isomorfeus_ferret_ext/test_sort.c +14 -24
- data/ext/isomorfeus_ferret_ext/test_store.c +96 -115
- data/ext/isomorfeus_ferret_ext/test_term.c +9 -15
- data/ext/isomorfeus_ferret_ext/test_term_vectors.c +9 -14
- data/ext/isomorfeus_ferret_ext/test_test.c +4 -8
- data/ext/isomorfeus_ferret_ext/test_threading.c +15 -30
- data/ext/isomorfeus_ferret_ext/testhelper.c +11 -21
- data/ext/isomorfeus_ferret_ext/testhelper.h +1 -1
- data/ext/isomorfeus_ferret_ext/tests_all.h +1 -2
- data/lib/isomorfeus/ferret/index/index.rb +1 -12
- data/lib/isomorfeus/ferret/version.rb +1 -1
- metadata +43 -4
@@ -10,142 +10,19 @@
|
|
10
10
|
#define HAVE_STRUCT_IOVEC
|
11
11
|
#endif
|
12
12
|
#include "mdbx.h"
|
13
|
+
#include "frt_ram_store.h"
|
14
|
+
#include "frt_in_stream.h"
|
15
|
+
#include "frt_out_stream.h"
|
13
16
|
|
14
17
|
#define FRT_LOCK_PREFIX "ferret-"
|
15
18
|
#define FRT_LOCK_EXT ".lck"
|
16
19
|
|
17
|
-
typedef struct FrtBuffer {
|
18
|
-
frt_uchar buf[FRT_BUFFER_SIZE];
|
19
|
-
frt_off_t start;
|
20
|
-
frt_off_t pos;
|
21
|
-
frt_off_t len;
|
22
|
-
} FrtBuffer;
|
23
|
-
|
24
20
|
typedef struct FrtStore FrtStore;
|
25
|
-
typedef struct FrtOutStream FrtOutStream;
|
26
|
-
struct FrtOutStreamMethods {
|
27
|
-
/* internal functions for the FrtInStream */
|
28
|
-
/**
|
29
|
-
* Flush +len+ characters from +src+ to the output stream +os+
|
30
|
-
*
|
31
|
-
* @param os self
|
32
|
-
* @param src the characters to write to the output stream
|
33
|
-
* @param len the number of characters to write
|
34
|
-
* @raise FRT_IO_ERROR if there is an error writing the characters
|
35
|
-
*/
|
36
|
-
void (*flush_i)(struct FrtOutStream *os, const frt_uchar *buf, int len);
|
37
|
-
|
38
|
-
/**
|
39
|
-
* Seek +pos+ in the output stream
|
40
|
-
*
|
41
|
-
* @param os self
|
42
|
-
* @param pos the position to seek in the stream
|
43
|
-
* @raise FRT_IO_ERROR if there is an error seeking in the output stream
|
44
|
-
*/
|
45
|
-
void (*seek_i)(struct FrtOutStream *os, frt_off_t pos);
|
46
|
-
|
47
|
-
/**
|
48
|
-
* Close any resources used by the output stream +os+
|
49
|
-
*
|
50
|
-
* @param os self
|
51
|
-
* @raise FRT_IO_ERROR if there is an error closing the file
|
52
|
-
*/
|
53
|
-
void (*close_i)(struct FrtOutStream *os);
|
54
|
-
};
|
55
|
-
|
56
|
-
typedef struct FrtRAMFile {
|
57
|
-
char *name;
|
58
|
-
frt_uchar **buffers;
|
59
|
-
int bufcnt;
|
60
|
-
frt_off_t len;
|
61
|
-
_Atomic unsigned int ref_cnt;
|
62
|
-
} FrtRAMFile;
|
63
|
-
|
64
|
-
struct FrtOutStream {
|
65
|
-
FrtBuffer buf;
|
66
|
-
frt_off_t pointer; /* only used by RAMOut */
|
67
|
-
FrtStore *store;
|
68
|
-
union {
|
69
|
-
int fd;
|
70
|
-
FrtRAMFile *rf;
|
71
|
-
} file;
|
72
|
-
const struct FrtOutStreamMethods *m;
|
73
|
-
};
|
74
|
-
|
75
|
-
typedef struct FrtCompoundInStream FrtCompoundInStream;
|
76
|
-
|
77
|
-
typedef struct FrtInStream FrtInStream;
|
78
|
-
|
79
|
-
struct FrtInStreamMethods {
|
80
|
-
/**
|
81
|
-
* Read +len+ characters from the input stream into the +offset+ position in
|
82
|
-
* +buf+, an array of unsigned characters.
|
83
|
-
*
|
84
|
-
* @param is self
|
85
|
-
* @param buf an array of characters which must be allocated with at least
|
86
|
-
* +offset+ + +len+ bytes
|
87
|
-
* @param len the number of bytes to read
|
88
|
-
* @raise FRT_IO_ERROR if there is an error reading from the input stream
|
89
|
-
*/
|
90
|
-
void (*read_i)(struct FrtInStream *is, frt_uchar *buf, int len);
|
91
|
-
|
92
|
-
/**
|
93
|
-
* Seek position +pos+ in input stream +is+
|
94
|
-
*
|
95
|
-
* @param is self
|
96
|
-
* @param pos the position to seek
|
97
|
-
* @raise FRT_IO_ERROR if the seek fails
|
98
|
-
*/
|
99
|
-
void (*seek_i)(struct FrtInStream *is, frt_off_t pos);
|
100
|
-
|
101
|
-
/**
|
102
|
-
* Returns the length of the input stream +is+
|
103
|
-
*
|
104
|
-
* @param is self
|
105
|
-
* @raise FRT_IO_ERROR if there is an error getting the file length
|
106
|
-
*/
|
107
|
-
frt_off_t (*length_i)(struct FrtInStream *is);
|
108
|
-
|
109
|
-
/**
|
110
|
-
* Close the resources allocated to the inputstream +is+
|
111
|
-
*
|
112
|
-
* @param is self
|
113
|
-
* @raise FRT_IO_ERROR if the close fails
|
114
|
-
*/
|
115
|
-
void (*close_i)(struct FrtInStream *is);
|
116
|
-
};
|
117
|
-
|
118
|
-
typedef struct FrtInStreamFile {
|
119
|
-
_Atomic unsigned int ref_cnt;
|
120
|
-
union {
|
121
|
-
int fd;
|
122
|
-
FrtRAMFile *rf;
|
123
|
-
} file;
|
124
|
-
} FrtInStreamFile;
|
125
|
-
|
126
|
-
struct FrtInStream {
|
127
|
-
FrtBuffer buf;
|
128
|
-
struct FrtInStreamFile *f;
|
129
|
-
union {
|
130
|
-
frt_off_t pointer; /* only used by RAMIn */
|
131
|
-
char *path; /* only used by FSIn */
|
132
|
-
FrtCompoundInStream *cis;
|
133
|
-
} d;
|
134
|
-
_Atomic unsigned int ref_cnt;
|
135
|
-
const struct FrtInStreamMethods *m;
|
136
|
-
};
|
137
|
-
|
138
|
-
struct FrtCompoundInStream {
|
139
|
-
FrtInStream *sub;
|
140
|
-
frt_off_t offset;
|
141
|
-
frt_off_t length;
|
142
|
-
};
|
143
|
-
|
144
|
-
#define frt_is_length(mis) mis->m->length_i(mis)
|
145
|
-
|
146
21
|
typedef struct FrtLock FrtLock;
|
22
|
+
|
147
23
|
struct FrtLock {
|
148
|
-
char *
|
24
|
+
const char *folder_name;
|
25
|
+
const char *name;
|
149
26
|
FrtStore *store;
|
150
27
|
int (*obtain)(FrtLock *lock);
|
151
28
|
int (*is_locked)(FrtLock *lock);
|
@@ -153,16 +30,10 @@ struct FrtLock {
|
|
153
30
|
VALUE rlock;
|
154
31
|
};
|
155
32
|
|
156
|
-
typedef struct FrtCompoundStore {
|
157
|
-
FrtStore *store;
|
158
|
-
const char *name;
|
159
|
-
FrtHash *entries;
|
160
|
-
FrtInStream *stream;
|
161
|
-
} FrtCompoundStore;
|
162
|
-
|
163
33
|
typedef struct MDBXInfo {
|
164
|
-
MDBX_env
|
165
|
-
char
|
34
|
+
MDBX_env *env;
|
35
|
+
const char *path;
|
36
|
+
FrtStore *temp_store;
|
166
37
|
} MDBXInfo;
|
167
38
|
|
168
39
|
struct FrtStore {
|
@@ -170,7 +41,6 @@ struct FrtStore {
|
|
170
41
|
pthread_mutex_t mutex_i; /* for internal use only */
|
171
42
|
pthread_mutex_t mutex; /* external mutex for use outside */
|
172
43
|
union {
|
173
|
-
char *path; /* for fs_store only */
|
174
44
|
FrtHash *ht; /* for ram_store only */
|
175
45
|
MDBXInfo *mdbx; /* for mdbx store only */
|
176
46
|
} dir;
|
@@ -182,52 +52,76 @@ struct FrtStore {
|
|
182
52
|
FrtHashSet *locks;
|
183
53
|
|
184
54
|
/**
|
185
|
-
* Create the
|
55
|
+
* Create the folder +folder_name+ in the store if it
|
56
|
+
* doesn't exist.
|
57
|
+
*
|
58
|
+
* @param self store
|
59
|
+
* @param folder_name the name of the folder to create
|
60
|
+
* @raise FRT_IO_ERROR if the folder cannot be created
|
61
|
+
*/
|
62
|
+
void (*create_folder)(FrtStore *self, const char *folder_name);
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Remove the folder +folder_name+ from the store.
|
66
|
+
*
|
67
|
+
* @param self store
|
68
|
+
* @param folder_name the name of the folder to remove
|
69
|
+
* @raise FRT_IO_ERROR if the folder cannot be created
|
70
|
+
*/
|
71
|
+
void (*remove_folder)(FrtStore *self, const char *folder_name);
|
72
|
+
|
73
|
+
/**
|
74
|
+
* Create the file +filename+ in the store.
|
186
75
|
*
|
187
|
-
* @param store
|
76
|
+
* @param self store
|
77
|
+
* @param folder_name the name of the folder
|
188
78
|
* @param filename the name of the file to create
|
189
79
|
* @raise FRT_IO_ERROR if the file cannot be created
|
190
80
|
*/
|
191
|
-
void (*touch)(FrtStore *
|
81
|
+
void (*touch)(FrtStore *self, const char *folder_name, const char *filename);
|
192
82
|
|
193
83
|
/**
|
194
|
-
* Return true if a file of name +filename+ exists in
|
84
|
+
* Return true if a file of name +filename+ exists in store.
|
195
85
|
*
|
196
|
-
* @param store
|
86
|
+
* @param self store
|
87
|
+
* @param folder_name the name of the folder
|
197
88
|
* @param filename the name of the file to check for
|
198
89
|
* @returns true if the file exists
|
199
|
-
* @raise FRT_IO_ERROR if there is an error checking for the files
|
90
|
+
* @raise FRT_IO_ERROR if there is an error checking for the files existence
|
200
91
|
*/
|
201
|
-
int (*exists)(FrtStore *
|
92
|
+
int (*exists)(FrtStore *self, const char *folder_name, const char *filename);
|
202
93
|
|
203
94
|
/**
|
204
|
-
* Remove the file +filename+ from the
|
95
|
+
* Remove the file +filename+ from the store.
|
205
96
|
*
|
206
|
-
* @param store
|
97
|
+
* @param self store
|
98
|
+
* @param folder_name the name of the folder
|
207
99
|
* @param filename the name of the file to remove
|
208
100
|
* @returns On success, zero is returned. On error, -1 is returned, and errno
|
209
101
|
* is set appropriately.
|
210
102
|
*/
|
211
|
-
int (*remove)(FrtStore *
|
103
|
+
int (*remove)(FrtStore *self, const char *folder_name, const char *filename);
|
212
104
|
|
213
105
|
/**
|
214
|
-
* Rename the file in the
|
106
|
+
* Rename the file in the store from the name +from+ to the name +to+.
|
215
107
|
*
|
216
|
-
* @param store
|
108
|
+
* @param self store
|
109
|
+
* @param folder_name the name of the folder
|
217
110
|
* @param from the name of the file to rename
|
218
111
|
* @param to the new name of the file
|
219
112
|
* @raise FRT_IO_ERROR if there is an error renaming the file
|
220
113
|
*/
|
221
|
-
void (*rename)(FrtStore *
|
114
|
+
void (*rename)(FrtStore *self, const char *folder_name, const char *from, const char *to);
|
222
115
|
|
223
116
|
/**
|
224
117
|
* Returns the number of files in the store.
|
225
118
|
*
|
226
|
-
* @param store
|
119
|
+
* @param self store
|
120
|
+
* @param folder_name the name of the folder
|
227
121
|
* @return the number of files in the store
|
228
122
|
* @raise FRT_IO_ERROR if there is an error opening the directory
|
229
123
|
*/
|
230
|
-
int (*count)(FrtStore *
|
124
|
+
int (*count)(FrtStore *self, const char *folder_name);
|
231
125
|
|
232
126
|
/**
|
233
127
|
* Call the function +func+ with each filename in the store and the arg
|
@@ -235,80 +129,87 @@ struct FrtStore {
|
|
235
129
|
* as the argument. If you need to pass more than one argument, you should
|
236
130
|
* pass a struct.
|
237
131
|
*
|
238
|
-
* @param store
|
132
|
+
* @param self store
|
133
|
+
* @param folder_name the name of the folder
|
239
134
|
* @param func the function to call with each files name and the +arg+
|
240
135
|
* passed
|
241
136
|
* @param arg the argument to pass to the function
|
242
137
|
* @raise FRT_IO_ERROR if there is an error opening the directory
|
243
138
|
*/
|
244
|
-
void (*each)(FrtStore *
|
245
|
-
void *arg);
|
139
|
+
void (*each)(FrtStore *self, const char *folder_name, void (*func)(const char *fname, void *arg), void *arg);
|
246
140
|
|
247
141
|
/**
|
248
142
|
* Clear all the locks in the store.
|
249
143
|
*
|
250
|
-
* @param store
|
144
|
+
* @param self store
|
145
|
+
* @param folder_name the name of the folder
|
251
146
|
* @raise FRT_IO_ERROR if there is an error opening the directory
|
252
147
|
*/
|
253
|
-
void (*clear_locks)(FrtStore *
|
148
|
+
void (*clear_locks)(FrtStore *self, const char *folder_name);
|
254
149
|
|
255
150
|
/**
|
256
151
|
* Clear all files from the store except the lock files.
|
257
152
|
*
|
258
|
-
* @param store
|
153
|
+
* @param self store
|
154
|
+
* @param folder_name the name of the folder
|
259
155
|
* @raise FRT_IO_ERROR if there is an error deleting the files
|
260
156
|
*/
|
261
|
-
void (*clear)(FrtStore *
|
157
|
+
void (*clear)(FrtStore *self, const char *folder_name);
|
262
158
|
|
263
159
|
/**
|
264
160
|
* Clear all files from the store including the lock files.
|
265
161
|
*
|
266
|
-
* @param store
|
162
|
+
* @param self store
|
163
|
+
* @param folder_name the name of the folder
|
267
164
|
* @raise FRT_IO_ERROR if there is an error deleting the files
|
268
165
|
*/
|
269
|
-
void (*clear_all)(FrtStore *
|
166
|
+
void (*clear_all)(FrtStore *self, const char *folder_name);
|
270
167
|
|
271
168
|
/**
|
272
|
-
* Return the length of the file +filename+ in +store
|
169
|
+
* Return the length of the file +filename+ in +store+.
|
273
170
|
*
|
274
|
-
* @param store
|
171
|
+
* @param self store
|
172
|
+
* @param folder_name the name of the folder
|
275
173
|
* @param the name of the file to check the length of
|
276
174
|
* @return the length of the file in bytes
|
277
175
|
* @raise FRT_IO_ERROR if there is an error checking the file length
|
278
176
|
*/
|
279
|
-
frt_off_t (*length)(FrtStore *
|
177
|
+
frt_off_t (*length)(FrtStore *self, const char *folder_name, const char *filename);
|
280
178
|
|
281
179
|
/**
|
282
180
|
* Allocate the resources needed for the output stream in the +store+ with
|
283
|
-
* the name +filename
|
181
|
+
* the name +filename+.
|
284
182
|
*
|
285
|
-
* @param store
|
183
|
+
* @param self store
|
184
|
+
* @param folder_name the name of the folder
|
286
185
|
* @param filename the name of the output stream
|
287
|
-
* @return a newly allocated
|
186
|
+
* @return a newly allocated file stream
|
288
187
|
* @raise FRT_IO_ERROR if there is an error opening the output stream
|
289
188
|
* resources
|
290
189
|
*/
|
291
|
-
FrtOutStream *(*new_output)(FrtStore *
|
190
|
+
FrtOutStream *(*new_output)(FrtStore *self, const char *folder_name, const char *filename);
|
292
191
|
|
293
192
|
/**
|
294
|
-
* Open an input stream in the +store+ with the name +filename
|
193
|
+
* Open an input stream in the +store+ with the name +filename+.
|
295
194
|
*
|
296
|
-
* @param store
|
195
|
+
* @param self store
|
196
|
+
* @param folder_name the name of the folder
|
297
197
|
* @param filename the name of the input stream
|
298
198
|
* @raise FRT_FILE_NOT_FOUND_ERROR if the input stream cannot be opened
|
299
199
|
*/
|
300
|
-
FrtInStream *(*open_input)(FrtStore *
|
200
|
+
FrtInStream *(*open_input)(FrtStore *self, const char *folder_name, const char *filename);
|
301
201
|
|
302
202
|
/**
|
303
|
-
* Obtain a lock on the lock +lock
|
203
|
+
* Obtain a lock on the lock +lock+.
|
304
204
|
*
|
305
|
-
* @param store
|
205
|
+
* @param self store
|
206
|
+
* @param folder_name the name of the folder
|
306
207
|
* @param lock the lock to obtain
|
307
208
|
*/
|
308
|
-
FrtLock *(*open_lock_i)(FrtStore *
|
209
|
+
FrtLock *(*open_lock_i)(FrtStore *self, const char *folder_name, const char *lockname);
|
309
210
|
|
310
211
|
/**
|
311
|
-
* Returns true if +lock+ is locked. To test if the file is locked:wq
|
212
|
+
* Returns true if +lock+ is locked. To test if the file is locked:wq.
|
312
213
|
*
|
313
214
|
* @param lock the lock to test
|
314
215
|
* @raise FRT_IO_ERROR if there is an error detecting the lock status
|
@@ -319,9 +220,9 @@ struct FrtStore {
|
|
319
220
|
* Internal function to close the store freeing implementation specific
|
320
221
|
* resources.
|
321
222
|
*
|
322
|
-
* @param store
|
223
|
+
* @param self store
|
323
224
|
*/
|
324
|
-
void (*close_i)(FrtStore *
|
225
|
+
void (*close_i)(FrtStore *self);
|
325
226
|
|
326
227
|
/**
|
327
228
|
* Reference to be used within ruby realm.
|
@@ -351,12 +252,13 @@ extern FrtStore *frt_open_ram_store(FrtStore *new_store);
|
|
351
252
|
* method would be used for example to read an index into memory for faster
|
352
253
|
* searching.
|
353
254
|
*
|
354
|
-
* @param
|
355
|
-
*
|
356
|
-
* @param
|
255
|
+
* @param to_store the target store
|
256
|
+
* @param from_store the store, whose contents will be copied into the newly allocated RAM store
|
257
|
+
* @param folder_name folder to be copied, will be create in the target store, if it doesn't exist
|
258
|
+
* @param close_store close the from_store whose contents where copied
|
357
259
|
* @return a newly allocated RAM FrtStore.
|
358
260
|
*/
|
359
|
-
extern FrtStore *frt_open_ram_store_and_copy(FrtStore *
|
261
|
+
extern FrtStore *frt_open_ram_store_and_copy(FrtStore *to_store, FrtStore *from_store, const char *folder_name, bool close_store);
|
360
262
|
|
361
263
|
/*
|
362
264
|
* == RamStore functions ==
|
@@ -425,7 +327,7 @@ extern void frt_with_lock(FrtLock *lock, void (*func)(void *arg), void *arg);
|
|
425
327
|
* @raise FRT_IO_ERROR if the lock is already locked
|
426
328
|
* @see frt_with_lock
|
427
329
|
*/
|
428
|
-
extern void frt_with_lock_name(FrtStore *store, const char *lock_name, void (*func)(void *arg), void *arg);
|
330
|
+
extern void frt_with_lock_name(FrtStore *store, const char *folder_name, const char *lock_name, void (*func)(void *arg), void *arg);
|
429
331
|
|
430
332
|
/**
|
431
333
|
* Remove a reference to the store. If the reference count gets to zero free
|
@@ -435,314 +337,6 @@ extern void frt_with_lock_name(FrtStore *store, const char *lock_name, void (*fu
|
|
435
337
|
*/
|
436
338
|
extern void frt_store_close(FrtStore *store);
|
437
339
|
|
438
|
-
/**
|
439
|
-
* Flush the buffered contents of the FrtOutStream to the store.
|
440
|
-
*
|
441
|
-
* @param os the FrtOutStream to flush
|
442
|
-
*/
|
443
|
-
extern void frt_os_flush(FrtOutStream *os);
|
444
|
-
|
445
|
-
/**
|
446
|
-
* Close the FrtOutStream after flushing the buffers, also freeing all allocated
|
447
|
-
* resources.
|
448
|
-
*
|
449
|
-
* @param os the FrtOutStream to close
|
450
|
-
*/
|
451
|
-
extern void frt_os_close(FrtOutStream *os);
|
452
|
-
|
453
|
-
/**
|
454
|
-
* Return the current position of FrtOutStream +os+.
|
455
|
-
*
|
456
|
-
* @param os the FrtOutStream to get the position from
|
457
|
-
* @return the current position in FrtOutStream +os+
|
458
|
-
*/
|
459
|
-
extern frt_off_t frt_os_pos(FrtOutStream *os);
|
460
|
-
|
461
|
-
/**
|
462
|
-
* Set the current position in FrtOutStream +os+.
|
463
|
-
*
|
464
|
-
* @param os the FrtOutStream to set the position in
|
465
|
-
* @param pos the new position in the FrtOutStream
|
466
|
-
* @raise FRT_IO_ERROR if there is a file-system IO error seeking the file
|
467
|
-
*/
|
468
|
-
extern void frt_os_seek(FrtOutStream *os, frt_off_t new_pos);
|
469
|
-
|
470
|
-
/**
|
471
|
-
* Write a single byte +b+ to the FrtOutStream +os+
|
472
|
-
*
|
473
|
-
* @param os the FrtOutStream to write to @param b the byte to write @raise
|
474
|
-
* FRT_IO_ERROR if there is an IO error writing to the file-system
|
475
|
-
*/
|
476
|
-
extern void frt_os_write_byte(FrtOutStream *os, frt_uchar b);
|
477
|
-
/**
|
478
|
-
* Write +len+ bytes from buffer +buf+ to the FrtOutStream +os+.
|
479
|
-
*
|
480
|
-
* @param os the FrtOutStream to write to
|
481
|
-
* @param len the number of bytes to write
|
482
|
-
* @param buf the buffer from which to get the bytes to write.
|
483
|
-
* @raise FRT_IO_ERROR if there is an IO error writing to the file-system
|
484
|
-
*/
|
485
|
-
extern void frt_os_write_bytes(FrtOutStream *os, const frt_uchar *buf, int len);
|
486
|
-
|
487
|
-
/**
|
488
|
-
* Write a 32-bit signed integer to the FrtOutStream
|
489
|
-
*
|
490
|
-
* @param os FrtOutStream to write to
|
491
|
-
* @param num the 32-bit signed integer to write
|
492
|
-
* @raise FRT_IO_ERROR if there is an error writing to the file-system
|
493
|
-
*/
|
494
|
-
extern void frt_os_write_i32(FrtOutStream *os, frt_i32 num);
|
495
|
-
|
496
|
-
/**
|
497
|
-
* Write a 64-bit signed integer to the FrtOutStream
|
498
|
-
*
|
499
|
-
*
|
500
|
-
* @param os FrtOutStream to write to
|
501
|
-
* @param num the 64-bit signed integer to write
|
502
|
-
* @raise FRT_IO_ERROR if there is an error writing to the file-system
|
503
|
-
*/
|
504
|
-
extern void frt_os_write_i64(FrtOutStream *os, frt_i64 num);
|
505
|
-
|
506
|
-
/**
|
507
|
-
* Write a 32-bit unsigned integer to the FrtOutStream
|
508
|
-
*
|
509
|
-
* @param os FrtOutStream to write to
|
510
|
-
* @param num the 32-bit unsigned integer to write
|
511
|
-
* @raise FRT_IO_ERROR if there is an error writing to the file-system
|
512
|
-
*/
|
513
|
-
extern void frt_os_write_u32(FrtOutStream *os, frt_u32 num);
|
514
|
-
|
515
|
-
/**
|
516
|
-
* Write a 64-bit unsigned integer to the FrtOutStream
|
517
|
-
*
|
518
|
-
* @param os FrtOutStream to write to
|
519
|
-
* @param num the 64-bit unsigned integer to write
|
520
|
-
* @raise FRT_IO_ERROR if there is an error writing to the file-system
|
521
|
-
*/
|
522
|
-
extern void frt_os_write_u64(FrtOutStream *os, frt_u64 num);
|
523
|
-
|
524
|
-
/**
|
525
|
-
* Write an unsigned integer to FrtOutStream in compressed VINT format.
|
526
|
-
* TODO: describe VINT format
|
527
|
-
*
|
528
|
-
* @param os FrtOutStream to write to
|
529
|
-
* @param num the integer to write
|
530
|
-
* @raise FRT_IO_ERROR if there is an error writing to the file-system
|
531
|
-
*/
|
532
|
-
extern void frt_os_write_vint(FrtOutStream *os, register unsigned int num);
|
533
|
-
|
534
|
-
/**
|
535
|
-
* Write an unsigned frt_off_t to FrtOutStream in compressed VINT format.
|
536
|
-
* TODO: describe VINT format
|
537
|
-
*
|
538
|
-
* @param os FrtOutStream to write to
|
539
|
-
* @param num the frt_off_t to write
|
540
|
-
* @raise FRT_IO_ERROR if there is an error writing to the file-system
|
541
|
-
*/
|
542
|
-
extern void frt_os_write_voff_t(FrtOutStream *os, register frt_off_t num);
|
543
|
-
|
544
|
-
/**
|
545
|
-
* Write an unsigned 64bit int to FrtOutStream in compressed VINT format.
|
546
|
-
* TODO: describe VINT format
|
547
|
-
*
|
548
|
-
* @param os FrtOutStream to write to
|
549
|
-
* @param num the 64bit int to write
|
550
|
-
* @raise FRT_IO_ERROR if there is an error writing to the file-system
|
551
|
-
*/
|
552
|
-
extern void frt_os_write_vll(FrtOutStream *os, register frt_u64 num);
|
553
|
-
|
554
|
-
/**
|
555
|
-
* Write a string with known length to the FrtOutStream. A string is an
|
556
|
-
* integer +length+ in VINT format (see frt_os_write_vint) followed by
|
557
|
-
* +length+ bytes. The string can then be read using frt_is_read_string.
|
558
|
-
*
|
559
|
-
* @param os FrtOutStream to write to
|
560
|
-
* @param str the string to write
|
561
|
-
* @param len the length of the string to write
|
562
|
-
* @raise FRT_IO_ERROR if there is an error writing to the file-system
|
563
|
-
*/
|
564
|
-
extern void frt_os_write_string_len(FrtOutStream *os,
|
565
|
-
const char *str,
|
566
|
-
int len);
|
567
|
-
|
568
|
-
/**
|
569
|
-
* Write a string to the FrtOutStream. A string is an integer +length+ in VINT
|
570
|
-
* format (see frt_os_write_vint) followed by +length+ bytes. The string can then
|
571
|
-
* be read using frt_is_read_string.
|
572
|
-
*
|
573
|
-
* @param os FrtOutStream to write to
|
574
|
-
* @param str the string to write
|
575
|
-
* @raise FRT_IO_ERROR if there is an error writing to the file-system
|
576
|
-
*/
|
577
|
-
extern void frt_os_write_string(FrtOutStream *os, const char *str);
|
578
|
-
|
579
|
-
/**
|
580
|
-
* Get the current position within an FrtInStream.
|
581
|
-
*
|
582
|
-
* @param is the FrtInStream to get the current position from
|
583
|
-
* @return the current position within the FrtInStream +is+
|
584
|
-
*/
|
585
|
-
extern frt_off_t frt_is_pos(FrtInStream *is);
|
586
|
-
|
587
|
-
/**
|
588
|
-
* Set the current position in FrtInStream +is+ to +pos+.
|
589
|
-
*
|
590
|
-
* @param is the FrtInStream to set the current position in
|
591
|
-
* @param pos the position in FrtInStream to seek
|
592
|
-
* @raise FRT_IO_ERROR if there is a error seeking from the file-system
|
593
|
-
* @raise FRT_EOF_ERROR if there is an attempt to seek past the end of the file
|
594
|
-
*/
|
595
|
-
extern void frt_is_seek(FrtInStream *is, frt_off_t pos);
|
596
|
-
|
597
|
-
/**
|
598
|
-
* Close the FrtInStream freeing all allocated resources.
|
599
|
-
*
|
600
|
-
* @param is the FrtInStream to close
|
601
|
-
* @raise FRT_IO_ERROR if there is an error closing the associated file
|
602
|
-
*/
|
603
|
-
extern void frt_is_close(FrtInStream *is);
|
604
|
-
|
605
|
-
/**
|
606
|
-
* Clone the FrtInStream allocating a new FrtInStream structure
|
607
|
-
*
|
608
|
-
* @param is the FrtInStream to clone
|
609
|
-
* @return a newly allocated FrtInStream which is a clone of +is+
|
610
|
-
*/
|
611
|
-
extern FrtInStream *frt_is_clone(FrtInStream *is);
|
612
|
-
|
613
|
-
/**
|
614
|
-
* Read a singly byte (unsigned char) from the FrtInStream +is+.
|
615
|
-
*
|
616
|
-
* @param is the Instream to read from
|
617
|
-
* @return a single unsigned char read from the FrtInStream +is+
|
618
|
-
* @raise FRT_IO_ERROR if there is a error reading from the file-system
|
619
|
-
* @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
|
620
|
-
*/
|
621
|
-
extern frt_uchar frt_is_read_byte(FrtInStream *is);
|
622
|
-
|
623
|
-
/**
|
624
|
-
* Read +len+ bytes from FrtInStream +is+ and write them to buffer +buf+
|
625
|
-
*
|
626
|
-
* @param is the FrtInStream to read from
|
627
|
-
* @param buf the buffer to read into, that is copy the bytes read to
|
628
|
-
* @param len the number of bytes to read
|
629
|
-
* @return the resultant buffer +buf+
|
630
|
-
* @raise FRT_IO_ERROR if there is a error reading from the file-system
|
631
|
-
* @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
|
632
|
-
*/
|
633
|
-
extern frt_uchar *frt_is_read_bytes(FrtInStream *is, frt_uchar *buf, int len);
|
634
|
-
|
635
|
-
/**
|
636
|
-
* Read a 32-bit unsigned integer from the FrtInStream.
|
637
|
-
*
|
638
|
-
* @param is the FrtInStream to read from
|
639
|
-
* @return a 32-bit unsigned integer
|
640
|
-
* @raise FRT_IO_ERROR if there is a error reading from the file-system
|
641
|
-
* @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
|
642
|
-
*/
|
643
|
-
extern frt_i32 frt_is_read_i32(FrtInStream *is);
|
644
|
-
|
645
|
-
/**
|
646
|
-
* Read a 64-bit unsigned integer from the FrtInStream.
|
647
|
-
*
|
648
|
-
* @param is the FrtInStream to read from
|
649
|
-
* @return a 64-bit unsigned integer
|
650
|
-
* @raise FRT_IO_ERROR if there is a error reading from the file-system
|
651
|
-
* @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
|
652
|
-
*/
|
653
|
-
extern frt_i64 frt_is_read_i64(FrtInStream *is);
|
654
|
-
|
655
|
-
/**
|
656
|
-
* Read a 32-bit signed integer from the FrtInStream.
|
657
|
-
*
|
658
|
-
* @param is the FrtInStream to read from
|
659
|
-
* @return a 32-bit signed integer
|
660
|
-
* @raise FRT_IO_ERROR if there is a error reading from the file-system
|
661
|
-
* @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
|
662
|
-
*/
|
663
|
-
extern frt_u32 frt_is_read_u32(FrtInStream *is);
|
664
|
-
|
665
|
-
/**
|
666
|
-
* Read a 64-bit signed integer from the FrtInStream.
|
667
|
-
*
|
668
|
-
* @param is the FrtInStream to read from
|
669
|
-
* @return a 64-bit signed integer
|
670
|
-
* @raise FRT_IO_ERROR if there is a error reading from the file-system
|
671
|
-
* @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
|
672
|
-
*/
|
673
|
-
extern frt_u64 frt_is_read_u64(FrtInStream *is);
|
674
|
-
|
675
|
-
/**
|
676
|
-
* Read a compressed (VINT) unsigned integer from the FrtInStream.
|
677
|
-
* TODO: describe VINT format
|
678
|
-
*
|
679
|
-
* @param is the FrtInStream to read from
|
680
|
-
* @return an int
|
681
|
-
* @raise FRT_IO_ERROR if there is a error reading from the file-system
|
682
|
-
* @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
|
683
|
-
*/
|
684
|
-
extern unsigned int frt_is_read_vint(FrtInStream *is);
|
685
|
-
|
686
|
-
/**
|
687
|
-
* Skip _cnt_ vints. This is a convenience method used for performance reasons
|
688
|
-
* to skip large numbers of vints. It is mostly used by TermDocEnums. When
|
689
|
-
* skipping positions os the proximity index file.
|
690
|
-
*
|
691
|
-
* @param is the FrtInStream to read from
|
692
|
-
* @param cnt the number of vints to skip
|
693
|
-
* @raise FRT_IO_ERROR if there is a error reading from the file-system
|
694
|
-
* @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
|
695
|
-
*/
|
696
|
-
extern void frt_is_skip_vints(FrtInStream *is, register int cnt);
|
697
|
-
|
698
|
-
/**
|
699
|
-
* Read a compressed (VINT) unsigned frt_off_t from the FrtInStream.
|
700
|
-
* TODO: describe VINT format
|
701
|
-
*
|
702
|
-
* @param is the FrtInStream to read from
|
703
|
-
* @return a frt_off_t
|
704
|
-
* @raise FRT_IO_ERROR if there is a error reading from the file-system
|
705
|
-
* @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
|
706
|
-
*/
|
707
|
-
extern frt_off_t frt_is_read_voff_t(FrtInStream *is);
|
708
|
-
|
709
|
-
/**
|
710
|
-
* Read a compressed (VINT) unsigned 64bit int from the FrtInStream.
|
711
|
-
* TODO: describe VINT format
|
712
|
-
*
|
713
|
-
* @param is the FrtInStream to read from
|
714
|
-
* @return a 64bit int
|
715
|
-
* @raise FRT_IO_ERROR if there is a error reading from the file-system
|
716
|
-
* @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
|
717
|
-
*/
|
718
|
-
extern frt_u64 frt_is_read_vll(FrtInStream *is);
|
719
|
-
|
720
|
-
/**
|
721
|
-
* Read a string from the FrtInStream. A string is an integer +length+ in vint
|
722
|
-
* format (see frt_is_read_vint) followed by +length+ bytes. This is the format
|
723
|
-
* used by frt_os_write_string.
|
724
|
-
*
|
725
|
-
* @param is the FrtInStream to read from
|
726
|
-
* @return a null byte delimited string
|
727
|
-
* @raise FRT_IO_ERROR if there is a error reading from the file-system
|
728
|
-
* @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
|
729
|
-
*/
|
730
|
-
extern char *frt_is_read_string(FrtInStream *is);
|
731
|
-
|
732
|
-
/**
|
733
|
-
* Read a string from the FrtInStream. A string is an integer +length+ in vint
|
734
|
-
* format (see frt_is_read_vint) followed by +length+ bytes. This is the format
|
735
|
-
* used by frt_os_write_string. This method is similar to +frt_is_read_string+ except
|
736
|
-
* that it will safely free all memory if there is an error reading the
|
737
|
-
* string.
|
738
|
-
*
|
739
|
-
* @param is the FrtInStream to read from
|
740
|
-
* @return a null byte delimited string
|
741
|
-
* @raise FRT_IO_ERROR if there is a error reading from the file-system
|
742
|
-
* @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
|
743
|
-
*/
|
744
|
-
extern char *frt_is_read_string_safe(FrtInStream *is);
|
745
|
-
|
746
340
|
/**
|
747
341
|
* Copy cnt bytes from Instream _is_ to FrtOutStream _os_.
|
748
342
|
*
|
@@ -764,13 +358,14 @@ extern void frt_is2os_copy_bytes(FrtInStream *is, FrtOutStream *os, int cnt);
|
|
764
358
|
extern void frt_is2os_copy_vints(FrtInStream *is, FrtOutStream *os, int cnt);
|
765
359
|
|
766
360
|
/**
|
767
|
-
* Print the filenames in a store to a buffer.
|
361
|
+
* Print the filenames in a store folder to a buffer.
|
768
362
|
*
|
769
363
|
* @param store the store to get the filenames from
|
364
|
+
* @param folder_name the folder to get the filenames from
|
770
365
|
*/
|
771
|
-
extern char *
|
366
|
+
extern char *frt_store_folder_to_s(FrtStore *store, const char *folder_name);
|
772
367
|
|
773
|
-
extern FrtLock *frt_open_lock(FrtStore *store, const char *lockname);
|
368
|
+
extern FrtLock *frt_open_lock(FrtStore *store, const char *folder_name, const char *lockname);
|
774
369
|
extern void frt_close_lock(FrtLock *lock);
|
775
370
|
|
776
371
|
/* required by submodules
|