summaryrefslogtreecommitdiffstats
path: root/searchcore/src
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@oath.com>2018-05-22 21:29:12 +0200
committerHenning Baldersheim <balder@oath.com>2018-05-23 23:21:04 +0200
commit69aae49a30dc657dfa5a603701ffe4ad231ea92f (patch)
tree9f2e743a208b1d2751b350f9d7ee5e8e274cb2de /searchcore/src
parentff2138aa963c5f7147779057465d97c3d22a7028 (diff)
Refactored to allow iteration over matching elements.
Diffstat (limited to 'searchcore/src')
-rw-r--r--searchcore/src/vespa/searchcore/proton/documentmetastore/search_context.cpp49
-rw-r--r--searchcore/src/vespa/searchcore/proton/documentmetastore/search_context.h16
2 files changed, 23 insertions, 42 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/search_context.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/search_context.cpp
index 068b7f4fa00..99865f6bd44 100644
--- a/searchcore/src/vespa/searchcore/proton/documentmetastore/search_context.cpp
+++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/search_context.cpp
@@ -12,15 +12,14 @@ using search::QueryTermSimple;
using search::fef::TermFieldMatchData;
using search::queryeval::SearchIterator;
-namespace proton {
-namespace documentmetastore {
+namespace proton::documentmetastore {
namespace {
class GidAllSearchIterator : public AttributeIteratorBase
{
private:
- virtual void
+ void
doSeek(uint32_t docId) override
{
if (_store.validLidFast(docId)) {
@@ -28,7 +27,7 @@ private:
}
}
- virtual void
+ void
doUnpack(uint32_t docId) override
{
_matchData->reset(docId);
@@ -37,8 +36,7 @@ private:
protected:
const DocumentMetaStore & _store;
public:
- GidAllSearchIterator(TermFieldMatchData *matchData,
- const DocumentMetaStore &store)
+ GidAllSearchIterator(TermFieldMatchData *matchData, const DocumentMetaStore &store)
: AttributeIteratorBase(matchData),
_store(store)
{
@@ -79,7 +77,7 @@ class GidSearchIterator : public GidAllSearchIterator
private:
const GlobalId & _gid;
- virtual void
+ void
doSeek(uint32_t docId) override
{
AttributeVector::DocId lid = 0;
@@ -90,9 +88,7 @@ private:
}
}
public:
- GidSearchIterator(TermFieldMatchData *matchData,
- const DocumentMetaStore &store,
- const GlobalId &gid)
+ GidSearchIterator(TermFieldMatchData *matchData, const DocumentMetaStore &store, const GlobalId &gid)
: GidAllSearchIterator(matchData, store),
_gid(gid)
{
@@ -101,23 +97,16 @@ public:
}
-bool
-SearchContext::onCmp(DocId docId, int32_t &weight) const
+int32_t
+SearchContext::onCmp(DocId, int32_t, int32_t &) const
{
- (void) docId;
- (void) weight;
- throw vespalib::IllegalStateException(
- "The function is not implemented for documentmetastore::SearchContext");
- return false;
+ throw vespalib::IllegalStateException("The function is not implemented for documentmetastore::SearchContext");
}
-bool
-SearchContext::onCmp(DocId docId) const
+int32_t
+SearchContext::onCmp(DocId, int32_t ) const
{
- (void) docId;
- throw vespalib::IllegalStateException(
- "The function is not implemented for documentmetastore::SearchContext");
- return false;
+ throw vespalib::IllegalStateException("The function is not implemented for documentmetastore::SearchContext");
}
unsigned int
@@ -127,15 +116,13 @@ SearchContext::approximateHits() const
}
SearchIterator::UP
-SearchContext::createIterator(TermFieldMatchData *matchData,
- bool strict)
+SearchContext::createIterator(TermFieldMatchData *matchData, bool strict)
{
return _isWord
- ? SearchIterator::UP(new GidSearchIterator(matchData, getStore(), _gid))
+ ? std::make_unique<GidSearchIterator>(matchData, getStore(), _gid)
: strict
- ? SearchIterator::UP(new GidStrictAllSearchIterator(matchData,
- getStore()))
- : SearchIterator::UP(new GidAllSearchIterator(matchData, getStore()));
+ ? std::make_unique<GidStrictAllSearchIterator>(matchData, getStore())
+ : std::make_unique<GidAllSearchIterator>(matchData, getStore());
}
const DocumentMetaStore &
@@ -144,12 +131,10 @@ SearchContext::getStore() const
return static_cast<const DocumentMetaStore &>(attribute());
}
-SearchContext::SearchContext(QueryTermSimple::UP qTerm,
- const DocumentMetaStore &toBeSearched)
+SearchContext::SearchContext(QueryTermSimple::UP qTerm, const DocumentMetaStore &toBeSearched)
: search::AttributeVector::SearchContext(toBeSearched),
_isWord(qTerm->isWord())
{
}
}
-}
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/search_context.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/search_context.h
index afd09be43e9..6e1eaa468c9 100644
--- a/searchcore/src/vespa/searchcore/proton/documentmetastore/search_context.h
+++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/search_context.h
@@ -6,8 +6,7 @@
#include <vespa/searchlib/attribute/attributevector.h>
#include "documentmetastore.h"
-namespace proton {
-namespace documentmetastore {
+namespace proton::documentmetastore {
/**
* Search context used to search the document meta store for all valid documents.
@@ -15,14 +14,14 @@ namespace documentmetastore {
class SearchContext : public search::AttributeVector::SearchContext
{
private:
- typedef search::AttributeVector::DocId DocId;
+ using DocId = search::AttributeVector::DocId;
bool _isWord;
document::GlobalId _gid;
unsigned int approximateHits() const override;
- bool onCmp(DocId docId, int32_t &weight) const override;
- bool onCmp(DocId docId) const override;
+ int32_t onCmp(DocId docId, int32_t elemId, int32_t &weight) const override;
+ int32_t onCmp(DocId docId, int32_t elemId) const override;
search::queryeval::SearchIterator::UP
createIterator(search::fef::TermFieldMatchData *matchData, bool strict) override;
@@ -30,10 +29,7 @@ private:
const DocumentMetaStore &getStore() const;
public:
- SearchContext(std::unique_ptr<search::QueryTermSimple> qTerm,
- const DocumentMetaStore &toBeSearched);
+ SearchContext(std::unique_ptr<search::QueryTermSimple> qTerm, const DocumentMetaStore &toBeSearched);
};
-} // namespace documentmetastore
-} // namespace proton
-
+}