summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@oath.com>2018-08-22 19:41:04 +0200
committerHenning Baldersheim <balder@oath.com>2018-08-22 19:41:04 +0200
commitf50549ea6d85de718634ead271ea30e5000b862e (patch)
treec1d4b8ef95d962fbf8d59e8773fb391a87897561 /searchcore
parent8679e520ae91268f9fd5345cd647b7819df93d01 (diff)
Avoid depending of ResultSet. Use more simpler types. Also remove some unused code and hide some implementation details.
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/attribute_operation.cpp26
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/attribute_operation.h7
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp4
3 files changed, 18 insertions, 19 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/attribute_operation.cpp b/searchcore/src/vespa/searchcore/proton/matching/attribute_operation.cpp
index 92a3331f8c3..0f3aa3c6c71 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/attribute_operation.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/attribute_operation.cpp
@@ -2,7 +2,6 @@
#include "attribute_operation.h"
#include <vespa/searchlib/attribute/singlenumericattribute.h>
-#include <vespa/searchlib/common/resultset.h>
#include <vespa/searchlib/common/bitvector.h>
#include <vespa/searchcommon/attribute/basictype.h>
#include <vespa/vespalib/util/exceptions.h>
@@ -102,7 +101,7 @@ struct UpdateFast {
template <typename OP>
class OperateOverResultSet : public AttributeOperation {
public:
- OperateOverResultSet(std::unique_ptr<search::ResultSet> result, typename OP::F::V operand)
+ OperateOverResultSet(FullResult && result, typename OP::F::V operand)
: _operand(operand),
_result(std::move(result))
{}
@@ -110,17 +109,17 @@ public:
void operator()(const search::AttributeVector &attributeVector) override {
OP op(const_cast<search::AttributeVector &>(attributeVector), _operand);
if (op.valid()) {
- search::RankedHit *hits = _result->getArray();
- size_t numHits = _result->getArrayUsed();
+ const search::RankedHit *hits = &_result.second[0];
+ size_t numHits = _result.second.size();
std::for_each(hits, hits+numHits, [&op](search::RankedHit hit) { op(hit.getDocId()); });
- if (_result->getBitOverflow()) {
- _result->getBitOverflow()->foreach_truebit([&op](uint32_t docId) { op(docId); });
+ if (_result.first) {
+ _result.first->foreach_truebit([&op](uint32_t docId) { op(docId); });
}
}
}
private:
typename OP::F::V _operand;
- std::unique_ptr<search::ResultSet> _result;
+ FullResult _result;
};
template<typename OP>
@@ -224,7 +223,7 @@ createOperation(std::vector<AttributeOperation::Hit> vector, T operand) {
template<typename T, typename OP>
std::unique_ptr<AttributeOperation>
-createOperation(std::unique_ptr<search::ResultSet> result, T operand) {
+createOperation(AttributeOperation::FullResult && result, T operand) {
return std::make_unique<OperateOverResultSet<OP>>(std::move(result), operand);
}
@@ -325,22 +324,19 @@ Operation::create(BasicType type, V hits) const {
std::unique_ptr<AttributeOperation>
AttributeOperation::create(BasicType type, const vespalib::string & operation, std::vector<uint32_t> docs) {
Operation op = Operation::create(operation);
- using R = std::vector<uint32_t>;
- return op.create<R>(type, std::move(docs));
+ return op.create<std::vector<uint32_t>>(type, std::move(docs));
}
std::unique_ptr<AttributeOperation>
AttributeOperation::create(BasicType type, const vespalib::string & operation, std::vector<Hit> docs) {
Operation op = Operation::create(operation);
- using R = std::vector<Hit>;
- return op.create<R>(type, std::move(docs));
+ return op.create<std::vector<Hit>>(type, std::move(docs));
}
std::unique_ptr<AttributeOperation>
-AttributeOperation::create(BasicType type, const vespalib::string & operation, std::unique_ptr<search::ResultSet> docs) {
+AttributeOperation::create(BasicType type, const vespalib::string & operation, FullResult && docs) {
Operation op = Operation::create(operation);
- using R = std::unique_ptr<search::ResultSet>;
- return op.create<R>(type, std::move(docs));
+ return op.create<FullResult>(type, std::move(docs));
}
}
diff --git a/searchcore/src/vespa/searchcore/proton/matching/attribute_operation.h b/searchcore/src/vespa/searchcore/proton/matching/attribute_operation.h
index 9295ca9b855..dd1594a5687 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/attribute_operation.h
+++ b/searchcore/src/vespa/searchcore/proton/matching/attribute_operation.h
@@ -3,22 +3,25 @@
#pragma once
#include <vespa/searchcore/proton/attribute/i_attribute_functor.h>
+#include <vespa/searchlib/common/rankedhit.h>
#include <vespa/searchcommon/attribute/basictype.h>
+#include <vespa/vespalib/util/array.h>
#include <vector>
-namespace search { class ResultSet; }
+namespace search { class BitVector; }
namespace proton::matching {
class AttributeOperation : public IAttributeFunctor {
public:
using Hit = std::pair<uint32_t, double>;
+ using FullResult = std::pair<std::unique_ptr<search::BitVector>, vespalib::Array<search::RankedHit>>;
static std::unique_ptr<AttributeOperation>
create(search::attribute::BasicType type, const vespalib::string & operation, std::vector<uint32_t> docIds);
static std::unique_ptr<AttributeOperation>
create(search::attribute::BasicType type, const vespalib::string & operation, std::vector<Hit> hits);
static std::unique_ptr<AttributeOperation>
- create(search::attribute::BasicType type, const vespalib::string & operation, std::unique_ptr<search::ResultSet> result);
+ create(search::attribute::BasicType type, const vespalib::string & operation, FullResult && result);
};
}
diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp
index 3c9f57dc02b..9b5f898495c 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp
@@ -303,7 +303,7 @@ MatchThread::processResult(const Doom & hardDoom,
}
if (hardDoom.doom()) return;
size_t totalHits = result->getNumHits();
- search::RankedHit *hits = result->getArray();
+ const search::RankedHit *hits = result->getArray();
size_t numHits = result->getArrayUsed();
search::BitVector *bits = result->getBitOverflow();
if (bits != nullptr && hits != nullptr) {
@@ -316,7 +316,7 @@ MatchThread::processResult(const Doom & hardDoom,
}
if (hardDoom.doom()) return;
size_t sortLimit = hasGrouping ? numHits : context.result->maxSize();
- context.sort->sorter->sortResults(hits, numHits, sortLimit);
+ result->sort(*context.sort->sorter, sortLimit);
if (hardDoom.doom()) return;
if (hasGrouping) {
search::grouping::GroupingManager man(*context.grouping);