blob: 6abf912c0970ceae8de95762a5c41ba96053ba04 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "document_db_reference.h"
#include "gid_to_lid_mapper_factory.h"
#include "gid_to_lid_change_registrator.h"
#include <vespa/searchcore/proton/documentmetastore/documentmetastore.h>
#include <vespa/searchlib/attribute/attributeguard.h>
#include <vespa/searchlib/attribute/imported_attribute_vector.h>
#include <vespa/searchcore/proton/attribute/i_attribute_manager.h>
#include <vespa/searchcore/proton/attribute/imported_attributes_repo.h>
namespace proton {
DocumentDBReference::DocumentDBReference(std::shared_ptr<IAttributeManager> attrMgr,
std::shared_ptr<const search::IDocumentMetaStoreContext> dmsContext,
std::shared_ptr<IGidToLidChangeHandler> gidToLidChangeHandler)
: _attrMgr(std::move(attrMgr)),
_dmsContext(std::move(dmsContext)),
_gidToLidChangeHandler(std::move(gidToLidChangeHandler))
{
}
DocumentDBReference::~DocumentDBReference()
{
}
std::shared_ptr<search::attribute::ReadableAttributeVector>
DocumentDBReference::getAttribute(vespalib::stringref name)
{
search::AttributeGuard::UP guard = _attrMgr->getAttribute(name);
if (guard && guard->valid()) {
return guard->getSP();
} else {
auto importedAttributesRepo = _attrMgr->getImportedAttributes();
if (importedAttributesRepo != nullptr) {
return importedAttributesRepo->get(name);
}
return std::shared_ptr<search::attribute::ReadableAttributeVector>();
}
}
std::shared_ptr<const search::IDocumentMetaStoreContext>
DocumentDBReference::getDocumentMetaStore() const
{
return _dmsContext;
}
std::shared_ptr<search::IGidToLidMapperFactory>
DocumentDBReference::getGidToLidMapperFactory()
{
return std::make_shared<GidToLidMapperFactory>(_dmsContext);
}
std::unique_ptr<GidToLidChangeRegistrator>
DocumentDBReference::makeGidToLidChangeRegistrator(const vespalib::string &docTypeName)
{
return std::make_unique<GidToLidChangeRegistrator>(_gidToLidChangeHandler, docTypeName);
}
} // namespace proton
|