isomorfeus-ferret 0.12.4 → 0.12.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +612 -612
  3. data/README.md +77 -48
  4. data/ext/isomorfeus_ferret_ext/bm_hash.c +9 -6
  5. data/ext/isomorfeus_ferret_ext/bm_micro_string.c +4 -2
  6. data/ext/isomorfeus_ferret_ext/brotli_common_constants.c +15 -0
  7. data/ext/isomorfeus_ferret_ext/brotli_common_constants.h +200 -0
  8. data/ext/isomorfeus_ferret_ext/brotli_common_context.c +156 -0
  9. data/ext/isomorfeus_ferret_ext/brotli_common_context.h +113 -0
  10. data/ext/isomorfeus_ferret_ext/brotli_common_dictionary.c +5914 -0
  11. data/ext/isomorfeus_ferret_ext/brotli_common_dictionary.h +64 -0
  12. data/ext/isomorfeus_ferret_ext/brotli_common_platform.c +22 -0
  13. data/ext/isomorfeus_ferret_ext/brotli_common_platform.h +594 -0
  14. data/ext/isomorfeus_ferret_ext/brotli_common_transform.c +291 -0
  15. data/ext/isomorfeus_ferret_ext/brotli_common_transform.h +85 -0
  16. data/ext/isomorfeus_ferret_ext/brotli_common_version.h +26 -0
  17. data/ext/isomorfeus_ferret_ext/brotli_dec_bit_reader.c +76 -0
  18. data/ext/isomorfeus_ferret_ext/brotli_dec_bit_reader.h +351 -0
  19. data/ext/isomorfeus_ferret_ext/brotli_dec_decode.c +2608 -0
  20. data/ext/isomorfeus_ferret_ext/brotli_dec_huffman.c +339 -0
  21. data/ext/isomorfeus_ferret_ext/brotli_dec_huffman.h +121 -0
  22. data/ext/isomorfeus_ferret_ext/brotli_dec_prefix.h +732 -0
  23. data/ext/isomorfeus_ferret_ext/brotli_dec_state.c +159 -0
  24. data/ext/isomorfeus_ferret_ext/brotli_dec_state.h +365 -0
  25. data/ext/isomorfeus_ferret_ext/brotli_decode.h +344 -0
  26. data/ext/isomorfeus_ferret_ext/brotli_enc_backward_references.c +145 -0
  27. data/ext/isomorfeus_ferret_ext/brotli_enc_backward_references.h +39 -0
  28. data/ext/isomorfeus_ferret_ext/brotli_enc_backward_references_hq.c +843 -0
  29. data/ext/isomorfeus_ferret_ext/brotli_enc_backward_references_hq.h +95 -0
  30. data/ext/isomorfeus_ferret_ext/brotli_enc_backward_references_inc.h +163 -0
  31. data/ext/isomorfeus_ferret_ext/brotli_enc_bit_cost.c +35 -0
  32. data/ext/isomorfeus_ferret_ext/brotli_enc_bit_cost.h +63 -0
  33. data/ext/isomorfeus_ferret_ext/brotli_enc_bit_cost_inc.h +127 -0
  34. data/ext/isomorfeus_ferret_ext/brotli_enc_block_encoder_inc.h +34 -0
  35. data/ext/isomorfeus_ferret_ext/brotli_enc_block_splitter.c +194 -0
  36. data/ext/isomorfeus_ferret_ext/brotli_enc_block_splitter.h +51 -0
  37. data/ext/isomorfeus_ferret_ext/brotli_enc_block_splitter_inc.h +440 -0
  38. data/ext/isomorfeus_ferret_ext/brotli_enc_brotli_bit_stream.c +1314 -0
  39. data/ext/isomorfeus_ferret_ext/brotli_enc_brotli_bit_stream.h +84 -0
  40. data/ext/isomorfeus_ferret_ext/brotli_enc_cluster.c +56 -0
  41. data/ext/isomorfeus_ferret_ext/brotli_enc_cluster.h +48 -0
  42. data/ext/isomorfeus_ferret_ext/brotli_enc_cluster_inc.h +320 -0
  43. data/ext/isomorfeus_ferret_ext/brotli_enc_command.c +28 -0
  44. data/ext/isomorfeus_ferret_ext/brotli_enc_command.h +190 -0
  45. data/ext/isomorfeus_ferret_ext/brotli_enc_compress_fragment.c +790 -0
  46. data/ext/isomorfeus_ferret_ext/brotli_enc_compress_fragment.h +61 -0
  47. data/ext/isomorfeus_ferret_ext/brotli_enc_compress_fragment_two_pass.c +645 -0
  48. data/ext/isomorfeus_ferret_ext/brotli_enc_compress_fragment_two_pass.h +54 -0
  49. data/ext/isomorfeus_ferret_ext/brotli_enc_dictionary_hash.c +1846 -0
  50. data/ext/isomorfeus_ferret_ext/brotli_enc_dictionary_hash.h +25 -0
  51. data/ext/isomorfeus_ferret_ext/brotli_enc_encode.c +1927 -0
  52. data/ext/isomorfeus_ferret_ext/brotli_enc_encoder_dict.c +33 -0
  53. data/ext/isomorfeus_ferret_ext/brotli_enc_encoder_dict.h +43 -0
  54. data/ext/isomorfeus_ferret_ext/brotli_enc_entropy_encode.c +503 -0
  55. data/ext/isomorfeus_ferret_ext/brotli_enc_entropy_encode.h +122 -0
  56. data/ext/isomorfeus_ferret_ext/brotli_enc_entropy_encode_static.h +539 -0
  57. data/ext/isomorfeus_ferret_ext/brotli_enc_fast_log.c +105 -0
  58. data/ext/isomorfeus_ferret_ext/brotli_enc_fast_log.h +66 -0
  59. data/ext/isomorfeus_ferret_ext/brotli_enc_find_match_length.h +79 -0
  60. data/ext/isomorfeus_ferret_ext/brotli_enc_hash.h +488 -0
  61. data/ext/isomorfeus_ferret_ext/brotli_enc_hash_composite_inc.h +125 -0
  62. data/ext/isomorfeus_ferret_ext/brotli_enc_hash_forgetful_chain_inc.h +293 -0
  63. data/ext/isomorfeus_ferret_ext/brotli_enc_hash_longest_match64_inc.h +267 -0
  64. data/ext/isomorfeus_ferret_ext/brotli_enc_hash_longest_match_inc.h +262 -0
  65. data/ext/isomorfeus_ferret_ext/brotli_enc_hash_longest_match_quickly_inc.h +266 -0
  66. data/ext/isomorfeus_ferret_ext/brotli_enc_hash_rolling_inc.h +212 -0
  67. data/ext/isomorfeus_ferret_ext/brotli_enc_hash_to_binary_tree_inc.h +329 -0
  68. data/ext/isomorfeus_ferret_ext/brotli_enc_histogram.c +100 -0
  69. data/ext/isomorfeus_ferret_ext/brotli_enc_histogram.h +63 -0
  70. data/ext/isomorfeus_ferret_ext/brotli_enc_histogram_inc.h +51 -0
  71. data/ext/isomorfeus_ferret_ext/brotli_enc_literal_cost.c +175 -0
  72. data/ext/isomorfeus_ferret_ext/brotli_enc_literal_cost.h +30 -0
  73. data/ext/isomorfeus_ferret_ext/brotli_enc_memory.c +170 -0
  74. data/ext/isomorfeus_ferret_ext/brotli_enc_memory.h +114 -0
  75. data/ext/isomorfeus_ferret_ext/brotli_enc_metablock.c +663 -0
  76. data/ext/isomorfeus_ferret_ext/brotli_enc_metablock.h +105 -0
  77. data/ext/isomorfeus_ferret_ext/brotli_enc_metablock_inc.h +183 -0
  78. data/ext/isomorfeus_ferret_ext/brotli_enc_params.h +46 -0
  79. data/ext/isomorfeus_ferret_ext/brotli_enc_prefix.h +53 -0
  80. data/ext/isomorfeus_ferret_ext/brotli_enc_quality.h +165 -0
  81. data/ext/isomorfeus_ferret_ext/brotli_enc_ringbuffer.h +167 -0
  82. data/ext/isomorfeus_ferret_ext/brotli_enc_static_dict.c +486 -0
  83. data/ext/isomorfeus_ferret_ext/brotli_enc_static_dict.h +40 -0
  84. data/ext/isomorfeus_ferret_ext/brotli_enc_static_dict_lut.h +5864 -0
  85. data/ext/isomorfeus_ferret_ext/brotli_enc_utf8_util.c +85 -0
  86. data/ext/isomorfeus_ferret_ext/brotli_enc_utf8_util.h +32 -0
  87. data/ext/isomorfeus_ferret_ext/brotli_enc_write_bits.h +87 -0
  88. data/ext/isomorfeus_ferret_ext/brotli_encode.h +448 -0
  89. data/ext/isomorfeus_ferret_ext/brotli_port.h +288 -0
  90. data/ext/isomorfeus_ferret_ext/brotli_types.h +83 -0
  91. data/ext/isomorfeus_ferret_ext/frb_index.c +35 -4
  92. data/ext/isomorfeus_ferret_ext/frb_store.c +34 -5
  93. data/ext/isomorfeus_ferret_ext/frt_document.h +1 -0
  94. data/ext/isomorfeus_ferret_ext/frt_fs_store.c +1 -0
  95. data/ext/isomorfeus_ferret_ext/frt_index.c +174 -25
  96. data/ext/isomorfeus_ferret_ext/frt_index.h +6 -3
  97. data/ext/isomorfeus_ferret_ext/frt_posh.h +11 -19
  98. data/ext/isomorfeus_ferret_ext/frt_q_parser.c +1844 -1911
  99. data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +12 -15
  100. data/ext/isomorfeus_ferret_ext/frt_ram_store.c +1 -0
  101. data/ext/isomorfeus_ferret_ext/frt_scanner.c +1 -0
  102. data/ext/isomorfeus_ferret_ext/frt_scanner_mb.c +1 -0
  103. data/ext/isomorfeus_ferret_ext/frt_scanner_utf8.c +1 -0
  104. data/ext/isomorfeus_ferret_ext/frt_search.h +1 -1
  105. data/ext/isomorfeus_ferret_ext/libstemmer.c +14 -11
  106. data/ext/isomorfeus_ferret_ext/libstemmer.h +4 -9
  107. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_basque.c +1167 -0
  108. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_basque.h +6 -0
  109. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_catalan.c +1433 -0
  110. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_catalan.h +6 -0
  111. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_danish.c +120 -143
  112. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_danish.h +1 -2
  113. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_dutch.c +217 -237
  114. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_dutch.h +1 -1
  115. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_english.c +377 -432
  116. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_english.h +1 -1
  117. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_finnish.c +298 -342
  118. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_finnish.h +1 -2
  119. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_french.c +530 -524
  120. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_french.h +1 -1
  121. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_german.c +201 -214
  122. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_german.h +1 -1
  123. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_hungarian.c +1 -1
  124. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_indonesian.c +394 -0
  125. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_indonesian.h +6 -0
  126. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_irish.c +457 -0
  127. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_irish.h +6 -0
  128. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_italian.c +396 -439
  129. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_italian.h +1 -1
  130. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_norwegian.c +104 -128
  131. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_norwegian.h +1 -1
  132. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_porter.c +242 -273
  133. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_porter.h +1 -1
  134. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_portuguese.c +406 -461
  135. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_portuguese.h +1 -2
  136. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_spanish.c +405 -456
  137. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_spanish.h +1 -1
  138. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_swedish.c +108 -126
  139. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_swedish.h +1 -1
  140. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_hungarian.c +849 -0
  141. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_hungarian.h +6 -0
  142. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_romanian.c +373 -405
  143. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_romanian.h +1 -1
  144. data/ext/isomorfeus_ferret_ext/stem_KOI8_R_russian.c +288 -305
  145. data/ext/isomorfeus_ferret_ext/stem_KOI8_R_russian.h +1 -1
  146. data/ext/isomorfeus_ferret_ext/stem_UTF_8_arabic.c +1651 -0
  147. data/ext/isomorfeus_ferret_ext/stem_UTF_8_arabic.h +6 -0
  148. data/ext/isomorfeus_ferret_ext/stem_UTF_8_armenian.c +546 -0
  149. data/ext/isomorfeus_ferret_ext/stem_UTF_8_armenian.h +6 -0
  150. data/ext/isomorfeus_ferret_ext/stem_UTF_8_basque.c +1171 -0
  151. data/ext/isomorfeus_ferret_ext/stem_UTF_8_basque.h +6 -0
  152. data/ext/isomorfeus_ferret_ext/stem_UTF_8_catalan.c +1436 -0
  153. data/ext/isomorfeus_ferret_ext/stem_UTF_8_catalan.h +6 -0
  154. data/ext/isomorfeus_ferret_ext/stem_UTF_8_danish.c +121 -141
  155. data/ext/isomorfeus_ferret_ext/stem_UTF_8_danish.h +1 -1
  156. data/ext/isomorfeus_ferret_ext/stem_UTF_8_dutch.c +221 -241
  157. data/ext/isomorfeus_ferret_ext/stem_UTF_8_dutch.h +1 -1
  158. data/ext/isomorfeus_ferret_ext/stem_UTF_8_english.c +381 -431
  159. data/ext/isomorfeus_ferret_ext/stem_UTF_8_english.h +1 -1
  160. data/ext/isomorfeus_ferret_ext/stem_UTF_8_finnish.c +300 -345
  161. data/ext/isomorfeus_ferret_ext/stem_UTF_8_finnish.h +1 -1
  162. data/ext/isomorfeus_ferret_ext/stem_UTF_8_french.c +518 -511
  163. data/ext/isomorfeus_ferret_ext/stem_UTF_8_french.h +1 -1
  164. data/ext/isomorfeus_ferret_ext/stem_UTF_8_german.c +201 -209
  165. data/ext/isomorfeus_ferret_ext/stem_UTF_8_german.h +1 -1
  166. data/ext/isomorfeus_ferret_ext/stem_UTF_8_greek.c +3660 -0
  167. data/ext/isomorfeus_ferret_ext/stem_UTF_8_greek.h +6 -0
  168. data/ext/isomorfeus_ferret_ext/stem_UTF_8_hindi.c +309 -0
  169. data/ext/isomorfeus_ferret_ext/stem_UTF_8_hindi.h +6 -0
  170. data/ext/isomorfeus_ferret_ext/stem_UTF_8_hungarian.c +306 -671
  171. data/ext/isomorfeus_ferret_ext/stem_UTF_8_hungarian.h +1 -1
  172. data/ext/isomorfeus_ferret_ext/stem_UTF_8_indonesian.c +394 -0
  173. data/ext/isomorfeus_ferret_ext/stem_UTF_8_indonesian.h +6 -0
  174. data/ext/isomorfeus_ferret_ext/stem_UTF_8_irish.c +457 -0
  175. data/ext/isomorfeus_ferret_ext/stem_UTF_8_irish.h +6 -0
  176. data/ext/isomorfeus_ferret_ext/stem_UTF_8_italian.c +400 -442
  177. data/ext/isomorfeus_ferret_ext/stem_UTF_8_italian.h +1 -1
  178. data/ext/isomorfeus_ferret_ext/stem_UTF_8_lithuanian.c +824 -0
  179. data/ext/isomorfeus_ferret_ext/stem_UTF_8_lithuanian.h +6 -0
  180. data/ext/isomorfeus_ferret_ext/stem_UTF_8_nepali.c +408 -0
  181. data/ext/isomorfeus_ferret_ext/stem_UTF_8_nepali.h +6 -0
  182. data/ext/isomorfeus_ferret_ext/stem_UTF_8_norwegian.c +105 -127
  183. data/ext/isomorfeus_ferret_ext/stem_UTF_8_norwegian.h +1 -1
  184. data/ext/isomorfeus_ferret_ext/stem_UTF_8_porter.c +245 -276
  185. data/ext/isomorfeus_ferret_ext/stem_UTF_8_porter.h +1 -1
  186. data/ext/isomorfeus_ferret_ext/stem_UTF_8_portuguese.c +409 -464
  187. data/ext/isomorfeus_ferret_ext/stem_UTF_8_portuguese.h +1 -1
  188. data/ext/isomorfeus_ferret_ext/stem_UTF_8_romanian.c +376 -408
  189. data/ext/isomorfeus_ferret_ext/stem_UTF_8_romanian.h +1 -1
  190. data/ext/isomorfeus_ferret_ext/stem_UTF_8_russian.c +272 -287
  191. data/ext/isomorfeus_ferret_ext/stem_UTF_8_russian.h +1 -1
  192. data/ext/isomorfeus_ferret_ext/stem_UTF_8_serbian.c +6530 -0
  193. data/ext/isomorfeus_ferret_ext/stem_UTF_8_serbian.h +6 -0
  194. data/ext/isomorfeus_ferret_ext/stem_UTF_8_spanish.c +407 -458
  195. data/ext/isomorfeus_ferret_ext/stem_UTF_8_spanish.h +1 -1
  196. data/ext/isomorfeus_ferret_ext/stem_UTF_8_swedish.c +110 -125
  197. data/ext/isomorfeus_ferret_ext/stem_UTF_8_swedish.h +1 -1
  198. data/ext/isomorfeus_ferret_ext/stem_UTF_8_tamil.c +1865 -0
  199. data/ext/isomorfeus_ferret_ext/stem_UTF_8_tamil.h +6 -0
  200. data/ext/isomorfeus_ferret_ext/stem_UTF_8_turkish.c +698 -806
  201. data/ext/isomorfeus_ferret_ext/stem_UTF_8_turkish.h +1 -1
  202. data/ext/isomorfeus_ferret_ext/stem_UTF_8_yiddish.c +1220 -0
  203. data/ext/isomorfeus_ferret_ext/stem_UTF_8_yiddish.h +6 -0
  204. data/ext/isomorfeus_ferret_ext/stem_api.c +1 -9
  205. data/ext/isomorfeus_ferret_ext/stem_api.h +1 -3
  206. data/ext/isomorfeus_ferret_ext/stem_header.h +30 -26
  207. data/ext/isomorfeus_ferret_ext/stem_modules.h +113 -26
  208. data/ext/isomorfeus_ferret_ext/stem_modules.txt +18 -5
  209. data/ext/isomorfeus_ferret_ext/stem_utilities.c +167 -132
  210. data/ext/isomorfeus_ferret_ext/test.c +7 -1
  211. data/ext/isomorfeus_ferret_ext/test_fields.c +57 -45
  212. data/ext/isomorfeus_ferret_ext/test_index.c +4 -1
  213. data/ext/isomorfeus_ferret_ext/test_search.c +0 -1
  214. data/lib/isomorfeus/ferret/version.rb +1 -1
  215. metadata +125 -5
  216. data/ext/isomorfeus_ferret_ext/q_parser.y +0 -1366
@@ -0,0 +1,288 @@
1
+ /* Copyright 2016 Google Inc. All Rights Reserved.
2
+
3
+ Distributed under MIT license.
4
+ See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5
+ */
6
+
7
+ /* Macros for compiler / platform specific API declarations. */
8
+
9
+ #ifndef BROTLI_COMMON_PORT_H_
10
+ #define BROTLI_COMMON_PORT_H_
11
+
12
+ /* The following macros were borrowed from https://github.com/nemequ/hedley
13
+ * with permission of original author - Evan Nemerson <evan@nemerson.com> */
14
+
15
+ /* >>> >>> >>> hedley macros */
16
+
17
+ #define BROTLI_MAKE_VERSION(major, minor, revision) \
18
+ (((major) * 1000000) + ((minor) * 1000) + (revision))
19
+
20
+ #if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
21
+ #define BROTLI_GNUC_VERSION \
22
+ BROTLI_MAKE_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
23
+ #elif defined(__GNUC__)
24
+ #define BROTLI_GNUC_VERSION BROTLI_MAKE_VERSION(__GNUC__, __GNUC_MINOR__, 0)
25
+ #endif
26
+
27
+ #if defined(BROTLI_GNUC_VERSION)
28
+ #define BROTLI_GNUC_VERSION_CHECK(major, minor, patch) \
29
+ (BROTLI_GNUC_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
30
+ #else
31
+ #define BROTLI_GNUC_VERSION_CHECK(major, minor, patch) (0)
32
+ #endif
33
+
34
+ #if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000)
35
+ #define BROTLI_MSVC_VERSION \
36
+ BROTLI_MAKE_VERSION((_MSC_FULL_VER / 10000000), \
37
+ (_MSC_FULL_VER % 10000000) / 100000, \
38
+ (_MSC_FULL_VER % 100000) / 100)
39
+ #elif defined(_MSC_FULL_VER)
40
+ #define BROTLI_MSVC_VERSION \
41
+ BROTLI_MAKE_VERSION((_MSC_FULL_VER / 1000000), \
42
+ (_MSC_FULL_VER % 1000000) / 10000, \
43
+ (_MSC_FULL_VER % 10000) / 10)
44
+ #elif defined(_MSC_VER)
45
+ #define BROTLI_MSVC_VERSION \
46
+ BROTLI_MAKE_VERSION(_MSC_VER / 100, _MSC_VER % 100, 0)
47
+ #endif
48
+
49
+ #if !defined(_MSC_VER)
50
+ #define BROTLI_MSVC_VERSION_CHECK(major, minor, patch) (0)
51
+ #elif defined(_MSC_VER) && (_MSC_VER >= 1400)
52
+ #define BROTLI_MSVC_VERSION_CHECK(major, minor, patch) \
53
+ (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
54
+ #elif defined(_MSC_VER) && (_MSC_VER >= 1200)
55
+ #define BROTLI_MSVC_VERSION_CHECK(major, minor, patch) \
56
+ (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
57
+ #else
58
+ #define BROTLI_MSVC_VERSION_CHECK(major, minor, patch) \
59
+ (_MSC_VER >= ((major * 100) + (minor)))
60
+ #endif
61
+
62
+ #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE)
63
+ #define BROTLI_INTEL_VERSION \
64
+ BROTLI_MAKE_VERSION(__INTEL_COMPILER / 100, \
65
+ __INTEL_COMPILER % 100, \
66
+ __INTEL_COMPILER_UPDATE)
67
+ #elif defined(__INTEL_COMPILER)
68
+ #define BROTLI_INTEL_VERSION \
69
+ BROTLI_MAKE_VERSION(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
70
+ #endif
71
+
72
+ #if defined(BROTLI_INTEL_VERSION)
73
+ #define BROTLI_INTEL_VERSION_CHECK(major, minor, patch) \
74
+ (BROTLI_INTEL_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
75
+ #else
76
+ #define BROTLI_INTEL_VERSION_CHECK(major, minor, patch) (0)
77
+ #endif
78
+
79
+ #if defined(__PGI) && \
80
+ defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
81
+ #define BROTLI_PGI_VERSION \
82
+ BROTLI_MAKE_VERSION(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
83
+ #endif
84
+
85
+ #if defined(BROTLI_PGI_VERSION)
86
+ #define BROTLI_PGI_VERSION_CHECK(major, minor, patch) \
87
+ (BROTLI_PGI_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
88
+ #else
89
+ #define BROTLI_PGI_VERSION_CHECK(major, minor, patch) (0)
90
+ #endif
91
+
92
+ #if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
93
+ #define BROTLI_SUNPRO_VERSION \
94
+ BROTLI_MAKE_VERSION( \
95
+ (((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), \
96
+ (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), \
97
+ (__SUNPRO_C & 0xf) * 10)
98
+ #elif defined(__SUNPRO_C)
99
+ #define BROTLI_SUNPRO_VERSION \
100
+ BROTLI_MAKE_VERSION((__SUNPRO_C >> 8) & 0xf, \
101
+ (__SUNPRO_C >> 4) & 0xf, \
102
+ (__SUNPRO_C) & 0xf)
103
+ #elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
104
+ #define BROTLI_SUNPRO_VERSION \
105
+ BROTLI_MAKE_VERSION( \
106
+ (((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), \
107
+ (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), \
108
+ (__SUNPRO_CC & 0xf) * 10)
109
+ #elif defined(__SUNPRO_CC)
110
+ #define BROTLI_SUNPRO_VERSION \
111
+ BROTLI_MAKE_VERSION((__SUNPRO_CC >> 8) & 0xf, \
112
+ (__SUNPRO_CC >> 4) & 0xf, \
113
+ (__SUNPRO_CC) & 0xf)
114
+ #endif
115
+
116
+ #if defined(BROTLI_SUNPRO_VERSION)
117
+ #define BROTLI_SUNPRO_VERSION_CHECK(major, minor, patch) \
118
+ (BROTLI_SUNPRO_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
119
+ #else
120
+ #define BROTLI_SUNPRO_VERSION_CHECK(major, minor, patch) (0)
121
+ #endif
122
+
123
+ #if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
124
+ #define BROTLI_ARM_VERSION \
125
+ BROTLI_MAKE_VERSION((__ARMCOMPILER_VERSION / 1000000), \
126
+ (__ARMCOMPILER_VERSION % 1000000) / 10000, \
127
+ (__ARMCOMPILER_VERSION % 10000) / 100)
128
+ #elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
129
+ #define BROTLI_ARM_VERSION \
130
+ BROTLI_MAKE_VERSION((__ARMCC_VERSION / 1000000), \
131
+ (__ARMCC_VERSION % 1000000) / 10000, \
132
+ (__ARMCC_VERSION % 10000) / 100)
133
+ #endif
134
+
135
+ #if defined(BROTLI_ARM_VERSION)
136
+ #define BROTLI_ARM_VERSION_CHECK(major, minor, patch) \
137
+ (BROTLI_ARM_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
138
+ #else
139
+ #define BROTLI_ARM_VERSION_CHECK(major, minor, patch) (0)
140
+ #endif
141
+
142
+ #if defined(__ibmxl__)
143
+ #define BROTLI_IBM_VERSION \
144
+ BROTLI_MAKE_VERSION(__ibmxl_version__, \
145
+ __ibmxl_release__, \
146
+ __ibmxl_modification__)
147
+ #elif defined(__xlC__) && defined(__xlC_ver__)
148
+ #define BROTLI_IBM_VERSION \
149
+ BROTLI_MAKE_VERSION(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
150
+ #elif defined(__xlC__)
151
+ #define BROTLI_IBM_VERSION BROTLI_MAKE_VERSION(__xlC__ >> 8, __xlC__ & 0xff, 0)
152
+ #endif
153
+
154
+ #if defined(BROTLI_IBM_VERSION)
155
+ #define BROTLI_IBM_VERSION_CHECK(major, minor, patch) \
156
+ (BROTLI_IBM_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
157
+ #else
158
+ #define BROTLI_IBM_VERSION_CHECK(major, minor, patch) (0)
159
+ #endif
160
+
161
+ #if defined(__TI_COMPILER_VERSION__)
162
+ #define BROTLI_TI_VERSION \
163
+ BROTLI_MAKE_VERSION((__TI_COMPILER_VERSION__ / 1000000), \
164
+ (__TI_COMPILER_VERSION__ % 1000000) / 1000, \
165
+ (__TI_COMPILER_VERSION__ % 1000))
166
+ #endif
167
+
168
+ #if defined(BROTLI_TI_VERSION)
169
+ #define BROTLI_TI_VERSION_CHECK(major, minor, patch) \
170
+ (BROTLI_TI_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
171
+ #else
172
+ #define BROTLI_TI_VERSION_CHECK(major, minor, patch) (0)
173
+ #endif
174
+
175
+ #if defined(__IAR_SYSTEMS_ICC__)
176
+ #if __VER__ > 1000
177
+ #define BROTLI_IAR_VERSION \
178
+ BROTLI_MAKE_VERSION((__VER__ / 1000000), \
179
+ (__VER__ / 1000) % 1000, \
180
+ (__VER__ % 1000))
181
+ #else
182
+ #define BROTLI_IAR_VERSION BROTLI_MAKE_VERSION(VER / 100, __VER__ % 100, 0)
183
+ #endif
184
+ #endif
185
+
186
+ #if defined(BROTLI_IAR_VERSION)
187
+ #define BROTLI_IAR_VERSION_CHECK(major, minor, patch) \
188
+ (BROTLI_IAR_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
189
+ #else
190
+ #define BROTLI_IAR_VERSION_CHECK(major, minor, patch) (0)
191
+ #endif
192
+
193
+ #if defined(__TINYC__)
194
+ #define BROTLI_TINYC_VERSION \
195
+ BROTLI_MAKE_VERSION(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
196
+ #endif
197
+
198
+ #if defined(BROTLI_TINYC_VERSION)
199
+ #define BROTLI_TINYC_VERSION_CHECK(major, minor, patch) \
200
+ (BROTLI_TINYC_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
201
+ #else
202
+ #define BROTLI_TINYC_VERSION_CHECK(major, minor, patch) (0)
203
+ #endif
204
+
205
+ #if defined(__has_attribute)
206
+ #define BROTLI_GNUC_HAS_ATTRIBUTE(attribute, major, minor, patch) \
207
+ __has_attribute(attribute)
208
+ #else
209
+ #define BROTLI_GNUC_HAS_ATTRIBUTE(attribute, major, minor, patch) \
210
+ BROTLI_GNUC_VERSION_CHECK(major, minor, patch)
211
+ #endif
212
+
213
+ #if defined(__has_builtin)
214
+ #define BROTLI_GNUC_HAS_BUILTIN(builtin, major, minor, patch) \
215
+ __has_builtin(builtin)
216
+ #else
217
+ #define BROTLI_GNUC_HAS_BUILTIN(builtin, major, minor, patch) \
218
+ BROTLI_GNUC_VERSION_CHECK(major, minor, patch)
219
+ #endif
220
+
221
+ #if defined(__has_feature)
222
+ #define BROTLI_HAS_FEATURE(feature) __has_feature(feature)
223
+ #else
224
+ #define BROTLI_HAS_FEATURE(feature) (0)
225
+ #endif
226
+
227
+ #if defined(ADDRESS_SANITIZER) || BROTLI_HAS_FEATURE(address_sanitizer) || \
228
+ defined(THREAD_SANITIZER) || BROTLI_HAS_FEATURE(thread_sanitizer) || \
229
+ defined(MEMORY_SANITIZER) || BROTLI_HAS_FEATURE(memory_sanitizer)
230
+ #define BROTLI_SANITIZED 1
231
+ #else
232
+ #define BROTLI_SANITIZED 0
233
+ #endif
234
+
235
+ #if defined(_WIN32) || defined(__CYGWIN__)
236
+ #define BROTLI_PUBLIC
237
+ #elif BROTLI_GNUC_VERSION_CHECK(3, 3, 0) || \
238
+ BROTLI_TI_VERSION_CHECK(8, 0, 0) || \
239
+ BROTLI_INTEL_VERSION_CHECK(16, 0, 0) || \
240
+ BROTLI_ARM_VERSION_CHECK(4, 1, 0) || \
241
+ BROTLI_IBM_VERSION_CHECK(13, 1, 0) || \
242
+ BROTLI_SUNPRO_VERSION_CHECK(5, 11, 0) || \
243
+ (BROTLI_TI_VERSION_CHECK(7, 3, 0) && \
244
+ defined(__TI_GNU_ATTRIBUTE_SUPPORT__) && defined(__TI_EABI__))
245
+ #define BROTLI_PUBLIC __attribute__ ((visibility ("default")))
246
+ #else
247
+ #define BROTLI_PUBLIC
248
+ #endif
249
+
250
+ #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
251
+ !defined(__STDC_NO_VLA__) && !defined(__cplusplus) && \
252
+ !defined(__PGI) && !defined(__PGIC__) && !defined(__TINYC__)
253
+ #define BROTLI_ARRAY_PARAM(name) (name)
254
+ #else
255
+ #define BROTLI_ARRAY_PARAM(name)
256
+ #endif
257
+
258
+ /* <<< <<< <<< end of hedley macros. */
259
+
260
+ #if defined(BROTLI_SHARED_COMPILATION)
261
+ #if defined(_WIN32)
262
+ #if defined(BROTLICOMMON_SHARED_COMPILATION)
263
+ #define BROTLI_COMMON_API __declspec(dllexport)
264
+ #else
265
+ #define BROTLI_COMMON_API __declspec(dllimport)
266
+ #endif /* BROTLICOMMON_SHARED_COMPILATION */
267
+ #if defined(BROTLIDEC_SHARED_COMPILATION)
268
+ #define BROTLI_DEC_API __declspec(dllexport)
269
+ #else
270
+ #define BROTLI_DEC_API __declspec(dllimport)
271
+ #endif /* BROTLIDEC_SHARED_COMPILATION */
272
+ #if defined(BROTLIENC_SHARED_COMPILATION)
273
+ #define BROTLI_ENC_API __declspec(dllexport)
274
+ #else
275
+ #define BROTLI_ENC_API __declspec(dllimport)
276
+ #endif /* BROTLIENC_SHARED_COMPILATION */
277
+ #else /* _WIN32 */
278
+ #define BROTLI_COMMON_API BROTLI_PUBLIC
279
+ #define BROTLI_DEC_API BROTLI_PUBLIC
280
+ #define BROTLI_ENC_API BROTLI_PUBLIC
281
+ #endif /* _WIN32 */
282
+ #else /* BROTLI_SHARED_COMPILATION */
283
+ #define BROTLI_COMMON_API
284
+ #define BROTLI_DEC_API
285
+ #define BROTLI_ENC_API
286
+ #endif
287
+
288
+ #endif /* BROTLI_COMMON_PORT_H_ */
@@ -0,0 +1,83 @@
1
+ /* Copyright 2013 Google Inc. All Rights Reserved.
2
+
3
+ Distributed under MIT license.
4
+ See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5
+ */
6
+
7
+ /**
8
+ * @file
9
+ * Common types used in decoder and encoder API.
10
+ */
11
+
12
+ #ifndef BROTLI_COMMON_TYPES_H_
13
+ #define BROTLI_COMMON_TYPES_H_
14
+
15
+ #include <stddef.h> /* for size_t */
16
+
17
+ #if defined(_MSC_VER) && (_MSC_VER < 1600)
18
+ typedef __int8 int8_t;
19
+ typedef unsigned __int8 uint8_t;
20
+ typedef __int16 int16_t;
21
+ typedef unsigned __int16 uint16_t;
22
+ typedef __int32 int32_t;
23
+ typedef unsigned __int32 uint32_t;
24
+ typedef unsigned __int64 uint64_t;
25
+ typedef __int64 int64_t;
26
+ #else
27
+ #include <stdint.h>
28
+ #endif /* defined(_MSC_VER) && (_MSC_VER < 1600) */
29
+
30
+ /**
31
+ * A portable @c bool replacement.
32
+ *
33
+ * ::BROTLI_BOOL is a "documentation" type: actually it is @c int, but in API it
34
+ * denotes a type, whose only values are ::BROTLI_TRUE and ::BROTLI_FALSE.
35
+ *
36
+ * ::BROTLI_BOOL values passed to Brotli should either be ::BROTLI_TRUE or
37
+ * ::BROTLI_FALSE, or be a result of ::TO_BROTLI_BOOL macros.
38
+ *
39
+ * ::BROTLI_BOOL values returned by Brotli should not be tested for equality
40
+ * with @c true, @c false, ::BROTLI_TRUE, ::BROTLI_FALSE, but rather should be
41
+ * evaluated, for example: @code{.cpp}
42
+ * if (SomeBrotliFunction(encoder, BROTLI_TRUE) &&
43
+ * !OtherBrotliFunction(decoder, BROTLI_FALSE)) {
44
+ * bool x = !!YetAnotherBrotliFunction(encoder, TO_BROLTI_BOOL(2 * 2 == 4));
45
+ * DoSomething(x);
46
+ * }
47
+ * @endcode
48
+ */
49
+ #define BROTLI_BOOL int
50
+ /** Portable @c true replacement. */
51
+ #define BROTLI_TRUE 1
52
+ /** Portable @c false replacement. */
53
+ #define BROTLI_FALSE 0
54
+ /** @c bool to ::BROTLI_BOOL conversion macros. */
55
+ #define TO_BROTLI_BOOL(X) (!!(X) ? BROTLI_TRUE : BROTLI_FALSE)
56
+
57
+ #define BROTLI_MAKE_UINT64_T(high, low) ((((uint64_t)(high)) << 32) | low)
58
+
59
+ #define BROTLI_UINT32_MAX (~((uint32_t)0))
60
+ #define BROTLI_SIZE_MAX (~((size_t)0))
61
+
62
+ /**
63
+ * Allocating function pointer type.
64
+ *
65
+ * @param opaque custom memory manager handle provided by client
66
+ * @param size requested memory region size; can not be @c 0
67
+ * @returns @c 0 in the case of failure
68
+ * @returns a valid pointer to a memory region of at least @p size bytes
69
+ * long otherwise
70
+ */
71
+ typedef void* (*brotli_alloc_func)(void* opaque, size_t size);
72
+
73
+ /**
74
+ * Deallocating function pointer type.
75
+ *
76
+ * This function @b SHOULD do nothing if @p address is @c 0.
77
+ *
78
+ * @param opaque custom memory manager handle provided by client
79
+ * @param address memory region pointer returned by ::brotli_alloc_func, or @c 0
80
+ */
81
+ typedef void (*brotli_free_func)(void* opaque, void* address);
82
+
83
+ #endif /* BROTLI_COMMON_TYPES_H_ */
@@ -41,6 +41,9 @@ static VALUE sym_store;
41
41
  static VALUE sym_index;
42
42
  static VALUE sym_term_vector;
43
43
 
44
+ static VALUE sym_compress;
45
+ static VALUE sym_compressed;
46
+
44
47
  static VALUE sym_untokenized;
45
48
  static VALUE sym_omit_norms;
46
49
  static VALUE sym_untokenized_omit_norms;
@@ -95,11 +98,13 @@ frb_fi_get_params(VALUE roptions,
95
98
  *store = FRT_STORE_NO;
96
99
  } else if (v == sym_yes || v == sym_true || v == Qtrue) {
97
100
  *store = FRT_STORE_YES;
101
+ } else if (v == sym_compress || v == sym_compressed) {
102
+ *store = FRT_STORE_COMPRESS;
98
103
  } else if (v == Qnil) {
99
104
  /* leave as default */
100
105
  } else {
101
106
  rb_raise(rb_eArgError, ":%s isn't a valid argument for :store."
102
- " Please choose from [:yes, :no]",
107
+ " Please choose from [:yes, :no, :compressed]",
103
108
  rb_id2name(SYM2ID(v)));
104
109
  }
105
110
 
@@ -219,6 +224,19 @@ frb_fi_is_stored(VALUE self)
219
224
  return fi_is_stored(fi) ? Qtrue : Qfalse;
220
225
  }
221
226
 
227
+ /*
228
+ * call-seq:
229
+ * fi.compressed? -> bool
230
+ *
231
+ * Return true if the field is stored in the index in compressed format.
232
+ */
233
+ static VALUE
234
+ frb_fi_is_compressed(VALUE self)
235
+ {
236
+ FrtFieldInfo *fi = (FrtFieldInfo *)DATA_PTR(self);
237
+ return fi_is_compressed(fi) ? Qtrue : Qfalse;
238
+ }
239
+
222
240
  /*
223
241
  * call-seq:
224
242
  * fi.indexed? -> bool
@@ -2698,7 +2716,7 @@ frb_ir_version(VALUE self)
2698
2716
  * == Summary
2699
2717
  *
2700
2718
  * The FieldInfo class is the field descriptor for the index. It specifies
2701
- * whether a field should be indexed and
2719
+ * whether a field is compressed or not or whether it should be indexed and
2702
2720
  * tokenized. Every field has a name which must be a symbol. There are three
2703
2721
  * properties that you can set, +:store+, +:index+ and +:term_vector+. You
2704
2722
  * can also set the default +:boost+ for a field as well.
@@ -2708,8 +2726,8 @@ frb_ir_version(VALUE self)
2708
2726
  * === :store
2709
2727
  *
2710
2728
  * The +:store+ property allows you to specify how a field is stored. You can
2711
- * leave a field unstored (+:no+), store it in it's original format (+:yes+).
2712
- * By default the document
2729
+ * leave a field unstored (+:no+), store it in it's original format (+:yes+)
2730
+ * or store it in compressed format (+:compressed+). By default the document
2713
2731
  * is stored in its original format. If the field is large and it is stored
2714
2732
  * elsewhere where it is easily accessible you might want to leave it
2715
2733
  * unstored. This will keep the index size a lot smaller and make the
@@ -2751,6 +2769,9 @@ frb_ir_version(VALUE self)
2751
2769
  * | | want to highlight matches.
2752
2770
  * | | or print match excerpts a la
2753
2771
  * | | Google search.
2772
+ * | |
2773
+ * | :compressed | Store field in compressed
2774
+ * | | format.
2754
2775
  * -------------|-------------------------|------------------------------
2755
2776
  * :index | :no | Do not make this field
2756
2777
  * | | searchable.
@@ -2809,6 +2830,9 @@ frb_ir_version(VALUE self)
2809
2830
  *
2810
2831
  * fi = FieldInfo.new(:created_on, :index => :untokenized_omit_norms,
2811
2832
  * :term_vector => :no)
2833
+ *
2834
+ * fi = FieldInfo.new(:image, :store => :compressed, :index => :no,
2835
+ * :term_vector => :no)
2812
2836
  */
2813
2837
  static void
2814
2838
  Init_FieldInfo(void)
@@ -2817,6 +2841,9 @@ Init_FieldInfo(void)
2817
2841
  sym_index = ID2SYM(rb_intern("index"));
2818
2842
  sym_term_vector = ID2SYM(rb_intern("term_vector"));
2819
2843
 
2844
+ sym_compress = ID2SYM(rb_intern("compress"));
2845
+ sym_compressed = ID2SYM(rb_intern("compressed"));
2846
+
2820
2847
  sym_untokenized = ID2SYM(rb_intern("untokenized"));
2821
2848
  sym_omit_norms = ID2SYM(rb_intern("omit_norms"));
2822
2849
  sym_untokenized_omit_norms = ID2SYM(rb_intern("untokenized_omit_norms"));
@@ -2831,6 +2858,7 @@ Init_FieldInfo(void)
2831
2858
  rb_define_method(cFieldInfo, "initialize", frb_fi_init, -1);
2832
2859
  rb_define_method(cFieldInfo, "name", frb_fi_name, 0);
2833
2860
  rb_define_method(cFieldInfo, "stored?", frb_fi_is_stored, 0);
2861
+ rb_define_method(cFieldInfo, "compressed?", frb_fi_is_compressed, 0);
2834
2862
  rb_define_method(cFieldInfo, "indexed?", frb_fi_is_indexed, 0);
2835
2863
  rb_define_method(cFieldInfo, "tokenized?", frb_fi_is_tokenized, 0);
2836
2864
  rb_define_method(cFieldInfo, "omit_norms?", frb_fi_omit_norms, 0);
@@ -2869,6 +2897,9 @@ Init_FieldInfo(void)
2869
2897
  * field_infos.add_field(:created_on, :index => :untokenized_omit_norms,
2870
2898
  * :term_vector => :no)
2871
2899
  *
2900
+ * field_infos.add_field(:image, :store => :compressed, :index => :no,
2901
+ * :term_vector => :no)
2902
+ *
2872
2903
  * field_infos.create_index("/path/to/index")
2873
2904
  *
2874
2905
  * == Default Properties
@@ -1,5 +1,6 @@
1
1
  #include "frt_store.h"
2
2
  #include "isomorfeus_ferret.h"
3
+ #include <time.h>
3
4
 
4
5
  static ID id_ref_cnt;
5
6
  VALUE cLock;
@@ -70,13 +71,26 @@ frb_lock_obtain(int argc, VALUE *argv, VALUE self)
70
71
  int timeout = 1;
71
72
  FrtLock *lock;
72
73
  GET_LOCK(lock, self);
74
+ bool got_lock = false;
75
+ bool got_timeout = false;
76
+ time_t end_t;
73
77
 
74
78
  if (rb_scan_args(argc, argv, "01", &rtimeout) > 0) {
75
79
  timeout = FIX2INT(rtimeout);
76
80
  }
77
- /* TODO: use the lock timeout */
78
- (void)timeout;
79
- if (!lock->obtain(lock)) {
81
+ end_t = time(NULL) + timeout;
82
+ if (lock->obtain(lock)) {
83
+ got_lock = true;
84
+ }
85
+ while (!got_lock && !got_timeout) {
86
+ frt_micro_sleep(10000);
87
+ if (lock->obtain(lock)) {
88
+ got_lock = true;
89
+ } else if (time(NULL) >= end_t) {
90
+ got_timeout = true;
91
+ }
92
+ }
93
+ if (!got_lock) {
80
94
  rb_raise(cLockError, "could not obtain lock: #%s", lock->name);
81
95
  }
82
96
  return Qtrue;
@@ -103,11 +117,26 @@ frb_lock_while_locked(int argc, VALUE *argv, VALUE self)
103
117
  int timeout = 1;
104
118
  FrtLock *lock;
105
119
  GET_LOCK(lock, self);
120
+ bool got_lock = false;
121
+ bool got_timeout = false;
122
+ time_t end_t;
123
+
106
124
  if (rb_scan_args(argc, argv, "01", &rtimeout) > 0) {
107
125
  timeout = FIX2INT(rtimeout);
108
126
  }
109
- (void)timeout;
110
- if (!lock->obtain(lock)) {
127
+ end_t = time(NULL) + timeout;
128
+ if (lock->obtain(lock)) {
129
+ got_lock = true;
130
+ }
131
+ while (!got_lock && !got_timeout) {
132
+ frt_micro_sleep(10000);
133
+ if (lock->obtain(lock)) {
134
+ got_lock = true;
135
+ } else if (time(NULL) >= end_t) {
136
+ got_timeout = true;
137
+ }
138
+ }
139
+ if (!got_lock) {
111
140
  rb_raise(cLockError, "could not obtain lock: #%s", lock->name);
112
141
  }
113
142
  rb_yield(Qnil);
@@ -20,6 +20,7 @@ typedef struct FrtDocField
20
20
  char **data;
21
21
  float boost;
22
22
  bool destroy_data : 1;
23
+ bool is_compressed : 1;
23
24
  } FrtDocField;
24
25
 
25
26
  extern FrtDocField *frt_df_new(FrtSymbol name);
@@ -241,6 +241,7 @@ static off_t fs_length(FrtStore *store, const char *filename)
241
241
 
242
242
  static void fso_flush_i(FrtOutStream *os, const frt_uchar *src, int len)
243
243
  {
244
+ if (len == 0) { return; }
244
245
  if (len != write(os->file.fd, src, len)) {
245
246
  FRT_RAISE(FRT_IO_ERROR, "flushing src of length %d, <%s>", len,
246
247
  strerror(errno));