blob: 7330f4376ea22f14904548c2f5e43e000a78cb7a (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/searchlib/index/schema_index_fields.h>
#include <memory>
#include <vector>
namespace document {
class DataType;
class Document;
class DocumentType;
class Field;
class FieldValue;
}
namespace vespalib { class ISequencedTaskExecutor; }
namespace search::memoryindex {
class IFieldIndexCollection;
/*
* Class containing shared context for document inverters that changes
* rarely (type dependent data, wiring).
*/
class DocumentInverterContext {
using IndexedFields = std::vector<std::unique_ptr<document::Field>>;
const index::Schema& _schema;
IndexedFields _indexed_fields;
const document::DataType* _data_type;
index::SchemaIndexFields _schema_index_fields;
vespalib::ISequencedTaskExecutor& _invert_threads;
vespalib::ISequencedTaskExecutor& _push_threads;
IFieldIndexCollection& _field_indexes;
void add_field(const document::DocumentType& doc_type, uint32_t fieldId);
void build_fields(const document::DocumentType& doc_type, const document::DataType* data_type);
public:
DocumentInverterContext(const index::Schema &schema,
vespalib::ISequencedTaskExecutor &invert_threads,
vespalib::ISequencedTaskExecutor &push_threads,
IFieldIndexCollection& field_indexes);
~DocumentInverterContext();
void set_data_type(const document::Document& doc);
const index::Schema& get_schema() const noexcept { return _schema; }
const index::SchemaIndexFields& get_schema_index_fields() const noexcept { return _schema_index_fields; }
vespalib::ISequencedTaskExecutor& get_invert_threads() noexcept { return _invert_threads; }
vespalib::ISequencedTaskExecutor& get_push_threads() noexcept { return _push_threads; }
IFieldIndexCollection& get_field_indexes() noexcept { return _field_indexes; }
std::unique_ptr<document::FieldValue> get_field_value(const document::Document& doc, uint32_t field_id) const;
};
}
|