Skip to content

Commit a6dd168

Browse files
committed
refactor: add typedef aliases to declutter some repeated statement of generic vectors (Predicate, Expression, Operator)
1 parent 96c6d70 commit a6dd168

35 files changed

Lines changed: 87 additions & 120 deletions

src/silo/query_engine/actions/action.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,7 @@ std::vector<schema::ColumnIdentifier> columnNamesToFields(
308308

309309
arrow::Result<QueryPlan> Action::toQueryPlanImpl(
310310
std::shared_ptr<const storage::Table> table,
311-
std::shared_ptr<std::vector<std::unique_ptr<filter::operators::Operator>>>
312-
partition_filter_operators,
311+
std::shared_ptr<filter::operators::OperatorVector> partition_filter_operators,
313312
const config::QueryOptions& query_options
314313
) {
315314
ARROW_ASSIGN_OR_RAISE(auto arrow_plan, arrow::acero::ExecPlan::Make());
@@ -326,8 +325,7 @@ arrow::Result<QueryPlan> Action::toQueryPlanImpl(
326325

327326
QueryPlan Action::toQueryPlan(
328327
std::shared_ptr<const storage::Table> table,
329-
std::shared_ptr<std::vector<std::unique_ptr<filter::operators::Operator>>>
330-
partition_filter_operators,
328+
std::shared_ptr<filter::operators::OperatorVector> partition_filter_operators,
331329
const config::QueryOptions& query_options
332330
) {
333331
auto query_plan = toQueryPlanImpl(table, partition_filter_operators, query_options);

src/silo/query_engine/actions/action.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ class Action {
5151

5252
QueryPlan toQueryPlan(
5353
std::shared_ptr<const storage::Table> table,
54-
std::shared_ptr<std::vector<std::unique_ptr<filter::operators::Operator>>>
55-
partition_filter_operators,
54+
std::shared_ptr<filter::operators::OperatorVector> partition_filter_operators,
5655
const config::QueryOptions& query_options
5756
);
5857

@@ -78,8 +77,7 @@ class Action {
7877
// If this method is not overloaded, a LegacyResultProducer will be created instead
7978
virtual arrow::Result<QueryPlan> toQueryPlanImpl(
8079
std::shared_ptr<const storage::Table> table,
81-
std::shared_ptr<std::vector<std::unique_ptr<filter::operators::Operator>>>
82-
partition_filter_operators,
80+
std::shared_ptr<filter::operators::OperatorVector> partition_filter_operators,
8381
const config::QueryOptions& query_options
8482
);
8583

src/silo/query_engine/actions/mutations.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ using silo::query_engine::filter::operators::Operator;
287287
template <typename SymbolType>
288288
arrow::Result<QueryPlan> Mutations<SymbolType>::toQueryPlanImpl(
289289
std::shared_ptr<const storage::Table> table,
290-
std::shared_ptr<std::vector<std::unique_ptr<Operator>>> partition_filter_operators,
290+
std::shared_ptr<filter::operators::OperatorVector> partition_filter_operators,
291291
const config::QueryOptions& query_options
292292
) {
293293
std::vector<std::string> sequence_names_to_evaluate;

src/silo/query_engine/actions/mutations.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ class Mutations : public Action {
102102

103103
arrow::Result<QueryPlan> toQueryPlanImpl(
104104
std::shared_ptr<const storage::Table> table,
105-
std::shared_ptr<std::vector<std::unique_ptr<filter::operators::Operator>>>
106-
partition_filter_operators,
105+
std::shared_ptr<filter::operators::OperatorVector> partition_filter_operators,
107106
const config::QueryOptions& query_options
108107
) override;
109108

src/silo/query_engine/actions/simple_select_action.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ void SimpleSelectAction::validateOrderByFields(const schema::TableSchema& schema
3333

3434
arrow::Result<QueryPlan> SimpleSelectAction::toQueryPlanImpl(
3535
std::shared_ptr<const storage::Table> table,
36-
std::shared_ptr<std::vector<std::unique_ptr<filter::operators::Operator>>>
37-
partition_filter_operators,
36+
std::shared_ptr<filter::operators::OperatorVector> partition_filter_operators,
3837
const config::QueryOptions& query_options
3938
) {
4039
validateOrderByFields(table->schema);

src/silo/query_engine/actions/simple_select_action.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ class SimpleSelectAction : public Action {
1616

1717
arrow::Result<QueryPlan> toQueryPlanImpl(
1818
std::shared_ptr<const storage::Table> table,
19-
std::shared_ptr<std::vector<std::unique_ptr<filter::operators::Operator>>>
20-
partition_filter_operators,
19+
std::shared_ptr<filter::operators::OperatorVector> partition_filter_operators,
2120
const config::QueryOptions& query_options
2221
) override;
2322
};

src/silo/query_engine/exec_node/legacy_result_producer.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ using filter::expressions::Expression;
1010
using filter::operators::Operator;
1111

1212
QueryResult createLegacyQueryResult(
13-
const std::vector<std::unique_ptr<filter::operators::Operator>>& partition_filter_operators,
13+
const filter::operators::OperatorVector& partition_filter_operators,
1414
const actions::Action* action,
1515
std::shared_ptr<const storage::Table> table
1616
) {
@@ -27,8 +27,7 @@ LegacyResultProducer::LegacyResultProducer(
2727
arrow::acero::ExecPlan* plan,
2828
const std::vector<silo::schema::ColumnIdentifier>& columns,
2929
std::shared_ptr<const storage::Table> table,
30-
std::shared_ptr<std::vector<std::unique_ptr<filter::operators::Operator>>>
31-
partition_filter_operators,
30+
std::shared_ptr<filter::operators::OperatorVector> partition_filter_operators,
3231
const actions::Action* action,
3332
size_t materialization_cutoff
3433
)

src/silo/query_engine/exec_node/legacy_result_producer.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ class LegacyResultProducer : public arrow::acero::ExecNode {
2929
arrow::acero::ExecPlan* plan,
3030
const std::vector<silo::schema::ColumnIdentifier>& columns,
3131
std::shared_ptr<const storage::Table> table,
32-
std::shared_ptr<std::vector<std::unique_ptr<filter::operators::Operator>>>
33-
partition_filter_operators,
32+
std::shared_ptr<filter::operators::OperatorVector> partition_filter_operators,
3433
const actions::Action* action,
3534
size_t materialization_cutoff
3635
);

src/silo/query_engine/exec_node/table_scan.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ class TableScan : public arrow::acero::ExecNode {
2323
std::map<schema::ColumnType, std::map<std::string, std::unique_ptr<arrow::ArrayBuilder>>>
2424
array_builders;
2525

26-
std::shared_ptr<std::vector<std::unique_ptr<filter::operators::Operator>>>
27-
partition_filter_operators;
26+
std::shared_ptr<filter::operators::OperatorVector> partition_filter_operators;
2827

2928
std::vector<silo::schema::ColumnIdentifier> output_fields;
3029
const std::shared_ptr<const storage::Table> table;
@@ -37,8 +36,7 @@ class TableScan : public arrow::acero::ExecNode {
3736
TableScan(
3837
arrow::acero::ExecPlan* plan,
3938
const std::vector<silo::schema::ColumnIdentifier>& columns,
40-
std::shared_ptr<std::vector<std::unique_ptr<filter::operators::Operator>>>
41-
partition_filter_operators,
39+
std::shared_ptr<filter::operators::OperatorVector> partition_filter_operators,
4240
std::shared_ptr<const storage::Table> table,
4341
size_t batch_size_cutoff
4442
)

src/silo/query_engine/filter/expressions/and.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525

2626
namespace silo::query_engine::filter::expressions {
2727

28-
using OperatorVector = std::vector<std::unique_ptr<operators::Operator>>;
2928
using operators::Operator;
29+
using operators::OperatorVector;
3030

31-
And::And(std::vector<std::unique_ptr<Expression>>&& children)
31+
And::And(ExpressionVector&& children)
3232
: children(std::move(children)) {}
3333

3434
std::string And::toString() const {
@@ -56,7 +56,7 @@ void inline appendVectorToVector(
5656
void logCompiledChildren(
5757
OperatorVector& non_negated_child_operators,
5858
OperatorVector& negated_child_operators,
59-
std::vector<std::unique_ptr<operators::Predicate>>& predicates
59+
operators::PredicateVector& predicates
6060
) {
6161
std::vector<std::string> child_operator_strings;
6262
std::ranges::transform(
@@ -89,12 +89,11 @@ void logCompiledChildren(
8989
}
9090
} // namespace
9191

92-
std::tuple<OperatorVector, OperatorVector, std::vector<std::unique_ptr<operators::Predicate>>> And::
93-
compileChildren(
94-
const Database& database,
95-
const storage::TablePartition& database_partition,
96-
AmbiguityMode mode
97-
) const {
92+
std::tuple<OperatorVector, OperatorVector, operators::PredicateVector> And::compileChildren(
93+
const Database& database,
94+
const storage::TablePartition& database_partition,
95+
AmbiguityMode mode
96+
) const {
9897
OperatorVector all_child_operators;
9998
std::ranges::transform(
10099
children,
@@ -105,7 +104,7 @@ std::tuple<OperatorVector, OperatorVector, std::vector<std::unique_ptr<operators
105104
);
106105
OperatorVector non_negated_child_operators;
107106
OperatorVector negated_child_operators;
108-
std::vector<std::unique_ptr<operators::Predicate>> predicates;
107+
operators::PredicateVector predicates;
109108
for (auto& child : all_child_operators) {
110109
if (child->type() == operators::FULL) {
111110
SPDLOG_TRACE("Skipping full child");
@@ -115,9 +114,7 @@ std::tuple<OperatorVector, OperatorVector, std::vector<std::unique_ptr<operators
115114
SPDLOG_TRACE("Shortcutting because found empty child");
116115
OperatorVector empty;
117116
empty.emplace_back(std::make_unique<operators::Empty>(database_partition.sequence_count));
118-
return {
119-
std::move(empty), OperatorVector(), std::vector<std::unique_ptr<operators::Predicate>>{}
120-
};
117+
return {std::move(empty), OperatorVector(), operators::PredicateVector{}};
121118
}
122119
if (child->type() == operators::INTERSECTION) {
123120
auto* intersection_child = dynamic_cast<operators::Intersection*>(child.get());
@@ -224,7 +221,7 @@ void from_json(const nlohmann::json& json, std::unique_ptr<And>& filter) {
224221
CHECK_SILO_QUERY(
225222
json["children"].is_array(), "The field 'children' in an And expression needs to be an array"
226223
);
227-
auto children = json.at("children").get<std::vector<std::unique_ptr<Expression>>>();
224+
auto children = json.at("children").get<ExpressionVector>();
228225
filter = std::make_unique<And>(std::move(children));
229226
}
230227

0 commit comments

Comments
 (0)