diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-04-17 09:33:53 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-06-22 12:47:00 +0000 |
commit | b56785323aaf66f1db473db130c2126ffdd76b9b (patch) | |
tree | 5b10903d9d500e2fe37cdfd8a5e078b4928c2753 /searchcore | |
parent | f323d7eadd378266f2523cf0771aa00abbcd8b0a (diff) |
Add a rank feature that will use the distribution key to provide a globally unique number.
unique = (docId << 16 | distributionKey)
Diffstat (limited to 'searchcore')
6 files changed, 20 insertions, 10 deletions
diff --git a/searchcore/src/apps/proton/proton.cpp b/searchcore/src/apps/proton/proton.cpp index 8f2be3257fc..8709b0d01b1 100644 --- a/searchcore/src/apps/proton/proton.cpp +++ b/searchcore/src/apps/proton/proton.cpp @@ -124,11 +124,9 @@ public: int64_t getGeneration() const override; }; -ProtonServiceLayerProcess::ProtonServiceLayerProcess(const config::ConfigUri & - configUri, +ProtonServiceLayerProcess::ProtonServiceLayerProcess(const config::ConfigUri & configUri, proton::Proton & proton, - PersistenceProvider * - downPersistence) + PersistenceProvider * downPersistence) : ServiceLayerProcess(configUri), _proton(proton), _metricManager(nullptr), diff --git a/searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp b/searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp index 721ee9978b0..118cad4d8ef 100644 --- a/searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp +++ b/searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp @@ -79,7 +79,7 @@ App::verify(const search::index::Schema &schema, const search::fef::Properties &props, const IConstantValueRepo &repo) { - proton::matching::IndexEnvironment indexEnv(schema, props, repo); + proton::matching::IndexEnvironment indexEnv(0, schema, props, repo); search::fef::BlueprintFactory factory; search::features::setup_search_features(factory); search::fef::test::setup_fef_test_plugin(factory); diff --git a/searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp b/searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp index 8c651c72df0..932ab6f4d14 100644 --- a/searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp +++ b/searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp @@ -42,7 +42,7 @@ struct Fixture { Fixture(Schema::UP schema_) : repo(), schema(std::move(schema_)), - env(*schema, Properties(), repo) + env(7, *schema, Properties(), repo) { } const FieldInfo *assertField(size_t idx, @@ -84,6 +84,11 @@ TEST_F("require that document meta store is always extracted in index environmen TEST_DO(f.assertHiddenAttributeField(0, "[documentmetastore]", DataType::RAW, CollectionType::SINGLE)); } +TEST_F("require that distribution key is visible in index environment", Fixture(buildEmptySchema())) +{ + ASSERT_EQUAL(7u, f.env.getDistributionKey()); +} + TEST_F("require that imported attribute fields are extracted in index environment", Fixture(buildSchema())) { ASSERT_EQUAL(3u, f.env.getNumFields()); diff --git a/searchcore/src/vespa/searchcore/proton/matching/indexenvironment.cpp b/searchcore/src/vespa/searchcore/proton/matching/indexenvironment.cpp index b86750f15ee..d6d185ccab4 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/indexenvironment.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/indexenvironment.cpp @@ -61,7 +61,8 @@ IndexEnvironment::insertField(const search::fef::FieldInfo &field) _fields.push_back(field); } -IndexEnvironment::IndexEnvironment(const search::index::Schema &schema, +IndexEnvironment::IndexEnvironment(uint32_t distributionKey, + const search::index::Schema &schema, const search::fef::Properties &props, const IConstantValueRepo &constantValueRepo) : _tableManager(), @@ -69,7 +70,8 @@ IndexEnvironment::IndexEnvironment(const search::index::Schema &schema, _fieldNames(), _fields(), _motivation(UNKNOWN), - _constantValueRepo(constantValueRepo) + _constantValueRepo(constantValueRepo), + _distributionKey(distributionKey) { _tableManager.addFactory(std::make_shared<search::fef::FunctionTableFactory>(256)); extractFields(schema); diff --git a/searchcore/src/vespa/searchcore/proton/matching/indexenvironment.h b/searchcore/src/vespa/searchcore/proton/matching/indexenvironment.h index 5696fbf2379..7da45909577 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/indexenvironment.h +++ b/searchcore/src/vespa/searchcore/proton/matching/indexenvironment.h @@ -25,6 +25,8 @@ private: std::vector<search::fef::FieldInfo> _fields; mutable FeatureMotivation _motivation; const IConstantValueRepo &_constantValueRepo; + uint32_t _distributionKey; + /** * Extract field information from the given schema and populate @@ -38,11 +40,13 @@ public: * Sets up this index environment based on the given schema and * properties. * + * @param distributionKey the distribution key for this node. * @param schema the index schema * @param props config * @param constantValueRepo repo used to access constant values for ranking **/ - IndexEnvironment(const search::index::Schema &schema, + IndexEnvironment(uint32_t distributionKey, + const search::index::Schema &schema, const search::fef::Properties &props, const IConstantValueRepo &constantValueRepo); @@ -55,6 +59,7 @@ public: void hintFeatureMotivation(FeatureMotivation motivation) const override; void hintFieldAccess(uint32_t fieldId) const override; void hintAttributeAccess(const string &name) const override; + uint32_t getDistributionKey() const override { return _distributionKey; } vespalib::eval::ConstantValue::UP getConstantValue(const vespalib::string &name) const override { return _constantValueRepo.getConstant(name); diff --git a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp index 93b4f63060f..735070002eb 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp @@ -100,7 +100,7 @@ handleGroupingSession(SessionManager &sessionMgr, GroupingContext & groupingCont Matcher::Matcher(const search::index::Schema &schema, const Properties &props, const vespalib::Clock &clock, QueryLimiter &queryLimiter, const IConstantValueRepo &constantValueRepo, uint32_t distributionKey) - : _indexEnv(schema, props, constantValueRepo), + : _indexEnv(distributionKey, schema, props, constantValueRepo), _blueprintFactory(), _rankSetup(), _viewResolver(ViewResolver::createFromSchema(schema)), |