ferret 0.9.6 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +1 -1
- data/README +12 -24
- data/Rakefile +38 -54
- data/TODO +14 -17
- data/ext/analysis.c +982 -823
- data/ext/analysis.h +133 -76
- data/ext/array.c +96 -58
- data/ext/array.h +40 -13
- data/ext/bitvector.c +476 -118
- data/ext/bitvector.h +264 -22
- data/ext/compound_io.c +217 -229
- data/ext/defines.h +49 -0
- data/ext/document.c +107 -317
- data/ext/document.h +31 -65
- data/ext/except.c +81 -36
- data/ext/except.h +117 -55
- data/ext/extconf.rb +2 -9
- data/ext/ferret.c +211 -104
- data/ext/ferret.h +22 -11
- data/ext/filter.c +97 -82
- data/ext/fs_store.c +348 -367
- data/ext/global.c +226 -188
- data/ext/global.h +44 -26
- data/ext/hash.c +474 -391
- data/ext/hash.h +441 -68
- data/ext/hashset.c +124 -96
- data/ext/hashset.h +169 -20
- data/ext/helper.c +56 -5
- data/ext/helper.h +7 -0
- data/ext/inc/lang.h +29 -49
- data/ext/inc/threading.h +31 -0
- data/ext/ind.c +288 -278
- data/ext/ind.h +68 -0
- data/ext/index.c +5688 -0
- data/ext/index.h +663 -616
- data/ext/lang.h +29 -49
- data/ext/libstemmer.c +3 -3
- data/ext/mem_pool.c +84 -0
- data/ext/mem_pool.h +35 -0
- data/ext/posh.c +1006 -0
- data/ext/posh.h +1007 -0
- data/ext/priorityqueue.c +117 -194
- data/ext/priorityqueue.h +135 -39
- data/ext/q_boolean.c +1305 -1108
- data/ext/q_const_score.c +106 -93
- data/ext/q_filtered_query.c +138 -135
- data/ext/q_fuzzy.c +206 -242
- data/ext/q_match_all.c +94 -80
- data/ext/q_multi_term.c +663 -0
- data/ext/q_parser.c +667 -593
- data/ext/q_phrase.c +992 -555
- data/ext/q_prefix.c +72 -61
- data/ext/q_range.c +235 -210
- data/ext/q_span.c +1480 -1166
- data/ext/q_term.c +273 -246
- data/ext/q_wildcard.c +127 -114
- data/ext/r_analysis.c +1720 -711
- data/ext/r_index.c +3049 -0
- data/ext/r_qparser.c +433 -146
- data/ext/r_search.c +2934 -1993
- data/ext/r_store.c +372 -143
- data/ext/r_utils.c +941 -0
- data/ext/ram_store.c +330 -326
- data/ext/search.c +1291 -668
- data/ext/search.h +403 -702
- data/ext/similarity.c +91 -113
- data/ext/similarity.h +45 -30
- data/ext/sort.c +721 -484
- data/ext/stopwords.c +361 -273
- data/ext/store.c +556 -58
- data/ext/store.h +706 -126
- data/ext/tags +3578 -2780
- data/ext/term_vectors.c +352 -0
- data/ext/threading.h +31 -0
- data/ext/win32.h +54 -0
- data/lib/ferret.rb +5 -17
- data/lib/ferret/document.rb +130 -2
- data/lib/ferret/index.rb +577 -26
- data/lib/ferret/number_tools.rb +157 -0
- data/lib/ferret_version.rb +3 -0
- data/test/test_helper.rb +5 -13
- data/test/unit/analysis/tc_analyzer.rb +513 -1
- data/test/unit/analysis/{ctc_tokenstream.rb → tc_token_stream.rb} +23 -0
- data/test/unit/index/tc_index.rb +183 -240
- data/test/unit/index/tc_index_reader.rb +312 -479
- data/test/unit/index/tc_index_writer.rb +397 -13
- data/test/unit/index/th_doc.rb +269 -206
- data/test/unit/query_parser/tc_query_parser.rb +40 -33
- data/test/unit/search/tc_filter.rb +59 -71
- data/test/unit/search/tc_fuzzy_query.rb +24 -16
- data/test/unit/search/tc_index_searcher.rb +23 -201
- data/test/unit/search/tc_multi_searcher.rb +78 -226
- data/test/unit/search/tc_search_and_sort.rb +93 -81
- data/test/unit/search/tc_sort.rb +23 -23
- data/test/unit/search/tc_sort_field.rb +7 -7
- data/test/unit/search/tc_spans.rb +51 -47
- data/test/unit/search/tm_searcher.rb +339 -0
- data/test/unit/store/tc_fs_store.rb +1 -1
- data/test/unit/store/tm_store_lock.rb +3 -3
- data/test/unit/tc_document.rb +81 -0
- data/test/unit/ts_analysis.rb +1 -1
- data/test/unit/ts_utils.rb +1 -1
- data/test/unit/utils/tc_bit_vector.rb +288 -0
- data/test/unit/utils/tc_number_tools.rb +117 -0
- data/test/unit/utils/tc_priority_queue.rb +106 -0
- metadata +140 -301
- data/CHANGELOG +0 -9
- data/ext/dummy.exe +0 -0
- data/ext/field.c +0 -408
- data/ext/frtio.h +0 -13
- data/ext/inc/except.h +0 -90
- data/ext/index_io.c +0 -382
- data/ext/index_rw.c +0 -2658
- data/ext/lang.c +0 -41
- data/ext/nix_io.c +0 -134
- data/ext/q_multi_phrase.c +0 -380
- data/ext/r_doc.c +0 -582
- data/ext/r_index_io.c +0 -1021
- data/ext/r_term.c +0 -219
- data/ext/term.c +0 -820
- data/ext/termdocs.c +0 -611
- data/ext/vector.c +0 -637
- data/ext/w32_io.c +0 -150
- data/lib/ferret/analysis.rb +0 -11
- data/lib/ferret/analysis/analyzers.rb +0 -112
- data/lib/ferret/analysis/standard_tokenizer.rb +0 -71
- data/lib/ferret/analysis/token.rb +0 -100
- data/lib/ferret/analysis/token_filters.rb +0 -86
- data/lib/ferret/analysis/token_stream.rb +0 -26
- data/lib/ferret/analysis/tokenizers.rb +0 -112
- data/lib/ferret/analysis/word_list_loader.rb +0 -27
- data/lib/ferret/document/document.rb +0 -152
- data/lib/ferret/document/field.rb +0 -312
- data/lib/ferret/index/compound_file_io.rb +0 -338
- data/lib/ferret/index/document_writer.rb +0 -289
- data/lib/ferret/index/field_infos.rb +0 -279
- data/lib/ferret/index/fields_io.rb +0 -181
- data/lib/ferret/index/index.rb +0 -675
- data/lib/ferret/index/index_file_names.rb +0 -33
- data/lib/ferret/index/index_reader.rb +0 -503
- data/lib/ferret/index/index_writer.rb +0 -534
- data/lib/ferret/index/multi_reader.rb +0 -377
- data/lib/ferret/index/multiple_term_doc_pos_enum.rb +0 -98
- data/lib/ferret/index/segment_infos.rb +0 -130
- data/lib/ferret/index/segment_merge_info.rb +0 -49
- data/lib/ferret/index/segment_merge_queue.rb +0 -16
- data/lib/ferret/index/segment_merger.rb +0 -358
- data/lib/ferret/index/segment_reader.rb +0 -412
- data/lib/ferret/index/segment_term_enum.rb +0 -169
- data/lib/ferret/index/segment_term_vector.rb +0 -58
- data/lib/ferret/index/term.rb +0 -53
- data/lib/ferret/index/term_buffer.rb +0 -83
- data/lib/ferret/index/term_doc_enum.rb +0 -291
- data/lib/ferret/index/term_enum.rb +0 -52
- data/lib/ferret/index/term_info.rb +0 -37
- data/lib/ferret/index/term_infos_io.rb +0 -321
- data/lib/ferret/index/term_vector_offset_info.rb +0 -20
- data/lib/ferret/index/term_vectors_io.rb +0 -553
- data/lib/ferret/query_parser.rb +0 -312
- data/lib/ferret/query_parser/query_parser.tab.rb +0 -928
- data/lib/ferret/search.rb +0 -50
- data/lib/ferret/search/boolean_clause.rb +0 -100
- data/lib/ferret/search/boolean_query.rb +0 -299
- data/lib/ferret/search/boolean_scorer.rb +0 -294
- data/lib/ferret/search/caching_wrapper_filter.rb +0 -40
- data/lib/ferret/search/conjunction_scorer.rb +0 -99
- data/lib/ferret/search/disjunction_sum_scorer.rb +0 -205
- data/lib/ferret/search/exact_phrase_scorer.rb +0 -32
- data/lib/ferret/search/explanation.rb +0 -41
- data/lib/ferret/search/field_cache.rb +0 -215
- data/lib/ferret/search/field_doc.rb +0 -31
- data/lib/ferret/search/field_sorted_hit_queue.rb +0 -184
- data/lib/ferret/search/filter.rb +0 -11
- data/lib/ferret/search/filtered_query.rb +0 -130
- data/lib/ferret/search/filtered_term_enum.rb +0 -79
- data/lib/ferret/search/fuzzy_query.rb +0 -154
- data/lib/ferret/search/fuzzy_term_enum.rb +0 -247
- data/lib/ferret/search/hit_collector.rb +0 -34
- data/lib/ferret/search/hit_queue.rb +0 -11
- data/lib/ferret/search/index_searcher.rb +0 -200
- data/lib/ferret/search/match_all_query.rb +0 -104
- data/lib/ferret/search/multi_phrase_query.rb +0 -216
- data/lib/ferret/search/multi_searcher.rb +0 -261
- data/lib/ferret/search/multi_term_query.rb +0 -65
- data/lib/ferret/search/non_matching_scorer.rb +0 -22
- data/lib/ferret/search/phrase_positions.rb +0 -55
- data/lib/ferret/search/phrase_query.rb +0 -214
- data/lib/ferret/search/phrase_scorer.rb +0 -152
- data/lib/ferret/search/prefix_query.rb +0 -54
- data/lib/ferret/search/query.rb +0 -140
- data/lib/ferret/search/query_filter.rb +0 -51
- data/lib/ferret/search/range_filter.rb +0 -103
- data/lib/ferret/search/range_query.rb +0 -139
- data/lib/ferret/search/req_excl_scorer.rb +0 -125
- data/lib/ferret/search/req_opt_sum_scorer.rb +0 -70
- data/lib/ferret/search/score_doc.rb +0 -38
- data/lib/ferret/search/score_doc_comparator.rb +0 -114
- data/lib/ferret/search/scorer.rb +0 -91
- data/lib/ferret/search/similarity.rb +0 -278
- data/lib/ferret/search/sloppy_phrase_scorer.rb +0 -47
- data/lib/ferret/search/sort.rb +0 -112
- data/lib/ferret/search/sort_comparator.rb +0 -60
- data/lib/ferret/search/sort_field.rb +0 -91
- data/lib/ferret/search/spans.rb +0 -12
- data/lib/ferret/search/spans/near_spans_enum.rb +0 -304
- data/lib/ferret/search/spans/span_first_query.rb +0 -79
- data/lib/ferret/search/spans/span_near_query.rb +0 -108
- data/lib/ferret/search/spans/span_not_query.rb +0 -130
- data/lib/ferret/search/spans/span_or_query.rb +0 -176
- data/lib/ferret/search/spans/span_query.rb +0 -25
- data/lib/ferret/search/spans/span_scorer.rb +0 -74
- data/lib/ferret/search/spans/span_term_query.rb +0 -105
- data/lib/ferret/search/spans/span_weight.rb +0 -84
- data/lib/ferret/search/spans/spans_enum.rb +0 -44
- data/lib/ferret/search/term_query.rb +0 -128
- data/lib/ferret/search/term_scorer.rb +0 -183
- data/lib/ferret/search/top_docs.rb +0 -36
- data/lib/ferret/search/top_field_docs.rb +0 -17
- data/lib/ferret/search/weight.rb +0 -54
- data/lib/ferret/search/wildcard_query.rb +0 -26
- data/lib/ferret/search/wildcard_term_enum.rb +0 -61
- data/lib/ferret/stemmers.rb +0 -1
- data/lib/ferret/stemmers/porter_stemmer.rb +0 -218
- data/lib/ferret/store.rb +0 -5
- data/lib/ferret/store/buffered_index_io.rb +0 -190
- data/lib/ferret/store/directory.rb +0 -141
- data/lib/ferret/store/fs_store.rb +0 -381
- data/lib/ferret/store/index_io.rb +0 -245
- data/lib/ferret/store/ram_store.rb +0 -286
- data/lib/ferret/utils.rb +0 -8
- data/lib/ferret/utils/bit_vector.rb +0 -123
- data/lib/ferret/utils/date_tools.rb +0 -138
- data/lib/ferret/utils/number_tools.rb +0 -91
- data/lib/ferret/utils/parameter.rb +0 -41
- data/lib/ferret/utils/priority_queue.rb +0 -120
- data/lib/ferret/utils/string_helper.rb +0 -47
- data/lib/ferret/utils/thread_local.rb +0 -28
- data/lib/ferret/utils/weak_key_hash.rb +0 -60
- data/lib/rferret.rb +0 -37
- data/rake_utils/code_statistics.rb +0 -106
- data/test/benchmark/tb_ram_store.rb +0 -76
- data/test/benchmark/tb_rw_vint.rb +0 -26
- data/test/functional/thread_safety_index_test.rb +0 -81
- data/test/functional/thread_safety_test.rb +0 -137
- data/test/longrunning/tc_numbertools.rb +0 -60
- data/test/longrunning/tm_store.rb +0 -19
- data/test/unit/analysis/ctc_analyzer.rb +0 -532
- data/test/unit/analysis/data/wordfile +0 -6
- data/test/unit/analysis/rtc_letter_tokenizer.rb +0 -20
- data/test/unit/analysis/rtc_lower_case_filter.rb +0 -20
- data/test/unit/analysis/rtc_lower_case_tokenizer.rb +0 -27
- data/test/unit/analysis/rtc_per_field_analyzer_wrapper.rb +0 -39
- data/test/unit/analysis/rtc_porter_stem_filter.rb +0 -16
- data/test/unit/analysis/rtc_standard_analyzer.rb +0 -20
- data/test/unit/analysis/rtc_standard_tokenizer.rb +0 -20
- data/test/unit/analysis/rtc_stop_analyzer.rb +0 -20
- data/test/unit/analysis/rtc_stop_filter.rb +0 -14
- data/test/unit/analysis/rtc_white_space_analyzer.rb +0 -21
- data/test/unit/analysis/rtc_white_space_tokenizer.rb +0 -20
- data/test/unit/analysis/rtc_word_list_loader.rb +0 -32
- data/test/unit/analysis/tc_token.rb +0 -25
- data/test/unit/document/rtc_field.rb +0 -28
- data/test/unit/document/tc_document.rb +0 -47
- data/test/unit/document/tc_field.rb +0 -98
- data/test/unit/index/rtc_compound_file_io.rb +0 -107
- data/test/unit/index/rtc_field_infos.rb +0 -127
- data/test/unit/index/rtc_fields_io.rb +0 -167
- data/test/unit/index/rtc_multiple_term_doc_pos_enum.rb +0 -83
- data/test/unit/index/rtc_segment_infos.rb +0 -74
- data/test/unit/index/rtc_segment_term_docs.rb +0 -17
- data/test/unit/index/rtc_segment_term_enum.rb +0 -60
- data/test/unit/index/rtc_segment_term_vector.rb +0 -71
- data/test/unit/index/rtc_term_buffer.rb +0 -57
- data/test/unit/index/rtc_term_info.rb +0 -19
- data/test/unit/index/rtc_term_infos_io.rb +0 -192
- data/test/unit/index/rtc_term_vectors_io.rb +0 -108
- data/test/unit/index/tc_term.rb +0 -27
- data/test/unit/index/tc_term_voi.rb +0 -18
- data/test/unit/search/rtc_similarity.rb +0 -37
- data/test/unit/search/rtc_sort_field.rb +0 -14
- data/test/unit/search/tc_multi_searcher2.rb +0 -126
- data/test/unit/store/rtc_fs_store.rb +0 -62
- data/test/unit/store/rtc_ram_store.rb +0 -15
- data/test/unit/store/rtm_store.rb +0 -150
- data/test/unit/store/rtm_store_lock.rb +0 -2
- data/test/unit/ts_document.rb +0 -2
- data/test/unit/utils/rtc_bit_vector.rb +0 -73
- data/test/unit/utils/rtc_date_tools.rb +0 -50
- data/test/unit/utils/rtc_number_tools.rb +0 -59
- data/test/unit/utils/rtc_parameter.rb +0 -40
- data/test/unit/utils/rtc_priority_queue.rb +0 -62
- data/test/unit/utils/rtc_string_helper.rb +0 -21
- data/test/unit/utils/rtc_thread.rb +0 -61
- data/test/unit/utils/rtc_weak_key_hash.rb +0 -25
- data/test/utils/number_to_spoken.rb +0 -132
data/ext/store.h
CHANGED
@@ -1,153 +1,733 @@
|
|
1
|
-
#include "global.h"
|
2
|
-
#include "hash.h"
|
3
|
-
|
4
1
|
#ifndef FRT_STORE_H
|
5
2
|
#define FRT_STORE_H
|
6
3
|
|
4
|
+
#include <sys/types.h>
|
5
|
+
#include "global.h"
|
6
|
+
#include "hash.h"
|
7
|
+
#include "threading.h"
|
8
|
+
|
7
9
|
#define BUFFER_SIZE 1024
|
8
10
|
#define LOCK_PREFIX "ferret-"
|
11
|
+
#define LOCK_EXT ".lck"
|
9
12
|
|
10
13
|
#define VINT_MAX_LEN 10
|
11
14
|
#define VINT_END BUFFER_SIZE - VINT_MAX_LEN
|
12
15
|
|
13
|
-
typedef struct Buffer
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
typedef struct Buffer
|
17
|
+
{
|
18
|
+
uchar buf[BUFFER_SIZE];
|
19
|
+
off_t start;
|
20
|
+
off_t pos;
|
21
|
+
off_t len;
|
18
22
|
} Buffer;
|
19
23
|
|
20
|
-
typedef struct OutStream
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
typedef struct OutStream OutStream;
|
25
|
+
struct OutStreamMethods {
|
26
|
+
/* internal functions for the InStream */
|
27
|
+
/**
|
28
|
+
* Flush +len+ characters from +src+ to the output stream +os+
|
29
|
+
*
|
30
|
+
* @param os self
|
31
|
+
* @param src the characters to write to the output stream
|
32
|
+
* @param len the number of characters to write
|
33
|
+
* @raise IO_ERROR if there is an error writing the characters
|
34
|
+
*/
|
35
|
+
void (*flush_i)(struct OutStream *os, uchar *buf, int len);
|
36
|
+
|
37
|
+
/**
|
38
|
+
* Seek +pos+ in the output stream
|
39
|
+
*
|
40
|
+
* @param os self
|
41
|
+
* @param pos the position to seek in the stream
|
42
|
+
* @raise IO_ERROR if there is an error seeking in the output stream
|
43
|
+
*/
|
44
|
+
void (*seek_i)(struct OutStream *os, off_t pos);
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Close any resources used by the output stream +os+
|
48
|
+
*
|
49
|
+
* @param os self
|
50
|
+
* @raise IO_ERROR if there is an closing the file
|
51
|
+
*/
|
52
|
+
void (*close_i)(struct OutStream *os);
|
53
|
+
};
|
54
|
+
|
55
|
+
typedef struct RAMFile
|
56
|
+
{
|
57
|
+
char *name;
|
58
|
+
uchar **buffers;
|
59
|
+
int bufcnt;
|
60
|
+
off_t len;
|
61
|
+
int ref_cnt;
|
62
|
+
} RAMFile;
|
63
|
+
|
64
|
+
struct OutStream
|
65
|
+
{
|
66
|
+
Buffer buf;
|
67
|
+
union
|
68
|
+
{
|
69
|
+
int fd;
|
70
|
+
RAMFile *rf;
|
71
|
+
} file;
|
72
|
+
off_t pointer; /* only used by RAMOut */
|
73
|
+
const struct OutStreamMethods *m;
|
74
|
+
};
|
28
75
|
|
29
76
|
typedef struct CompoundInStream CompoundInStream;
|
30
77
|
|
31
|
-
typedef struct InStream
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
78
|
+
typedef struct InStream InStream;
|
79
|
+
|
80
|
+
struct InStreamMethods
|
81
|
+
{
|
82
|
+
/**
|
83
|
+
* Read +len+ characters from the input stream into the +offset+ position in
|
84
|
+
* +buf+, an array of unsigned characters.
|
85
|
+
*
|
86
|
+
* @param is self
|
87
|
+
* @param buf an array of characters which must be allocated with at least
|
88
|
+
* +offset+ + +len+ bytes
|
89
|
+
* @param len the number of bytes to read
|
90
|
+
* @raise IO_ERROR if there is an error reading from the input stream
|
91
|
+
*/
|
92
|
+
void (*read_i)(struct InStream *is, uchar *buf, int len);
|
93
|
+
|
94
|
+
/**
|
95
|
+
* Seek position +pos+ in input stream +is+
|
96
|
+
*
|
97
|
+
* @param is self
|
98
|
+
* @param pos the position to seek
|
99
|
+
* @raise IO_ERROR if the seek fails
|
100
|
+
*/
|
101
|
+
void (*seek_i)(struct InStream *is, off_t pos);
|
102
|
+
|
103
|
+
/**
|
104
|
+
* Returns the length of the input stream +is+
|
105
|
+
*
|
106
|
+
* @param is self
|
107
|
+
* @raise IO_ERROR if there is an error getting the file length
|
108
|
+
*/
|
109
|
+
off_t (*length_i)(struct InStream *is);
|
110
|
+
|
111
|
+
/**
|
112
|
+
* Close the resources allocated to the inputstream +is+
|
113
|
+
*
|
114
|
+
* @param is self
|
115
|
+
* @raise IO_ERROR if the close fails
|
116
|
+
*/
|
117
|
+
void (*close_i)(struct InStream *is);
|
118
|
+
};
|
119
|
+
|
120
|
+
struct InStream
|
121
|
+
{
|
122
|
+
Buffer buf;
|
123
|
+
union
|
124
|
+
{
|
125
|
+
int fd;
|
126
|
+
RAMFile *rf;
|
127
|
+
} file;
|
128
|
+
union
|
129
|
+
{
|
130
|
+
off_t pointer; /* only used by RAMIn */
|
131
|
+
char *path; /* only used by FSIn */
|
132
|
+
CompoundInStream *cis;
|
133
|
+
} d;
|
134
|
+
int *ref_cnt_ptr;
|
135
|
+
const struct InStreamMethods *m;
|
136
|
+
};
|
137
|
+
|
138
|
+
struct CompoundInStream
|
139
|
+
{
|
140
|
+
InStream *sub;
|
141
|
+
off_t offset;
|
142
|
+
off_t length;
|
51
143
|
};
|
52
144
|
|
53
|
-
#define is_length(mis) mis->
|
145
|
+
#define is_length(mis) mis->m->length_i(mis)
|
54
146
|
|
55
147
|
typedef struct Store Store;
|
56
148
|
typedef struct Lock Lock;
|
57
|
-
struct Lock
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
149
|
+
struct Lock
|
150
|
+
{
|
151
|
+
char *name;
|
152
|
+
Store *store;
|
153
|
+
int (*obtain)(Lock *lock);
|
154
|
+
int (*is_locked)(Lock *lock);
|
155
|
+
void (*release)(Lock *lock);
|
63
156
|
};
|
64
157
|
|
65
|
-
typedef struct CompoundStore
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
158
|
+
typedef struct CompoundStore
|
159
|
+
{
|
160
|
+
Store *store;
|
161
|
+
const char *name;
|
162
|
+
HashTable *entries;
|
163
|
+
InStream *stream;
|
70
164
|
} CompoundStore;
|
71
165
|
|
72
|
-
struct Store
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
166
|
+
struct Store
|
167
|
+
{
|
168
|
+
int ref_cnt; /* for fs_store only */
|
169
|
+
mutex_t mutex_i; /* for internal use only */
|
170
|
+
mutex_t mutex; /* external mutex for use outside */
|
171
|
+
union
|
172
|
+
{
|
173
|
+
char *path; /* for fs_store only */
|
174
|
+
HashTable *ht; /* for ram_store only */
|
175
|
+
CompoundStore *cmpd; /* for compound_store only */
|
176
|
+
} dir;
|
177
|
+
|
178
|
+
/**
|
179
|
+
* Create the file +filename+ in the +store+.
|
180
|
+
*
|
181
|
+
* @param store self
|
182
|
+
* @param filename the name of the file to create
|
183
|
+
* @raise IO_ERROR if the file cannot be created
|
184
|
+
*/
|
185
|
+
void (*touch)(Store *store, char *filename);
|
186
|
+
|
187
|
+
/**
|
188
|
+
* Return true if a file of name +filename+ exists in +store+.
|
189
|
+
*
|
190
|
+
* @param store self
|
191
|
+
* @param filename the name of the file to check for
|
192
|
+
* @returns true if the file exists
|
193
|
+
* @raise IO_ERROR if there is an error checking for the files existance
|
194
|
+
*/
|
195
|
+
int (*exists)(Store *store, char *filename);
|
196
|
+
|
197
|
+
/**
|
198
|
+
* Remove the file +filename+ from the +store+
|
199
|
+
*
|
200
|
+
* @param store self
|
201
|
+
* @param filename the name of the file to remove
|
202
|
+
* @returns On success, zero is returned. On error, -1 is returned, and errno
|
203
|
+
* is set appropriately.
|
204
|
+
*/
|
205
|
+
int (*remove)(Store *store, char *filename);
|
206
|
+
|
207
|
+
/**
|
208
|
+
* Rename the file in the +store+ from the name +from+ to the name +to+.
|
209
|
+
*
|
210
|
+
* @param store self
|
211
|
+
* @param from the name of the file to rename
|
212
|
+
* @param to the new name of the file
|
213
|
+
* @raise IO_ERROR if there is an error renaming the file
|
214
|
+
*/
|
215
|
+
void (*rename)(Store *store, char *from, char *to);
|
216
|
+
|
217
|
+
/**
|
218
|
+
* Returns the number of files in the store.
|
219
|
+
*
|
220
|
+
* @param store self
|
221
|
+
* @return the number of files in the store
|
222
|
+
* @raise IO_ERROR if there is an error opening the directory
|
223
|
+
*/
|
224
|
+
int (*count)(Store *store);
|
225
|
+
|
226
|
+
/**
|
227
|
+
* Call the function +func+ with each filename in the store and the arg
|
228
|
+
* that you passed. If you need to open the file you should pass the store
|
229
|
+
* as the argument. If you need to pass more than one argument, you should
|
230
|
+
* pass a struct.
|
231
|
+
*
|
232
|
+
* @param store self
|
233
|
+
* @param func the function to call with each files name and the +arg+
|
234
|
+
* passed
|
235
|
+
* @param arg the argument to pass to the function
|
236
|
+
* @raise IO_ERROR if there is an error opening the directory
|
237
|
+
*/
|
238
|
+
void (*each)(Store *store, void (*func)(char *fname, void *arg),
|
239
|
+
void *arg);
|
240
|
+
|
241
|
+
/**
|
242
|
+
* Clear all the locks in the store.
|
243
|
+
*
|
244
|
+
* @param store self
|
245
|
+
* @raise IO_ERROR if there is an error opening the directory
|
246
|
+
*/
|
247
|
+
void (*clear_locks)(Store *store);
|
248
|
+
|
249
|
+
/**
|
250
|
+
* Clear all files from the store except the lock files.
|
251
|
+
*
|
252
|
+
* @param store self
|
253
|
+
* @raise IO_ERROR if there is an error deleting the files
|
254
|
+
*/
|
255
|
+
void (*clear)(Store *store);
|
256
|
+
|
257
|
+
/**
|
258
|
+
* Clear all files from the store including the lock files.
|
259
|
+
*
|
260
|
+
* @param store self
|
261
|
+
* @raise IO_ERROR if there is an error deleting the files
|
262
|
+
*/
|
263
|
+
void (*clear_all)(Store *store);
|
264
|
+
|
265
|
+
/**
|
266
|
+
* Return the length of the file +filename+ in +store+
|
267
|
+
*
|
268
|
+
* @param store self
|
269
|
+
* @param the name of the file to check the length of
|
270
|
+
* @return the length of the file in bytes
|
271
|
+
* @raise IO_ERROR if there is an error checking the file length
|
272
|
+
*/
|
273
|
+
off_t (*length)(Store *store, char *filename);
|
274
|
+
|
275
|
+
/**
|
276
|
+
* Allocate the resources needed for the output stream in the +store+ with
|
277
|
+
* the name +filename+
|
278
|
+
*
|
279
|
+
* @param store self
|
280
|
+
* @param filename the name of the output stream
|
281
|
+
* @return a newly allocated filestream
|
282
|
+
* @raise IO_ERROR if there is an error opening the output stream
|
283
|
+
* resources
|
284
|
+
*/
|
285
|
+
OutStream *(*new_output)(Store *store, const char *filename);
|
286
|
+
|
287
|
+
/**
|
288
|
+
* Open an input stream in the +store+ with the name +filename+
|
289
|
+
*
|
290
|
+
* @param store self
|
291
|
+
* @param filename the name of the input stream
|
292
|
+
* @raise IO_ERROR if the input stream cannot be opened
|
293
|
+
*/
|
294
|
+
InStream *(*open_input)(Store *store, const char *filename);
|
295
|
+
|
296
|
+
/**
|
297
|
+
* Obtain a lock on the lock +lock+
|
298
|
+
*
|
299
|
+
* @param store self
|
300
|
+
* @param lock the lock to obtain
|
301
|
+
*/
|
302
|
+
Lock *(*open_lock)(Store *store, char *lockname);
|
303
|
+
|
304
|
+
/**
|
305
|
+
* Returns true if +lock+ is locked. To test if the file is locked:wq
|
306
|
+
*
|
307
|
+
* @param lock the lock to test
|
308
|
+
* @raise IO_ERROR if there is an error detecting the lock status
|
309
|
+
*/
|
310
|
+
void (*close_lock)(Lock *lock);
|
311
|
+
|
312
|
+
/**
|
313
|
+
* Internal function to close the store freeing implementation specific
|
314
|
+
* resources.
|
315
|
+
*
|
316
|
+
* @param store self
|
317
|
+
*/
|
318
|
+
void (*close_i)(Store *store);
|
96
319
|
};
|
97
320
|
|
98
|
-
|
99
|
-
Store
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
321
|
+
/**
|
322
|
+
* Create a newly allocated file-system Store at the pathname designated. The
|
323
|
+
* pathname must be the name of an existing directory.
|
324
|
+
*
|
325
|
+
* @param pathname the pathname of the directory to be used by the index
|
326
|
+
* @return a newly allocated file-system Store.
|
327
|
+
*/
|
328
|
+
extern Store *open_fs_store(const char *pathname);
|
329
|
+
|
330
|
+
/**
|
331
|
+
* Create a newly allocated in-memory or RAM Store.
|
332
|
+
*
|
333
|
+
* @return a newly allocated RAM Store.
|
334
|
+
*/
|
335
|
+
extern Store *open_ram_store();
|
336
|
+
|
337
|
+
/**
|
338
|
+
* Create a newly allocated in-memory or RAM Store. Copy the contents of
|
339
|
+
* another store into this store. Then close the other store if required. This
|
340
|
+
* method would be used for example to read an index into memory for faster
|
341
|
+
* searching.
|
342
|
+
*
|
343
|
+
* @param store the whose contents will be copied into the newly allocated RAM
|
344
|
+
* store
|
345
|
+
* @param close_store close the store whose contents where copied
|
346
|
+
* @return a newly allocated RAM Store.
|
347
|
+
*/
|
348
|
+
extern Store *open_ram_store_and_copy(Store *store, bool close_store);
|
349
|
+
|
350
|
+
/**
|
351
|
+
* Open a compound store. This is basically store which is stored within a
|
352
|
+
* single file and can in turn be stored within either a FileSystem or RAM
|
353
|
+
* store.
|
354
|
+
*
|
355
|
+
* @param store the store within which this compound store will be stored
|
356
|
+
* @param filename the name of the file in which to store the compound store
|
357
|
+
* @return a newly allocated Compound Store.
|
358
|
+
*/
|
359
|
+
extern Store *open_cmpd_store(Store *store, const char *filename);
|
360
|
+
|
361
|
+
/*
|
362
|
+
* == RamStore functions ==
|
363
|
+
*
|
364
|
+
* These functions or optimizations to be used when you know you are using a
|
365
|
+
* Ram OutStream.
|
366
|
+
*/
|
367
|
+
|
368
|
+
/**
|
369
|
+
* Return the length of the OutStream in bytes.
|
370
|
+
*
|
371
|
+
* @param os the OutStream who's length you want
|
372
|
+
* @return the length of +os+ in bytes
|
373
|
+
*/
|
374
|
+
extern off_t ramo_length(OutStream *os);
|
375
|
+
|
376
|
+
/**
|
377
|
+
* Reset the OutStream removing any data written to it. Since it is a RAM
|
378
|
+
* file, all that needs to be done is set the length to 0.
|
379
|
+
*
|
380
|
+
* @param os the OutStream to reset
|
381
|
+
*/
|
382
|
+
extern void ramo_reset(OutStream *os);
|
383
|
+
|
384
|
+
/**
|
385
|
+
* Write the contents of a RAM OutStream to another OutStream.
|
386
|
+
*
|
387
|
+
* @param from_os the OutStream to write from
|
388
|
+
* @param to_os the OutStream to write to
|
389
|
+
*/
|
390
|
+
extern void ramo_write_to(OutStream *from_os, OutStream *to_os);
|
391
|
+
|
392
|
+
/**
|
393
|
+
* Create a buffer RAM OutStream which is unassociated with any RAM Store.
|
394
|
+
* This OutStream can be used to write temporary data too. When the time
|
395
|
+
* comes, this data can be written to another OutStream (which might possibly
|
396
|
+
* be a file-system OutStream) using ramo_write_to.
|
397
|
+
*
|
398
|
+
* @return A newly allocated RAM OutStream
|
399
|
+
*/
|
400
|
+
extern OutStream *ram_new_buffer();
|
401
|
+
|
402
|
+
/**
|
403
|
+
* Destroy a RAM OutStream which is unassociated with any RAM Store, freeing
|
404
|
+
* all resources allocated to it.
|
405
|
+
*
|
406
|
+
* @param os the OutStream to destroy
|
407
|
+
*/
|
408
|
+
extern void ram_destroy_buffer(OutStream *os);
|
409
|
+
|
410
|
+
/**
|
411
|
+
* Call the function +func+ with the +lock+ locked. The argument +arg+ will be
|
412
|
+
* passed to +func+. If you need to pass more than one argument you should use
|
413
|
+
* a struct. When the function is finished, release the lock.
|
414
|
+
*
|
415
|
+
* @param lock lock to be locked while func is called
|
416
|
+
* @param func function to call with the lock locked
|
417
|
+
* @param arg argument to pass to the function
|
418
|
+
* @raise IO_ERROR if the lock is already locked
|
419
|
+
* @see with_lock_name
|
420
|
+
*/
|
421
|
+
extern void with_lock(Lock *lock, void (*func)(void *arg), void *arg);
|
422
|
+
|
423
|
+
/**
|
424
|
+
* Create a lock in the +store+ with the name +lock_name+. Call the function
|
425
|
+
* +func+ with the lock locked. The argument +arg+ will be passed to +func+.
|
426
|
+
* If you need to pass more than one argument you should use a struct. When
|
427
|
+
* the function is finished, release and destroy the lock.
|
428
|
+
*
|
429
|
+
* @param store store to open the lock in
|
430
|
+
* @param lock_name name of the lock to open
|
431
|
+
* @param func function to call with the lock locked
|
432
|
+
* @param arg argument to pass to the function
|
433
|
+
* @raise IO_ERROR if the lock is already locked
|
434
|
+
* @see with_lock
|
435
|
+
*/
|
436
|
+
extern void with_lock_name(Store *store, char *lock_name,
|
437
|
+
void (*func)(void *arg), void *arg);
|
438
|
+
|
439
|
+
/**
|
440
|
+
* Remove a reference to the store. If the reference count gets to zero free
|
441
|
+
* all resources used by the store.
|
442
|
+
*
|
443
|
+
* @param store the store to be dereferenced
|
444
|
+
*/
|
445
|
+
extern void store_deref(Store *store);
|
446
|
+
|
447
|
+
/**
|
448
|
+
* Flush the buffered contents of the OutStream to the store.
|
449
|
+
*
|
450
|
+
* @param os the OutStream to flush
|
451
|
+
*/
|
452
|
+
extern void os_flush(OutStream *os);
|
453
|
+
|
454
|
+
/**
|
455
|
+
* Close the OutStream after flushing the buffers, also freeing all allocated
|
456
|
+
* resources.
|
457
|
+
*
|
458
|
+
* @param os the OutStream to close
|
459
|
+
*/
|
460
|
+
extern void os_close(OutStream *os);
|
461
|
+
|
462
|
+
/**
|
463
|
+
* Return the current position of OutStream +os+.
|
464
|
+
*
|
465
|
+
* @param os the OutStream to get the position from
|
466
|
+
* @return the current position in OutStream +os+
|
467
|
+
*/
|
468
|
+
extern off_t os_pos(OutStream *os);
|
469
|
+
|
470
|
+
/**
|
471
|
+
* Set the current position in OutStream +os+.
|
472
|
+
*
|
473
|
+
* @param os the OutStream to set the position in
|
474
|
+
* @param pos the new position in the OutStream
|
475
|
+
* @raise IO_ERROR if there is a file-system IO error seeking the file
|
476
|
+
*/
|
477
|
+
extern void os_seek(OutStream *os, off_t new_pos);
|
478
|
+
|
479
|
+
/**
|
480
|
+
* Write a single byte +b+ to the OutStream +os+
|
481
|
+
*
|
482
|
+
* @param os the OutStream to write to @param b the byte to write @raise
|
483
|
+
* IO_ERROR if there is an IO error writing to the file-system
|
484
|
+
*/
|
485
|
+
extern void os_write_byte(OutStream *os, uchar b);
|
486
|
+
/**
|
487
|
+
* Write +len+ bytes from buffer +buf+ to the OutStream +os+.
|
488
|
+
*
|
489
|
+
* @param os the OutStream to write to
|
490
|
+
* @param len the number of bytes to write
|
491
|
+
* @param buf the buffer from which to get the bytes to write.
|
492
|
+
* @raise IO_ERROR if there is an IO error writing to the file-system
|
493
|
+
*/
|
494
|
+
extern void os_write_bytes(OutStream *os, uchar *buf, int len);
|
495
|
+
|
496
|
+
/**
|
497
|
+
* Write a 32-bit signed integer to the OutStream
|
498
|
+
*
|
499
|
+
* @param os OutStream to write to
|
500
|
+
* @param num the 32-bit signed integer to write
|
501
|
+
* @raise IO_ERROR if there is an error writing to the file-system
|
502
|
+
*/
|
503
|
+
extern void os_write_i32(OutStream *os, f_i32 num);
|
504
|
+
|
505
|
+
/**
|
506
|
+
* Write a 64-bit signed integer to the OutStream
|
507
|
+
*
|
508
|
+
*
|
509
|
+
* @param os OutStream to write to
|
510
|
+
* @param num the 64-bit signed integer to write
|
511
|
+
* @raise IO_ERROR if there is an error writing to the file-system
|
512
|
+
*/
|
513
|
+
extern void os_write_i64(OutStream *os, f_i64 num);
|
514
|
+
|
515
|
+
/**
|
516
|
+
* Write a 32-bit unsigned integer to the OutStream
|
517
|
+
*
|
518
|
+
* @param os OutStream to write to
|
519
|
+
* @param num the 32-bit unsigned integer to write
|
520
|
+
* @raise IO_ERROR if there is an error writing to the file-system
|
521
|
+
*/
|
522
|
+
extern void os_write_u32(OutStream *os, f_u32 num);
|
523
|
+
|
524
|
+
/**
|
525
|
+
* Write a 64-bit unsigned integer to the OutStream
|
526
|
+
*
|
527
|
+
* @param os OutStream to write to
|
528
|
+
* @param num the 64-bit unsigned integer to write
|
529
|
+
* @raise IO_ERROR if there is an error writing to the file-system
|
530
|
+
*/
|
531
|
+
extern void os_write_u64(OutStream *os, f_u64 num);
|
532
|
+
|
533
|
+
/**
|
534
|
+
* Write an unsigned integer to OutStream in compressed VINT format.
|
535
|
+
* TODO: describe VINT format
|
536
|
+
*
|
537
|
+
* @param os OutStream to write to
|
538
|
+
* @param num the integer to write
|
539
|
+
* @raise IO_ERROR if there is an error writing to the file-system
|
540
|
+
*/
|
541
|
+
extern void os_write_vint(OutStream *os, register unsigned int num);
|
542
|
+
|
543
|
+
/**
|
544
|
+
* Write an unsigned off_t to OutStream in compressed VINT format.
|
545
|
+
* TODO: describe VINT format
|
546
|
+
*
|
547
|
+
* @param os OutStream to write to
|
548
|
+
* @param num the off_t to write
|
549
|
+
* @raise IO_ERROR if there is an error writing to the file-system
|
550
|
+
*/
|
551
|
+
extern void os_write_voff_t(OutStream *os, register off_t num);
|
552
|
+
|
553
|
+
/**
|
554
|
+
* Write a string to the OutStream. A string is an integer +length+ in VINT
|
555
|
+
* format (see os_write_vint) followed by +length+ bytes. The string can then
|
556
|
+
* be read using is_read_string.
|
557
|
+
*
|
558
|
+
* @param os OutStream to write to
|
559
|
+
* @param str the string to write
|
560
|
+
* @raise IO_ERROR if there is an error writing to the file-system
|
561
|
+
*/
|
562
|
+
extern void os_write_string(OutStream *os, char *str);
|
563
|
+
/**
|
564
|
+
* Get the current position within an InStream.
|
565
|
+
*
|
566
|
+
* @param is the InStream to get the current position from
|
567
|
+
* @return the current position within the InStream +is+
|
568
|
+
*/
|
569
|
+
extern off_t is_pos(InStream *is);
|
570
|
+
|
571
|
+
/**
|
572
|
+
* Set the current position in InStream +is+ to +pos+.
|
573
|
+
*
|
574
|
+
* @param is the InStream to set the current position in
|
575
|
+
* @param pos the position in InStream to seek
|
576
|
+
* @raise IO_ERROR if there is a error seeking from the file-system
|
577
|
+
* @raise EOF_ERROR if there is an attempt to seek past the end of the file
|
578
|
+
*/
|
579
|
+
extern void is_seek(InStream *is, off_t pos);
|
580
|
+
|
581
|
+
/**
|
582
|
+
* Close the InStream freeing all allocated resources.
|
583
|
+
*
|
584
|
+
* @param is the InStream to close
|
585
|
+
* @raise IO_ERROR if there is an error closing the associated file
|
586
|
+
*/
|
587
|
+
extern void is_close(InStream *is);
|
588
|
+
|
589
|
+
/**
|
590
|
+
* Clone the InStream allocating a new InStream structure
|
591
|
+
*
|
592
|
+
* @param is the InStream to clone
|
593
|
+
* @return a newly allocated InStream which is a clone of +is+
|
594
|
+
*/
|
595
|
+
extern InStream *is_clone(InStream *is);
|
596
|
+
|
597
|
+
/**
|
598
|
+
* Read a singly byte (unsigned char) from the InStream +is+.
|
599
|
+
*
|
600
|
+
* @param is the Instream to read from
|
601
|
+
* @return a single unsigned char read from the InStream +is+
|
602
|
+
* @raise IO_ERROR if there is a error reading from the file-system
|
603
|
+
* @raise EOF_ERROR if there is an attempt to read past the end of the file
|
604
|
+
*/
|
605
|
+
extern inline uchar is_read_byte(InStream *is);
|
606
|
+
|
607
|
+
/**
|
608
|
+
* Read +len+ bytes from InStream +is+ and write them to buffer +buf+
|
609
|
+
*
|
610
|
+
* @param is the InStream to read from
|
611
|
+
* @param buf the buffer to read into, that is copy the bytes read to
|
612
|
+
* @param len the number of bytes to read
|
613
|
+
* @return the resultant buffer +buf+
|
614
|
+
* @raise IO_ERROR if there is a error reading from the file-system
|
615
|
+
* @raise EOF_ERROR if there is an attempt to read past the end of the file
|
616
|
+
*/
|
617
|
+
extern uchar *is_read_bytes(InStream *is, uchar *buf, int len);
|
618
|
+
|
619
|
+
/**
|
620
|
+
* Read a 32-bit unsigned integer from the InStream.
|
621
|
+
*
|
622
|
+
* @param is the InStream to read from
|
623
|
+
* @return a 32-bit unsigned integer
|
624
|
+
* @raise IO_ERROR if there is a error reading from the file-system
|
625
|
+
* @raise EOF_ERROR if there is an attempt to read past the end of the file
|
626
|
+
*/
|
627
|
+
extern f_i32 is_read_i32(InStream *is);
|
628
|
+
|
629
|
+
/**
|
630
|
+
* Read a 64-bit unsigned integer from the InStream.
|
631
|
+
*
|
632
|
+
* @param is the InStream to read from
|
633
|
+
* @return a 64-bit unsigned integer
|
634
|
+
* @raise IO_ERROR if there is a error reading from the file-system
|
635
|
+
* @raise EOF_ERROR if there is an attempt to read past the end of the file
|
636
|
+
*/
|
637
|
+
extern f_i64 is_read_i64(InStream *is);
|
638
|
+
|
639
|
+
/**
|
640
|
+
* Read a 32-bit signed integer from the InStream.
|
641
|
+
*
|
642
|
+
* @param is the InStream to read from
|
643
|
+
* @return a 32-bit signed integer
|
644
|
+
* @raise IO_ERROR if there is a error reading from the file-system
|
645
|
+
* @raise EOF_ERROR if there is an attempt to read past the end of the file
|
646
|
+
*/
|
647
|
+
extern f_u32 is_read_u32(InStream *is);
|
648
|
+
|
649
|
+
/**
|
650
|
+
* Read a 64-bit signed integer from the InStream.
|
651
|
+
*
|
652
|
+
* @param is the InStream to read from
|
653
|
+
* @return a 64-bit signed integer
|
654
|
+
* @raise IO_ERROR if there is a error reading from the file-system
|
655
|
+
* @raise EOF_ERROR if there is an attempt to read past the end of the file
|
656
|
+
*/
|
657
|
+
extern f_u64 is_read_u64(InStream *is);
|
658
|
+
|
659
|
+
/**
|
660
|
+
* Read a compressed (VINT) unsigned integer from the InStream.
|
661
|
+
* TODO: describe VINT format
|
662
|
+
*
|
663
|
+
* @param is the InStream to read from
|
664
|
+
* @return an int
|
665
|
+
* @raise IO_ERROR if there is a error reading from the file-system
|
666
|
+
* @raise EOF_ERROR if there is an attempt to read past the end of the file
|
667
|
+
*/
|
668
|
+
extern inline unsigned int is_read_vint(InStream *is);
|
669
|
+
|
670
|
+
/**
|
671
|
+
* Skip _cnt_ vints. This is a convenience method used for performance reasons
|
672
|
+
* to skip large numbers of vints. It is mostly used by TermDocEnums. When
|
673
|
+
* skipping positions os the proximity index file.
|
674
|
+
*
|
675
|
+
* @param is the InStream to read from
|
676
|
+
* @param cnt the number of vints to skip
|
677
|
+
* @raise IO_ERROR if there is a error reading from the file-system
|
678
|
+
* @raise EOF_ERROR if there is an attempt to read past the end of the file
|
679
|
+
*/
|
680
|
+
extern inline void is_skip_vints(InStream *is, register int cnt);
|
681
|
+
|
682
|
+
/**
|
683
|
+
* Read a compressed (VINT) unsigned off_t from the InStream.
|
684
|
+
* TODO: describe VINT format
|
685
|
+
*
|
686
|
+
* @param is the InStream to read from
|
687
|
+
* @return a off_t
|
688
|
+
* @raise IO_ERROR if there is a error reading from the file-system
|
689
|
+
* @raise EOF_ERROR if there is an attempt to read past the end of the file
|
690
|
+
*/
|
691
|
+
extern inline off_t is_read_voff_t(InStream *is);
|
692
|
+
|
693
|
+
/**
|
694
|
+
* Read a string from the InStream. A string is an integer +length+ in vint
|
695
|
+
* format (see is_read_vint) followed by +length+ bytes. This is the format
|
696
|
+
* used by os_write_string.
|
697
|
+
*
|
698
|
+
* @param is the InStream to read from
|
699
|
+
* @return a null byte delimited string
|
700
|
+
* @raise IO_ERROR if there is a error reading from the file-system
|
701
|
+
* @raise EOF_ERROR if there is an attempt to read past the end of the file
|
702
|
+
*/
|
703
|
+
extern char *is_read_string(InStream *is);
|
704
|
+
|
705
|
+
/**
|
706
|
+
* Copy cnt bytes from Instream _is_ to OutStream _os_.
|
707
|
+
*
|
708
|
+
* @param is the InStream to read from
|
709
|
+
* @param os the OutStream to write to
|
710
|
+
* @raise IO_ERROR
|
711
|
+
* @raise EOF_ERROR
|
712
|
+
*/
|
713
|
+
extern void is2os_copy_bytes(InStream *is, OutStream *os, int cnt);
|
714
|
+
|
715
|
+
/**
|
716
|
+
* Copy cnt vints from Instream _is_ to OutStream _os_.
|
717
|
+
*
|
718
|
+
* @param is the InStream to read from
|
719
|
+
* @param os the OutStream to write to
|
720
|
+
* @raise IO_ERROR
|
721
|
+
* @raise EOF_ERROR
|
722
|
+
*/
|
723
|
+
extern void is2os_copy_vints(InStream *is, OutStream *os, int cnt);
|
152
724
|
|
725
|
+
/**
|
726
|
+
* Print the filenames in a store to a buffer.
|
727
|
+
*
|
728
|
+
* @param store the store to get the filenames from
|
729
|
+
* @param buf the buffer to print the filenames to
|
730
|
+
* @paran len the length of the buffer
|
731
|
+
*/
|
732
|
+
extern char *store_to_s(Store *store, char *buf, int buf_size);
|
153
733
|
#endif
|