aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2020-08-31 16:01:13 +0200
committerGitHub <noreply@github.com>2020-08-31 16:01:13 +0200
commit3128fbf9c2103caec86bb0a4343aa0acf20bbf1d (patch)
tree59f06b38d0037f499d03edfddf8cb92abbcdc242 /searchlib
parent078b0dcd710adc8bd53add3fb482b920d8806a93 (diff)
parent4595593de766c75ca8a967875d090035e7880fac (diff)
Merge pull request #14193 from vespa-engine/toregge/extend-document-weight-attribute-interface
Extend Document weight attribute interface to use dictionary snapshot
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/attribute/bitvector/bitvector_test.cpp2
-rw-r--r--searchlib/src/tests/attribute/document_weight_iterator/document_weight_iterator_test.cpp61
-rw-r--r--searchlib/src/tests/queryeval/parallel_weak_and/parallel_weak_and_test.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp17
-rw-r--r--searchlib/src/vespa/searchlib/attribute/i_document_weight_attribute.h17
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.h10
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp23
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multistringpostattribute.h10
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp29
-rw-r--r--searchlib/src/vespa/searchlib/test/weightedchildrenverifiers.h2
10 files changed, 139 insertions, 34 deletions
diff --git a/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp b/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp
index 24919fb2341..04d2dfe4d52 100644
--- a/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp
+++ b/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp
@@ -491,7 +491,7 @@ BitVectorTest::test(BasicType bt,
v->asDocumentWeightAttribute();
if (dwa != NULL) {
search::IDocumentWeightAttribute::LookupResult lres =
- dwa->lookup(getSearchStr<VectorType>());
+ dwa->lookup(getSearchStr<VectorType>(), dwa->get_dictionary_snapshot());
typedef search::queryeval::DocumentWeightSearchIterator DWSI;
typedef search::queryeval::SearchIterator SI;
TermFieldMatchData md;
diff --git a/searchlib/src/tests/attribute/document_weight_iterator/document_weight_iterator_test.cpp b/searchlib/src/tests/attribute/document_weight_iterator/document_weight_iterator_test.cpp
index cf1506a9118..d8a1d03f1a8 100644
--- a/searchlib/src/tests/attribute/document_weight_iterator/document_weight_iterator_test.cpp
+++ b/searchlib/src/tests/attribute/document_weight_iterator/document_weight_iterator_test.cpp
@@ -3,6 +3,7 @@
#include <vespa/searchlib/attribute/attribute.h>
#include <vespa/searchlib/attribute/attributefactory.h>
#include <vespa/searchlib/attribute/attributeguard.h>
+#include <vespa/searchlib/attribute/attribute_read_guard.h>
#include <vespa/searchlib/attribute/attributememorysavetarget.h>
#include <vespa/searchlib/attribute/attributevector.h>
#include <vespa/searchlib/attribute/attributevector.hpp>
@@ -22,6 +23,7 @@
#include <vespa/searchlib/test/searchiteratorverifier.h>
#include <vespa/searchlib/util/randomgenerator.h>
#include <vespa/vespalib/testkit/test_kit.h>
+#include <vespa/vespalib/test/insertion_operators.h>
#include <vespa/log/log.h>
LOG_SETUP("document_weight_iterator_test");
@@ -124,17 +126,17 @@ void verify_invalid_lookup(IDocumentWeightAttribute::LookupResult result) {
}
TEST_F("require that integer lookup works correctly", LongFixture) {
- verify_valid_lookup(f1.api->lookup("111"));
- verify_invalid_lookup(f1.api->lookup("222"));
+ verify_valid_lookup(f1.api->lookup("111", f1.api->get_dictionary_snapshot()));
+ verify_invalid_lookup(f1.api->lookup("222", f1.api->get_dictionary_snapshot()));
}
TEST_F("require string lookup works correctly", StringFixture) {
- verify_valid_lookup(f1.api->lookup("foo"));
- verify_invalid_lookup(f1.api->lookup("bar"));
+ verify_valid_lookup(f1.api->lookup("foo", f1.api->get_dictionary_snapshot()));
+ verify_invalid_lookup(f1.api->lookup("bar", f1.api->get_dictionary_snapshot()));
}
void verify_posting(const IDocumentWeightAttribute &api, const char *term) {
- auto result = api.lookup(term);
+ auto result = api.lookup(term, api.get_dictionary_snapshot());
ASSERT_TRUE(result.posting_idx.valid());
std::vector<DocumentWeightIterator> itr_store;
api.create(result.posting_idx, itr_store);
@@ -168,6 +170,53 @@ TEST_F("require that string iterators are created correctly", StringFixture) {
verify_posting(*f1.api, "foo");
}
+TEST_F("require that dictionary snapshot works", LongFixture)
+{
+ auto read_guard = f1.attr->makeReadGuard(false);
+ auto dictionary_snapshot = f1.api->get_dictionary_snapshot();
+ auto lookup1 = f1.api->lookup("111", dictionary_snapshot);
+ EXPECT_TRUE(lookup1.enum_idx.valid());
+ f1.attr->clearDoc(1);
+ f1.attr->clearDoc(5);
+ f1.attr->clearDoc(7);
+ f1.attr->commit();
+ auto lookup2 = f1.api->lookup("111", f1.api->get_dictionary_snapshot());
+ EXPECT_FALSE(lookup2.enum_idx.valid());
+ auto lookup3 = f1.api->lookup("111", dictionary_snapshot);
+ EXPECT_TRUE(lookup3.enum_idx.valid());
+ EXPECT_EQUAL(lookup1.enum_idx.ref(), lookup3.enum_idx.ref());
+}
+
+TEST_F("require that collect_folded works for string", StringFixture)
+{
+ StringAttribute *attr = static_cast<StringAttribute *>(f1.attr.get());
+ set_doc(attr, 2, "bar", 30);
+ attr->commit();
+ set_doc(attr, 3, "FOO", 30);
+ attr->commit();
+ auto dictionary_snapshot = f1.api->get_dictionary_snapshot();
+ auto lookup1 = f1.api->lookup("foo", dictionary_snapshot);
+ std::vector<vespalib::string> folded;
+ std::function<void(vespalib::datastore::EntryRef)> save_folded = [&folded,attr](vespalib::datastore::EntryRef enum_idx) { folded.emplace_back(attr->getFromEnum(enum_idx.ref())); };
+ f1.api->collect_folded(lookup1.enum_idx, dictionary_snapshot, save_folded);
+ std::vector<vespalib::string> expected_folded{"FOO", "foo"};
+ EXPECT_EQUAL(expected_folded, folded);
+}
+
+TEST_F("require that collect_folded works for integers", LongFixture)
+{
+ IntegerAttributeTemplate<int64_t> *attr = dynamic_cast<IntegerAttributeTemplate<int64_t> *>(f1.attr.get());
+ set_doc(attr, 2, int64_t(112), 30);
+ attr->commit();
+ auto dictionary_snapshot = f1.api->get_dictionary_snapshot();
+ auto lookup1 = f1.api->lookup("111", dictionary_snapshot);
+ std::vector<int64_t> folded;
+ std::function<void(vespalib::datastore::EntryRef)> save_folded = [&folded,attr](vespalib::datastore::EntryRef enum_idx) { folded.emplace_back(attr->getFromEnum(enum_idx.ref())); };
+ f1.api->collect_folded(lookup1.enum_idx, dictionary_snapshot, save_folded);
+ std::vector<int64_t> expected_folded{int64_t(111)};
+ EXPECT_EQUAL(expected_folded, folded);
+}
+
class Verifier : public search::test::SearchIteratorVerifier {
public:
Verifier();
@@ -176,7 +225,7 @@ public:
(void) strict;
const IDocumentWeightAttribute *api(_attr->asDocumentWeightAttribute());
ASSERT_TRUE(api != nullptr);
- auto dict_entry = api->lookup("123");
+ auto dict_entry = api->lookup("123", api->get_dictionary_snapshot());
ASSERT_TRUE(dict_entry.posting_idx.valid());
return std::make_unique<queryeval::DocumentWeightSearchIterator>(_tfmd, *api, dict_entry);
}
diff --git a/searchlib/src/tests/queryeval/parallel_weak_and/parallel_weak_and_test.cpp b/searchlib/src/tests/queryeval/parallel_weak_and/parallel_weak_and_test.cpp
index 9761b0da2d7..f2c02d02080 100644
--- a/searchlib/src/tests/queryeval/parallel_weak_and/parallel_weak_and_test.cpp
+++ b/searchlib/src/tests/queryeval/parallel_weak_and/parallel_weak_and_test.cpp
@@ -674,7 +674,7 @@ private:
MatchParams match_params(_dummy_heap, _dummy_heap.getMinScore(), 1.0, 1);
std::vector<IDocumentWeightAttribute::LookupResult> dict_entries;
for (size_t i = 0; i < _num_children; ++i) {
- dict_entries.push_back(_helper.dwa().lookup(vespalib::make_string("%zu", i).c_str()));
+ dict_entries.push_back(_helper.dwa().lookup(vespalib::make_string("%zu", i).c_str(), _helper.dwa().get_dictionary_snapshot()));
}
return create_wand(_use_dwa, _tfmd, match_params, _weights, dict_entries, _helper.dwa(), strict);
}
diff --git a/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp b/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp
index b9e4bf565ef..4ab80ebce7d 100644
--- a/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp
@@ -322,6 +322,7 @@ private:
std::vector<int32_t> _weights;
std::vector<IDocumentWeightAttribute::LookupResult> _terms;
const IDocumentWeightAttribute &_attr;
+ vespalib::datastore::EntryRef _dictionary_snapshot;
public:
DirectWeightedSetBlueprint(const FieldSpec &field, const IDocumentWeightAttribute &attr, size_t size_hint)
@@ -329,7 +330,8 @@ public:
_estimate(),
_weights(),
_terms(),
- _attr(attr)
+ _attr(attr),
+ _dictionary_snapshot(_attr.get_dictionary_snapshot())
{
set_allow_termwise_eval(true);
_weights.reserve(size_hint);
@@ -337,7 +339,7 @@ public:
}
void addTerm(const vespalib::string &term, int32_t weight) {
- IDocumentWeightAttribute::LookupResult result = _attr.lookup(term);
+ IDocumentWeightAttribute::LookupResult result = _attr.lookup(term, _dictionary_snapshot);
HitEstimate childEst(result.posting_size, (result.posting_size == 0));
if (!childEst.empty) {
if (_estimate.empty) {
@@ -394,6 +396,7 @@ private:
std::vector<int32_t> _weights;
std::vector<IDocumentWeightAttribute::LookupResult> _terms;
const IDocumentWeightAttribute &_attr;
+ vespalib::datastore::EntryRef _dictionary_snapshot;
public:
DirectWandBlueprint(const FieldSpec &field, const IDocumentWeightAttribute &attr, uint32_t scoresToTrack,
@@ -406,14 +409,16 @@ public:
_scoresAdjustFrequency(queryeval::DEFAULT_PARALLEL_WAND_SCORES_ADJUST_FREQUENCY),
_weights(),
_terms(),
- _attr(attr)
+ _attr(attr),
+ _dictionary_snapshot(_attr.get_dictionary_snapshot())
+
{
_weights.reserve(size_hint);
_terms.reserve(size_hint);
}
void addTerm(const vespalib::string &term, int32_t weight) {
- IDocumentWeightAttribute::LookupResult result = _attr.lookup(term);
+ IDocumentWeightAttribute::LookupResult result = _attr.lookup(term, _dictionary_snapshot);
HitEstimate childEst(result.posting_size, (result.posting_size == 0));
if (!childEst.empty) {
if (_estimate.empty) {
@@ -464,6 +469,7 @@ class DirectAttributeBlueprint : public queryeval::SimpleLeafBlueprint
private:
vespalib::string _attrName;
const IDocumentWeightAttribute &_attr;
+ vespalib::datastore::EntryRef _dictionary_snapshot;
IDocumentWeightAttribute::LookupResult _dict_entry;
public:
@@ -472,7 +478,8 @@ public:
: SimpleLeafBlueprint(field),
_attrName(name),
_attr(attr),
- _dict_entry(_attr.lookup(term))
+ _dictionary_snapshot(_attr.get_dictionary_snapshot()),
+ _dict_entry(_attr.lookup(term, _dictionary_snapshot))
{
setEstimate(HitEstimate(_dict_entry.posting_size, (_dict_entry.posting_size == 0)));
}
diff --git a/searchlib/src/vespa/searchlib/attribute/i_document_weight_attribute.h b/searchlib/src/vespa/searchlib/attribute/i_document_weight_attribute.h
index ed184a7370e..e0cfd446da5 100644
--- a/searchlib/src/vespa/searchlib/attribute/i_document_weight_attribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/i_document_weight_attribute.h
@@ -4,6 +4,8 @@
#include "postinglisttraits.h"
+#include <functional>
+
namespace search {
namespace query { class Node; }
@@ -17,11 +19,18 @@ struct IDocumentWeightAttribute
const uint32_t posting_size;
const int32_t min_weight;
const int32_t max_weight;
- LookupResult() : posting_idx(), posting_size(0), min_weight(0), max_weight(0) {}
- LookupResult(vespalib::datastore::EntryRef posting_idx_in, uint32_t posting_size_in, int32_t min_weight_in, int32_t max_weight_in)
- : posting_idx(posting_idx_in), posting_size(posting_size_in), min_weight(min_weight_in), max_weight(max_weight_in) {}
+ const vespalib::datastore::EntryRef enum_idx;
+ LookupResult() : posting_idx(), posting_size(0), min_weight(0), max_weight(0), enum_idx() {}
+ LookupResult(vespalib::datastore::EntryRef posting_idx_in, uint32_t posting_size_in, int32_t min_weight_in, int32_t max_weight_in, vespalib::datastore::EntryRef enum_idx_in)
+ : posting_idx(posting_idx_in), posting_size(posting_size_in), min_weight(min_weight_in), max_weight(max_weight_in), enum_idx(enum_idx_in) {}
};
- virtual LookupResult lookup(const vespalib::string &term) const = 0;
+ virtual vespalib::datastore::EntryRef get_dictionary_snapshot() const = 0;
+ virtual LookupResult lookup(const vespalib::string &term, vespalib::datastore::EntryRef dictionary_snapshot) const = 0;
+ /*
+ * Collect enum indexes (via callback) where folded
+ * (e.g. lowercased) value equals the folded value for enum_idx.
+ */
+ virtual void collect_folded(vespalib::datastore::EntryRef enum_idx, vespalib::datastore::EntryRef dictionary_snapshot, const std::function<void(vespalib::datastore::EntryRef)>& callback) const = 0;
virtual void create(vespalib::datastore::EntryRef idx, std::vector<DocumentWeightIterator> &dst) const = 0;
virtual DocumentWeightIterator create(vespalib::datastore::EntryRef idx) const = 0;
virtual ~IDocumentWeightAttribute() {}
diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.h b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.h
index fa962f8d469..c09366cdaea 100644
--- a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.h
@@ -32,12 +32,14 @@ public:
using EnumStoreBatchUpdater = typename EnumStore::BatchUpdater;
private:
- struct DocumentWeightAttributeAdapter : IDocumentWeightAttribute {
+ struct DocumentWeightAttributeAdapter final : IDocumentWeightAttribute {
const MultiValueNumericPostingAttribute &self;
DocumentWeightAttributeAdapter(const MultiValueNumericPostingAttribute &self_in) : self(self_in) {}
- virtual LookupResult lookup(const vespalib::string &term) const override final;
- virtual void create(vespalib::datastore::EntryRef idx, std::vector<DocumentWeightIterator> &dst) const override final;
- virtual DocumentWeightIterator create(vespalib::datastore::EntryRef idx) const override final;
+ vespalib::datastore::EntryRef get_dictionary_snapshot() const override;
+ LookupResult lookup(const vespalib::string &term, vespalib::datastore::EntryRef dictionary_snapshot) const override;
+ void collect_folded(vespalib::datastore::EntryRef enum_idx, vespalib::datastore::EntryRef dictionary_snapshot, const std::function<void(vespalib::datastore::EntryRef)>& callback) const override;
+ void create(vespalib::datastore::EntryRef idx, std::vector<DocumentWeightIterator> &dst) const override;
+ DocumentWeightIterator create(vespalib::datastore::EntryRef idx) const override;
};
DocumentWeightAttributeAdapter _document_weight_attribute_adapter;
diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp
index 283c3da00b1..1fd1cd09bea 100644
--- a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp
@@ -83,11 +83,18 @@ MultiValueNumericPostingAttribute<B, M>::getSearch(QueryTermSimpleUP qTerm,
}
template <typename B, typename M>
+vespalib::datastore::EntryRef
+MultiValueNumericPostingAttribute<B, M>::DocumentWeightAttributeAdapter::get_dictionary_snapshot() const
+{
+ const Dictionary &dictionary = self._enumStore.get_posting_dictionary();
+ return dictionary.getFrozenView().getRoot();
+}
+
+template <typename B, typename M>
IDocumentWeightAttribute::LookupResult
-MultiValueNumericPostingAttribute<B, M>::DocumentWeightAttributeAdapter::lookup(const vespalib::string &term) const
+MultiValueNumericPostingAttribute<B, M>::DocumentWeightAttributeAdapter::lookup(const vespalib::string &term, vespalib::datastore::EntryRef dictionary_snapshot) const
{
const Dictionary &dictionary = self._enumStore.get_posting_dictionary();
- const FrozenDictionary frozenDictionary(dictionary.getFrozenView());
DictionaryConstIterator dictItr(vespalib::btree::BTreeNode::Ref(), dictionary.getAllocator());
char *end = nullptr;
@@ -95,13 +102,13 @@ MultiValueNumericPostingAttribute<B, M>::DocumentWeightAttributeAdapter::lookup(
if (*end == '\0') {
auto comp = self._enumStore.make_comparator(int_term);
- dictItr.lower_bound(frozenDictionary.getRoot(), EnumIndex(), comp);
+ dictItr.lower_bound(dictionary_snapshot, EnumIndex(), comp);
if (dictItr.valid() && !comp(EnumIndex(), dictItr.getKey())) {
vespalib::datastore::EntryRef pidx(dictItr.getData());
if (pidx.valid()) {
const PostingList &plist = self.getPostingList();
auto minmax = plist.getAggregated(pidx);
- return LookupResult(pidx, plist.frozenSize(pidx), minmax.getMin(), minmax.getMax());
+ return LookupResult(pidx, plist.frozenSize(pidx), minmax.getMin(), minmax.getMax(), dictItr.getKey());
}
}
}
@@ -110,6 +117,14 @@ MultiValueNumericPostingAttribute<B, M>::DocumentWeightAttributeAdapter::lookup(
template <typename B, typename M>
void
+MultiValueNumericPostingAttribute<B, M>::DocumentWeightAttributeAdapter::collect_folded(vespalib::datastore::EntryRef enum_idx, vespalib::datastore::EntryRef dictionary_snapshot, const std::function<void(vespalib::datastore::EntryRef)>& callback)const
+{
+ (void) dictionary_snapshot;
+ callback(enum_idx);
+}
+
+template <typename B, typename M>
+void
MultiValueNumericPostingAttribute<B, M>::DocumentWeightAttributeAdapter::create(vespalib::datastore::EntryRef idx, std::vector<DocumentWeightIterator> &dst) const
{
assert(idx.valid());
diff --git a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.h b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.h
index c755c5cb649..142879f4578 100644
--- a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.h
@@ -30,12 +30,14 @@ public:
using EnumStoreBatchUpdater = typename EnumStore::BatchUpdater;
private:
- struct DocumentWeightAttributeAdapter : IDocumentWeightAttribute {
+ struct DocumentWeightAttributeAdapter final : IDocumentWeightAttribute {
const MultiValueStringPostingAttributeT &self;
DocumentWeightAttributeAdapter(const MultiValueStringPostingAttributeT &self_in) : self(self_in) {}
- virtual LookupResult lookup(const vespalib::string &term) const override final;
- virtual void create(vespalib::datastore::EntryRef idx, std::vector<DocumentWeightIterator> &dst) const override final;
- virtual DocumentWeightIterator create(vespalib::datastore::EntryRef idx) const override final;
+ vespalib::datastore::EntryRef get_dictionary_snapshot() const override;
+ LookupResult lookup(const vespalib::string &term, vespalib::datastore::EntryRef dictionary_snapshot) const override;
+ void collect_folded(vespalib::datastore::EntryRef enum_idx, vespalib::datastore::EntryRef dictionary_snapshot, const std::function<void(vespalib::datastore::EntryRef)>& callback) const override;
+ void create(vespalib::datastore::EntryRef idx, std::vector<DocumentWeightIterator> &dst) const override;
+ DocumentWeightIterator create(vespalib::datastore::EntryRef idx) const override;
};
DocumentWeightAttributeAdapter _document_weight_attribute_adapter;
diff --git a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp
index 7bc62169b3c..4263eacfa52 100644
--- a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp
@@ -99,21 +99,28 @@ MultiValueStringPostingAttributeT<B, T>::getSearch(QueryTermSimpleUP qTerm,
template <typename B, typename T>
+vespalib::datastore::EntryRef
+MultiValueStringPostingAttributeT<B, T>::DocumentWeightAttributeAdapter::get_dictionary_snapshot() const
+{
+ const Dictionary &dictionary = self._enumStore.get_posting_dictionary();
+ return dictionary.getFrozenView().getRoot();
+}
+
+template <typename B, typename T>
IDocumentWeightAttribute::LookupResult
-MultiValueStringPostingAttributeT<B, T>::DocumentWeightAttributeAdapter::lookup(const vespalib::string &term) const
+MultiValueStringPostingAttributeT<B, T>::DocumentWeightAttributeAdapter::lookup(const vespalib::string &term, vespalib::datastore::EntryRef dictionary_snapshot) const
{
const Dictionary &dictionary = self._enumStore.get_posting_dictionary();
- const FrozenDictionary frozenDictionary(dictionary.getFrozenView());
DictionaryConstIterator dictItr(vespalib::btree::BTreeNode::Ref(), dictionary.getAllocator());
auto comp = self._enumStore.make_folded_comparator(term.c_str());
- dictItr.lower_bound(frozenDictionary.getRoot(), EnumIndex(), comp);
+ dictItr.lower_bound(dictionary_snapshot, EnumIndex(), comp);
if (dictItr.valid() && !comp(EnumIndex(), dictItr.getKey())) {
vespalib::datastore::EntryRef pidx(dictItr.getData());
if (pidx.valid()) {
const PostingList &plist = self.getPostingList();
auto minmax = plist.getAggregated(pidx);
- return LookupResult(pidx, plist.frozenSize(pidx), minmax.getMin(), minmax.getMax());
+ return LookupResult(pidx, plist.frozenSize(pidx), minmax.getMin(), minmax.getMax(), dictItr.getKey());
}
}
return LookupResult();
@@ -121,6 +128,20 @@ MultiValueStringPostingAttributeT<B, T>::DocumentWeightAttributeAdapter::lookup(
template <typename B, typename T>
void
+MultiValueStringPostingAttributeT<B, T>::DocumentWeightAttributeAdapter::collect_folded(vespalib::datastore::EntryRef enum_idx, vespalib::datastore::EntryRef dictionary_snapshot, const std::function<void(vespalib::datastore::EntryRef)>& callback) const
+{
+ const Dictionary &dictionary = self._enumStore.get_posting_dictionary();
+ DictionaryConstIterator dictItr(vespalib::btree::BTreeNode::Ref(), dictionary.getAllocator());
+ auto comp = self._enumStore.make_folded_comparator();
+ dictItr.lower_bound(dictionary_snapshot, enum_idx, comp);
+ while (dictItr.valid() && !comp(enum_idx, dictItr.getKey())) {
+ callback(dictItr.getKey());
+ ++dictItr;
+ }
+}
+
+template <typename B, typename T>
+void
MultiValueStringPostingAttributeT<B, T>::DocumentWeightAttributeAdapter::create(vespalib::datastore::EntryRef idx, std::vector<DocumentWeightIterator> &dst) const
{
assert(idx.valid());
diff --git a/searchlib/src/vespa/searchlib/test/weightedchildrenverifiers.h b/searchlib/src/vespa/searchlib/test/weightedchildrenverifiers.h
index cabb108d2e1..2ef03ba97ef 100644
--- a/searchlib/src/vespa/searchlib/test/weightedchildrenverifiers.h
+++ b/searchlib/src/vespa/searchlib/test/weightedchildrenverifiers.h
@@ -63,7 +63,7 @@ public:
(void) strict;
std::vector<DocumentWeightIterator> children;
for (size_t i = 0; i < _num_children; ++i) {
- auto dict_entry = _helper.dwa().lookup(vespalib::make_string("%zu", i).c_str());
+ auto dict_entry = _helper.dwa().lookup(vespalib::make_string("%zu", i).c_str(), _helper.dwa().get_dictionary_snapshot());
_helper.dwa().create(dict_entry.posting_idx, children);
}
return create(std::move(children));