isomorfeus-ferret 0.17.2 → 0.17.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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 -125
- 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 +8 -6
- data/ext/isomorfeus_ferret_ext/frt_except.h +1 -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 +35 -45
- data/ext/isomorfeus_ferret_ext/frt_in_stream.h +3 -2
- data/ext/isomorfeus_ferret_ext/frt_ind.c +20 -38
- data/ext/isomorfeus_ferret_ext/frt_index.c +292 -790
- data/ext/isomorfeus_ferret_ext/frt_index.h +1 -102
- data/ext/isomorfeus_ferret_ext/frt_lang.c +5 -10
- data/ext/isomorfeus_ferret_ext/frt_lazy_doc.c +3 -3
- data/ext/isomorfeus_ferret_ext/frt_lazy_doc.h +1 -1
- data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.c +18 -25
- data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.h +5 -5
- 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 +31 -43
- data/ext/isomorfeus_ferret_ext/frt_out_stream.h +2 -2
- 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_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 -25
- data/ext/isomorfeus_ferret_ext/frt_store.h +86 -52
- 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 -23
- 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 -487
- 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 +14 -20
- 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 -1
- data/lib/isomorfeus/ferret/version.rb +1 -1
- metadata +24 -4
@@ -2,6 +2,7 @@
|
|
2
2
|
#define FRT_INDEX_H
|
3
3
|
|
4
4
|
#include "frt_global.h"
|
5
|
+
#include "frt_field_infos.h"
|
5
6
|
#include "frt_document.h"
|
6
7
|
#include "frt_analysis.h"
|
7
8
|
#include "frt_hash.h"
|
@@ -56,84 +57,6 @@ extern FrtCacheObject *frt_co_create(FrtHash *ref_tab1, FrtHash *ref_tab2,
|
|
56
57
|
void *ref1, void *ref2, frt_free_ft destroy, void *obj);
|
57
58
|
extern FrtHash *frt_co_hash_create();
|
58
59
|
|
59
|
-
/****************************************************************************
|
60
|
-
*
|
61
|
-
* FrtFieldInfo
|
62
|
-
*
|
63
|
-
****************************************************************************/
|
64
|
-
|
65
|
-
#define FRT_FI_DEFAULTS_BM FRT_FI_IS_STORED_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM | FRT_FI_STORE_TERM_VECTOR_BM | FRT_FI_STORE_POSITIONS_BM | FRT_FI_STORE_OFFSETS_BM
|
66
|
-
#define FRT_FI_IS_STORED_BM 0x001
|
67
|
-
#define FRT_FI_IS_COMPRESSED_BM 0x002
|
68
|
-
#define FRT_FI_IS_INDEXED_BM 0x004
|
69
|
-
#define FRT_FI_IS_TOKENIZED_BM 0x008
|
70
|
-
#define FRT_FI_OMIT_NORMS_BM 0x010
|
71
|
-
#define FRT_FI_STORE_TERM_VECTOR_BM 0x020
|
72
|
-
#define FRT_FI_STORE_POSITIONS_BM 0x040
|
73
|
-
#define FRT_FI_STORE_OFFSETS_BM 0x080
|
74
|
-
#define FRT_FI_COMPRESSION_BROTLI_BM 0x100
|
75
|
-
#define FRT_FI_COMPRESSION_BZ2_BM 0x200
|
76
|
-
#define FRT_FI_COMPRESSION_LZ4_BM 0x400
|
77
|
-
|
78
|
-
typedef struct FrtFieldInfo {
|
79
|
-
ID name;
|
80
|
-
float boost;
|
81
|
-
unsigned int bits;
|
82
|
-
int number;
|
83
|
-
_Atomic unsigned int ref_cnt;
|
84
|
-
VALUE rfi;
|
85
|
-
} FrtFieldInfo;
|
86
|
-
|
87
|
-
extern FrtFieldInfo *frt_fi_alloc();
|
88
|
-
extern FrtFieldInfo *frt_fi_init(FrtFieldInfo *fi, ID name, unsigned int bits);
|
89
|
-
extern FrtFieldInfo *frt_fi_new(ID name, unsigned int bits);
|
90
|
-
extern char *frt_fi_to_s(FrtFieldInfo *fi);
|
91
|
-
extern void frt_fi_deref(FrtFieldInfo *fi);
|
92
|
-
|
93
|
-
#define bits_is_stored(bits) ((bits & FRT_FI_IS_STORED_BM) != 0)
|
94
|
-
#define bits_is_compressed(bits) ((bits & FRT_FI_IS_COMPRESSED_BM) != 0)
|
95
|
-
#define bits_is_compressed_brotli(bits) ((bits & FRT_FI_COMPRESSION_BROTLI_BM) != 0)
|
96
|
-
#define bits_is_compressed_bz2(bits) ((bits & FRT_FI_COMPRESSION_BZ2_BM) != 0)
|
97
|
-
#define bits_is_compressed_lz4(bits) ((bits & FRT_FI_COMPRESSION_LZ4_BM) != 0)
|
98
|
-
#define bits_is_indexed(bits) ((bits & FRT_FI_IS_INDEXED_BM) != 0)
|
99
|
-
#define bits_is_tokenized(bits) ((bits & FRT_FI_IS_TOKENIZED_BM) != 0)
|
100
|
-
#define bits_omit_norms(bits) ((bits & FRT_FI_OMIT_NORMS_BM) != 0)
|
101
|
-
#define bits_store_term_vector(bits) ((bits & FRT_FI_STORE_TERM_VECTOR_BM) != 0)
|
102
|
-
#define bits_store_positions(bits) ((bits & FRT_FI_STORE_POSITIONS_BM) != 0)
|
103
|
-
#define bits_store_offsets(bits) ((bits & FRT_FI_STORE_OFFSETS_BM) != 0)
|
104
|
-
#define bits_has_norms(bits)\
|
105
|
-
((bits & (FRT_FI_OMIT_NORMS_BM|FRT_FI_IS_INDEXED_BM)) == FRT_FI_IS_INDEXED_BM)
|
106
|
-
|
107
|
-
/****************************************************************************
|
108
|
-
*
|
109
|
-
* FrtFieldInfos
|
110
|
-
*
|
111
|
-
****************************************************************************/
|
112
|
-
|
113
|
-
#define FIELD_INFOS_INIT_CAPA 4
|
114
|
-
/* carry changes over to dummy_fis in test/test_segments.c */
|
115
|
-
typedef struct FrtFieldInfos {
|
116
|
-
unsigned int bits;
|
117
|
-
int size;
|
118
|
-
int capa;
|
119
|
-
FrtFieldInfo **fields;
|
120
|
-
FrtHash *field_dict;
|
121
|
-
_Atomic unsigned int ref_cnt;
|
122
|
-
VALUE rfis;
|
123
|
-
} FrtFieldInfos;
|
124
|
-
|
125
|
-
FrtFieldInfos *frt_fis_alloc();
|
126
|
-
FrtFieldInfos *frt_fis_init(FrtFieldInfos *fis, unsigned int bits);
|
127
|
-
FrtFieldInfos *frt_fis_new(unsigned int bits);
|
128
|
-
extern FrtFieldInfo *frt_fis_add_field(FrtFieldInfos *fis, FrtFieldInfo *fi);
|
129
|
-
extern FrtFieldInfo *frt_fis_get_field(FrtFieldInfos *fis, ID name);
|
130
|
-
extern int frt_fis_get_field_num(FrtFieldInfos *fis, ID name);
|
131
|
-
extern FrtFieldInfo *frt_fis_get_or_add_field(FrtFieldInfos *fis, ID name);
|
132
|
-
extern void frt_fis_write(FrtFieldInfos *fis, FrtOutStream *os);
|
133
|
-
extern FrtFieldInfos *frt_fis_read(FrtInStream *is);
|
134
|
-
extern char *frt_fis_to_s(FrtFieldInfos *fis);
|
135
|
-
extern void frt_fis_deref(FrtFieldInfos *fis);
|
136
|
-
|
137
60
|
/****************************************************************************
|
138
61
|
*
|
139
62
|
* FrtSegmentInfo
|
@@ -771,28 +694,4 @@ extern int frt_iw_doc_count(FrtIndexWriter *iw);
|
|
771
694
|
extern void frt_iw_commit(FrtIndexWriter *iw);
|
772
695
|
extern void frt_iw_add_readers(FrtIndexWriter *iw, FrtIndexReader **readers, const int r_cnt);
|
773
696
|
|
774
|
-
/****************************************************************************
|
775
|
-
*
|
776
|
-
* FrtCompoundWriter
|
777
|
-
*
|
778
|
-
****************************************************************************/
|
779
|
-
|
780
|
-
#define FRT_CW_INIT_CAPA 16
|
781
|
-
typedef struct FrtCWFileEntry {
|
782
|
-
char *name;
|
783
|
-
frt_off_t dir_offset;
|
784
|
-
frt_off_t data_offset;
|
785
|
-
} FrtCWFileEntry;
|
786
|
-
|
787
|
-
typedef struct FrtCompoundWriter {
|
788
|
-
FrtStore *store;
|
789
|
-
const char *name;
|
790
|
-
FrtHashSet *ids;
|
791
|
-
FrtCWFileEntry *file_entries;
|
792
|
-
} FrtCompoundWriter;
|
793
|
-
|
794
|
-
extern FrtCompoundWriter *frt_open_cw(FrtStore *store, char *name);
|
795
|
-
extern void frt_cw_add_file(FrtCompoundWriter *cw, char *id);
|
796
|
-
extern void frt_cw_close(FrtCompoundWriter *cw, FrtDeleter *dlr);
|
797
|
-
|
798
697
|
#endif
|
@@ -8,8 +8,7 @@
|
|
8
8
|
#include "frt_global.h"
|
9
9
|
|
10
10
|
/* emalloc: malloc and report if error */
|
11
|
-
void *frt_emalloc(size_t size)
|
12
|
-
{
|
11
|
+
void *frt_emalloc(size_t size) {
|
13
12
|
void *p = malloc(size);
|
14
13
|
|
15
14
|
if (p == NULL) {
|
@@ -20,8 +19,7 @@ void *frt_emalloc(size_t size)
|
|
20
19
|
}
|
21
20
|
|
22
21
|
/* frt_ecalloc: malloc, zeroset and report if error */
|
23
|
-
void *frt_ecalloc(size_t size)
|
24
|
-
{
|
22
|
+
void *frt_ecalloc(size_t size) {
|
25
23
|
void *p = calloc(1, size);
|
26
24
|
|
27
25
|
if (p == NULL) {
|
@@ -32,8 +30,7 @@ void *frt_ecalloc(size_t size)
|
|
32
30
|
}
|
33
31
|
|
34
32
|
/* frt_erealloc: realloc and report if error */
|
35
|
-
void *frt_erealloc(void *ptr, size_t size)
|
36
|
-
{
|
33
|
+
void *frt_erealloc(void *ptr, size_t size) {
|
37
34
|
void *p = realloc(ptr, size);
|
38
35
|
|
39
36
|
if (p == NULL) {
|
@@ -47,8 +44,7 @@ void frt_micro_sleep(const int micro_seconds) {
|
|
47
44
|
rb_thread_wait_for(rb_time_interval(rb_float_new((double)micro_seconds/1000000.0)));
|
48
45
|
}
|
49
46
|
|
50
|
-
/* void frt_micro_sleep(const int micro_seconds)
|
51
|
-
{
|
47
|
+
/* void frt_micro_sleep(const int micro_seconds) {
|
52
48
|
#if (defined POSH_OS_WIN32 || defined POSH_OS_WIN64) && !defined __MINGW32__
|
53
49
|
Sleep(micro_seconds / 1000);
|
54
50
|
#else
|
@@ -81,8 +77,7 @@ void FRT_VEXIT(const char *err_type, const char *fmt, va_list args)
|
|
81
77
|
fprintf(EXCEPTION_STREAM, "\n");
|
82
78
|
if (frt_x_abort_on_exception) {
|
83
79
|
exit(2); /* conventional value for failed execution */
|
84
|
-
}
|
85
|
-
else {
|
80
|
+
} else {
|
86
81
|
frt_x_has_aborted = true;
|
87
82
|
}
|
88
83
|
}
|
@@ -1,10 +1,10 @@
|
|
1
1
|
#include "frt_lazy_doc.h"
|
2
2
|
|
3
|
-
FrtLazyDoc *frt_lazy_doc_new(int
|
3
|
+
FrtLazyDoc *frt_lazy_doc_new(int field_count, FrtInStream *fdt_in) {
|
4
4
|
FrtLazyDoc *self = FRT_ALLOC(FrtLazyDoc);
|
5
5
|
self->field_dictionary = frt_h_new_ptr((frt_free_ft)&frt_lazy_df_destroy);
|
6
|
-
self->
|
7
|
-
self->fields = FRT_ALLOC_AND_ZERO_N(FrtLazyDocField *,
|
6
|
+
self->field_count = field_count;
|
7
|
+
self->fields = FRT_ALLOC_AND_ZERO_N(FrtLazyDocField *, field_count);
|
8
8
|
self->fields_in = frt_is_clone(fdt_in);
|
9
9
|
self->loaded = false;
|
10
10
|
return self;
|
@@ -2,12 +2,12 @@
|
|
2
2
|
#include "frt_lazy_doc_field.h"
|
3
3
|
#include "frt_lazy_doc.h"
|
4
4
|
|
5
|
-
FrtLazyDocField *frt_lazy_df_new(ID name, const int size, FrtCompressionType
|
5
|
+
FrtLazyDocField *frt_lazy_df_new(ID name, const int size, FrtCompressionType compression_type) {
|
6
6
|
FrtLazyDocField *self = FRT_ALLOC(FrtLazyDocField);
|
7
7
|
self->name = name;
|
8
8
|
self->size = size;
|
9
9
|
self->data = FRT_ALLOC_AND_ZERO_N(FrtLazyDocFieldData, size);
|
10
|
-
self->
|
10
|
+
self->compression_type = compression_type;
|
11
11
|
self->decompressed = false;
|
12
12
|
self->loaded = false;
|
13
13
|
return self;
|
@@ -17,26 +17,27 @@ void frt_lazy_df_destroy(FrtLazyDocField *self) {
|
|
17
17
|
int i;
|
18
18
|
for (i = self->size - 1; i >= 0; i--) {
|
19
19
|
if (self->data[i].text) {
|
20
|
-
free(self->data[i].text);
|
20
|
+
free((void *)self->data[i].text);
|
21
21
|
}
|
22
22
|
}
|
23
23
|
free(self->data);
|
24
24
|
free(self);
|
25
25
|
}
|
26
26
|
|
27
|
-
char *frt_lazy_df_get_data(FrtLazyDocField *self, int i) {
|
28
|
-
char *text = NULL;
|
27
|
+
const char *frt_lazy_df_get_data(FrtLazyDocField *self, int i) {
|
28
|
+
const char *text = NULL;
|
29
29
|
if (i < self->size && i >= 0) {
|
30
30
|
text = self->data[i].text;
|
31
31
|
if (NULL == text) {
|
32
|
-
const int read_len = self->data[i].length
|
32
|
+
const int read_len = self->data[i].length;
|
33
33
|
frt_is_seek(self->doc->fields_in, self->data[i].start);
|
34
|
-
if (self->data[i].
|
35
|
-
self->data[i].text = text = frt_is_read_compressed_bytes(self->doc->fields_in, read_len, &(self->data[i].length), self->data[i].
|
34
|
+
if (self->data[i].compression_type != FRT_COMPRESSION_NONE) {
|
35
|
+
self->data[i].text = text = frt_is_read_compressed_bytes(self->doc->fields_in, read_len, &(self->data[i].length), self->data[i].compression_type);
|
36
36
|
} else {
|
37
|
-
|
38
|
-
frt_is_read_bytes(self->doc->fields_in, (frt_uchar *)
|
39
|
-
|
37
|
+
char *d = FRT_ALLOC_N(char, read_len + 1);
|
38
|
+
frt_is_read_bytes(self->doc->fields_in, (frt_uchar *)d, read_len);
|
39
|
+
d[read_len] = '\0';
|
40
|
+
self->data[i].text = text = d;
|
40
41
|
}
|
41
42
|
self->loaded = true;
|
42
43
|
}
|
@@ -46,14 +47,13 @@ char *frt_lazy_df_get_data(FrtLazyDocField *self, int i) {
|
|
46
47
|
}
|
47
48
|
|
48
49
|
void frt_lazy_df_get_bytes(FrtLazyDocField *self, char *buf, int start, int len) {
|
49
|
-
if (self->
|
50
|
+
if (self->compression_type != FRT_COMPRESSION_NONE && !self->decompressed) {
|
50
51
|
int i;
|
51
52
|
self->len = 0;
|
52
53
|
for (i = self->size-1; i >= 0; i--) {
|
53
54
|
(void)frt_lazy_df_get_data(self, i);
|
54
|
-
self->len += self->data[i].length
|
55
|
+
self->len += self->data[i].length;
|
55
56
|
}
|
56
|
-
self->len--; /* each field separated by ' ' but no need to add to end */
|
57
57
|
self->decompressed = true;
|
58
58
|
}
|
59
59
|
if (start < 0 || start >= self->len) {
|
@@ -67,7 +67,7 @@ void frt_lazy_df_get_bytes(FrtLazyDocField *self, char *buf, int start, int len)
|
|
67
67
|
FRT_RAISE(FRT_IO_ERROR, "Tried to read past end of field. Field is only %d "
|
68
68
|
"bytes long but tried to read to %d", self->len, start + len);
|
69
69
|
}
|
70
|
-
if (self->
|
70
|
+
if (self->compression_type != FRT_COMPRESSION_NONE) {
|
71
71
|
int cur_start = 0, buf_start = 0, cur_end, i, copy_start, copy_len;
|
72
72
|
for (i = 0; i < self->size; i++) {
|
73
73
|
cur_end = cur_start + self->data[i].length;
|
@@ -77,21 +77,14 @@ void frt_lazy_df_get_bytes(FrtLazyDocField *self, char *buf, int start, int len)
|
|
77
77
|
if (copy_len >= len) {
|
78
78
|
copy_len = len;
|
79
79
|
len = 0;
|
80
|
-
}
|
81
|
-
else {
|
80
|
+
} else {
|
82
81
|
len -= copy_len;
|
83
82
|
}
|
84
|
-
memcpy(buf + buf_start,
|
85
|
-
self->data[i].text + copy_start,
|
86
|
-
copy_len);
|
83
|
+
memcpy(buf + buf_start, self->data[i].text + copy_start, copy_len);
|
87
84
|
buf_start += copy_len;
|
88
|
-
if (len > 0) {
|
89
|
-
buf[buf_start++] = ' ';
|
90
|
-
len--;
|
91
|
-
}
|
92
85
|
if (len == 0) break;
|
93
86
|
}
|
94
|
-
cur_start = cur_end
|
87
|
+
cur_start = cur_end;
|
95
88
|
}
|
96
89
|
} else {
|
97
90
|
frt_is_seek(self->doc->fields_in, self->data[0].start + start);
|
@@ -9,8 +9,8 @@ typedef struct FrtLazyDocFieldData {
|
|
9
9
|
frt_off_t start;
|
10
10
|
int length;
|
11
11
|
rb_encoding *encoding;
|
12
|
-
FrtCompressionType
|
13
|
-
char
|
12
|
+
FrtCompressionType compression_type; /* as stored */
|
13
|
+
const char *text;
|
14
14
|
} FrtLazyDocFieldData;
|
15
15
|
|
16
16
|
typedef struct FrtLazyDoc FrtLazyDoc;
|
@@ -20,13 +20,13 @@ typedef struct FrtLazyDocField {
|
|
20
20
|
FrtLazyDoc *doc;
|
21
21
|
int size; /* number of data elements */
|
22
22
|
int len; /* length of data elements concatenated */
|
23
|
-
FrtCompressionType
|
23
|
+
FrtCompressionType compression_type; /* as configured */
|
24
24
|
bool decompressed;
|
25
25
|
bool loaded;
|
26
26
|
} FrtLazyDocField;
|
27
27
|
|
28
|
-
extern FrtLazyDocField *frt_lazy_df_new(ID name, const int size, FrtCompressionType
|
29
|
-
extern char *frt_lazy_df_get_data(FrtLazyDocField *self, int i);
|
28
|
+
extern FrtLazyDocField *frt_lazy_df_new(ID name, const int size, FrtCompressionType compression_type);
|
29
|
+
extern const char *frt_lazy_df_get_data(FrtLazyDocField *self, int i);
|
30
30
|
extern void frt_lazy_df_get_bytes(FrtLazyDocField *self, char *buf, int start, int len);
|
31
31
|
extern void frt_lazy_df_destroy(FrtLazyDocField *self);
|
32
32
|
|