summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@broadpark.no>2017-09-06 16:43:01 +0200
committerGitHub <noreply@github.com>2017-09-06 16:43:01 +0200
commitf0727265fb2a36c1664beca309a7c9aa83dc41ac (patch)
treea1381da7b97b483e925045c483f5f35b4f9a0912 /searchlib
parent6904c661f29763762c84f672bca812b3339f912e (diff)
Revert "Use gid to lid change handler interface directly"
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.cpp42
-rw-r--r--searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.h15
2 files changed, 57 insertions, 0 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.cpp b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.cpp
index 036f482b2e8..270f4d51788 100644
--- a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.cpp
@@ -147,5 +147,47 @@ long ImportedAttributeVector::onSerializeForDescendingSort(DocId doc,
_reference_attribute->getReferencedLid(doc), serTo, available, bc);
}
+namespace {
+
+class ImportedAttributeGuard : public AttributeGuard {
+public:
+ ImportedAttributeGuard(const AttributeVectorSP& target_attr,
+ const AttributeVectorSP& reference_attr)
+ : AttributeGuard(),
+ _target_attr_guard(target_attr),
+ _reference_attr_guard(reference_attr)
+ {
+ }
+
+private:
+ AttributeGuard _target_attr_guard;
+ AttributeGuard _reference_attr_guard;
+};
+
+class ImportedAttributeEnumGuard : public AttributeEnumGuard {
+public:
+ ImportedAttributeEnumGuard(const AttributeVectorSP& target_attr,
+ const AttributeVectorSP& reference_attr)
+ : AttributeEnumGuard(AttributeVectorSP()),
+ _target_attr_enum_guard(target_attr),
+ _reference_attr_guard(reference_attr)
+ {
+ }
+
+private:
+ AttributeEnumGuard _target_attr_enum_guard;
+ AttributeGuard _reference_attr_guard;
+};
+
+}
+
+std::unique_ptr<AttributeGuard> ImportedAttributeVector::acquireGuard() const {
+ return std::make_unique<ImportedAttributeGuard>(_target_attribute, _reference_attribute);
+}
+
+std::unique_ptr<AttributeEnumGuard> ImportedAttributeVector::acquireEnumGuard() const {
+ return std::make_unique<ImportedAttributeEnumGuard>(_target_attribute, _reference_attribute);
+}
+
}
}
diff --git a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.h b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.h
index bddd0fa9093..686818c1093 100644
--- a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.h
+++ b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.h
@@ -66,6 +66,21 @@ public:
return _target_attribute;
}
+ /**
+ * Acquire an opaque composite guard that covers both the target attribute and
+ * the reference attribute. Note that these are not directly accessible via the
+ * returned guard object itself; it does not expose a valid pointer (i.e. get() will
+ * return nullptr).
+ */
+ std::unique_ptr<AttributeGuard> acquireGuard() const;
+ /**
+ * Acquires a composite guard similar to acquireGuard(), but the target attribute is
+ * covered by an AttributeEnumGuard instead of a regular AttributeGuard.
+ *
+ * The reference attribute is _not_ covered by an enum guard.
+ */
+ std::unique_ptr<AttributeEnumGuard> acquireEnumGuard() const;
+
/*
* Create an imported attribute with a snapshot of lid to lid mapping.
*/