Skip to content

Commit b845dd2

Browse files
Merge pull request #36604 from vespa-engine/johsol/spec-remove
Remove Spec and make builder of blueprint factories
2 parents 6a3f2d2 + c6722e8 commit b845dd2

6 files changed

Lines changed: 43 additions & 213 deletions

File tree

searchlib/src/tests/queryeval/iterator_benchmark/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ vespa_add_executable(searchlib_iterator_benchmark_test_app TEST
33
SOURCES
44
attribute_ctx_builder.cpp
55
benchmark_blueprint_factory.cpp
6-
benchmark_spec.cpp
6+
blueprint_factory_builder.cpp
77
common.cpp
88
disk_index_builder.cpp
99
intermediate_blueprint_factory.cpp

searchlib/src/tests/queryeval/iterator_benchmark/benchmark_spec.cpp

Lines changed: 0 additions & 115 deletions
This file was deleted.

searchlib/src/tests/queryeval/iterator_benchmark/benchmark_spec.h

Lines changed: 0 additions & 90 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
2+
3+
#include "blueprint_factory_builder.h"
4+
5+
namespace search::queryeval::test {
6+
7+
FactoryPtr term(FieldConfig field, uint32_t num_docs, uint32_t default_values_per_document, double hit_ratio) {
8+
return make_blueprint_factory(field, QueryOperator::Term, num_docs, default_values_per_document, hit_ratio, 1, false);
9+
}
10+
11+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
2+
3+
#pragma once
4+
5+
/*
6+
* Ergonomic builder pattern over blueprint factories.
7+
*/
8+
9+
#include "benchmark_blueprint_factory.h"
10+
#include "common.h"
11+
#include "intermediate_blueprint_factory.h"
12+
13+
namespace search::queryeval::test {
14+
15+
using FactoryPtr = std::shared_ptr<BenchmarkBlueprintFactory>;
16+
17+
FactoryPtr term(FieldConfig field, uint32_t num_docs, uint32_t default_values_per_document, double hit_ratio);
18+
19+
template <class... Cs>
20+
FactoryPtr and_(Cs&&... cs) {
21+
auto up = std::make_unique<AndBlueprintFactory>();
22+
(up->add_child(std::forward<Cs>(cs)), ...);
23+
return up;
24+
}
25+
26+
}

searchlib/src/tests/queryeval/iterator_benchmark/iterator_benchmark_test.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
22

33
#include "benchmark_blueprint_factory.h"
4-
#include "benchmark_spec.h"
4+
#include "blueprint_factory_builder.h"
55
#include "common.h"
66
#include "intermediate_blueprint_factory.h"
77

@@ -1102,20 +1102,18 @@ TEST(IteratorBenchmark, btree_vs_array_nonstrict_crossover) {
11021102

11031103
TEST(IteratorBenchmark, spec_factory_test) {
11041104
auto tree = and_(
1105-
term(int32_fs, 0.01),
1106-
or_(term(str_fs, 0.1), term(str_fs, 0.3)));
1105+
term(int32_fs, num_docs, 0, 0.01),
1106+
term(str_fs, num_docs, 0, 0.3));
11071107

1108-
SpecBlueprintFactory factory(std::move(tree), num_docs);
1109-
1110-
auto res = benchmark_search(factory,
1108+
auto res = benchmark_search(*tree,
11111109
num_docs + 1,
11121110
/*strict*/ true,
11131111
/*force_strict*/ false,
11141112
/*unpack_iterator*/ false,
11151113
/*filter_hit_ratio*/ 1.0,
11161114
PlanningAlgo::Cost);
11171115

1118-
std::cout << factory.get_name(/*unused*/ *factory.make_blueprint()) << "\n";
1116+
std::cout << tree->get_name(/*unused*/ *tree->make_blueprint()) << "\n";
11191117
std::cout << "time_ms=" << res.time_ms
11201118
<< " seeks=" << res.seeks
11211119
<< " hits=" << res.hits

0 commit comments

Comments
 (0)