Skip to content

Commit fc0be7e

Browse files
more refactor
1 parent 9295c8e commit fc0be7e

1 file changed

Lines changed: 10 additions & 21 deletions

File tree

asap-query-engine/src/engines/simple_engine.rs

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,21 +1333,14 @@ impl SimpleEngine {
13331333
rhs: f64,
13341334
) -> f64 {
13351335
use promql_parser::parser::token::{T_ADD, T_DIV, T_MOD, T_MUL, T_POW, T_SUB};
1336-
let id = op.id();
1337-
if id == T_ADD {
1338-
lhs + rhs
1339-
} else if id == T_SUB {
1340-
lhs - rhs
1341-
} else if id == T_MUL {
1342-
lhs * rhs
1343-
} else if id == T_DIV {
1344-
lhs / rhs
1345-
} else if id == T_MOD {
1346-
lhs % rhs
1347-
} else if id == T_POW {
1348-
lhs.powf(rhs)
1349-
} else {
1350-
f64::NAN
1336+
match op.id() {
1337+
id if id == T_ADD => lhs + rhs,
1338+
id if id == T_SUB => lhs - rhs,
1339+
id if id == T_MUL => lhs * rhs,
1340+
id if id == T_DIV => lhs / rhs,
1341+
id if id == T_MOD => lhs % rhs,
1342+
id if id == T_POW => lhs.powf(rhs),
1343+
_ => f64::NAN,
13511344
}
13521345
}
13531346

@@ -2849,9 +2842,7 @@ impl SimpleEngine {
28492842
}
28502843

28512844
// Try to use optimized batch merge for KLL accumulators
2852-
if !accumulators.is_empty()
2853-
&& accumulators[0].get_accumulator_type() == AggregationType::DatasketchesKLL
2854-
{
2845+
if accumulators[0].get_accumulator_type() == AggregationType::DatasketchesKLL {
28552846
use crate::precompute_operators::datasketches_kll_accumulator::DatasketchesKLLAccumulator;
28562847

28572848
match DatasketchesKLLAccumulator::merge_multiple(accumulators) {
@@ -2867,9 +2858,7 @@ impl SimpleEngine {
28672858
}
28682859

28692860
// Try to use optimized batch merge for CountMinSketch accumulators
2870-
if !accumulators.is_empty()
2871-
&& accumulators[0].get_accumulator_type() == AggregationType::CountMinSketch
2872-
{
2861+
if accumulators[0].get_accumulator_type() == AggregationType::CountMinSketch {
28732862
use crate::precompute_operators::count_min_sketch_accumulator::CountMinSketchAccumulator;
28742863

28752864
match CountMinSketchAccumulator::merge_multiple(accumulators) {

0 commit comments

Comments
 (0)