blob: 6c8535f8563e99c7bc95e28762b40b6c29442e26 (
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "postinglisthandle.h"
#include "postinglistcountfile.h"
#include <vespa/searchlib/common/tunefileinfo.h>
#include <limits>
class FastOS_FileInterface;
namespace search::common { class FileHeaderContext; }
namespace search::index {
/**
* Interface for dictionary file containing words and counts for words.
*/
class DictionaryFileSeqRead : public PostingListCountFileSeqRead {
public:
DictionaryFileSeqRead() { }
~DictionaryFileSeqRead();
/**
* Read word and counts. Only nonzero counts are returned. If at
* end of dictionary then noWordNumHigh() is returned as word number.
*/
virtual void readWord(vespalib::string &word, uint64_t &wordNum, PostingListCounts &counts) = 0;
static uint64_t noWordNum() { return 0u; }
static uint64_t noWordNumHigh() {
return std::numeric_limits<uint64_t>::max();
}
};
/**
* Interface for dictionary file containing words and count for words.
*/
class DictionaryFileSeqWrite : public PostingListCountFileSeqWrite {
public:
DictionaryFileSeqWrite() { }
~DictionaryFileSeqWrite();
/**
* Write word and counts. Only nonzero counts should be supplied.
*/
virtual void writeWord(vespalib::stringref word, const PostingListCounts &counts) = 0;
};
/**
* Interface for dictionary file containing words and counts.
*/
class DictionaryFileRandRead {
protected:
// Can be examined after open
bool _memoryMapped;
public:
DictionaryFileRandRead();
virtual ~DictionaryFileRandRead();
virtual bool lookup(vespalib::stringref word, uint64_t &wordNum,
PostingListOffsetAndCounts &offsetAndCounts) = 0;
/**
* Open dictionary file for random read.
*/
virtual bool open(const vespalib::string &name, const TuneFileRandRead &tuneFileRead) = 0;
/**
* Close dictionary file.
*/
virtual bool close() = 0;
bool getMemoryMapped() const { return _memoryMapped; }
virtual uint64_t getNumWordIds() const = 0;
protected:
void afterOpen(FastOS_FileInterface &file);
};
}
|