From f0727265fb2a36c1664beca309a7c9aa83dc41ac Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Wed, 6 Sep 2017 16:43:01 +0200 Subject: Revert "Use gid to lid change handler interface directly" --- .../attribute/imported_attribute_vector.cpp | 42 ++++++++++++++++++++++ .../attribute/imported_attribute_vector.h | 15 ++++++++ 2 files changed, 57 insertions(+) (limited to 'searchlib') 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 ImportedAttributeVector::acquireGuard() const { + return std::make_unique(_target_attribute, _reference_attribute); +} + +std::unique_ptr ImportedAttributeVector::acquireEnumGuard() const { + return std::make_unique(_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 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 acquireEnumGuard() const; + /* * Create an imported attribute with a snapshot of lid to lid mapping. */ -- cgit v1.2.3