isomorfeus-ferret 0.12.7 → 0.13.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +101 -19
  3. data/README.md +85 -13
  4. data/ext/isomorfeus_ferret_ext/bm_bitvector.c +22 -30
  5. data/ext/isomorfeus_ferret_ext/bm_hash.c +6 -12
  6. data/ext/isomorfeus_ferret_ext/bm_micro_string.c +3 -6
  7. data/ext/isomorfeus_ferret_ext/bm_store.c +11 -22
  8. data/ext/isomorfeus_ferret_ext/brotli_common_dictionary.c +1 -1
  9. data/ext/isomorfeus_ferret_ext/brotli_dec_decode.c +1 -1
  10. data/ext/isomorfeus_ferret_ext/bzlib.c +1572 -0
  11. data/ext/isomorfeus_ferret_ext/bzlib.h +282 -0
  12. data/ext/isomorfeus_ferret_ext/bzlib_blocksort.c +1094 -0
  13. data/ext/isomorfeus_ferret_ext/bzlib_compress.c +672 -0
  14. data/ext/isomorfeus_ferret_ext/bzlib_crctable.c +104 -0
  15. data/ext/isomorfeus_ferret_ext/bzlib_decompress.c +652 -0
  16. data/ext/isomorfeus_ferret_ext/bzlib_huffman.c +205 -0
  17. data/ext/isomorfeus_ferret_ext/bzlib_private.h +509 -0
  18. data/ext/isomorfeus_ferret_ext/bzlib_randtable.c +84 -0
  19. data/ext/isomorfeus_ferret_ext/fio_tmpfile.h +53 -53
  20. data/ext/isomorfeus_ferret_ext/frb_analysis.c +785 -1192
  21. data/ext/isomorfeus_ferret_ext/frb_index.c +497 -495
  22. data/ext/isomorfeus_ferret_ext/frb_qparser.c +48 -60
  23. data/ext/isomorfeus_ferret_ext/frb_search.c +1520 -1002
  24. data/ext/isomorfeus_ferret_ext/frb_store.c +96 -96
  25. data/ext/isomorfeus_ferret_ext/frb_threading.h +0 -1
  26. data/ext/isomorfeus_ferret_ext/frb_utils.c +147 -196
  27. data/ext/isomorfeus_ferret_ext/frt_analysis.c +695 -1090
  28. data/ext/isomorfeus_ferret_ext/frt_analysis.h +174 -170
  29. data/ext/isomorfeus_ferret_ext/frt_array.c +2 -4
  30. data/ext/isomorfeus_ferret_ext/frt_bitvector.c +9 -16
  31. data/ext/isomorfeus_ferret_ext/frt_bitvector.h +32 -81
  32. data/ext/isomorfeus_ferret_ext/frt_document.c +15 -20
  33. data/ext/isomorfeus_ferret_ext/frt_document.h +10 -10
  34. data/ext/isomorfeus_ferret_ext/frt_except.c +5 -12
  35. data/ext/isomorfeus_ferret_ext/frt_field_index.c +3 -3
  36. data/ext/isomorfeus_ferret_ext/frt_field_index.h +6 -7
  37. data/ext/isomorfeus_ferret_ext/frt_filter.c +35 -46
  38. data/ext/isomorfeus_ferret_ext/frt_fs_store.c +1 -0
  39. data/ext/isomorfeus_ferret_ext/frt_global.c +91 -200
  40. data/ext/isomorfeus_ferret_ext/frt_global.h +7 -18
  41. data/ext/isomorfeus_ferret_ext/frt_hash.c +1 -2
  42. data/ext/isomorfeus_ferret_ext/frt_ind.c +32 -35
  43. data/ext/isomorfeus_ferret_ext/frt_ind.h +9 -9
  44. data/ext/isomorfeus_ferret_ext/frt_index.c +603 -410
  45. data/ext/isomorfeus_ferret_ext/frt_index.h +272 -291
  46. data/ext/isomorfeus_ferret_ext/frt_lang.c +0 -2
  47. data/ext/isomorfeus_ferret_ext/frt_mempool.c +1 -2
  48. data/ext/isomorfeus_ferret_ext/frt_multimapper.c +4 -7
  49. data/ext/isomorfeus_ferret_ext/frt_q_boolean.c +68 -91
  50. data/ext/isomorfeus_ferret_ext/frt_q_const_score.c +35 -38
  51. data/ext/isomorfeus_ferret_ext/frt_q_filtered_query.c +53 -72
  52. data/ext/isomorfeus_ferret_ext/frt_q_fuzzy.c +25 -32
  53. data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +21 -23
  54. data/ext/isomorfeus_ferret_ext/frt_q_multi_term.c +66 -103
  55. data/ext/isomorfeus_ferret_ext/frt_q_parser.c +207 -195
  56. data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +20 -16
  57. data/ext/isomorfeus_ferret_ext/frt_q_prefix.c +17 -14
  58. data/ext/isomorfeus_ferret_ext/frt_q_range.c +102 -131
  59. data/ext/isomorfeus_ferret_ext/frt_q_span.c +179 -178
  60. data/ext/isomorfeus_ferret_ext/frt_q_term.c +47 -60
  61. data/ext/isomorfeus_ferret_ext/frt_q_wildcard.c +18 -16
  62. data/ext/isomorfeus_ferret_ext/frt_ram_store.c +45 -84
  63. data/ext/isomorfeus_ferret_ext/frt_search.c +105 -146
  64. data/ext/isomorfeus_ferret_ext/frt_search.h +331 -320
  65. data/ext/isomorfeus_ferret_ext/frt_similarity.c +5 -13
  66. data/ext/isomorfeus_ferret_ext/frt_similarity.h +7 -12
  67. data/ext/isomorfeus_ferret_ext/frt_sort.c +105 -149
  68. data/ext/isomorfeus_ferret_ext/frt_store.c +13 -7
  69. data/ext/isomorfeus_ferret_ext/frt_store.h +10 -2
  70. data/ext/isomorfeus_ferret_ext/frt_threading.h +0 -1
  71. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +22 -112
  72. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.h +2 -32
  73. data/ext/isomorfeus_ferret_ext/lz4.c +2495 -0
  74. data/ext/isomorfeus_ferret_ext/lz4.h +774 -0
  75. data/ext/isomorfeus_ferret_ext/lz4frame.c +1899 -0
  76. data/ext/isomorfeus_ferret_ext/lz4frame.h +623 -0
  77. data/ext/isomorfeus_ferret_ext/lz4hc.c +1615 -0
  78. data/ext/isomorfeus_ferret_ext/lz4hc.h +413 -0
  79. data/ext/isomorfeus_ferret_ext/lz4xxhash.c +1030 -0
  80. data/ext/isomorfeus_ferret_ext/lz4xxhash.h +328 -0
  81. data/ext/isomorfeus_ferret_ext/stem_modules.h +0 -86
  82. data/ext/isomorfeus_ferret_ext/test.c +0 -17
  83. data/ext/isomorfeus_ferret_ext/test_1710.c +11 -12
  84. data/ext/isomorfeus_ferret_ext/test_analysis.c +590 -583
  85. data/ext/isomorfeus_ferret_ext/test_compound_io.c +1 -1
  86. data/ext/isomorfeus_ferret_ext/test_document.c +19 -15
  87. data/ext/isomorfeus_ferret_ext/test_except.c +1 -2
  88. data/ext/isomorfeus_ferret_ext/test_fields.c +59 -60
  89. data/ext/isomorfeus_ferret_ext/test_file_deleter.c +10 -27
  90. data/ext/isomorfeus_ferret_ext/test_filter.c +11 -8
  91. data/ext/isomorfeus_ferret_ext/test_global.c +0 -46
  92. data/ext/isomorfeus_ferret_ext/test_hash.c +2 -2
  93. data/ext/isomorfeus_ferret_ext/test_hashset.c +1 -1
  94. data/ext/isomorfeus_ferret_ext/test_highlighter.c +15 -11
  95. data/ext/isomorfeus_ferret_ext/test_index.c +372 -365
  96. data/ext/isomorfeus_ferret_ext/test_q_const_score.c +5 -3
  97. data/ext/isomorfeus_ferret_ext/test_q_filtered.c +5 -3
  98. data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +13 -10
  99. data/ext/isomorfeus_ferret_ext/test_q_parser.c +45 -7
  100. data/ext/isomorfeus_ferret_ext/test_q_span.c +15 -12
  101. data/ext/isomorfeus_ferret_ext/test_ram_store.c +3 -3
  102. data/ext/isomorfeus_ferret_ext/test_search.c +60 -64
  103. data/ext/isomorfeus_ferret_ext/test_segments.c +5 -4
  104. data/ext/isomorfeus_ferret_ext/test_sort.c +17 -14
  105. data/ext/isomorfeus_ferret_ext/test_store.c +2 -0
  106. data/ext/isomorfeus_ferret_ext/test_term.c +3 -1
  107. data/ext/isomorfeus_ferret_ext/test_term_vectors.c +9 -10
  108. data/ext/isomorfeus_ferret_ext/test_test.c +1 -2
  109. data/ext/isomorfeus_ferret_ext/test_threading.c +9 -10
  110. data/ext/isomorfeus_ferret_ext/testhelper.c +1 -2
  111. data/lib/isomorfeus/ferret/version.rb +1 -1
  112. metadata +27 -57
  113. data/ext/isomorfeus_ferret_ext/email.rl +0 -21
  114. data/ext/isomorfeus_ferret_ext/frt_scanner.c +0 -900
  115. data/ext/isomorfeus_ferret_ext/frt_scanner.h +0 -28
  116. data/ext/isomorfeus_ferret_ext/frt_scanner_mb.c +0 -6706
  117. data/ext/isomorfeus_ferret_ext/frt_scanner_utf8.c +0 -4420
  118. data/ext/isomorfeus_ferret_ext/scanner.h +0 -28
  119. data/ext/isomorfeus_ferret_ext/scanner.in +0 -43
  120. data/ext/isomorfeus_ferret_ext/scanner.rl +0 -84
  121. data/ext/isomorfeus_ferret_ext/scanner_mb.rl +0 -200
  122. data/ext/isomorfeus_ferret_ext/scanner_utf8.rl +0 -85
  123. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_basque.c +0 -1167
  124. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_basque.h +0 -6
  125. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_catalan.c +0 -1433
  126. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_catalan.h +0 -6
  127. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_danish.c +0 -301
  128. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_danish.h +0 -6
  129. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_dutch.c +0 -590
  130. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_dutch.h +0 -6
  131. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_english.c +0 -1049
  132. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_english.h +0 -6
  133. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_finnish.c +0 -705
  134. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_finnish.h +0 -6
  135. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_french.c +0 -1239
  136. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_french.h +0 -6
  137. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_german.c +0 -477
  138. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_german.h +0 -6
  139. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_hungarian.c +0 -1217
  140. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_hungarian.h +0 -7
  141. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_indonesian.c +0 -394
  142. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_indonesian.h +0 -6
  143. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_irish.c +0 -457
  144. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_irish.h +0 -6
  145. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_italian.c +0 -1009
  146. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_italian.h +0 -6
  147. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_norwegian.c +0 -259
  148. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_norwegian.h +0 -6
  149. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_porter.c +0 -704
  150. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_porter.h +0 -6
  151. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_portuguese.c +0 -948
  152. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_portuguese.h +0 -6
  153. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_spanish.c +0 -1028
  154. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_spanish.h +0 -6
  155. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_swedish.c +0 -275
  156. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_swedish.h +0 -6
  157. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_hungarian.c +0 -849
  158. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_hungarian.h +0 -6
  159. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_romanian.c +0 -952
  160. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_romanian.h +0 -6
  161. data/ext/isomorfeus_ferret_ext/stem_KOI8_R_russian.c +0 -669
  162. data/ext/isomorfeus_ferret_ext/stem_KOI8_R_russian.h +0 -6
  163. data/ext/isomorfeus_ferret_ext/stem_modules.txt +0 -63
  164. data/ext/isomorfeus_ferret_ext/uchar-ucs4.rl +0 -1854
  165. data/ext/isomorfeus_ferret_ext/uchar-utf8.rl +0 -1999
  166. data/ext/isomorfeus_ferret_ext/url.rl +0 -27
@@ -0,0 +1,413 @@
1
+ /*
2
+ LZ4 HC - High Compression Mode of LZ4
3
+ Header File
4
+ Copyright (C) 2011-2017, Yann Collet.
5
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
6
+
7
+ Redistribution and use in source and binary forms, with or without
8
+ modification, are permitted provided that the following conditions are
9
+ met:
10
+
11
+ * Redistributions of source code must retain the above copyright
12
+ notice, this list of conditions and the following disclaimer.
13
+ * Redistributions in binary form must reproduce the above
14
+ copyright notice, this list of conditions and the following disclaimer
15
+ in the documentation and/or other materials provided with the
16
+ distribution.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ You can contact the author at :
31
+ - LZ4 source repository : https://github.com/lz4/lz4
32
+ - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c
33
+ */
34
+ #ifndef LZ4_HC_H_19834876238432
35
+ #define LZ4_HC_H_19834876238432
36
+
37
+ #if defined (__cplusplus)
38
+ extern "C" {
39
+ #endif
40
+
41
+ /* --- Dependency --- */
42
+ /* note : lz4hc requires lz4.h/lz4.c for compilation */
43
+ #include "lz4.h" /* stddef, LZ4LIB_API, LZ4_DEPRECATED */
44
+
45
+
46
+ /* --- Useful constants --- */
47
+ #define LZ4HC_CLEVEL_MIN 3
48
+ #define LZ4HC_CLEVEL_DEFAULT 9
49
+ #define LZ4HC_CLEVEL_OPT_MIN 10
50
+ #define LZ4HC_CLEVEL_MAX 12
51
+
52
+
53
+ /*-************************************
54
+ * Block Compression
55
+ **************************************/
56
+ /*! LZ4_compress_HC() :
57
+ * Compress data from `src` into `dst`, using the powerful but slower "HC" algorithm.
58
+ * `dst` must be already allocated.
59
+ * Compression is guaranteed to succeed if `dstCapacity >= LZ4_compressBound(srcSize)` (see "lz4.h")
60
+ * Max supported `srcSize` value is LZ4_MAX_INPUT_SIZE (see "lz4.h")
61
+ * `compressionLevel` : any value between 1 and LZ4HC_CLEVEL_MAX will work.
62
+ * Values > LZ4HC_CLEVEL_MAX behave the same as LZ4HC_CLEVEL_MAX.
63
+ * @return : the number of bytes written into 'dst'
64
+ * or 0 if compression fails.
65
+ */
66
+ LZ4LIB_API int LZ4_compress_HC (const char* src, char* dst, int srcSize, int dstCapacity, int compressionLevel);
67
+
68
+
69
+ /* Note :
70
+ * Decompression functions are provided within "lz4.h" (BSD license)
71
+ */
72
+
73
+
74
+ /*! LZ4_compress_HC_extStateHC() :
75
+ * Same as LZ4_compress_HC(), but using an externally allocated memory segment for `state`.
76
+ * `state` size is provided by LZ4_sizeofStateHC().
77
+ * Memory segment must be aligned on 8-bytes boundaries (which a normal malloc() should do properly).
78
+ */
79
+ LZ4LIB_API int LZ4_sizeofStateHC(void);
80
+ LZ4LIB_API int LZ4_compress_HC_extStateHC(void* stateHC, const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel);
81
+
82
+
83
+ /*! LZ4_compress_HC_destSize() : v1.9.0+
84
+ * Will compress as much data as possible from `src`
85
+ * to fit into `targetDstSize` budget.
86
+ * Result is provided in 2 parts :
87
+ * @return : the number of bytes written into 'dst' (necessarily <= targetDstSize)
88
+ * or 0 if compression fails.
89
+ * `srcSizePtr` : on success, *srcSizePtr is updated to indicate how much bytes were read from `src`
90
+ */
91
+ LZ4LIB_API int LZ4_compress_HC_destSize(void* stateHC,
92
+ const char* src, char* dst,
93
+ int* srcSizePtr, int targetDstSize,
94
+ int compressionLevel);
95
+
96
+
97
+ /*-************************************
98
+ * Streaming Compression
99
+ * Bufferless synchronous API
100
+ **************************************/
101
+ typedef union LZ4_streamHC_u LZ4_streamHC_t; /* incomplete type (defined later) */
102
+
103
+ /*! LZ4_createStreamHC() and LZ4_freeStreamHC() :
104
+ * These functions create and release memory for LZ4 HC streaming state.
105
+ * Newly created states are automatically initialized.
106
+ * A same state can be used multiple times consecutively,
107
+ * starting with LZ4_resetStreamHC_fast() to start a new stream of blocks.
108
+ */
109
+ LZ4LIB_API LZ4_streamHC_t* LZ4_createStreamHC(void);
110
+ LZ4LIB_API int LZ4_freeStreamHC (LZ4_streamHC_t* streamHCPtr);
111
+
112
+ /*
113
+ These functions compress data in successive blocks of any size,
114
+ using previous blocks as dictionary, to improve compression ratio.
115
+ One key assumption is that previous blocks (up to 64 KB) remain read-accessible while compressing next blocks.
116
+ There is an exception for ring buffers, which can be smaller than 64 KB.
117
+ Ring-buffer scenario is automatically detected and handled within LZ4_compress_HC_continue().
118
+
119
+ Before starting compression, state must be allocated and properly initialized.
120
+ LZ4_createStreamHC() does both, though compression level is set to LZ4HC_CLEVEL_DEFAULT.
121
+
122
+ Selecting the compression level can be done with LZ4_resetStreamHC_fast() (starts a new stream)
123
+ or LZ4_setCompressionLevel() (anytime, between blocks in the same stream) (experimental).
124
+ LZ4_resetStreamHC_fast() only works on states which have been properly initialized at least once,
125
+ which is automatically the case when state is created using LZ4_createStreamHC().
126
+
127
+ After reset, a first "fictional block" can be designated as initial dictionary,
128
+ using LZ4_loadDictHC() (Optional).
129
+
130
+ Invoke LZ4_compress_HC_continue() to compress each successive block.
131
+ The number of blocks is unlimited.
132
+ Previous input blocks, including initial dictionary when present,
133
+ must remain accessible and unmodified during compression.
134
+
135
+ It's allowed to update compression level anytime between blocks,
136
+ using LZ4_setCompressionLevel() (experimental).
137
+
138
+ 'dst' buffer should be sized to handle worst case scenarios
139
+ (see LZ4_compressBound(), it ensures compression success).
140
+ In case of failure, the API does not guarantee recovery,
141
+ so the state _must_ be reset.
142
+ To ensure compression success
143
+ whenever `dst` buffer size cannot be made >= LZ4_compressBound(),
144
+ consider using LZ4_compress_HC_continue_destSize().
145
+
146
+ Whenever previous input blocks can't be preserved unmodified in-place during compression of next blocks,
147
+ it's possible to copy the last blocks into a more stable memory space, using LZ4_saveDictHC().
148
+ Return value of LZ4_saveDictHC() is the size of dictionary effectively saved into 'safeBuffer' (<= 64 KB)
149
+
150
+ After completing a streaming compression,
151
+ it's possible to start a new stream of blocks, using the same LZ4_streamHC_t state,
152
+ just by resetting it, using LZ4_resetStreamHC_fast().
153
+ */
154
+
155
+ LZ4LIB_API void LZ4_resetStreamHC_fast(LZ4_streamHC_t* streamHCPtr, int compressionLevel); /* v1.9.0+ */
156
+ LZ4LIB_API int LZ4_loadDictHC (LZ4_streamHC_t* streamHCPtr, const char* dictionary, int dictSize);
157
+
158
+ LZ4LIB_API int LZ4_compress_HC_continue (LZ4_streamHC_t* streamHCPtr,
159
+ const char* src, char* dst,
160
+ int srcSize, int maxDstSize);
161
+
162
+ /*! LZ4_compress_HC_continue_destSize() : v1.9.0+
163
+ * Similar to LZ4_compress_HC_continue(),
164
+ * but will read as much data as possible from `src`
165
+ * to fit into `targetDstSize` budget.
166
+ * Result is provided into 2 parts :
167
+ * @return : the number of bytes written into 'dst' (necessarily <= targetDstSize)
168
+ * or 0 if compression fails.
169
+ * `srcSizePtr` : on success, *srcSizePtr will be updated to indicate how much bytes were read from `src`.
170
+ * Note that this function may not consume the entire input.
171
+ */
172
+ LZ4LIB_API int LZ4_compress_HC_continue_destSize(LZ4_streamHC_t* LZ4_streamHCPtr,
173
+ const char* src, char* dst,
174
+ int* srcSizePtr, int targetDstSize);
175
+
176
+ LZ4LIB_API int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, int maxDictSize);
177
+
178
+
179
+
180
+ /*^**********************************************
181
+ * !!!!!! STATIC LINKING ONLY !!!!!!
182
+ ***********************************************/
183
+
184
+ /*-******************************************************************
185
+ * PRIVATE DEFINITIONS :
186
+ * Do not use these definitions directly.
187
+ * They are merely exposed to allow static allocation of `LZ4_streamHC_t`.
188
+ * Declare an `LZ4_streamHC_t` directly, rather than any type below.
189
+ * Even then, only do so in the context of static linking, as definitions may change between versions.
190
+ ********************************************************************/
191
+
192
+ #define LZ4HC_DICTIONARY_LOGSIZE 16
193
+ #define LZ4HC_MAXD (1<<LZ4HC_DICTIONARY_LOGSIZE)
194
+ #define LZ4HC_MAXD_MASK (LZ4HC_MAXD - 1)
195
+
196
+ #define LZ4HC_HASH_LOG 15
197
+ #define LZ4HC_HASHTABLESIZE (1 << LZ4HC_HASH_LOG)
198
+ #define LZ4HC_HASH_MASK (LZ4HC_HASHTABLESIZE - 1)
199
+
200
+
201
+ typedef struct LZ4HC_CCtx_internal LZ4HC_CCtx_internal;
202
+ struct LZ4HC_CCtx_internal
203
+ {
204
+ LZ4_u32 hashTable[LZ4HC_HASHTABLESIZE];
205
+ LZ4_u16 chainTable[LZ4HC_MAXD];
206
+ const LZ4_byte* end; /* next block here to continue on current prefix */
207
+ const LZ4_byte* base; /* All index relative to this position */
208
+ const LZ4_byte* dictBase; /* alternate base for extDict */
209
+ LZ4_u32 dictLimit; /* below that point, need extDict */
210
+ LZ4_u32 lowLimit; /* below that point, no more dict */
211
+ LZ4_u32 nextToUpdate; /* index from which to continue dictionary update */
212
+ short compressionLevel;
213
+ LZ4_i8 favorDecSpeed; /* favor decompression speed if this flag set,
214
+ otherwise, favor compression ratio */
215
+ LZ4_i8 dirty; /* stream has to be fully reset if this flag is set */
216
+ const LZ4HC_CCtx_internal* dictCtx;
217
+ };
218
+
219
+
220
+ /* Do not use these definitions directly !
221
+ * Declare or allocate an LZ4_streamHC_t instead.
222
+ */
223
+ #define LZ4_STREAMHCSIZE 262200 /* static size, for inter-version compatibility */
224
+ #define LZ4_STREAMHCSIZE_VOIDP (LZ4_STREAMHCSIZE / sizeof(void*))
225
+ union LZ4_streamHC_u {
226
+ void* table[LZ4_STREAMHCSIZE_VOIDP];
227
+ LZ4HC_CCtx_internal internal_donotuse;
228
+ }; /* previously typedef'd to LZ4_streamHC_t */
229
+
230
+ /* LZ4_streamHC_t :
231
+ * This structure allows static allocation of LZ4 HC streaming state.
232
+ * This can be used to allocate statically, on state, or as part of a larger structure.
233
+ *
234
+ * Such state **must** be initialized using LZ4_initStreamHC() before first use.
235
+ *
236
+ * Note that invoking LZ4_initStreamHC() is not required when
237
+ * the state was created using LZ4_createStreamHC() (which is recommended).
238
+ * Using the normal builder, a newly created state is automatically initialized.
239
+ *
240
+ * Static allocation shall only be used in combination with static linking.
241
+ */
242
+
243
+ /* LZ4_initStreamHC() : v1.9.0+
244
+ * Required before first use of a statically allocated LZ4_streamHC_t.
245
+ * Before v1.9.0 : use LZ4_resetStreamHC() instead
246
+ */
247
+ LZ4LIB_API LZ4_streamHC_t* LZ4_initStreamHC (void* buffer, size_t size);
248
+
249
+
250
+ /*-************************************
251
+ * Deprecated Functions
252
+ **************************************/
253
+ /* see lz4.h LZ4_DISABLE_DEPRECATE_WARNINGS to turn off deprecation warnings */
254
+
255
+ /* deprecated compression functions */
256
+ LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC (const char* source, char* dest, int inputSize);
257
+ LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize);
258
+ LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC2 (const char* source, char* dest, int inputSize, int compressionLevel);
259
+ LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC2_limitedOutput(const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
260
+ LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC_withStateHC (void* state, const char* source, char* dest, int inputSize);
261
+ LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC_limitedOutput_withStateHC (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
262
+ LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC2_withStateHC (void* state, const char* source, char* dest, int inputSize, int compressionLevel);
263
+ LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC2_limitedOutput_withStateHC(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
264
+ LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize);
265
+ LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC_limitedOutput_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize, int maxOutputSize);
266
+
267
+ /* Obsolete streaming functions; degraded functionality; do not use!
268
+ *
269
+ * In order to perform streaming compression, these functions depended on data
270
+ * that is no longer tracked in the state. They have been preserved as well as
271
+ * possible: using them will still produce a correct output. However, use of
272
+ * LZ4_slideInputBufferHC() will truncate the history of the stream, rather
273
+ * than preserve a window-sized chunk of history.
274
+ */
275
+ LZ4_DEPRECATED("use LZ4_createStreamHC() instead") LZ4LIB_API void* LZ4_createHC (const char* inputBuffer);
276
+ LZ4_DEPRECATED("use LZ4_saveDictHC() instead") LZ4LIB_API char* LZ4_slideInputBufferHC (void* LZ4HC_Data);
277
+ LZ4_DEPRECATED("use LZ4_freeStreamHC() instead") LZ4LIB_API int LZ4_freeHC (void* LZ4HC_Data);
278
+ LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC2_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel);
279
+ LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC2_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
280
+ LZ4_DEPRECATED("use LZ4_createStreamHC() instead") LZ4LIB_API int LZ4_sizeofStreamStateHC(void);
281
+ LZ4_DEPRECATED("use LZ4_initStreamHC() instead") LZ4LIB_API int LZ4_resetStreamStateHC(void* state, char* inputBuffer);
282
+
283
+
284
+ /* LZ4_resetStreamHC() is now replaced by LZ4_initStreamHC().
285
+ * The intention is to emphasize the difference with LZ4_resetStreamHC_fast(),
286
+ * which is now the recommended function to start a new stream of blocks,
287
+ * but cannot be used to initialize a memory segment containing arbitrary garbage data.
288
+ *
289
+ * It is recommended to switch to LZ4_initStreamHC().
290
+ * LZ4_resetStreamHC() will generate deprecation warnings in a future version.
291
+ */
292
+ LZ4LIB_API void LZ4_resetStreamHC (LZ4_streamHC_t* streamHCPtr, int compressionLevel);
293
+
294
+
295
+ #if defined (__cplusplus)
296
+ }
297
+ #endif
298
+
299
+ #endif /* LZ4_HC_H_19834876238432 */
300
+
301
+
302
+ /*-**************************************************
303
+ * !!!!! STATIC LINKING ONLY !!!!!
304
+ * Following definitions are considered experimental.
305
+ * They should not be linked from DLL,
306
+ * as there is no guarantee of API stability yet.
307
+ * Prototypes will be promoted to "stable" status
308
+ * after successfull usage in real-life scenarios.
309
+ ***************************************************/
310
+ #ifdef LZ4_HC_STATIC_LINKING_ONLY /* protection macro */
311
+ #ifndef LZ4_HC_SLO_098092834
312
+ #define LZ4_HC_SLO_098092834
313
+
314
+ #define LZ4_STATIC_LINKING_ONLY /* LZ4LIB_STATIC_API */
315
+ #include "lz4.h"
316
+
317
+ #if defined (__cplusplus)
318
+ extern "C" {
319
+ #endif
320
+
321
+ /*! LZ4_setCompressionLevel() : v1.8.0+ (experimental)
322
+ * It's possible to change compression level
323
+ * between successive invocations of LZ4_compress_HC_continue*()
324
+ * for dynamic adaptation.
325
+ */
326
+ LZ4LIB_STATIC_API void LZ4_setCompressionLevel(
327
+ LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel);
328
+
329
+ /*! LZ4_favorDecompressionSpeed() : v1.8.2+ (experimental)
330
+ * Opt. Parser will favor decompression speed over compression ratio.
331
+ * Only applicable to levels >= LZ4HC_CLEVEL_OPT_MIN.
332
+ */
333
+ LZ4LIB_STATIC_API void LZ4_favorDecompressionSpeed(
334
+ LZ4_streamHC_t* LZ4_streamHCPtr, int favor);
335
+
336
+ /*! LZ4_resetStreamHC_fast() : v1.9.0+
337
+ * When an LZ4_streamHC_t is known to be in a internally coherent state,
338
+ * it can often be prepared for a new compression with almost no work, only
339
+ * sometimes falling back to the full, expensive reset that is always required
340
+ * when the stream is in an indeterminate state (i.e., the reset performed by
341
+ * LZ4_resetStreamHC()).
342
+ *
343
+ * LZ4_streamHCs are guaranteed to be in a valid state when:
344
+ * - returned from LZ4_createStreamHC()
345
+ * - reset by LZ4_resetStreamHC()
346
+ * - memset(stream, 0, sizeof(LZ4_streamHC_t))
347
+ * - the stream was in a valid state and was reset by LZ4_resetStreamHC_fast()
348
+ * - the stream was in a valid state and was then used in any compression call
349
+ * that returned success
350
+ * - the stream was in an indeterminate state and was used in a compression
351
+ * call that fully reset the state (LZ4_compress_HC_extStateHC()) and that
352
+ * returned success
353
+ *
354
+ * Note:
355
+ * A stream that was last used in a compression call that returned an error
356
+ * may be passed to this function. However, it will be fully reset, which will
357
+ * clear any existing history and settings from the context.
358
+ */
359
+ LZ4LIB_STATIC_API void LZ4_resetStreamHC_fast(
360
+ LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel);
361
+
362
+ /*! LZ4_compress_HC_extStateHC_fastReset() :
363
+ * A variant of LZ4_compress_HC_extStateHC().
364
+ *
365
+ * Using this variant avoids an expensive initialization step. It is only safe
366
+ * to call if the state buffer is known to be correctly initialized already
367
+ * (see above comment on LZ4_resetStreamHC_fast() for a definition of
368
+ * "correctly initialized"). From a high level, the difference is that this
369
+ * function initializes the provided state with a call to
370
+ * LZ4_resetStreamHC_fast() while LZ4_compress_HC_extStateHC() starts with a
371
+ * call to LZ4_resetStreamHC().
372
+ */
373
+ LZ4LIB_STATIC_API int LZ4_compress_HC_extStateHC_fastReset (
374
+ void* state,
375
+ const char* src, char* dst,
376
+ int srcSize, int dstCapacity,
377
+ int compressionLevel);
378
+
379
+ /*! LZ4_attach_HC_dictionary() :
380
+ * This is an experimental API that allows for the efficient use of a
381
+ * static dictionary many times.
382
+ *
383
+ * Rather than re-loading the dictionary buffer into a working context before
384
+ * each compression, or copying a pre-loaded dictionary's LZ4_streamHC_t into a
385
+ * working LZ4_streamHC_t, this function introduces a no-copy setup mechanism,
386
+ * in which the working stream references the dictionary stream in-place.
387
+ *
388
+ * Several assumptions are made about the state of the dictionary stream.
389
+ * Currently, only streams which have been prepared by LZ4_loadDictHC() should
390
+ * be expected to work.
391
+ *
392
+ * Alternatively, the provided dictionary stream pointer may be NULL, in which
393
+ * case any existing dictionary stream is unset.
394
+ *
395
+ * A dictionary should only be attached to a stream without any history (i.e.,
396
+ * a stream that has just been reset).
397
+ *
398
+ * The dictionary will remain attached to the working stream only for the
399
+ * current stream session. Calls to LZ4_resetStreamHC(_fast) will remove the
400
+ * dictionary context association from the working stream. The dictionary
401
+ * stream (and source buffer) must remain in-place / accessible / unchanged
402
+ * through the lifetime of the stream session.
403
+ */
404
+ LZ4LIB_STATIC_API void LZ4_attach_HC_dictionary(
405
+ LZ4_streamHC_t *working_stream,
406
+ const LZ4_streamHC_t *dictionary_stream);
407
+
408
+ #if defined (__cplusplus)
409
+ }
410
+ #endif
411
+
412
+ #endif /* LZ4_HC_SLO_098092834 */
413
+ #endif /* LZ4_HC_STATIC_LINKING_ONLY */