21
21
#include <fluent-bit/flb_mem.h>
22
22
#include <fluent-bit/flb_log.h>
23
23
#include <fluent-bit/flb_gzip.h>
24
+ #include <fluent-bit/flb_zstd.h>
24
25
#include <fluent-bit/flb_compression.h>
25
26
26
27
static size_t flb_decompression_context_get_read_buffer_offset (
@@ -131,7 +132,12 @@ void flb_decompression_context_destroy(struct flb_decompression_context *context
131
132
}
132
133
133
134
if (context -> inner_context != NULL ) {
134
- flb_gzip_decompression_context_destroy (context -> inner_context );
135
+ if (context -> algorithm == FLB_COMPRESSION_ALGORITHM_GZIP ) {
136
+ flb_gzip_decompression_context_destroy (context -> inner_context );
137
+ }
138
+ else if (context -> algorithm == FLB_COMPRESSION_ALGORITHM_ZSTD ) {
139
+ flb_zstd_decompression_context_destroy (context -> inner_context );
140
+ }
135
141
136
142
context -> inner_context = NULL ;
137
143
}
@@ -178,6 +184,9 @@ struct flb_decompression_context *flb_decompression_context_create(int algorithm
178
184
if (algorithm == FLB_COMPRESSION_ALGORITHM_GZIP ) {
179
185
context -> inner_context = flb_gzip_decompression_context_create ();
180
186
}
187
+ else if (algorithm == FLB_COMPRESSION_ALGORITHM_ZSTD ) {
188
+ context -> inner_context = flb_zstd_decompression_context_create ();
189
+ }
181
190
else {
182
191
flb_error ("invalid compression algorithm : %d" , algorithm );
183
192
@@ -199,7 +208,12 @@ struct flb_decompression_context *flb_decompression_context_create(int algorithm
199
208
context -> input_buffer_size = input_buffer_size ;
200
209
context -> read_buffer = context -> read_buffer ;
201
210
context -> algorithm = algorithm ;
202
- context -> state = FLB_DECOMPRESSOR_STATE_EXPECTING_HEADER ;
211
+ if (algorithm == FLB_COMPRESSION_ALGORITHM_GZIP ) {
212
+ context -> state = FLB_DECOMPRESSOR_STATE_EXPECTING_HEADER ;
213
+ }
214
+ else if (algorithm == FLB_COMPRESSION_ALGORITHM_ZSTD ) {
215
+ context -> state = FLB_DECOMPRESSOR_STATE_EXPECTING_BODY ;
216
+ }
203
217
204
218
return context ;
205
219
}
@@ -215,6 +229,12 @@ int flb_decompress(struct flb_decompression_context *context,
215
229
output_length );
216
230
217
231
}
232
+ else if (context -> algorithm == FLB_COMPRESSION_ALGORITHM_ZSTD ) {
233
+ return flb_zstd_decompressor_dispatch (context ,
234
+ output_buffer ,
235
+ output_length );
236
+
237
+ }
218
238
}
219
239
220
240
return FLB_DECOMPRESSOR_FAILURE ;
0 commit comments