aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/test/diskindex/threelevelcountbuffers.h
blob: 79fb31a69e48d3a78e660437256ac1947b03e78b (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/searchlib/bitcompression/countcompression.h>
#include <limits>

namespace search::diskindex {

class ThreeLevelCountWriteBuffers
{
public:
    using EC = search::bitcompression::PostingListCountFileEncodeContext;
    EC &_sse;
    EC &_spe;
    EC &_pe;
    ComprFileWriteContext _wcsse;
    ComprFileWriteContext _wcspe;
    ComprFileWriteContext _wcpe;

    uint32_t _ssHeaderLen; // Length of header for sparse sparse file (bytes)
    uint32_t _spHeaderLen; // Length of header for sparse page file (bytes)
    uint32_t _pHeaderLen;  // Length of header for page file (bytes)

    uint64_t _ssFileBitSize;
    uint64_t _spFileBitSize;
    uint64_t _pFileBitSize;

    ThreeLevelCountWriteBuffers(EC &sse, EC &spe, EC &pe);
    ~ThreeLevelCountWriteBuffers();

    void flush();

    // unit test method.  Just pads without writing proper header
    void startPad(uint32_t ssHeaderLen, uint32_t spHeaderLen, uint32_t pHeaderLen);
};


class ThreeLevelCountReadBuffers
{
public:
    using EC = search::bitcompression::PostingListCountFileEncodeContext;
    using DC = search::bitcompression::PostingListCountFileDecodeContext;
    DC &_ssd;
    DC &_spd;
    DC &_pd;
    ComprFileReadContext _rcssd;
    ComprFileReadContext _rcspd;
    ComprFileReadContext _rcpd;

    uint32_t _ssHeaderLen;
    uint32_t _spHeaderLen;
    uint32_t _pHeaderLen;

    uint64_t _ssFileBitSize;
    uint64_t _spFileBitSize;
    uint64_t _pFileBitSize;

    // Unit test usage constructor.
    ThreeLevelCountReadBuffers(DC &ssd, DC &spd, DC &pd, ThreeLevelCountWriteBuffers &wb);

    // Normal usage constructor
    ThreeLevelCountReadBuffers(DC &ssd, DC &spd, DC &pd);
    ~ThreeLevelCountReadBuffers();
};

}