@@ -2,6 +2,7 @@ package logql
2
2
3
3
import (
4
4
"container/heap"
5
+ "context"
5
6
"fmt"
6
7
"slices"
7
8
"strings"
@@ -322,7 +323,7 @@ type CountMinSketchVectorStepEvaluator struct {
322
323
buffer []byte
323
324
}
324
325
325
- var _ StepEvaluator = NewQuantileSketchVectorStepEvaluator (nil , 0 )
326
+ var _ StepEvaluator = NewCountMinSketchVectorStepEvaluator (nil )
326
327
327
328
func NewCountMinSketchVectorStepEvaluator (vec * CountMinSketchVector ) * CountMinSketchVectorStepEvaluator {
328
329
return & CountMinSketchVectorStepEvaluator {
@@ -357,3 +358,45 @@ func (e *CountMinSketchVectorStepEvaluator) Next() (bool, int64, StepResult) {
357
358
func (* CountMinSketchVectorStepEvaluator ) Close () error { return nil }
358
359
359
360
func (* CountMinSketchVectorStepEvaluator ) Error () error { return nil }
361
+
362
+ var _ StepEvaluator = (* CountMinSketchEvalStepEvaluator )(nil )
363
+
364
+ // CountMinSketchEvalStepEvaluator transforms a CountMinSketchEvalExpr into a CountMinSketchVector.
365
+ type CountMinSketchEvalStepEvaluator struct {
366
+ ctx context.Context
367
+ nextEvFactory SampleEvaluatorFactory
368
+ expr * CountMinSketchEvalExpr
369
+ params Params
370
+ }
371
+
372
+ func NewCountMinSketchEvalStepEvaluator (ctx context.Context , nextEvFactory SampleEvaluatorFactory , expr * CountMinSketchEvalExpr , params Params ) (* CountMinSketchEvalStepEvaluator , error ) {
373
+ return & CountMinSketchEvalStepEvaluator {
374
+ ctx : ctx ,
375
+ nextEvFactory : nextEvFactory ,
376
+ expr : expr ,
377
+ params : params ,
378
+ }, nil
379
+ }
380
+
381
+ func (e * CountMinSketchEvalStepEvaluator ) Next () (bool , int64 , StepResult ) {
382
+ nextEv , err := e .nextEvFactory .NewStepEvaluator (e .ctx , e .nextEvFactory , e .expr .SampleExpr , e .params )
383
+ if err != nil {
384
+ return false , 0 , CountMinSketchVector {}
385
+ }
386
+
387
+ ok , _ , results := nextEv .Next ()
388
+ if ! ok {
389
+ return false , 0 , CountMinSketchVector {}
390
+ }
391
+
392
+ data := results .CountMinSketchVec ()
393
+ handler := NewCountMinSketchVectorStepEvaluator (& data )
394
+
395
+ return handler .Next ()
396
+ }
397
+
398
+ func (* CountMinSketchEvalStepEvaluator ) Close () error { return nil }
399
+
400
+ func (* CountMinSketchEvalStepEvaluator ) Error () error { return nil }
401
+
402
+ func (e * CountMinSketchEvalStepEvaluator ) Explain (_ Node ) {}
0 commit comments