Skip to content

Commit

Permalink
Refactor the time function name
Browse files Browse the repository at this point in the history
Signed-off-by: Jon Kartago Lamida <[email protected]>
  • Loading branch information
lamida committed Jan 22, 2025
1 parent bcddf7a commit 2cf7ef4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pkg/streamingpromql/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TimeFunctionOperatorFactory(name string, f functions.FunctionOverInstantVec

} else {
// if the argument is not provided, it will default to vector(time())
inner = scalars.NewScalarToInstantVector(functions.NewScalarTime(timeRange, memoryConsumptionTracker, expressionPosition), expressionPosition)
inner = scalars.NewScalarToInstantVector(functions.NewTime(timeRange, memoryConsumptionTracker, expressionPosition), expressionPosition)
}

var o types.InstantVectorOperator = functions.NewFunctionOverInstantVector(inner, nil, memoryConsumptionTracker, f, expressionPosition, timeRange)
Expand Down Expand Up @@ -489,7 +489,7 @@ func timeOperatorFactory(args []types.Operator, memoryConsumptionTracker *limiti
return nil, fmt.Errorf("expected exactly 0 arguments for time, got %v", len(args))
}

return functions.NewScalarTime(timeRange, memoryConsumptionTracker, expressionPosition), nil
return functions.NewTime(timeRange, memoryConsumptionTracker, expressionPosition), nil
}

func instantVectorToScalarOperatorFactory(args []types.Operator, memoryConsumptionTracker *limiting.MemoryConsumptionTracker, _ *annotations.Annotations, expressionPosition posrange.PositionRange, timeRange types.QueryTimeRange) (types.ScalarOperator, error) {
Expand Down
16 changes: 8 additions & 8 deletions pkg/streamingpromql/operators/functions/times.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,27 @@ import (
"github.com/grafana/mimir/pkg/streamingpromql/types"
)

type ScalarTime struct {
type Time struct {
TimeRange types.QueryTimeRange
MemoryConsumptionTracker *limiting.MemoryConsumptionTracker
expressionPosition posrange.PositionRange
}

var _ types.ScalarOperator = &ScalarTime{}
var _ types.ScalarOperator = &Time{}

func NewScalarTime(
func NewTime(
timeRange types.QueryTimeRange,
memoryConsumptionTracker *limiting.MemoryConsumptionTracker,
expressionPosition posrange.PositionRange,
) *ScalarTime {
return &ScalarTime{
) *Time {
return &Time{
TimeRange: timeRange,
MemoryConsumptionTracker: memoryConsumptionTracker,
expressionPosition: expressionPosition,
}
}

func (s *ScalarTime) GetValues(_ context.Context) (types.ScalarData, error) {
func (s *Time) GetValues(_ context.Context) (types.ScalarData, error) {
samples, err := types.FPointSlicePool.Get(s.TimeRange.StepCount, s.MemoryConsumptionTracker)

if err != nil {
Expand All @@ -55,11 +55,11 @@ func (s *ScalarTime) GetValues(_ context.Context) (types.ScalarData, error) {
return types.ScalarData{Samples: samples}, nil
}

func (s *ScalarTime) ExpressionPosition() posrange.PositionRange {
func (s *Time) ExpressionPosition() posrange.PositionRange {
return s.expressionPosition
}

func (s *ScalarTime) Close() {
func (s *Time) Close() {
// Nothing to do.
}

Expand Down

0 comments on commit 2cf7ef4

Please sign in to comment.