aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/diskindex/pagedict4randread.h
blob: 051efa486ddf3e7c5441d09d21b4a5eb5d475cd7 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/searchlib/index/dictionaryfile.h>
#include <vespa/searchlib/bitcompression/compression.h>
#include <vespa/searchlib/bitcompression/countcompression.h>
#include <vespa/searchlib/bitcompression/pagedict4.h>

namespace search::diskindex {

class PageDict4RandRead : public index::DictionaryFileRandRead
{
    using DC = bitcompression::PostingListCountFileDecodeContext;
    using SSReader = bitcompression::PageDict4SSReader;

    using SSLookupRes = bitcompression::PageDict4SSLookupRes;
    using SPLookupRes = bitcompression::PageDict4SPLookupRes;
    using PLookupRes = bitcompression::PageDict4PLookupRes;
    using PageDict4PageParams = bitcompression::PageDict4PageParams;

    using PostingListCounts = index::PostingListCounts;
    using PostingListOffsetAndCounts = index::PostingListOffsetAndCounts;

    std::unique_ptr<SSReader> _ssReader;

    DC _ssd;
    ComprFileReadContext _ssReadContext;
    std::unique_ptr<FastOS_FileInterface> _ssfile;
    std::unique_ptr<FastOS_FileInterface> _spfile;
    std::unique_ptr<FastOS_FileInterface> _pfile;

    uint64_t _ssFileBitSize;
    uint64_t _spFileBitSize;
    uint64_t _pFileBitSize;
    uint32_t _ssHeaderLen;
    uint32_t _spHeaderLen;
    uint32_t _pHeaderLen;

    void readSSHeader();
    void readSPHeader();
    void readPHeader();
public:
    PageDict4RandRead();
    ~PageDict4RandRead();

    bool lookup(vespalib::stringref word, uint64_t &wordNum,
                PostingListOffsetAndCounts &offsetAndCounts) override;

    bool open(const vespalib::string &name, const TuneFileRandRead &tuneFileRead) override;

    bool close() override;
    uint64_t getNumWordIds() const override;
};

}