blob: 31cd4ecee73674597caabf189d0204e3b0e252ad (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/searchlib/fef/blueprint.h>
namespace search::features {
/**
* Implements the blueprint for the unique rank feature.
*
* This will compute a globally unique id based on lid and distribution key.
* Cheap way to get deterministic ordering
* It will change if documents change lid.
*/
class GlobalSequenceBlueprint : public fef::Blueprint
{
private:
uint32_t _distributionKey;
public:
GlobalSequenceBlueprint();
void visitDumpFeatures(const fef::IIndexEnvironment & env, fef::IDumpFeatureVisitor & visitor) const override;
fef::Blueprint::UP createInstance() const override;
fef::ParameterDescriptions getDescriptions() const override {
return fef::ParameterDescriptions();
}
bool setup(const fef::IIndexEnvironment & env, const fef::ParameterList & params) override;
fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override;
static uint64_t globalSequence(uint32_t docId, uint32_t distrKey) {
return (1ul << 48) - ((uint64_t(docId) << 16)| distrKey);
}
};
}
|