aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorGeir Storli <geirst@oath.com>2017-09-06 07:48:21 +0000
committerGeir Storli <geirst@oath.com>2017-09-06 15:45:25 +0000
commitf77fff6223051fe8238eb5f9160348e422fe76f0 (patch)
treeaa11461beccc20606584a7dd712efd96bec30c55 /searchlib
parent2b98bb212c745205d37666b3fdb9ad18243cb8fd (diff)
Instantiate bit vector search cache in imported attribute vectors if visibility delay > 0.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.cpp22
-rw-r--r--searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.h19
-rw-r--r--searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.cpp3
-rw-r--r--searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.h3
-rw-r--r--searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h2
5 files changed, 39 insertions, 10 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..0ec65f60d41 100644
--- a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.cpp
@@ -3,7 +3,7 @@
#include "imported_attribute_vector.h"
#include "imported_attribute_vector_read_guard.h"
#include "imported_search_context.h"
-#include "attributeguard.h"
+#include "bitvector_search_cache.h"
#include <vespa/searchlib/query/queryterm.h>
#include <vespa/vespalib/util/exceptions.h>
@@ -13,10 +13,24 @@ namespace attribute {
ImportedAttributeVector::ImportedAttributeVector(
vespalib::stringref name,
std::shared_ptr<ReferenceAttribute> reference_attribute,
- std::shared_ptr<AttributeVector> target_attribute)
+ std::shared_ptr<AttributeVector> target_attribute,
+ bool use_search_cache)
: _name(name),
_reference_attribute(std::move(reference_attribute)),
- _target_attribute(std::move(target_attribute))
+ _target_attribute(std::move(target_attribute)),
+ _search_cache(use_search_cache ? std::make_shared<BitVectorSearchCache>() :
+ std::shared_ptr<BitVectorSearchCache>())
+{
+}
+
+ImportedAttributeVector::ImportedAttributeVector(vespalib::stringref name,
+ std::shared_ptr<ReferenceAttribute> reference_attribute,
+ std::shared_ptr<AttributeVector> target_attribute,
+ std::shared_ptr<BitVectorSearchCache> search_cache)
+ : _name(name),
+ _reference_attribute(std::move(reference_attribute)),
+ _target_attribute(std::move(target_attribute)),
+ _search_cache(std::move(search_cache))
{
}
@@ -27,7 +41,7 @@ std::unique_ptr<ImportedAttributeVector>
ImportedAttributeVector::makeReadGuard(bool stableEnumGuard) const
{
return std::make_unique<ImportedAttributeVectorReadGuard>
- (getName(), getReferenceAttribute(), getTargetAttribute(), stableEnumGuard);
+ (getName(), getReferenceAttribute(), getTargetAttribute(), getSearchCache(), stableEnumGuard);
}
const vespalib::string& search::attribute::ImportedAttributeVector::getName() const {
diff --git a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.h b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.h
index bddd0fa9093..568c0ff4cce 100644
--- a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.h
+++ b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.h
@@ -14,6 +14,8 @@ class AttributeEnumGuard;
namespace attribute {
+class BitVectorSearchCache;
+
/**
* Attribute vector which does not store values of its own, but rather serves as a
* convenient indirection wrapper towards a target vector, usually in another
@@ -29,7 +31,12 @@ public:
using SP = std::shared_ptr<ImportedAttributeVector>;
ImportedAttributeVector(vespalib::stringref name,
std::shared_ptr<ReferenceAttribute> reference_attribute,
- std::shared_ptr<AttributeVector> target_attribute);
+ std::shared_ptr<AttributeVector> target_attribute,
+ bool use_search_cache);
+ ImportedAttributeVector(vespalib::stringref name,
+ std::shared_ptr<ReferenceAttribute> reference_attribute,
+ std::shared_ptr<AttributeVector> target_attribute,
+ std::shared_ptr<BitVectorSearchCache> search_cache);
~ImportedAttributeVector();
const vespalib::string & getName() const override;
@@ -65,6 +72,9 @@ public:
const std::shared_ptr<AttributeVector>& getTargetAttribute() const noexcept {
return _target_attribute;
}
+ const std::shared_ptr<BitVectorSearchCache> &getSearchCache() const {
+ return _search_cache;
+ }
/*
* Create an imported attribute with a snapshot of lid to lid mapping.
@@ -77,9 +87,10 @@ protected:
const common::BlobConverter * bc) const override;
- vespalib::string _name;
- std::shared_ptr<ReferenceAttribute> _reference_attribute;
- std::shared_ptr<AttributeVector> _target_attribute;
+ vespalib::string _name;
+ std::shared_ptr<ReferenceAttribute> _reference_attribute;
+ std::shared_ptr<AttributeVector> _target_attribute;
+ std::shared_ptr<BitVectorSearchCache> _search_cache;
};
} // attribute
diff --git a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.cpp b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.cpp
index 563834e6cdb..9586e2be79b 100644
--- a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.cpp
@@ -9,8 +9,9 @@ ImportedAttributeVectorReadGuard::ImportedAttributeVectorReadGuard(
vespalib::stringref name,
std::shared_ptr<ReferenceAttribute> reference_attribute,
std::shared_ptr<AttributeVector> target_attribute,
+ std::shared_ptr<BitVectorSearchCache> search_cache,
bool stableEnumGuard)
- : ImportedAttributeVector(name, std::move(reference_attribute), std::move(target_attribute)),
+ : ImportedAttributeVector(name, std::move(reference_attribute), std::move(target_attribute), std::move(search_cache)),
_referencedLids(),
_referencedLidLimit(0u),
_reference_attribute_guard(_reference_attribute),
diff --git a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.h b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.h
index f4db2b538d5..77554fdb849 100644
--- a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.h
+++ b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.h
@@ -7,6 +7,8 @@
namespace search::attribute {
+class BitVectorSearchCache;
+
/*
* Short lived attribute vector that does not store values on its own.
*
@@ -31,6 +33,7 @@ public:
ImportedAttributeVectorReadGuard(vespalib::stringref name,
std::shared_ptr<ReferenceAttribute> reference_attribute,
std::shared_ptr<AttributeVector> target_attribute,
+ std::shared_ptr<BitVectorSearchCache> search_cache,
bool stableEnumGuard);
~ImportedAttributeVectorReadGuard();
diff --git a/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h b/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h
index 85a2b140039..b14822090f6 100644
--- a/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h
+++ b/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h
@@ -116,7 +116,7 @@ struct ImportedAttributeFixture {
std::shared_ptr<ImportedAttributeVector>
create_attribute_vector_from_members(vespalib::stringref name = default_imported_attr_name()) {
- return std::make_shared<ImportedAttributeVector>(name, reference_attr, target_attr);
+ return std::make_shared<ImportedAttributeVector>(name, reference_attr, target_attr, false);
}
template<typename AttrVecType>