blob: 7d316c084c505b72461d34a3c93e1138df8d113d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "input.h"
#include <vector>
struct LZ4F_dctx_s;
namespace vespalib {
/**
* Input filter decompressing data stored in framed lz4 format.
**/
class Lz4InputDecoder : public Input
{
private:
Input &_input;
std::vector<char> _buffer;
size_t _used;
size_t _pos;
bool _eof;
bool _failed;
vespalib::string _reason;
LZ4F_dctx_s *_ctx;
void fail(const char *reason);
void decode_more();
public:
Lz4InputDecoder(Input &input, size_t buffer_size);
~Lz4InputDecoder();
Memory obtain() override;
Input &evict(size_t bytes) override;
bool failed() const { return _failed; }
const vespalib::string &reason() const { return _reason; }
};
} // namespace vespalib
|