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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "fast_access_doc_subdb_configurer.h"
#include "storeonlydocsubdb.h"
#include <vespa/searchcore/proton/attribute/attributemanager.h>
#include <vespa/searchcore/proton/common/docid_limit.h>
#include <vespa/searchcore/proton/metrics/attribute_metrics.h>
#include <vespa/searchcore/proton/metrics/metricswireservice.h>
namespace search::attribute { class Interlock; }
namespace proton {
/**
* The fast-access sub database keeps fast-access attribute fields in memory
* in addition to the underlying document store managed by the parent class.
*
* Partial updates and document selection on one of these attribute fields will be
* fast compared to only using the document store.
* This class is used as base class for the searchable sub database and directly by
* the "2.notready" sub database for handling not-ready documents.
* When used by the "2.notready" sub database attributes that are added without any files
* on disk will be populated based on the content of the document store upon initialization
* of the sub database.
*/
class FastAccessDocSubDB : public StoreOnlyDocSubDB
{
public:
struct Config
{
const StoreOnlyDocSubDB::Config _storeOnlyCfg;
const bool _hasAttributes;
const bool _addMetrics;
const bool _fastAccessAttributesOnly;
Config(const StoreOnlyDocSubDB::Config &storeOnlyCfg,
bool hasAttributes,
bool addMetrics,
bool fastAccessAttributesOnly)
: _storeOnlyCfg(storeOnlyCfg),
_hasAttributes(hasAttributes),
_addMetrics(addMetrics),
_fastAccessAttributesOnly(fastAccessAttributesOnly)
{ }
};
struct Context
{
const StoreOnlyDocSubDB::Context _storeOnlyCtx;
AttributeMetrics &_subAttributeMetrics;
MetricsWireService &_metricsWireService;
std::shared_ptr<search::attribute::Interlock> _attribute_interlock;
Context(const StoreOnlyDocSubDB::Context &storeOnlyCtx,
AttributeMetrics &subAttributeMetrics,
MetricsWireService &metricsWireService,
std::shared_ptr<search::attribute::Interlock> attribute_interlock)
: _storeOnlyCtx(storeOnlyCtx),
_subAttributeMetrics(subAttributeMetrics),
_metricsWireService(metricsWireService),
_attribute_interlock(std::move(attribute_interlock))
{ }
~Context();
};
private:
using AttributesConfig = vespa::config::search::AttributesConfig;
using Configurer = FastAccessDocSubDBConfigurer;
const bool _hasAttributes;
const bool _fastAccessAttributesOnly;
AttributeManager::SP _initAttrMgr;
Configurer::FeedViewVarHolder _fastAccessFeedView;
Configurer _configurer;
AttributeMetrics &_subAttributeMetrics;
std::shared_ptr<initializer::InitializerTask>
createAttributeManagerInitializer(const DocumentDBConfig &configSnapshot,
SerialNum configSerialNum,
std::shared_ptr<initializer::InitializerTask> documentMetaStoreInitTask,
DocumentMetaStore::SP documentMetaStore,
std::shared_ptr<AttributeManager::SP> attrMgrResult) const;
void setupAttributeManager(AttributeManager::SP attrMgrResult);
void initFeedView(IAttributeWriter::SP writer, const DocumentDBConfig &configSnapshot);
protected:
using Parent = StoreOnlyDocSubDB;
const bool _addMetrics;
MetricsWireService &_metricsWireService;
std::shared_ptr<search::attribute::Interlock> _attribute_interlock;
DocIdLimit _docIdLimit;
std::unique_ptr<AttributeCollectionSpec> createAttributeSpec(const AttributesConfig &attrCfg, const AllocStrategy& alloc_strategy, std::optional<SerialNum> serialNum) const;
AttributeManager::SP getAndResetInitAttributeManager();
virtual IFlushTargetList getFlushTargetsInternal() override;
void reconfigureAttributeMetrics(const IAttributeManager &newMgr, const IAttributeManager &oldMgr);
IReprocessingTask::UP createReprocessingTask(IReprocessingInitializer &initializer,
const std::shared_ptr<const document::DocumentTypeRepo> &docTypeRepo) const;
public:
FastAccessDocSubDB(const Config &cfg, const Context &ctx);
~FastAccessDocSubDB();
std::unique_ptr<DocumentSubDbInitializer>
createInitializer(const DocumentDBConfig &configSnapshot, SerialNum configSerialNum,
const IndexConfig &indexCfg) const override;
void setup(const DocumentSubDbInitializerResult &initResult) override;
void initViews(const DocumentDBConfig &configSnapshot) override;
std::unique_ptr<const DocumentSubDBReconfig>
prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params) override;
IReprocessingTask::List
applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot,
SerialNum serialNum, const ReconfigParams ¶ms, IDocumentDBReferenceResolver &resolver, const DocumentSubDBReconfig& prepared_reconfig) override;
proton::IAttributeManager::SP getAttributeManager() const override;
IDocumentRetriever::UP getDocumentRetriever() override;
void onReplayDone() override;
void onReprocessDone(SerialNum serialNum) override;
SerialNum getOldestFlushedSerial() override;
SerialNum getNewestFlushedSerial() override;
virtual void pruneRemovedFields(SerialNum serialNum) override;
TransientResourceUsage get_transient_resource_usage() const override;
};
} // namespace proton
|