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.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/ext/isomorfeus_ferret_ext/benchmark.c +9 -20
  3. data/ext/isomorfeus_ferret_ext/benchmarks_all.h +1 -2
  4. data/ext/isomorfeus_ferret_ext/bm_hash.c +1 -2
  5. data/ext/isomorfeus_ferret_ext/brotli_dec_decode.c +4 -2
  6. data/ext/isomorfeus_ferret_ext/brotli_enc_encode.c +3 -2
  7. data/ext/isomorfeus_ferret_ext/frb_analysis.c +4 -5
  8. data/ext/isomorfeus_ferret_ext/frb_field_info.c +3 -4
  9. data/ext/isomorfeus_ferret_ext/frb_index.c +118 -125
  10. data/ext/isomorfeus_ferret_ext/frb_lazy_doc.c +14 -16
  11. data/ext/isomorfeus_ferret_ext/frb_search.c +31 -23
  12. data/ext/isomorfeus_ferret_ext/frb_store.c +27 -13
  13. data/ext/isomorfeus_ferret_ext/frb_utils.c +3 -6
  14. data/ext/isomorfeus_ferret_ext/frt_analysis.c +39 -46
  15. data/ext/isomorfeus_ferret_ext/frt_analysis.h +9 -9
  16. data/ext/isomorfeus_ferret_ext/frt_array.c +11 -22
  17. data/ext/isomorfeus_ferret_ext/frt_bitvector.h +3 -6
  18. data/ext/isomorfeus_ferret_ext/frt_doc_field.c +87 -0
  19. data/ext/isomorfeus_ferret_ext/frt_doc_field.h +26 -0
  20. data/ext/isomorfeus_ferret_ext/frt_document.c +4 -97
  21. data/ext/isomorfeus_ferret_ext/frt_document.h +2 -27
  22. data/ext/isomorfeus_ferret_ext/frt_except.c +8 -6
  23. data/ext/isomorfeus_ferret_ext/frt_except.h +1 -2
  24. data/ext/isomorfeus_ferret_ext/frt_field_index.c +13 -32
  25. data/ext/isomorfeus_ferret_ext/frt_field_index.h +0 -6
  26. data/ext/isomorfeus_ferret_ext/frt_field_info.c +69 -0
  27. data/ext/isomorfeus_ferret_ext/frt_field_info.h +49 -0
  28. data/ext/isomorfeus_ferret_ext/frt_field_infos.c +196 -0
  29. data/ext/isomorfeus_ferret_ext/frt_field_infos.h +35 -0
  30. data/ext/isomorfeus_ferret_ext/frt_global.c +10 -4
  31. data/ext/isomorfeus_ferret_ext/frt_global.h +11 -15
  32. data/ext/isomorfeus_ferret_ext/frt_hash.c +8 -8
  33. data/ext/isomorfeus_ferret_ext/frt_hash.h +1 -2
  34. data/ext/isomorfeus_ferret_ext/frt_hashset.c +20 -40
  35. data/ext/isomorfeus_ferret_ext/frt_hashset.h +1 -2
  36. data/ext/isomorfeus_ferret_ext/frt_helper.c +7 -15
  37. data/ext/isomorfeus_ferret_ext/frt_in_stream.c +35 -45
  38. data/ext/isomorfeus_ferret_ext/frt_in_stream.h +3 -2
  39. data/ext/isomorfeus_ferret_ext/frt_ind.c +20 -38
  40. data/ext/isomorfeus_ferret_ext/frt_index.c +292 -790
  41. data/ext/isomorfeus_ferret_ext/frt_index.h +1 -102
  42. data/ext/isomorfeus_ferret_ext/frt_lang.c +5 -10
  43. data/ext/isomorfeus_ferret_ext/frt_lazy_doc.c +3 -3
  44. data/ext/isomorfeus_ferret_ext/frt_lazy_doc.h +1 -1
  45. data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.c +18 -25
  46. data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.h +5 -5
  47. data/ext/isomorfeus_ferret_ext/frt_mdbx_store.c +102 -70
  48. data/ext/isomorfeus_ferret_ext/frt_mempool.c +8 -16
  49. data/ext/isomorfeus_ferret_ext/frt_multimapper.c +23 -46
  50. data/ext/isomorfeus_ferret_ext/frt_multimapper.h +4 -8
  51. data/ext/isomorfeus_ferret_ext/frt_out_stream.c +31 -43
  52. data/ext/isomorfeus_ferret_ext/frt_out_stream.h +2 -2
  53. data/ext/isomorfeus_ferret_ext/frt_posh.c +6 -819
  54. data/ext/isomorfeus_ferret_ext/frt_posh.h +0 -57
  55. data/ext/isomorfeus_ferret_ext/frt_priorityqueue.c +11 -22
  56. data/ext/isomorfeus_ferret_ext/frt_priorityqueue.h +1 -2
  57. data/ext/isomorfeus_ferret_ext/frt_q_boolean.c +85 -171
  58. data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +8 -16
  59. data/ext/isomorfeus_ferret_ext/frt_q_multi_term.c +1 -2
  60. data/ext/isomorfeus_ferret_ext/frt_q_parser.c +49 -98
  61. data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +52 -104
  62. data/ext/isomorfeus_ferret_ext/frt_q_range.c +6 -12
  63. data/ext/isomorfeus_ferret_ext/frt_q_span.c +113 -226
  64. data/ext/isomorfeus_ferret_ext/frt_q_wildcard.c +1 -2
  65. data/ext/isomorfeus_ferret_ext/frt_ram_store.c +134 -85
  66. data/ext/isomorfeus_ferret_ext/frt_search.c +82 -164
  67. data/ext/isomorfeus_ferret_ext/frt_similarity.c +11 -22
  68. data/ext/isomorfeus_ferret_ext/frt_similarity.h +1 -2
  69. data/ext/isomorfeus_ferret_ext/frt_store.c +13 -25
  70. data/ext/isomorfeus_ferret_ext/frt_store.h +86 -52
  71. data/ext/isomorfeus_ferret_ext/frt_term_vectors.c +8 -16
  72. data/ext/isomorfeus_ferret_ext/frt_win32.h +5 -10
  73. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +12 -11
  74. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.h +11 -13
  75. data/ext/isomorfeus_ferret_ext/lz4.c +422 -195
  76. data/ext/isomorfeus_ferret_ext/lz4.h +114 -46
  77. data/ext/isomorfeus_ferret_ext/lz4frame.c +421 -242
  78. data/ext/isomorfeus_ferret_ext/lz4frame.h +122 -53
  79. data/ext/isomorfeus_ferret_ext/lz4hc.c +127 -111
  80. data/ext/isomorfeus_ferret_ext/lz4hc.h +14 -14
  81. data/ext/isomorfeus_ferret_ext/lz4xxhash.h +1 -1
  82. data/ext/isomorfeus_ferret_ext/mdbx.c +3762 -2526
  83. data/ext/isomorfeus_ferret_ext/mdbx.h +115 -70
  84. data/ext/isomorfeus_ferret_ext/test.c +40 -87
  85. data/ext/isomorfeus_ferret_ext/test.h +3 -6
  86. data/ext/isomorfeus_ferret_ext/test_1710.c +11 -13
  87. data/ext/isomorfeus_ferret_ext/test_analysis.c +32 -64
  88. data/ext/isomorfeus_ferret_ext/test_array.c +6 -12
  89. data/ext/isomorfeus_ferret_ext/test_bitvector.c +12 -24
  90. data/ext/isomorfeus_ferret_ext/test_document.c +23 -33
  91. data/ext/isomorfeus_ferret_ext/test_except.c +10 -21
  92. data/ext/isomorfeus_ferret_ext/test_fields.c +62 -68
  93. data/ext/isomorfeus_ferret_ext/test_file_deleter.c +15 -23
  94. data/ext/isomorfeus_ferret_ext/test_filter.c +17 -27
  95. data/ext/isomorfeus_ferret_ext/test_global.c +14 -29
  96. data/ext/isomorfeus_ferret_ext/test_hash.c +19 -38
  97. data/ext/isomorfeus_ferret_ext/test_hashset.c +8 -16
  98. data/ext/isomorfeus_ferret_ext/test_helper.c +4 -8
  99. data/ext/isomorfeus_ferret_ext/test_highlighter.c +16 -28
  100. data/ext/isomorfeus_ferret_ext/test_index.c +277 -487
  101. data/ext/isomorfeus_ferret_ext/test_lang.c +7 -14
  102. data/ext/isomorfeus_ferret_ext/test_mdbx_store.c +2 -5
  103. data/ext/isomorfeus_ferret_ext/test_mempool.c +5 -10
  104. data/ext/isomorfeus_ferret_ext/test_multimapper.c +3 -6
  105. data/ext/isomorfeus_ferret_ext/test_priorityqueue.c +9 -18
  106. data/ext/isomorfeus_ferret_ext/test_q_const_score.c +4 -6
  107. data/ext/isomorfeus_ferret_ext/test_q_filtered.c +3 -4
  108. data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +9 -15
  109. data/ext/isomorfeus_ferret_ext/test_q_parser.c +8 -16
  110. data/ext/isomorfeus_ferret_ext/test_q_span.c +19 -35
  111. data/ext/isomorfeus_ferret_ext/test_ram_store.c +14 -13
  112. data/ext/isomorfeus_ferret_ext/test_search.c +60 -109
  113. data/ext/isomorfeus_ferret_ext/test_segments.c +8 -13
  114. data/ext/isomorfeus_ferret_ext/test_similarity.c +2 -4
  115. data/ext/isomorfeus_ferret_ext/test_sort.c +14 -24
  116. data/ext/isomorfeus_ferret_ext/test_store.c +96 -115
  117. data/ext/isomorfeus_ferret_ext/test_term.c +9 -15
  118. data/ext/isomorfeus_ferret_ext/test_term_vectors.c +9 -14
  119. data/ext/isomorfeus_ferret_ext/test_test.c +4 -8
  120. data/ext/isomorfeus_ferret_ext/test_threading.c +14 -20
  121. data/ext/isomorfeus_ferret_ext/testhelper.c +11 -21
  122. data/ext/isomorfeus_ferret_ext/testhelper.h +1 -1
  123. data/ext/isomorfeus_ferret_ext/tests_all.h +1 -2
  124. data/lib/isomorfeus/ferret/index/index.rb +1 -1
  125. data/lib/isomorfeus/ferret/version.rb +1 -1
  126. metadata +24 -4
@@ -6,13 +6,11 @@
6
6
  #define St(state) ((FrtState *)(state))
7
7
  #define UCtoI(val) ((int)(unsigned char)(val))
8
8
 
9
- static void state_destroy(FrtState *state)
10
- {
9
+ static void state_destroy(FrtState *state) {
11
10
  state->destroy_i(state);
12
11
  }
13
12
 
14
- typedef struct LetterState
15
- {
13
+ typedef struct LetterState {
16
14
  FrtState super;
17
15
  int c;
18
16
  int val;
@@ -21,30 +19,25 @@ typedef struct LetterState
21
19
 
22
20
  #define LSt(state) ((LetterState *)(state))
23
21
 
24
- static int lstate_next(LetterState *self, int c, int *states)
25
- {
22
+ static int lstate_next(LetterState *self, int c, int *states) {
26
23
  if (c == self->c) {
27
24
  states[0] = self->val;
28
25
  return 1;
29
- }
30
- else {
26
+ } else {
31
27
  return 0;
32
28
  }
33
29
  }
34
30
 
35
- static int lstate_is_match(LetterState *self, char **mapping)
36
- {
31
+ static int lstate_is_match(LetterState *self, char **mapping) {
37
32
  if (self->val < 0) {
38
33
  *mapping = self->mapping;
39
34
  return self->val;
40
- }
41
- else {
35
+ } else {
42
36
  return 0;
43
37
  }
44
38
  }
45
39
 
46
- static LetterState *lstate_new(int c, int val)
47
- {
40
+ static LetterState *lstate_new(int c, int val) {
48
41
  LetterState *self = FRT_ALLOC(LetterState);
49
42
  self->c = c;
50
43
  self->val = val;
@@ -55,28 +48,24 @@ static LetterState *lstate_new(int c, int val)
55
48
  return self;
56
49
  }
57
50
 
58
- typedef struct NonDeterministicState
59
- {
51
+ typedef struct NonDeterministicState {
60
52
  FrtState super;
61
53
  int *states[256];
62
54
  int size[256];
63
55
  int capa[256];
64
56
  } NonDeterministicState;
65
57
 
66
- static int ndstate_next(NonDeterministicState *self, int c, int *states)
67
- {
58
+ static int ndstate_next(NonDeterministicState *self, int c, int *states) {
68
59
  int size = self->size[c];
69
60
  memcpy(states, self->states[c], size * sizeof(int));
70
61
  return size;
71
62
  }
72
63
 
73
- static void ndstate_add(NonDeterministicState *self, int c, int state)
74
- {
64
+ static void ndstate_add(NonDeterministicState *self, int c, int state) {
75
65
  if (self->capa[c] <= self->size[c]) {
76
66
  if (self->capa[c] == 0) {
77
67
  self->capa[c] = 4;
78
- }
79
- else {
68
+ } else {
80
69
  self->capa[c] <<= 1;
81
70
  }
82
71
  FRT_REALLOC_N(self->states[c], int, self->capa[c]);
@@ -92,8 +81,7 @@ static void ndstate_destroy_i(NonDeterministicState *self) {
92
81
  free(self);
93
82
  }
94
83
 
95
- static int ndstate_is_match(FrtState *self, char **mapping)
96
- {
84
+ static int ndstate_is_match(FrtState *self, char **mapping) {
97
85
  (void)self; (void)mapping;
98
86
  return 0;
99
87
  }
@@ -118,8 +106,7 @@ FrtMultiMapper *frt_mulmap_new(void) {
118
106
  return self;
119
107
  }
120
108
 
121
- static void mulmap_free_dstates(FrtMultiMapper *self)
122
- {
109
+ static void mulmap_free_dstates(FrtMultiMapper *self) {
123
110
  if (self->d_size > 0) {
124
111
  int i;
125
112
  for (i = self->d_size - 1; i >= 0; i--) {
@@ -129,8 +116,7 @@ static void mulmap_free_dstates(FrtMultiMapper *self)
129
116
  }
130
117
  }
131
118
 
132
- void frt_mulmap_add_mapping(FrtMultiMapper *self, const char *pattern, const char *rep)
133
- {
119
+ void frt_mulmap_add_mapping(FrtMultiMapper *self, const char *pattern, const char *rep) {
134
120
  if (pattern == NULL || pattern[0] == '\0') {
135
121
  FRT_RAISE(FRT_ARG_ERROR, "Tried to add empty pattern to multi_mapper");
136
122
  } else {
@@ -147,16 +133,14 @@ void frt_mulmap_add_mapping(FrtMultiMapper *self, const char *pattern, const cha
147
133
  }
148
134
 
149
135
 
150
- static void mulmap_bv_set_states(FrtBitVector *bv, int *states, int cnt)
151
- {
136
+ static void mulmap_bv_set_states(FrtBitVector *bv, int *states, int cnt) {
152
137
  int i;
153
138
  for (i = cnt - 1; i >= 0; i--) {
154
139
  frt_bv_set(bv, states[i]);
155
140
  }
156
141
  }
157
142
 
158
- static FrtDeterministicState *mulmap_process_state(FrtMultiMapper *self, FrtBitVector *bv)
159
- {
143
+ static FrtDeterministicState *mulmap_process_state(FrtMultiMapper *self, FrtBitVector *bv) {
160
144
  FrtDeterministicState *current_state
161
145
  = (FrtDeterministicState *)frt_h_get(self->dstates_map, bv);
162
146
  if (current_state == NULL) {
@@ -197,15 +181,13 @@ static FrtDeterministicState *mulmap_process_state(FrtMultiMapper *self, FrtBitV
197
181
  }
198
182
  current_state->next[(int)c] = mulmap_process_state(self, nxt_bv);
199
183
  }
200
- }
201
- else {
184
+ } else {
202
185
  frt_bv_destroy(bv);
203
186
  }
204
187
  return current_state;
205
188
  }
206
189
 
207
- void frt_mulmap_compile(FrtMultiMapper *self)
208
- {
190
+ void frt_mulmap_compile(FrtMultiMapper *self) {
209
191
  NonDeterministicState *start = ndstate_new();
210
192
  int i, j;
211
193
  int size = 1;
@@ -254,8 +236,7 @@ void frt_mulmap_compile(FrtMultiMapper *self)
254
236
  free(nstates);
255
237
  }
256
238
 
257
- int frt_mulmap_map_len(FrtMultiMapper *self, char *to, char *from, int capa)
258
- {
239
+ int frt_mulmap_map_len(FrtMultiMapper *self, char *to, char *from, int capa) {
259
240
  FrtDeterministicState *start = self->dstates[0];
260
241
  FrtDeterministicState *state = start;
261
242
  char *s = from, *d = to, *end = to + capa - 1;
@@ -273,8 +254,7 @@ int frt_mulmap_map_len(FrtMultiMapper *self, char *to, char *from, int capa)
273
254
  memcpy(d, state->mapping, len);
274
255
  d += len;
275
256
  state = start;
276
- }
277
- else {
257
+ } else {
278
258
  *(d++) = *s;
279
259
  }
280
260
  s++;
@@ -283,15 +263,13 @@ int frt_mulmap_map_len(FrtMultiMapper *self, char *to, char *from, int capa)
283
263
  return d - to;
284
264
  }
285
265
 
286
- char *frt_mulmap_map(FrtMultiMapper *self, char *to, char *from, int capa)
287
- {
266
+ char *frt_mulmap_map(FrtMultiMapper *self, char *to, char *from, int capa) {
288
267
  frt_mulmap_map_len(self, to, from, capa);
289
268
  return to;
290
269
  }
291
270
 
292
271
  /* Maps a string to a dynamically allocated string */
293
- char *frt_mulmap_dynamic_map(FrtMultiMapper *self, char *from)
294
- {
272
+ char *frt_mulmap_dynamic_map(FrtMultiMapper *self, char *from) {
295
273
  FrtDeterministicState *start = self->dstates[0];
296
274
  FrtDeterministicState *state = start;
297
275
  int capa = strlen(from);
@@ -312,8 +290,7 @@ char *frt_mulmap_dynamic_map(FrtMultiMapper *self, char *from)
312
290
  memcpy(d, state->mapping, len);
313
291
  d += len;
314
292
  state = start;
315
- }
316
- else {
293
+ } else {
317
294
  *(d++) = *s;
318
295
  }
319
296
  s++;
@@ -3,29 +3,25 @@
3
3
 
4
4
  #include "frt_hash.h"
5
5
 
6
- typedef struct FrtState
7
- {
6
+ typedef struct FrtState {
8
7
  int (*next)(struct FrtState *self, int c, int *states);
9
8
  void (*destroy_i)(struct FrtState *self);
10
9
  int (*is_match)(struct FrtState *self, char **mapping);
11
10
  } FrtState;
12
11
 
13
- typedef struct FrtDeterministicState
14
- {
12
+ typedef struct FrtDeterministicState {
15
13
  struct FrtDeterministicState *next[256];
16
14
  int longest_match;
17
15
  char *mapping;
18
16
  int mapping_len;
19
17
  } FrtDeterministicState;
20
18
 
21
- typedef struct FrtMapping
22
- {
19
+ typedef struct FrtMapping {
23
20
  char *pattern;
24
21
  char *replacement;
25
22
  } FrtMapping;
26
23
 
27
- typedef struct FrtMultiMapper
28
- {
24
+ typedef struct FrtMultiMapper {
29
25
  FrtMapping **mappings;
30
26
  int size;
31
27
  int capa;
@@ -1,3 +1,8 @@
1
+ /* prevent warning: #warning Please include winsock2.h before windows.h [-Wcpp] */
2
+ #ifdef _WIN32
3
+ # include <winsock2.h>
4
+ #endif
5
+
1
6
  #include "brotli_decode.h"
2
7
  #include "brotli_encode.h"
3
8
  #include "bzlib.h"
@@ -16,6 +21,7 @@
16
21
  */
17
22
  FrtOutStream *frt_os_new(void) {
18
23
  FrtOutStream *os = FRT_ALLOC(FrtOutStream);
24
+ os->folder_name = NULL;
19
25
  os->buf.start = 0;
20
26
  os->buf.pos = 0;
21
27
  os->buf.len = 0;
@@ -27,27 +33,26 @@ FrtOutStream *frt_os_new(void) {
27
33
  *
28
34
  * @param the OutStream to flush
29
35
  */
30
- void frt_os_flush(FrtOutStream *os)
31
- {
36
+ void frt_os_flush(FrtOutStream *os) {
32
37
  os->m->flush_i(os, os->buf.buf, os->buf.pos);
33
38
  os->buf.start += os->buf.pos;
34
39
  os->buf.pos = 0;
35
40
  }
36
41
 
37
- void frt_os_close(FrtOutStream *os)
38
- {
42
+ void frt_os_close(FrtOutStream *os) {
39
43
  frt_os_flush(os);
40
44
  os->m->close_i(os);
45
+ if (os->folder_name) {
46
+ free((void *)os->folder_name);
47
+ }
41
48
  free(os);
42
49
  }
43
50
 
44
- off_t frt_os_pos(FrtOutStream *os)
45
- {
51
+ off_t frt_os_pos(FrtOutStream *os) {
46
52
  return os->buf.start + os->buf.pos;
47
53
  }
48
54
 
49
- void frt_os_seek(FrtOutStream *os, frt_off_t new_pos)
50
- {
55
+ void frt_os_seek(FrtOutStream *os, frt_off_t new_pos) {
51
56
  frt_os_flush(os);
52
57
  os->buf.start = new_pos;
53
58
  os->m->seek_i(os, new_pos);
@@ -66,29 +71,25 @@ void frt_os_seek(FrtOutStream *os, frt_off_t new_pos)
66
71
  * @param b the byte to write
67
72
  * @raise FRT_IO_ERROR if there is an IO error writing to the filesystem
68
73
  */
69
- void frt_os_write_byte(FrtOutStream *os, frt_uchar b)
70
- {
74
+ void frt_os_write_byte(FrtOutStream *os, frt_uchar b) {
71
75
  if (os->buf.pos >= (FRT_BUFFER_SIZE - 1)) {
72
76
  frt_os_flush(os);
73
77
  }
74
78
  write_byte(os, b);
75
79
  }
76
80
 
77
- void frt_os_write_bytes(FrtOutStream *os, const frt_uchar *buf, int len)
78
- {
81
+ void frt_os_write_bytes(FrtOutStream *os, const frt_uchar *buf, int len) {
79
82
  if (len < (FRT_BUFFER_SIZE - os->buf.pos)) {
80
83
  memcpy(os->buf.buf + os->buf.pos, buf, len);
81
84
  os->buf.pos += len;
82
- }
83
- else {
85
+ } else {
84
86
  frt_os_flush(os);
85
87
  int pos = 0;
86
88
  int size;
87
89
  while (pos < len) {
88
90
  if (len - pos < FRT_BUFFER_SIZE) {
89
91
  size = len - pos;
90
- }
91
- else {
92
+ } else {
92
93
  size = FRT_BUFFER_SIZE;
93
94
  }
94
95
  os->m->flush_i(os, buf + pos, size);
@@ -98,16 +99,14 @@ void frt_os_write_bytes(FrtOutStream *os, const frt_uchar *buf, int len)
98
99
  }
99
100
  }
100
101
 
101
- void frt_os_write_i32(FrtOutStream *os, frt_i32 num)
102
- {
102
+ void frt_os_write_i32(FrtOutStream *os, frt_i32 num) {
103
103
  frt_os_write_byte(os, (frt_uchar)((num >> 24) & 0xFF));
104
104
  frt_os_write_byte(os, (frt_uchar)((num >> 16) & 0xFF));
105
105
  frt_os_write_byte(os, (frt_uchar)((num >> 8) & 0xFF));
106
106
  frt_os_write_byte(os, (frt_uchar)(num & 0xFF));
107
107
  }
108
108
 
109
- void frt_os_write_i64(FrtOutStream *os, frt_i64 num)
110
- {
109
+ void frt_os_write_i64(FrtOutStream *os, frt_i64 num) {
111
110
  frt_os_write_byte(os, (frt_uchar)((num >> 56) & 0xFF));
112
111
  frt_os_write_byte(os, (frt_uchar)((num >> 48) & 0xFF));
113
112
  frt_os_write_byte(os, (frt_uchar)((num >> 40) & 0xFF));
@@ -118,16 +117,14 @@ void frt_os_write_i64(FrtOutStream *os, frt_i64 num)
118
117
  frt_os_write_byte(os, (frt_uchar)(num & 0xFF));
119
118
  }
120
119
 
121
- void frt_os_write_u32(FrtOutStream *os, frt_u32 num)
122
- {
120
+ void frt_os_write_u32(FrtOutStream *os, frt_u32 num) {
123
121
  frt_os_write_byte(os, (frt_uchar)((num >> 24) & 0xFF));
124
122
  frt_os_write_byte(os, (frt_uchar)((num >> 16) & 0xFF));
125
123
  frt_os_write_byte(os, (frt_uchar)((num >> 8) & 0xFF));
126
124
  frt_os_write_byte(os, (frt_uchar)(num & 0xFF));
127
125
  }
128
126
 
129
- void frt_os_write_u64(FrtOutStream *os, frt_u64 num)
130
- {
127
+ void frt_os_write_u64(FrtOutStream *os, frt_u64 num) {
131
128
  frt_os_write_byte(os, (frt_uchar)((num >> 56) & 0xFF));
132
129
  frt_os_write_byte(os, (frt_uchar)((num >> 48) & 0xFF));
133
130
  frt_os_write_byte(os, (frt_uchar)((num >> 40) & 0xFF));
@@ -139,16 +136,14 @@ void frt_os_write_u64(FrtOutStream *os, frt_u64 num)
139
136
  }
140
137
 
141
138
  /* optimized to use an unchecked write if there is space */
142
- void frt_os_write_vint(FrtOutStream *os, register unsigned int num)
143
- {
139
+ void frt_os_write_vint(FrtOutStream *os, register unsigned int num) {
144
140
  if (os->buf.pos > VINT_END) {
145
141
  while (num > 127) {
146
142
  frt_os_write_byte(os, (frt_uchar)((num & 0x7f) | 0x80));
147
143
  num >>= 7;
148
144
  }
149
145
  frt_os_write_byte(os, (frt_uchar)(num));
150
- }
151
- else {
146
+ } else {
152
147
  while (num > 127) {
153
148
  write_byte(os, (frt_uchar)((num & 0x7f) | 0x80));
154
149
  num >>= 7;
@@ -158,16 +153,14 @@ void frt_os_write_vint(FrtOutStream *os, register unsigned int num)
158
153
  }
159
154
 
160
155
  /* optimized to use an unchecked write if there is space */
161
- void frt_os_write_voff_t(FrtOutStream *os, register frt_off_t num)
162
- {
156
+ void frt_os_write_voff_t(FrtOutStream *os, register frt_off_t num) {
163
157
  if (os->buf.pos > VINT_END) {
164
158
  while (num > 127) {
165
159
  frt_os_write_byte(os, (frt_uchar)((num & 0x7f) | 0x80));
166
160
  num >>= 7;
167
161
  }
168
162
  frt_os_write_byte(os, (frt_uchar)num);
169
- }
170
- else {
163
+ } else {
171
164
  while (num > 127) {
172
165
  write_byte(os, (frt_uchar)((num & 0x7f) | 0x80));
173
166
  num >>= 7;
@@ -177,16 +170,14 @@ void frt_os_write_voff_t(FrtOutStream *os, register frt_off_t num)
177
170
  }
178
171
 
179
172
  /* optimized to use an unchecked write if there is space */
180
- void frt_os_write_vll(FrtOutStream *os, register frt_u64 num)
181
- {
173
+ void frt_os_write_vll(FrtOutStream *os, register frt_u64 num) {
182
174
  if (os->buf.pos > VINT_END) {
183
175
  while (num > 127) {
184
176
  frt_os_write_byte(os, (frt_uchar)((num & 0x7f) | 0x80));
185
177
  num >>= 7;
186
178
  }
187
179
  frt_os_write_byte(os, (frt_uchar)num);
188
- }
189
- else {
180
+ } else {
190
181
  while (num > 127) {
191
182
  write_byte(os, (frt_uchar)((num & 0x7f) | 0x80));
192
183
  num >>= 7;
@@ -195,14 +186,12 @@ void frt_os_write_vll(FrtOutStream *os, register frt_u64 num)
195
186
  }
196
187
  }
197
188
 
198
- void frt_os_write_string_len(FrtOutStream *os, const char *str, int len)
199
- {
189
+ void frt_os_write_string_len(FrtOutStream *os, const char *str, int len) {
200
190
  frt_os_write_vint(os, len);
201
191
  frt_os_write_bytes(os, (frt_uchar *)str, len);
202
192
  }
203
193
 
204
- void frt_os_write_string(FrtOutStream *os, const char *str)
205
- {
194
+ void frt_os_write_string(FrtOutStream *os, const char *str) {
206
195
  frt_os_write_string_len(os, str, (int)strlen(str));
207
196
  }
208
197
 
@@ -331,8 +320,8 @@ finish:
331
320
  return compressed_length;
332
321
  }
333
322
 
334
- int frt_os_write_compressed_bytes(FrtOutStream* out_stream, frt_uchar *data, int length, FrtCompressionType compression) {
335
- switch (compression) {
323
+ int frt_os_write_compressed_bytes(FrtOutStream* out_stream, frt_uchar *data, int length, FrtCompressionType compression_type) {
324
+ switch (compression_type) {
336
325
  case FRT_COMPRESSION_BROTLI:
337
326
  return frt_os_write_brotli_compressed_bytes(out_stream, data, length);
338
327
  case FRT_COMPRESSION_BZ2:
@@ -342,5 +331,4 @@ int frt_os_write_compressed_bytes(FrtOutStream* out_stream, frt_uchar *data, int
342
331
  default:
343
332
  return -1;
344
333
  }
345
-
346
334
  }
@@ -38,11 +38,11 @@ struct FrtOutStreamMethods {
38
38
  };
39
39
 
40
40
  struct FrtOutStream {
41
+ const char *folder_name;
41
42
  FrtBuffer buf;
42
43
  frt_off_t pointer; /* only used by RAMOut */
43
44
  FrtStore *store;
44
45
  union {
45
- int fd;
46
46
  FrtRAMFile *rf;
47
47
  } file;
48
48
  const struct FrtOutStreamMethods *m;
@@ -193,6 +193,6 @@ extern void frt_os_write_string_len(FrtOutStream *os,
193
193
  */
194
194
  extern void frt_os_write_string(FrtOutStream *os, const char *str);
195
195
 
196
- extern int frt_os_write_compressed_bytes(FrtOutStream* out_stream, frt_uchar *data, int length, FrtCompressionType compression);
196
+ extern int frt_os_write_compressed_bytes(FrtOutStream* out_stream, frt_uchar *data, int length, FrtCompressionType compression_type);
197
197
 
198
198
  #endif