aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/attribute/reference_attribute.h1
-rw-r--r--searchlib/src/vespa/searchlib/common/i_gid_to_lid_mapper_factory.h1
-rw-r--r--searchlib/src/vespa/searchlib/test/mock_attribute_manager.h60
3 files changed, 62 insertions, 0 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/reference_attribute.h b/searchlib/src/vespa/searchlib/attribute/reference_attribute.h
index 1d7c53f83a1..ebff6c2bff6 100644
--- a/searchlib/src/vespa/searchlib/attribute/reference_attribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/reference_attribute.h
@@ -74,6 +74,7 @@ public:
void update(DocId doc, const GlobalId &gid);
const Reference *getReference(DocId doc);
void setGidToLidMapperFactory(std::shared_ptr<IGidToLidMapperFactory> gidToLidMapperFactory);
+ std::shared_ptr<IGidToLidMapperFactory> getGidToLidMapperFactory() const { return _gidToLidMapperFactory; }
DocId getReferencedLid(DocId doc) const;
void notifyGidToLidChange(const GlobalId &gid, DocId referencedLid);
};
diff --git a/searchlib/src/vespa/searchlib/common/i_gid_to_lid_mapper_factory.h b/searchlib/src/vespa/searchlib/common/i_gid_to_lid_mapper_factory.h
index fadd0b74020..5f57ada4486 100644
--- a/searchlib/src/vespa/searchlib/common/i_gid_to_lid_mapper_factory.h
+++ b/searchlib/src/vespa/searchlib/common/i_gid_to_lid_mapper_factory.h
@@ -12,6 +12,7 @@ class IGidToLidMapper;
class IGidToLidMapperFactory
{
public:
+ using SP = std::shared_ptr<IGidToLidMapperFactory>;
virtual ~IGidToLidMapperFactory() { }
virtual std::unique_ptr<IGidToLidMapper> getMapper() const = 0;
};
diff --git a/searchlib/src/vespa/searchlib/test/mock_attribute_manager.h b/searchlib/src/vespa/searchlib/test/mock_attribute_manager.h
new file mode 100644
index 00000000000..bd5e0b0b8d2
--- /dev/null
+++ b/searchlib/src/vespa/searchlib/test/mock_attribute_manager.h
@@ -0,0 +1,60 @@
+// Copyright 2017 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#pragma once
+
+#include <vespa/searchlib/attribute/attributecontext.h>
+#include <vespa/searchlib/attribute/attributeguard.h>
+#include <vespa/searchlib/attribute/attributevector.h>
+#include <vespa/searchlib/attribute/iattributemanager.h>
+
+namespace search {
+namespace attribute {
+namespace test {
+
+class MockAttributeManager : public search::IAttributeManager {
+protected:
+ using AttributeMap = std::map<string, AttributeVector::SP>;
+
+ AttributeMap _attributes;
+
+ AttributeVector::SP
+ findAttribute(const vespalib::string &name) const {
+ AttributeMap::const_iterator itr = _attributes.find(name);
+ if (itr != _attributes.end()) {
+ return itr->second;
+ }
+ return AttributeVector::SP();
+ }
+
+public:
+ MockAttributeManager() : _attributes() {}
+
+ virtual AttributeGuard::UP getAttribute(const vespalib::string &name) const override {
+ AttributeVector::SP attr = findAttribute(name);
+ return AttributeGuard::UP(new AttributeGuard(attr));
+ }
+
+ virtual AttributeGuard::UP getAttributeStableEnum(const vespalib::string &name) const override {
+ AttributeVector::SP attr = findAttribute(name);
+ return AttributeGuard::UP(new AttributeEnumGuard(attr));
+ }
+
+ virtual void getAttributeList(std::vector<AttributeGuard> &list) const override {
+ list.reserve(_attributes.size());
+ for (const auto &attr : _attributes) {
+ list.push_back(AttributeGuard(attr.second));
+ }
+ }
+
+ virtual IAttributeContext::UP createContext() const override {
+ return IAttributeContext::UP(new AttributeContext(*this));
+ }
+
+ void addAttribute(const vespalib::string &name, const AttributeVector::SP &attr) {
+ attr->addReservedDoc();
+ _attributes[name] = attr;
+ }
+};
+
+}
+}
+}