aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/test/fakedata/bitencode64.h
blob: 851c4af103013f5e106dd520153f0341e07d0363 (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
39
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <vector>
#include <vespa/searchlib/bitcompression/compression.h>
#include <vespa/searchlib/util/comprfile.h>

namespace search::fakedata {

template <bool bigEndian>
class BitEncode64 : public bitcompression::EncodeContext64<bigEndian>
{
    search::ComprFileWriteContext _cbuf;

public:
    BitEncode64();
    ~BitEncode64() override;

    using EC = bitcompression::EncodeContext64<bigEndian>;

    void writeComprBuffer() {
        _cbuf.writeComprBuffer(true);
    }

    void writeComprBufferIfNeeded() {
        if (this->_valI >= this->_valE)
            _cbuf.writeComprBuffer(false);
    }

    std::pair<uint64_t *, size_t>
    grabComprBuffer(vespalib::alloc::Alloc & comprAlloc) {
        return _cbuf.grabComprBuffer(comprAlloc);
    }
};

extern template class BitEncode64<true>;
extern template class BitEncode64<false>;

}