aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeir Storli <geirst@oath.com>2017-09-06 15:04:54 +0000
committerGeir Storli <geirst@oath.com>2017-09-06 15:45:26 +0000
commit9a2a64a3bd9a20ce2e5697a450ce5bc4896179b1 (patch)
treeea919030a331b3280e62cdb4ad796486ad64636a
parentf77fff6223051fe8238eb5f9160348e422fe76f0 (diff)
Use bit vector search cache in imported search context if available.
Try to use bit vector from cache for the given query term if found. Insert bit vector posting list into cache after calculation.
-rw-r--r--searchlib/src/tests/attribute/bitvector_search_cache/bitvector_search_cache_test.cpp33
-rw-r--r--searchlib/src/tests/attribute/imported_search_context/imported_search_context_test.cpp78
-rw-r--r--searchlib/src/vespa/searchlib/attribute/bitvector_search_cache.cpp8
-rw-r--r--searchlib/src/vespa/searchlib/attribute/bitvector_search_cache.h14
-rw-r--r--searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp26
-rw-r--r--searchlib/src/vespa/searchlib/attribute/imported_search_context.h5
-rw-r--r--searchlib/src/vespa/searchlib/attribute/posting_list_merger.h3
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/simpleresult.cpp9
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/simpleresult.h11
-rw-r--r--searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h43
10 files changed, 180 insertions, 50 deletions
diff --git a/searchlib/src/tests/attribute/bitvector_search_cache/bitvector_search_cache_test.cpp b/searchlib/src/tests/attribute/bitvector_search_cache/bitvector_search_cache_test.cpp
index 7b395a6459c..1f738a209df 100644
--- a/searchlib/src/tests/attribute/bitvector_search_cache/bitvector_search_cache_test.cpp
+++ b/searchlib/src/tests/attribute/bitvector_search_cache/bitvector_search_cache_test.cpp
@@ -8,48 +8,49 @@ using namespace search;
using namespace search::attribute;
using BitVectorSP = BitVectorSearchCache::BitVectorSP;
+using Entry = BitVectorSearchCache::Entry;
-BitVectorSP
-makeBitVector()
+Entry::SP
+makeEntry()
{
- return BitVectorSP(BitVector::create(5).release());
+ return std::make_shared<Entry>(BitVector::create(5), 10);
}
struct Fixture {
BitVectorSearchCache cache;
- BitVectorSP vec1;
- BitVectorSP vec2;
+ Entry::SP entry1;
+ Entry::SP entry2;
Fixture()
: cache(),
- vec1(makeBitVector()),
- vec2(makeBitVector())
+ entry1(makeEntry()),
+ entry2(makeEntry())
{}
};
TEST_F("require that bit vectors can be inserted and retrieved", Fixture)
{
EXPECT_EQUAL(0u, f.cache.size());
- f.cache.insert("foo", f.vec1);
- f.cache.insert("bar", f.vec2);
+ f.cache.insert("foo", f.entry1);
+ f.cache.insert("bar", f.entry2);
EXPECT_EQUAL(2u, f.cache.size());
- EXPECT_EQUAL(f.vec1, f.cache.find("foo"));
- EXPECT_EQUAL(f.vec2, f.cache.find("bar"));
+ EXPECT_EQUAL(f.entry1, f.cache.find("foo"));
+ EXPECT_EQUAL(f.entry2, f.cache.find("bar"));
EXPECT_TRUE(f.cache.find("baz").get() == nullptr);
}
TEST_F("require that insert() doesn't replace existing bit vector", Fixture)
{
- f.cache.insert("foo", f.vec1);
- f.cache.insert("foo", f.vec2);
+ f.cache.insert("foo", f.entry1);
+ f.cache.insert("foo", f.entry2);
EXPECT_EQUAL(1u, f.cache.size());
- EXPECT_EQUAL(f.vec1, f.cache.find("foo"));
+ EXPECT_EQUAL(f.entry1, f.cache.find("foo"));
}
TEST_F("require that cache can be cleared", Fixture)
{
- f.cache.insert("foo", f.vec1);
- f.cache.insert("bar", f.vec2);
+ f.cache.insert("foo", f.entry1);
+ f.cache.insert("bar", f.entry2);
EXPECT_EQUAL(2u, f.cache.size());
f.cache.clear();
diff --git a/searchlib/src/tests/attribute/imported_search_context/imported_search_context_test.cpp b/searchlib/src/tests/attribute/imported_search_context/imported_search_context_test.cpp
index c9e0757ee16..f6ab6bb50bf 100644
--- a/searchlib/src/tests/attribute/imported_search_context/imported_search_context_test.cpp
+++ b/searchlib/src/tests/attribute/imported_search_context/imported_search_context_test.cpp
@@ -1,21 +1,28 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/searchlib/test/imported_attribute_fixture.h>
+#include <vespa/searchcommon/attribute/search_context_params.h>
#include <vespa/searchlib/attribute/imported_search_context.h>
#include <vespa/searchlib/fef/termfieldmatchdata.h>
-#include <vespa/searchcommon/attribute/search_context_params.h>
+#include <vespa/searchlib/queryeval/simpleresult.h>
+#include <vespa/searchlib/test/imported_attribute_fixture.h>
+#include <vespa/vespalib/test/insertion_operators.h>
namespace search::attribute {
using fef::TermFieldMatchData;
+using queryeval::SearchIterator;
+using queryeval::SimpleResult;
using vespalib::Trinary;
struct Fixture : ImportedAttributeFixture {
+
+ Fixture(bool useSearchCache = false) : ImportedAttributeFixture(useSearchCache) {}
+
std::unique_ptr<ImportedSearchContext> create_context(std::unique_ptr<QueryTermSimple> term) {
return std::make_unique<ImportedSearchContext>(std::move(term), SearchContextParams(), *imported_attr);
}
- std::unique_ptr<queryeval::SearchIterator> create_iterator(
+ std::unique_ptr<SearchIterator> create_iterator(
ImportedSearchContext& ctx,
TermFieldMatchData& match,
bool strict) {
@@ -25,17 +32,21 @@ struct Fixture : ImportedAttributeFixture {
return iter;
}
- std::unique_ptr<queryeval::SearchIterator> create_non_strict_iterator(
+ std::unique_ptr<SearchIterator> create_non_strict_iterator(
ImportedSearchContext& ctx,
TermFieldMatchData& match) {
return create_iterator(ctx, match, false);
}
- std::unique_ptr<queryeval::SearchIterator> create_strict_iterator(
+ std::unique_ptr<SearchIterator> create_strict_iterator(
ImportedSearchContext& ctx,
TermFieldMatchData& match) {
return create_iterator(ctx, match, true);
}
+
+ void assertSearch(const std::vector<uint32_t> &expDocIds, SearchIterator &iter) {
+ EXPECT_EQUAL(SimpleResult(expDocIds), SimpleResult().searchStrict(iter, imported_attr->getNumDocs()));
+ }
};
template <typename Iterator>
@@ -339,6 +350,63 @@ TEST_F("queryTerm() returns term context was created with", WsetValueFixture) {
EXPECT_EQUAL(std::string("helloworld"), std::string(ctx->queryTerm().getTerm()));
}
+struct SearchCacheFixture : Fixture {
+ SearchCacheFixture() : Fixture(true) {
+ reset_with_single_value_reference_mappings<IntegerAttribute, int32_t>(
+ BasicType::INT32,
+ {{DocId(3), dummy_gid(5), DocId(5), 5678},
+ {DocId(4), dummy_gid(6), DocId(6), 1234},
+ {DocId(5), dummy_gid(8), DocId(8), 5678},
+ {DocId(7), dummy_gid(9), DocId(9), 4321}},
+ FastSearchConfig::ExplicitlyEnabled,
+ FilterConfig::ExplicitlyEnabled);
+ }
+};
+
+BitVectorSearchCache::Entry::SP
+makeSearchCacheEntry(const std::vector<uint32_t> docIds, uint32_t docIdLimit)
+{
+ std::shared_ptr<BitVector> bitVector = BitVector::create(docIdLimit);
+ for (uint32_t docId : docIds) {
+ bitVector->setBit(docId);
+ }
+ return std::make_shared<BitVectorSearchCache::Entry>(bitVector, docIdLimit);
+}
+
+TEST_F("Bit vector from search cache is used if found", SearchCacheFixture)
+{
+ f.imported_attr->getSearchCache()->insert("5678",
+ makeSearchCacheEntry({2, 6}, f.imported_attr->getNumDocs()));
+ auto ctx = f.create_context(word_term("5678"));
+ ctx->fetchPostings(true);
+ TermFieldMatchData match;
+ auto iter = f.create_strict_iterator(*ctx, match);
+ TEST_DO(f.assertSearch({2, 6}, *iter)); // Note: would be {3, 5} if cache was not used
+}
+
+void
+assertBitVector(const std::vector<uint32_t> &expDocIds, const BitVector &bitVector)
+{
+ std::vector<uint32_t> actDocsIds;
+ bitVector.foreach_truebit([&](uint32_t docId){ actDocsIds.push_back(docId); });
+ EXPECT_EQUAL(expDocIds, actDocsIds);
+}
+
+TEST_F("Entry is inserted into search cache if bit vector posting list is used", SearchCacheFixture)
+{
+ EXPECT_EQUAL(0u, f.imported_attr->getSearchCache()->size());
+ auto ctx = f.create_context(word_term("5678"));
+ ctx->fetchPostings(true);
+ TermFieldMatchData match;
+ auto iter = f.create_strict_iterator(*ctx, match);
+ TEST_DO(f.assertSearch({3, 5}, *iter));
+
+ EXPECT_EQUAL(1u, f.imported_attr->getSearchCache()->size());
+ auto cacheEntry = f.imported_attr->getSearchCache()->find("5678");
+ EXPECT_EQUAL(cacheEntry->docIdLimit, f.imported_attr->getNumDocs());
+ TEST_DO(assertBitVector({3, 5}, *cacheEntry->bitVector));
+}
+
}
TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/searchlib/src/vespa/searchlib/attribute/bitvector_search_cache.cpp b/searchlib/src/vespa/searchlib/attribute/bitvector_search_cache.cpp
index cf9b459d900..cf49856234a 100644
--- a/searchlib/src/vespa/searchlib/attribute/bitvector_search_cache.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/bitvector_search_cache.cpp
@@ -19,13 +19,13 @@ BitVectorSearchCache::~BitVectorSearchCache()
}
void
-BitVectorSearchCache::insert(const vespalib::string &term, BitVectorSP bitVector)
+BitVectorSearchCache::insert(const vespalib::string &term, Entry::SP entry)
{
LockGuard guard(_mutex);
- _cache.insert(std::make_pair(term, std::move(bitVector)));
+ _cache.insert(std::make_pair(term, std::move(entry)));
}
-BitVectorSP
+BitVectorSearchCache::Entry::SP
BitVectorSearchCache::find(const vespalib::string &term) const
{
LockGuard guard(_mutex);
@@ -33,7 +33,7 @@ BitVectorSearchCache::find(const vespalib::string &term) const
if (itr != _cache.end()) {
return itr->second;
}
- return BitVectorSP();
+ return Entry::SP();
}
size_t
diff --git a/searchlib/src/vespa/searchlib/attribute/bitvector_search_cache.h b/searchlib/src/vespa/searchlib/attribute/bitvector_search_cache.h
index 4b6589459ca..73fb95e1752 100644
--- a/searchlib/src/vespa/searchlib/attribute/bitvector_search_cache.h
+++ b/searchlib/src/vespa/searchlib/attribute/bitvector_search_cache.h
@@ -22,9 +22,17 @@ class BitVectorSearchCache {
public:
using BitVectorSP = std::shared_ptr<BitVector>;
+ struct Entry {
+ using SP = std::shared_ptr<Entry>;
+ BitVectorSP bitVector;
+ uint32_t docIdLimit;
+ Entry(BitVectorSP bitVector_, uint32_t docIdLimit_)
+ : bitVector(std::move(bitVector_)), docIdLimit(docIdLimit_) {}
+ };
+
private:
using LockGuard = std::lock_guard<std::mutex>;
- using Cache = vespalib::hash_map<vespalib::string, BitVectorSP>;
+ using Cache = vespalib::hash_map<vespalib::string, Entry::SP>;
mutable std::mutex _mutex;
Cache _cache;
@@ -32,8 +40,8 @@ private:
public:
BitVectorSearchCache();
~BitVectorSearchCache();
- void insert(const vespalib::string &term, BitVectorSP bitVector);
- BitVectorSP find(const vespalib::string &term) const;
+ void insert(const vespalib::string &term, Entry::SP entry);
+ Entry::SP find(const vespalib::string &term) const;
size_t size() const;
void clear();
};
diff --git a/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp b/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp
index 5a040941e67..26e51f77ccf 100644
--- a/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp
@@ -1,5 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include "bitvector_search_cache.h"
#include "imported_search_context.h"
#include "imported_attribute_vector.h"
#include <vespa/searchlib/common/bitvectoriterator.h>
@@ -24,6 +25,10 @@ ImportedSearchContext::ImportedSearchContext(
const SearchContextParams& params,
const ImportedAttributeVector& imported_attribute)
: _imported_attribute(imported_attribute),
+ _queryTerm(term->getTerm()),
+ _useSearchCache(_imported_attribute.getSearchCache().get() != nullptr),
+ _searchCacheLookup((_useSearchCache ? _imported_attribute.getSearchCache()->find(_queryTerm) :
+ std::shared_ptr<BitVectorSearchCache::Entry>())),
_reference_attribute(*_imported_attribute.getReferenceAttribute()),
_target_attribute(*_imported_attribute.getTargetAttribute()),
_target_search_context(_target_attribute.getSearch(std::move(term), params)),
@@ -43,6 +48,9 @@ unsigned int ImportedSearchContext::approximateHits() const {
std::unique_ptr<queryeval::SearchIterator>
ImportedSearchContext::createIterator(fef::TermFieldMatchData* matchData, bool strict) {
+ if (_searchCacheLookup) {
+ return BitVectorIterator::create(_searchCacheLookup->bitVector.get(), _searchCacheLookup->docIdLimit, *matchData, strict);
+ }
if (_merger.hasArray()) {
if (_merger.emptyArray()) {
return SearchIterator::UP(new EmptySearch());
@@ -204,12 +212,24 @@ void ImportedSearchContext::makeMergedPostings(bool isFilter)
_merger.merge();
}
+void
+ImportedSearchContext::considerAddSearchCacheEntry()
+{
+ if (_useSearchCache && _merger.hasBitVector()) {
+ auto cacheEntry = std::make_shared<BitVectorSearchCache::Entry>(_merger.getBitVectorSP(), _merger.getDocIdLimit());
+ _imported_attribute.getSearchCache()->insert(_queryTerm, std::move(cacheEntry));
+ }
+}
+
void ImportedSearchContext::fetchPostings(bool strict) {
assert(!_fetchPostingsDone);
_fetchPostingsDone = true;
- _target_search_context->fetchPostings(strict);
- if (strict || _target_attribute.getConfig().fastSearch()) {
- makeMergedPostings(_target_attribute.getConfig().getIsFilter());
+ if (!_searchCacheLookup) {
+ _target_search_context->fetchPostings(strict);
+ if (strict || _target_attribute.getConfig().fastSearch()) {
+ makeMergedPostings(_target_attribute.getConfig().getIsFilter());
+ considerAddSearchCacheEntry();
+ }
}
}
diff --git a/searchlib/src/vespa/searchlib/attribute/imported_search_context.h b/searchlib/src/vespa/searchlib/attribute/imported_search_context.h
index c4a6101ac0a..f3f44332a2e 100644
--- a/searchlib/src/vespa/searchlib/attribute/imported_search_context.h
+++ b/searchlib/src/vespa/searchlib/attribute/imported_search_context.h
@@ -3,6 +3,7 @@
#pragma once
#include "attributevector.h"
+#include "bitvector_search_cache.h"
#include <vespa/searchcommon/attribute/i_search_context.h>
#include <vespa/searchlib/attribute/posting_list_merger.h>
#include <vespa/vespalib/util/arrayref.h>
@@ -26,6 +27,9 @@ class SearchContextParams;
class ImportedSearchContext : public ISearchContext {
using ReferencedLids = vespalib::ConstArrayRef<uint32_t>;
const ImportedAttributeVector& _imported_attribute;
+ vespalib::string _queryTerm;
+ bool _useSearchCache;
+ BitVectorSearchCache::Entry::SP _searchCacheLookup;
const ReferenceAttribute& _reference_attribute;
const AttributeVector& _target_attribute;
std::unique_ptr<AttributeVector::SearchContext> _target_search_context;
@@ -40,6 +44,7 @@ class ImportedSearchContext : public ISearchContext {
}
void makeMergedPostings(bool isFilter);
+ void considerAddSearchCacheEntry();
public:
ImportedSearchContext(std::unique_ptr<QueryTermSimple> term,
const SearchContextParams& params,
diff --git a/searchlib/src/vespa/searchlib/attribute/posting_list_merger.h b/searchlib/src/vespa/searchlib/attribute/posting_list_merger.h
index 8220b529aac..8568661dfdd 100644
--- a/searchlib/src/vespa/searchlib/attribute/posting_list_merger.h
+++ b/searchlib/src/vespa/searchlib/attribute/posting_list_merger.h
@@ -21,7 +21,7 @@ class PostingListMerger
PostingVector _array;
StartVector _startPos;
- std::unique_ptr<BitVector> _bitVector;
+ std::shared_ptr<BitVector> _bitVector;
uint32_t _docIdLimit;
bool _arrayValid;
@@ -39,6 +39,7 @@ public:
bool emptyArray() const { return _array.empty(); }
vespalib::ConstArrayRef<Posting> getArray() const { return _array; }
const BitVector *getBitVector() const { return _bitVector.get(); }
+ const std::shared_ptr<BitVector> &getBitVectorSP() const { return _bitVector; }
uint32_t getDocIdLimit() const { return _docIdLimit; }
template <typename PostingListType>
diff --git a/searchlib/src/vespa/searchlib/queryeval/simpleresult.cpp b/searchlib/src/vespa/searchlib/queryeval/simpleresult.cpp
index 5195f03b8db..de2582dda6b 100644
--- a/searchlib/src/vespa/searchlib/queryeval/simpleresult.cpp
+++ b/searchlib/src/vespa/searchlib/queryeval/simpleresult.cpp
@@ -20,7 +20,7 @@ SimpleResult::clear()
tmp.swap(_hits);
}
-void
+SimpleResult &
SimpleResult::search(SearchIterator &sb)
{
clear();
@@ -30,9 +30,10 @@ SimpleResult::search(SearchIterator &sb)
sb.unpack(sb.getDocId());
_hits.push_back(sb.getDocId());
}
+ return *this;
}
-void
+SimpleResult &
SimpleResult::searchStrict(SearchIterator &sb, uint32_t docIdLimit)
{
clear();
@@ -42,9 +43,10 @@ SimpleResult::searchStrict(SearchIterator &sb, uint32_t docIdLimit)
sb.unpack(sb.getDocId());
_hits.push_back(sb.getDocId());
}
+ return *this;
}
-void
+SimpleResult &
SimpleResult::search(SearchIterator &sb, uint32_t docIdLimit)
{
clear();
@@ -57,6 +59,7 @@ SimpleResult::search(SearchIterator &sb, uint32_t docIdLimit)
_hits.push_back(docId);
}
}
+ return *this;
}
std::ostream &
diff --git a/searchlib/src/vespa/searchlib/queryeval/simpleresult.h b/searchlib/src/vespa/searchlib/queryeval/simpleresult.h
index 30c88bb10c7..4a1fcb25e7a 100644
--- a/searchlib/src/vespa/searchlib/queryeval/simpleresult.h
+++ b/searchlib/src/vespa/searchlib/queryeval/simpleresult.h
@@ -23,6 +23,11 @@ public:
SimpleResult() : _hits() {}
/**
+ * Create a result with the given hits.
+ */
+ SimpleResult(const std::vector<uint32_t> &hits) : _hits(hits) {}
+
+ /**
* Obtain the number of hits
*
* @return number of hits
@@ -58,8 +63,8 @@ public:
*
* @param sb search object
**/
- void search(SearchIterator &sb);
- void searchStrict(SearchIterator &sb, uint32_t docIdLimit);
+ SimpleResult &search(SearchIterator &sb);
+ SimpleResult &searchStrict(SearchIterator &sb, uint32_t docIdLimit);
/**
* Fill this result with all the hits returned by the given search
@@ -69,7 +74,7 @@ public:
* @param sb search object
* @param docIdLimit the end of the docId range for this search iterator
**/
- void search(SearchIterator &sb, uint32_t docIdLimit);
+ SimpleResult &search(SearchIterator &sb, uint32_t docIdLimit);
/**
* Test of we contain the same hits as rhs.
diff --git a/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h b/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h
index b14822090f6..3620a1df725 100644
--- a/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h
+++ b/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h
@@ -44,34 +44,47 @@ enum class FastSearchConfig {
Default
};
+enum class FilterConfig {
+ ExplicitlyEnabled,
+ Default
+};
+
template<typename AttrVecType>
std::shared_ptr<AttrVecType> create_typed_attribute(BasicType basic_type,
CollectionType collection_type,
FastSearchConfig fast_search = FastSearchConfig::Default,
+ FilterConfig filter = FilterConfig::Default,
vespalib::stringref name = "parent") {
Config cfg(basic_type, collection_type);
if (fast_search == FastSearchConfig::ExplicitlyEnabled) {
cfg.setFastSearch(true);
}
+ if (filter == FilterConfig::ExplicitlyEnabled) {
+ cfg.setIsFilter(true);
+ }
return std::dynamic_pointer_cast<AttrVecType>(
AttributeFactory::createAttribute(name, std::move(cfg)));
}
template<typename AttrVecType>
-std::shared_ptr<AttrVecType> create_single_attribute(BasicType type, vespalib::stringref name = "parent") {
- return create_typed_attribute<AttrVecType>(type, CollectionType::SINGLE, FastSearchConfig::Default, name);
+std::shared_ptr<AttrVecType> create_single_attribute(BasicType type,
+ FastSearchConfig fast_search = FastSearchConfig::Default,
+ FilterConfig filter = FilterConfig::Default,
+ vespalib::stringref name = "parent") {
+ return create_typed_attribute<AttrVecType>(type, CollectionType::SINGLE, fast_search, filter, name);
}
template<typename AttrVecType>
std::shared_ptr<AttrVecType> create_array_attribute(BasicType type, vespalib::stringref name = "parent") {
- return create_typed_attribute<AttrVecType>(type, CollectionType::ARRAY, FastSearchConfig::Default, name);
+ return create_typed_attribute<AttrVecType>(type, CollectionType::ARRAY,
+ FastSearchConfig::Default, FilterConfig::Default, name);
}
template<typename AttrVecType>
std::shared_ptr<AttrVecType> create_wset_attribute(BasicType type,
FastSearchConfig fast_search = FastSearchConfig::Default,
vespalib::stringref name = "parent") {
- return create_typed_attribute<AttrVecType>(type, CollectionType::WSET, fast_search, name);
+ return create_typed_attribute<AttrVecType>(type, CollectionType::WSET, fast_search, FilterConfig::Default, name);
}
template<typename VectorType>
@@ -89,12 +102,13 @@ std::unique_ptr<QueryTermSimple> word_term(vespalib::stringref term) {
}
struct ImportedAttributeFixture {
+ bool use_search_cache;
std::shared_ptr<AttributeVector> target_attr;
std::shared_ptr<ReferenceAttribute> reference_attr;
std::shared_ptr<ImportedAttributeVector> imported_attr;
std::shared_ptr<MockGidToLidMapperFactory> mapper_factory;
- ImportedAttributeFixture();
+ ImportedAttributeFixture(bool use_search_cache_ = false);
virtual ~ImportedAttributeFixture();
@@ -116,7 +130,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, false);
+ return std::make_shared<ImportedAttributeVector>(name, reference_attr, target_attr, use_search_cache);
}
template<typename AttrVecType>
@@ -169,8 +183,10 @@ struct ImportedAttributeFixture {
template<typename AttrVecType, typename ValueType>
void reset_with_single_value_reference_mappings(
BasicType type,
- const std::vector<LidToLidMapping<ValueType>> &mappings) {
- reset_with_new_target_attr(create_single_attribute<AttrVecType>(type));
+ const std::vector<LidToLidMapping<ValueType>> &mappings,
+ FastSearchConfig fast_search = FastSearchConfig::Default,
+ FilterConfig filter = FilterConfig::Default) {
+ reset_with_new_target_attr(create_single_attribute<AttrVecType>(type, fast_search, filter));
// Fun experiment: rename `auto& mapping` to `auto& m` and watch GCC howl about
// shadowing a variable... that exists in the set_up_and_map function!
set_up_and_map<AttrVecType>(mappings, [this](auto &target_vec, auto &mapping) {
@@ -205,8 +221,9 @@ struct ImportedAttributeFixture {
}
};
-ImportedAttributeFixture::ImportedAttributeFixture()
- : target_attr(create_single_attribute<IntegerAttribute>(BasicType::INT32)),
+ImportedAttributeFixture::ImportedAttributeFixture(bool use_search_cache_)
+ : use_search_cache(use_search_cache_),
+ target_attr(create_single_attribute<IntegerAttribute>(BasicType::INT32)),
reference_attr(create_reference_attribute()),
imported_attr(create_attribute_vector_from_members()),
mapper_factory(std::make_shared<MockGidToLidMapperFactory>()) {
@@ -240,8 +257,10 @@ template<typename AttrVecType, typename ValueType>
void reset_with_single_value_reference_mappings(
ImportedAttributeFixture &f,
BasicType type,
- const std::vector<ImportedAttributeFixture::LidToLidMapping<ValueType>> &mappings) {
- f.reset_with_single_value_reference_mappings<AttrVecType, ValueType>(type, mappings);
+ const std::vector<ImportedAttributeFixture::LidToLidMapping<ValueType>> &mappings,
+ FastSearchConfig fast_search = FastSearchConfig::Default,
+ FilterConfig filter = FilterConfig::Default) {
+ f.reset_with_single_value_reference_mappings<AttrVecType, ValueType>(type, mappings, fast_search, filter);
}
template<typename AttrVecType, typename ValueType>