Skip to content

Commit

Permalink
Merge pull request #32956 from vespa-engine/geirst/parameters-when-cr…
Browse files Browse the repository at this point in the history
…eating-blueprints

Rename parameter struct available when creating blueprints.
  • Loading branch information
toregge authored Nov 27, 2024
2 parents 36b8d1b + c24f1c6 commit 7ae77c0
Show file tree
Hide file tree
Showing 15 changed files with 108 additions and 106 deletions.
4 changes: 2 additions & 2 deletions searchcore/src/tests/proton/matching/matching_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1288,8 +1288,8 @@ struct AttributeBlueprintParamsFixture {
rank_properties.add(FuzzyAlgorithm::NAME, fuzzy_matching_algorithm);
}
~AttributeBlueprintParamsFixture();
AttributeBlueprintParams extract(uint32_t active_docids = 9, uint32_t docid_limit = 10) const {
return MatchToolsFactory::extract_attribute_blueprint_params(rank_setup, rank_properties, active_docids, docid_limit);
CreateBlueprintParams extract(uint32_t active_docids = 9, uint32_t docid_limit = 10) const {
return MatchToolsFactory::extract_create_blueprint_params(rank_setup, rank_properties, active_docids, docid_limit);
}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include <vespa/eval/eval/simple_value.h>
#include <vespa/eval/eval/value_codec.h>
#include <vespa/eval/eval/tensor_spec.h>
#include <vespa/eval/eval/value_codec.h>
#include <vespa/searchcore/proton/matching/requestcontext.h>
#include <vespa/searchlib/attribute/attribute_blueprint_params.h>
#include <vespa/searchlib/fef/test/indexenvironment.h>
#include <vespa/searchlib/fef/test/queryenvironment.h>
#include <vespa/vespalib/util/testclock.h>
#include <vespa/vespalib/util/simple_thread_bundle.h>
#include <vespa/searchlib/queryeval/create_blueprint_params.h>
#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/vespalib/util/simple_thread_bundle.h>
#include <vespa/vespalib/util/testclock.h>

using search::attribute::AttributeBlueprintParams;
using search::attribute::IAttributeContext;
using search::attribute::IAttributeFunctor;
using search::attribute::IAttributeVector;
using search::fef::test::IndexEnvironment;
using search::fef::test::QueryEnvironment;
using search::queryeval::CreateBlueprintParams;
using vespalib::eval::SimpleValue;
using vespalib::eval::TensorSpec;
using vespalib::eval::Value;
Expand Down Expand Up @@ -58,7 +58,7 @@ class RequestContextTest : public ::testing::Test {
_attr_ctx(),
_index_env(),
_query_env(&_index_env),
_request_ctx(_doom, _thread_bundle, _attr_ctx, _query_env, _query_env.getObjectStore(), AttributeBlueprintParams(), nullptr),
_request_ctx(_doom, _thread_bundle, _attr_ctx, _query_env, _query_env.getObjectStore(), CreateBlueprintParams(), nullptr),
_query_tensor(SimpleValue::from_spec(TensorSpec("tensor(x[2])")
.add({{"x", 0}}, 3).add({{"x", 1}}, 5)))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#include "same_element_builder.h"
#include <vespa/searchcorespi/index/indexsearchable.h>
#include <vespa/searchlib/query/tree/customtypevisitor.h>
#include <vespa/searchlib/queryeval/leaf_blueprints.h>
#include <vespa/searchlib/queryeval/intermediate_blueprints.h>
#include <vespa/searchlib/queryeval/create_blueprint_params.h>
#include <vespa/searchlib/queryeval/equiv_blueprint.h>
#include <vespa/searchlib/queryeval/get_weight_from_node.h>
#include <vespa/searchlib/attribute/attribute_blueprint_params.h>
#include <vespa/searchlib/queryeval/intermediate_blueprints.h>
#include <vespa/searchlib/queryeval/leaf_blueprints.h>
#include <vespa/vespalib/util/issue.h>

using namespace search::queryeval;
Expand Down Expand Up @@ -71,8 +71,8 @@ class BlueprintBuilderVisitor :

void buildWeakAnd(ProtonWeakAnd &n) {
auto *wand = new WeakAndBlueprint(n.getTargetNumHits(),
_requestContext.get_attribute_blueprint_params().weakand_range,
_requestContext.get_attribute_blueprint_params().weakand_stop_word_strategy,
_requestContext.get_create_blueprint_params().weakand_range,
_requestContext.get_create_blueprint_params().weakand_stop_word_strategy,
is_search_multi_threaded());
Blueprint::UP result(wand);
for (auto node : n.getChildren()) {
Expand Down
26 changes: 13 additions & 13 deletions searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@
#include "querynodes.h"
#include "rangequerylocator.h"
#include <vespa/searchcorespi/index/indexsearchable.h>
#include <vespa/searchlib/attribute/attribute_blueprint_params.h>
#include <vespa/searchlib/attribute/attribute_operation.h>
#include <vespa/searchlib/attribute/diversity.h>
#include <vespa/searchlib/queryeval/flow.h>
#include <vespa/searchlib/queryeval/wand/wand_parts.h>
#include <vespa/searchlib/engine/trace.h>
#include <vespa/searchlib/features/first_phase_rank_lookup.h>
#include <vespa/searchlib/fef/indexproperties.h>
#include <vespa/searchlib/fef/ranksetup.h>
#include <vespa/searchlib/queryeval/create_blueprint_params.h>
#include <vespa/searchlib/queryeval/flow.h>
#include <vespa/searchlib/queryeval/wand/wand_parts.h>
#include <vespa/vespalib/util/issue.h>
#include <vespa/vespalib/util/thread_bundle.h>

using search::queryeval::IDiversifier;
using search::attribute::diversity::DiversityFilter;
using search::attribute::BasicType;
using search::attribute::AttributeBlueprintParams;
using search::attribute::diversity::DiversityFilter;
using search::queryeval::CreateBlueprintParams;
using search::queryeval::ExecuteInfo;
using search::queryeval::IDiversifier;
using vespalib::Issue;

using namespace search::fef::indexproperties::matchphase;
Expand Down Expand Up @@ -183,12 +183,12 @@ MatchToolsFactory(QueryLimiter & queryLimiter,
uint32_t maxNumHits,
bool is_search)
: _queryLimiter(queryLimiter),
_attribute_blueprint_params(extract_attribute_blueprint_params(rankSetup, rankProperties, metaStore.getNumActiveLids(), searchContext.getDocIdLimit())),
_create_blueprint_params(extract_create_blueprint_params(rankSetup, rankProperties, metaStore.getNumActiveLids(), searchContext.getDocIdLimit())),
_query(),
_match_limiter(),
_queryEnv(indexEnv, attributeContext, rankProperties, searchContext.getIndexes()),
_requestContext(doom, thread_bundle, attributeContext, _queryEnv, _queryEnv.getObjectStore(),
_attribute_blueprint_params, metaStoreReadGuard),
_create_blueprint_params, metaStoreReadGuard),
_mdl(),
_rankSetup(rankSetup),
_featureOverrides(featureOverrides),
Expand Down Expand Up @@ -221,8 +221,8 @@ MatchToolsFactory(QueryLimiter & queryLimiter,
_query.fetchPostings(ExecuteInfo::create(in_flow.rate(), _requestContext.getDoom(), thread_bundle));
if (is_search) {
_query.handle_global_filter(_requestContext, searchContext.getDocIdLimit(),
_attribute_blueprint_params.global_filter_lower_limit,
_attribute_blueprint_params.global_filter_upper_limit, trace, sort_by_cost);
_create_blueprint_params.global_filter_lower_limit,
_create_blueprint_params.global_filter_upper_limit, trace, sort_by_cost);
}
_query.freeze();
trace.addEvent(5, "Prepare shared state for multi-threaded rank executors");
Expand Down Expand Up @@ -345,9 +345,9 @@ MatchToolsFactory::get_feature_rename_map() const
return _rankSetup.get_feature_rename_map();
}

AttributeBlueprintParams
MatchToolsFactory::extract_attribute_blueprint_params(const RankSetup& rank_setup, const Properties& rank_properties,
uint32_t active_docids, uint32_t docid_limit)
CreateBlueprintParams
MatchToolsFactory::extract_create_blueprint_params(const RankSetup& rank_setup, const Properties& rank_properties,
uint32_t active_docids, uint32_t docid_limit)
{
double lower_limit = GlobalFilterLowerLimit::lookup(rank_properties, rank_setup.get_global_filter_lower_limit());
double upper_limit = GlobalFilterUpperLimit::lookup(rank_properties, rank_setup.get_global_filter_upper_limit());
Expand Down
12 changes: 6 additions & 6 deletions searchcore/src/vespa/searchcore/proton/matching/match_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class MatchToolsFactory
private:
using IAttributeFunctor = search::attribute::IAttributeFunctor;
using IAttributeContext = search::attribute::IAttributeContext;
using AttributeBlueprintParams = search::attribute::AttributeBlueprintParams;
using CreateBlueprintParams = search::queryeval::CreateBlueprintParams;
using MatchDataLayout = search::fef::MatchDataLayout;
using Properties = search::fef::Properties;
using RankProgram = search::fef::RankProgram;
Expand All @@ -122,7 +122,7 @@ class MatchToolsFactory
using IDiversifier = search::queryeval::IDiversifier;
using FirstPhaseRankLookup = search::features::FirstPhaseRankLookup;
QueryLimiter & _queryLimiter;
AttributeBlueprintParams _attribute_blueprint_params;
CreateBlueprintParams _create_blueprint_params;
Query _query;
MaybeMatchPhaseLimiter::UP _match_limiter;
std::unique_ptr<RangeQueryLocator> _rangeLocator;
Expand Down Expand Up @@ -181,15 +181,15 @@ class MatchToolsFactory
const StringStringMap & get_feature_rename_map() const;

/**
* Extracts attribute blueprint parameters from the rank-profile and query.
* Extracts create blueprint parameters from the rank-profile and query.
*
* The global filter parameters are expected to be in the range [0.0, 1.0], which matches the range of the estimated hit ratio of the query.
* When searchable-copies > 1, we must scale the parameters to match the effective range of the estimated hit ratio.
* This is done by multiplying with the active hit ratio (active docids / docid limit).
*/
static AttributeBlueprintParams
extract_attribute_blueprint_params(const RankSetup& rank_setup, const Properties& rank_properties,
uint32_t active_docids, uint32_t docid_limit);
static CreateBlueprintParams
extract_create_blueprint_params(const RankSetup& rank_setup, const Properties& rank_properties,
uint32_t active_docids, uint32_t docid_limit);
FirstPhaseRankLookup* get_first_phase_rank_lookup() const noexcept { return _first_phase_rank_lookup; }
const search::IDocumentMetaStore & metaStore() const noexcept { return _metaStore; }
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ RequestContext::RequestContext(const Doom & doom,
IAttributeContext & attributeContext,
const search::fef::IQueryEnvironment& query_env,
search::fef::IObjectStore& shared_store,
const search::attribute::AttributeBlueprintParams& attribute_blueprint_params,
const search::queryeval::CreateBlueprintParams& create_blueprint_params,
const MetaStoreReadGuardSP * metaStoreReadGuard)
: _doom(doom),
_thread_bundle(thread_bundle_in),
_attributeContext(attributeContext),
_query_env(query_env),
_shared_store(shared_store),
_attribute_blueprint_params(attribute_blueprint_params),
_create_blueprint_params(create_blueprint_params),
_metaStoreReadGuard(metaStoreReadGuard)
{ }

Expand Down
12 changes: 6 additions & 6 deletions searchcore/src/vespa/searchcore/proton/matching/requestcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#pragma once

#include <vespa/eval/eval/value.h>
#include <vespa/searchlib/queryeval/irequestcontext.h>
#include <vespa/searchcommon/attribute/iattributecontext.h>
#include <vespa/searchlib/attribute/attribute_blueprint_params.h>
#include <vespa/searchlib/queryeval/create_blueprint_params.h>
#include <vespa/searchlib/queryeval/irequestcontext.h>
#include <vespa/vespalib/util/doom.h>

namespace search::fef {
Expand All @@ -27,7 +27,7 @@ class RequestContext : public search::queryeval::IRequestContext,
IAttributeContext& attributeContext,
const search::fef::IQueryEnvironment& query_env,
search::fef::IObjectStore& shared_store,
const search::attribute::AttributeBlueprintParams& attribute_blueprint_params,
const search::queryeval::CreateBlueprintParams& create_blueprint_params,
const MetaStoreReadGuardSP * metaStoreReadGuard);

const Doom & getDoom() const override { return _doom; }
Expand All @@ -39,8 +39,8 @@ class RequestContext : public search::queryeval::IRequestContext,

const vespalib::eval::Value* get_query_tensor(const std::string& tensor_name) const override;

const search::attribute::AttributeBlueprintParams& get_attribute_blueprint_params() const override {
return _attribute_blueprint_params;
const search::queryeval::CreateBlueprintParams& get_create_blueprint_params() const override {
return _create_blueprint_params;
}
const MetaStoreReadGuardSP * getMetaStoreReadGuard() const override {
return _metaStoreReadGuard;
Expand All @@ -52,7 +52,7 @@ class RequestContext : public search::queryeval::IRequestContext,
IAttributeContext & _attributeContext;
const search::fef::IQueryEnvironment & _query_env;
search::fef::IObjectStore & _shared_store;
search::attribute::AttributeBlueprintParams _attribute_blueprint_params;
search::queryeval::CreateBlueprintParams _create_blueprint_params;
const MetaStoreReadGuardSP * _metaStoreReadGuard;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ using TermMap = vespalib::hash_set<std::string>;
namespace {
class WarmupRequestContext : public IRequestContext {
using IAttributeVector = search::attribute::IAttributeVector;
using AttributeBlueprintParams = search::attribute::AttributeBlueprintParams;
using CreateBlueprintParams = search::queryeval::CreateBlueprintParams;
public:
explicit WarmupRequestContext();
~WarmupRequestContext() override;
Expand All @@ -42,10 +42,10 @@ class WarmupRequestContext : public IRequestContext {
const IAttributeVector *getAttribute(std::string_view) const override { return nullptr; }
const IAttributeVector *getAttributeStableEnum(std::string_view) const override { return nullptr; }
const vespalib::eval::Value* get_query_tensor(const std::string&) const override;
const AttributeBlueprintParams& get_attribute_blueprint_params() const override { return _params; }
const CreateBlueprintParams& get_create_blueprint_params() const override { return _params; }
const MetaStoreReadGuardSP * getMetaStoreReadGuard() const override { return nullptr; }
private:
const AttributeBlueprintParams _params;
const CreateBlueprintParams _params;
};
class WarmupTask : public vespalib::Executor::Task {
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "isearchableindexcollection.h"
#include "warmupconfig.h"
#include <vespa/searchlib/attribute/attribute_blueprint_params.h>
#include <vespa/searchlib/queryeval/create_blueprint_params.h>
#include <vespa/vespalib/util/doom.h>
#include <vespa/vespalib/util/executor.h>
#include <vespa/vespalib/util/monitored_refcount.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "attribute_blueprint_factory.h"
#include "attribute_blueprint_params.h"
#include "attribute_object_visitor.h"
#include "attribute_weighted_set_blueprint.h"
#include "direct_multi_term_blueprint.h"
Expand All @@ -19,6 +18,7 @@
#include <vespa/searchlib/query/query_term_ucs4.h>
#include <vespa/searchlib/query/tree/stackdumpcreator.h>
#include <vespa/searchlib/queryeval/andsearchstrict.h>
#include <vespa/searchlib/queryeval/create_blueprint_params.h>
#include <vespa/searchlib/queryeval/create_blueprint_visitor_helper.h>
#include <vespa/searchlib/queryeval/dot_product_blueprint.h>
#include <vespa/searchlib/queryeval/dot_product_search.h>
Expand Down Expand Up @@ -74,6 +74,7 @@ using search::queryeval::AndBlueprint;
using search::queryeval::AndSearchStrict;
using search::queryeval::Blueprint;
using search::queryeval::ComplexLeafBlueprint;
using search::queryeval::CreateBlueprintParams;
using search::queryeval::CreateBlueprintVisitorHelper;
using search::queryeval::DotProductBlueprint;
using search::queryeval::FieldSpec;
Expand Down Expand Up @@ -621,7 +622,7 @@ class CreateBlueprintVisitor : public CreateBlueprintVisitorHelper
template <class TermNode>
void visitTerm(TermNode &n) {
SearchContextParams scParams = createContextParams(_field.isFilter());
scParams.fuzzy_matching_algorithm(getRequestContext().get_attribute_blueprint_params().fuzzy_matching_algorithm);
scParams.fuzzy_matching_algorithm(getRequestContext().get_create_blueprint_params().fuzzy_matching_algorithm);
const string stack = StackDumpCreator::create(n);
setResult(std::make_unique<AttributeFieldBlueprint>(_field, _attr, stack, scParams));
}
Expand Down Expand Up @@ -765,7 +766,7 @@ class CreateBlueprintVisitor : public CreateBlueprintVisitorHelper
}
try {
auto calc = tensor::DistanceCalculator::make_with_validation(_attr, *query_tensor);
const auto& params = getRequestContext().get_attribute_blueprint_params();
const auto& params = getRequestContext().get_create_blueprint_params();
setResult(std::make_unique<queryeval::NearestNeighborBlueprint>(_field,
std::move(calc),
n.get_target_num_hits(),
Expand Down

This file was deleted.

Loading

0 comments on commit 7ae77c0

Please sign in to comment.