blob: 6cd186cf391ece295f93c361dc162b303f9e605b (
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 Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "flush_all_strategy.h"
#include <algorithm>
using search::SerialNum;
using searchcorespi::IFlushTarget;
namespace proton {
namespace {
class CompareTarget
{
public:
bool
operator ()(const FlushContext::SP &lfc,
const FlushContext::SP &rfc) const;
};
bool
CompareTarget::operator()(const FlushContext::SP &lfc,
const FlushContext::SP &rfc) const
{
const IFlushTarget &lhs = *lfc->getTarget();
const IFlushTarget &rhs = *rfc->getTarget();
// Note: This assumes that last flush time is stable while doing sort
return lhs.getLastFlushTime() < rhs.getLastFlushTime();
}
}
FlushAllStrategy::FlushAllStrategy()
{
}
FlushContext::List
FlushAllStrategy::getFlushTargets(const FlushContext::List &targetList,
const flushengine::TlsStatsMap&,
const flushengine::ActiveFlushStats&) const
{
if (targetList.empty()) {
return {};
}
FlushContext::List fv(targetList);
std::sort(fv.begin(), fv.end(), CompareTarget());
return fv;
}
} // namespace proton
|