Skip to content

Commit

Permalink
expr.NewAggregatorExpr: pass in zed.Context (#5063)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattnibs authored Mar 5, 2024
1 parent b36c7bf commit 38763f8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion compiler/kernel/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (b *Builder) compileExpr(e dag.Expr) (expr.Evaluator, error) {
if err != nil {
return nil, err
}
return expr.NewAggregatorExpr(agg), nil
return expr.NewAggregatorExpr(b.zctx(), agg), nil
case *dag.OverExpr:
return b.compileOverExpr(e)
default:
Expand Down
5 changes: 2 additions & 3 deletions runtime/sam/expr/agg.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func (a *Aggregator) Apply(zctx *zed.Context, ectx Context, f agg.Function, this
// NewAggregatorExpr returns an Evaluator from agg. The returned Evaluator
// retains the same functionality of the aggregation only it returns it's
// current state every time a new value is consumed.
func NewAggregatorExpr(agg *Aggregator) Evaluator {
return &aggregatorExpr{agg: agg}
func NewAggregatorExpr(zctx *zed.Context, agg *Aggregator) Evaluator {
return &aggregatorExpr{agg: agg, zctx: zctx}
}

type aggregatorExpr struct {
Expand All @@ -63,7 +63,6 @@ var _ Evaluator = (*aggregatorExpr)(nil)
func (s *aggregatorExpr) Eval(ectx Context, val zed.Value) zed.Value {
if s.fn == nil {
s.fn = s.agg.NewFunction()
s.zctx = zed.NewContext() //XXX
}
s.agg.Apply(s.zctx, ectx, s.fn, val)
return s.fn.Result(s.zctx)
Expand Down

0 comments on commit 38763f8

Please sign in to comment.