blob: d031e1893ce98b90c201ba37dadcee5944d06482 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/vespalib/util/dual_merge_director.h>
#include <vespa/searchlib/common/rankedhit.h>
#include <vector>
namespace proton::matching {
/**
* The best hits from each match thread are put into a partial result
* and merged with results from other threads.
**/
class PartialResult : public vespalib::DualMergeDirector::Source
{
public:
using SortRef = std::pair<const char *, size_t>;
PartialResult(size_t maxSize_in, bool hasSortData_in);
PartialResult(const PartialResult &) = delete;
PartialResult & operator =(const PartialResult &) = delete;
~PartialResult() override;
size_t size() const { return _hits.size(); }
size_t maxSize() const { return _maxSize; }
size_t totalHits() const { return _totalHits; }
bool hasSortData() const { return _hasSortData; }
size_t sortDataSize() const { return _sortDataSize; }
const search::RankedHit &hit(size_t i) const { return _hits[i]; }
const SortRef &sortData(size_t i) const { return _sortData[i]; }
void totalHits(size_t th) { _totalHits = th; }
void add(const search::RankedHit &h) {
_hits.push_back(h);
}
void add(const search::RankedHit &h, const SortRef &sd) {
_hits.push_back(h);
_sortData.push_back(sd);
_sortDataSize += sd.second;
}
void merge(Source &rhs) override;
private:
std::vector<search::RankedHit> _hits;
std::vector<SortRef> _sortData;
size_t _maxSize;
size_t _totalHits;
bool _hasSortData;
size_t _sortDataSize;
};
}
|