public static bool IsAccumulator(this AstUnaryOperator @operator, out AstAccumulatorOperator accumulatorOperator) { switch (@operator) { case AstUnaryOperator.AddToSet: accumulatorOperator = AstAccumulatorOperator.AddToSet; return(true); case AstUnaryOperator.Avg: accumulatorOperator = AstAccumulatorOperator.Avg; return(true); case AstUnaryOperator.First: accumulatorOperator = AstAccumulatorOperator.First; return(true); case AstUnaryOperator.Last: accumulatorOperator = AstAccumulatorOperator.Last; return(true); case AstUnaryOperator.Max: accumulatorOperator = AstAccumulatorOperator.Max; return(true); case AstUnaryOperator.Min: accumulatorOperator = AstAccumulatorOperator.Min; return(true); case AstUnaryOperator.Push: accumulatorOperator = AstAccumulatorOperator.Push; return(true); case AstUnaryOperator.StdDevPop: accumulatorOperator = AstAccumulatorOperator.StdDevPop; return(true); case AstUnaryOperator.StdDevSamp: accumulatorOperator = AstAccumulatorOperator.StdDevSamp; return(true); case AstUnaryOperator.Sum: accumulatorOperator = AstAccumulatorOperator.Sum; return(true); default: accumulatorOperator = default; return(false); } }
public static string Render(this AstAccumulatorOperator @operator) { return(@operator switch { AstAccumulatorOperator.AddToSet => "$addToSet", AstAccumulatorOperator.Avg => "$avg", AstAccumulatorOperator.First => "$first", AstAccumulatorOperator.Last => "$last", AstAccumulatorOperator.Max => "$max", AstAccumulatorOperator.MergeObjects => "$mergeObjects", AstAccumulatorOperator.Min => "$min", AstAccumulatorOperator.Push => "$push", AstAccumulatorOperator.StdDevPop => "$stdDevPop", AstAccumulatorOperator.StdDevSamp => "$stdDevSamp", AstAccumulatorOperator.Sum => "$sum", _ => throw new InvalidOperationException($"Unexpected accumulator operator: {@operator}.") });
public static AstAccumulatorField AccumulatorField(string name, AstAccumulatorOperator @operator, AstExpression arg) { var value = new AstAccumulatorExpression(@operator, arg); return(new AstAccumulatorField(name, value)); }
public static AstAccumulatorExpression AccumulatorExpression(AstAccumulatorOperator @operator, AstExpression arg) { return(new AstAccumulatorExpression(@operator, arg)); }
public AstAccumulatorExpression(AstAccumulatorOperator @operator, AstExpression arg) { _operator = @operator; _arg = Ensure.IsNotNull(arg, nameof(arg)); }