Skip to content

Commit d3c891c

Browse files
committed
plan,execution: tests,benchmarks
Signed-off-by: Michael Hoffmann <[email protected]>
1 parent ccd2596 commit d3c891c

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

engine/bench_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ func BenchmarkRangeQuery(b *testing.B) {
135135
query string
136136
storage *teststorage.TestStorage
137137
}{
138+
{
139+
name: "experiment",
140+
query: "sum(http_requests_total)",
141+
storage: sixHourDataset,
142+
},
138143
{
139144
name: "vector selector",
140145
query: "http_requests_total",
@@ -298,7 +303,6 @@ func BenchmarkRangeQuery(b *testing.B) {
298303
EnableAtModifier: true,
299304
EnableNegativeOffset: true,
300305
},
301-
SelectorBatchSize: 256,
302306
}
303307

304308
for _, tc := range cases {

engine/engine_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2671,6 +2671,16 @@ func TestInstantQuery(t *testing.T) {
26712671
query string
26722672
queryTime time.Time
26732673
}{
2674+
{
2675+
name: "experiment",
2676+
load: `load 30s
2677+
http_requests_total{pod="nginx-0", route="/"} 1+1x30
2678+
http_requests_total{pod="nginx-1", route="/"} 2+1x30
2679+
http_requests_total{pod="nginx-2", route="/"} 3+1x30
2680+
http_requests_total{pod="nginx-3", route="/"} 4+1x30`,
2681+
query: `sum(exp(http_requests_total))`,
2682+
queryTime: time.Unix(300, 0),
2683+
},
26742684
{
26752685
name: "offset and @ modifiers",
26762686
load: `load 30s

logicalplan/sharded_aggregations.go

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,23 @@ func (m ShardedAggregations) Optimize(plan parser.Expr, _ *query.Options) (parse
4646
return false
4747
}
4848
// TODO: only care about sum now
49-
if aggr.Op != parser.SUM {
49+
if aggr.Op == parser.COUNT {
5050
return false
5151
}
52-
call, ok := (*current).(*parser.Call)
53-
if !ok {
54-
return false
55-
}
56-
if len(call.Args) != 1 {
57-
return false
58-
}
59-
vs, ok := call.Args[0].(*parser.VectorSelector)
52+
vs, ok := (*current).(*parser.VectorSelector)
6053
if !ok {
6154
return false
6255
}
6356

6457
coalesce := Coalesce{make([]parser.Expr, m.Shards)}
6558
for i := range coalesce.Shards {
66-
coalesce.Shards[i] = &parser.Call{
67-
Func: call.Func,
68-
PosRange: call.PosRange,
69-
Args: []parser.Expr{vectorSelectorForShard(vs, i, m.Shards)},
59+
coalesce.Shards[i] = &parser.AggregateExpr{
60+
Op: aggr.Op,
61+
Expr: vectorSelectorForShard(vs, i, m.Shards),
62+
Param: aggr.Param,
63+
Grouping: aggr.Grouping,
64+
Without: aggr.Without,
65+
PosRange: aggr.PosRange,
7066
}
7167
}
7268

logicalplan/sharded_aggregations_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ func TestShardedAggregations(t *testing.T) {
1919
expected string
2020
}{
2121
{
22-
name: "sum exp",
23-
expr: `sum(exp(X))`,
22+
name: "sum",
23+
expr: `topk(10, X)`,
2424
expected: ``,
2525
},
2626
}

0 commit comments

Comments
 (0)