blob: 99e39ff499837f8beb7b285d5eed2d9c5f824429 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/searchlib/index/indexbuilder.h>
#include <vespa/searchlib/common/tunefileinfo.h>
#include <limits>
#include <vector>
namespace search::common { class FileHeaderContext; }
namespace search::index { class IFieldLengthInspector; }
namespace search::diskindex {
class BitVectorCandidate;
/**
* Class used to build a disk index for the set of index fields specified in a schema.
*
* The resulting disk index consists of field indexes that are independent of each other.
*/
class IndexBuilder : public index::IndexBuilder {
public:
// Schema argument must live until IndexBuilder has been deleted.
IndexBuilder(const index::Schema &schema, vespalib::stringref prefix, uint32_t docIdLimit);
~IndexBuilder() override;
void startField(uint32_t fieldId) override;
void endField() override;
void startWord(vespalib::stringref word) override;
void endWord() override;
void add_document(const index::DocIdAndFeatures &features) override;
vespalib::string appendToPrefix(vespalib::stringref name) const;
void open(uint64_t numWordIds, const index::IFieldLengthInspector &field_length_inspector,
const TuneFileIndexing &tuneFileIndexing,
const common::FileHeaderContext &fileHandleContext);
void close();
private:
class FieldHandle;
const index::Schema &_schema;
std::vector<FieldHandle> _fields;
const vespalib::string _prefix;
vespalib::string _curWord;
const uint32_t _docIdLimit;
int32_t _curFieldId;
uint32_t _lowestOKFieldId;
uint32_t _curDocId;
bool _inWord;
static std::vector<IndexBuilder::FieldHandle> extractFields(const index::Schema &schema, IndexBuilder & builder);
static uint32_t noDocId() {
return std::numeric_limits<uint32_t>::max();
}
static uint64_t noWordNumHigh() {
return std::numeric_limits<uint64_t>::max();
}
FieldHandle & currentField();
};
}
|