blob: 07d9deae020748816ca9d5a2f734a6269fb8a48f (
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "global_sequence_feature.h"
#include <vespa/vespalib/util/stash.h>
using namespace search::fef;
namespace search::features {
namespace {
/**
* Implements the executor for combining lid and distribution key to form a globally unique value.
*/
class GlobalSequenceExecutor : public fef::FeatureExecutor {
private:
uint32_t _distributionKey;
public:
GlobalSequenceExecutor(uint32_t distributionKey)
: _distributionKey(distributionKey)
{
}
void execute(uint32_t docId) override {
outputs().set_number(0, GlobalSequenceBlueprint::globalSequence(docId, _distributionKey));
}
};
}
GlobalSequenceBlueprint::GlobalSequenceBlueprint() :
Blueprint("globalSequence"),
_distributionKey(0)
{
}
void
GlobalSequenceBlueprint::visitDumpFeatures(const IIndexEnvironment &, IDumpFeatureVisitor &) const
{
}
bool
GlobalSequenceBlueprint::setup(const IIndexEnvironment & env, const ParameterList & )
{
_distributionKey = env.getDistributionKey();
assert( _distributionKey < 0x10000);
describeOutput("out", "Returns (1 << 48) - ((lid << 16) | distributionKey)");
return true;
}
Blueprint::UP
GlobalSequenceBlueprint::createInstance() const
{
return std::make_unique<GlobalSequenceBlueprint>();
}
FeatureExecutor &
GlobalSequenceBlueprint::createExecutor(const IQueryEnvironment &, vespalib::Stash &stash) const
{
return stash.create<GlobalSequenceExecutor>(_distributionKey);
}
}
|