aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeir Storli <geirstorli@yahoo.no>2017-08-25 15:45:45 +0200
committerGitHub <noreply@github.com>2017-08-25 15:45:45 +0200
commit83d657ff273250f436227a89b1e31982ac14eade (patch)
treeb1b53ceb2acda0e4d8816f92c928b9b499812172
parent4e9024298277da258fb15629994e67a69033ec6a (diff)
parentf526a00fe6db2afccbde7a74f77531b1a7c12d24 (diff)
Merge pull request #3222 from vespa-engine/toregge/add-boundary-check-when-mapping-to-referenced-lid
Add boundary check when mapping to referenced lid, to avoid
-rw-r--r--searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp9
-rw-r--r--searchlib/src/vespa/searchlib/attribute/imported_search_context.h18
2 files changed, 14 insertions, 13 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp b/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp
index b0ac12ce8f9..0834df280fd 100644
--- a/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp
@@ -33,6 +33,7 @@ ImportedSearchContext::ImportedSearchContext(
_target_attribute(*_imported_attribute.getTargetAttribute()),
_target_search_context(_target_attribute.getSearch(std::move(term), params)),
_referencedLids(_reference_attribute.getReferencedLids()),
+ _referencedLidLimit(_target_attribute.getCommittedDocIdLimit()),
_merger(_reference_attribute.getCommittedDocIdLimit()),
_fetchPostingsDone(false)
{
@@ -190,13 +191,5 @@ const vespalib::string& ImportedSearchContext::attributeName() const {
return _imported_attribute.getName();
}
-bool ImportedSearchContext::cmp(DocId docId, int32_t& weight) const {
- return _target_search_context->cmp(_referencedLids[docId], weight);
-}
-
-bool ImportedSearchContext::cmp(DocId docId) const {
- return _target_search_context->cmp(_referencedLids[docId]);
-}
-
} // attribute
} // search
diff --git a/searchlib/src/vespa/searchlib/attribute/imported_search_context.h b/searchlib/src/vespa/searchlib/attribute/imported_search_context.h
index 9be4578fac0..c142754e302 100644
--- a/searchlib/src/vespa/searchlib/attribute/imported_search_context.h
+++ b/searchlib/src/vespa/searchlib/attribute/imported_search_context.h
@@ -35,9 +35,15 @@ class ImportedSearchContext : public ISearchContext {
const AttributeVector& _target_attribute;
std::unique_ptr<AttributeVector::SearchContext> _target_search_context;
ReferencedLids _referencedLids;
+ uint32_t _referencedLidLimit;
PostingListMerger<int32_t> _merger;
bool _fetchPostingsDone;
+ uint32_t getReferencedLid(uint32_t lid) const {
+ uint32_t referencedLid = _referencedLids[lid];
+ return ((referencedLid >= _referencedLidLimit) ? 0u : referencedLid);
+ }
+
void makeMergedPostings();
public:
ImportedSearchContext(std::unique_ptr<QueryTermSimple> term,
@@ -62,8 +68,13 @@ public:
using DocId = IAttributeVector::DocId;
- bool cmp(DocId docId, int32_t& weight) const;
- bool cmp(DocId docId) const;
+ bool cmp(DocId docId, int32_t& weight) const {
+ return _target_search_context->cmp(getReferencedLid(docId), weight);
+ }
+
+ bool cmp(DocId docId) const {
+ return _target_search_context->cmp(getReferencedLid(docId));
+ }
const ReferenceAttribute& attribute() const noexcept { return _reference_attribute; }
@@ -74,6 +85,3 @@ public:
} // attribute
} // search
-
-
-