示例#1
0
 public AggregationTAAReaderLinearFirstLastForge(
     Type underlyingType,
     AggregationAccessorLinearType accessType,
     ExprNode optionalEvaluator)
 {
     ResultType = underlyingType;
     this.accessType = accessType;
     this.optionalEvaluator = optionalEvaluator;
 }
示例#2
0
        private AggregationMultiFunctionMethodDesc HandleMethodFirstLast(
            ExprNode[] childNodes,
            AggregationAccessorLinearType methodType,
            ExprValidationContext validationContext)
        {
            var underlyingType = ContainedEventType.UnderlyingType;
            if (childNodes.Length == 0) {
                var forge = new AggregationMethodLinearFirstLastForge(underlyingType, methodType, null);
                return new AggregationMultiFunctionMethodDesc(forge, null, null, ContainedEventType);
            }

            if (childNodes.Length == 1) {
                if (childNodes[0] is ExprWildcard) {
                    var forgeX = new AggregationMethodLinearFirstLastForge(underlyingType, methodType, null);
                    return new AggregationMultiFunctionMethodDesc(forgeX, null, null, ContainedEventType);
                }

                if (childNodes[0] is ExprStreamUnderlyingNode) {
                    throw new ExprValidationException("Stream-wildcard is not allowed for table column access");
                }

                // Expressions apply to events held, thereby validate in terms of event value expressions
                var paramNode = childNodes[0];
                var streams = TableCompileTimeUtil.StreamTypeFromTableColumn(ContainedEventType);
                var localValidationContext = new ExprValidationContext(streams, validationContext);
                paramNode = ExprNodeUtilityValidate.GetValidatedSubtree(ExprNodeOrigin.AGGPARAM, paramNode, localValidationContext);
                var forge = new AggregationMethodLinearFirstLastForge(paramNode.Forge.EvaluationType, methodType, paramNode);
                return new AggregationMultiFunctionMethodDesc(forge, null, null, null);
            }

            if (childNodes.Length == 2) {
                int? constant = null;
                var indexEvalNode = childNodes[1];
                var indexEvalType = indexEvalNode.Forge.EvaluationType;
                if (indexEvalType != typeof(int?) && indexEvalType != typeof(int)) {
                    throw new ExprValidationException(GetErrorPrefix(methodType) + " requires a constant index expression that returns an integer value");
                }

                ExprNode indexExpr;
                if (indexEvalNode.Forge.ForgeConstantType == ExprForgeConstantType.COMPILETIMECONST) {
                    constant = indexEvalNode.Forge.ExprEvaluator.Evaluate(null, true, null).AsBoxedInt32();
                    indexExpr = null;
                }
                else {
                    indexExpr = indexEvalNode;
                }

                var forge = new AggregationMethodLinearFirstLastIndexForge(
                    underlyingType,
                    methodType,
                    constant,
                    indexExpr);
                return new AggregationMultiFunctionMethodDesc(forge, null, null, ContainedEventType);
            }

            throw new ExprValidationException("Invalid number of parameters");
        }
 public AggregationMethodLinearFirstLastForge(
     Type underlyingType,
     AggregationAccessorLinearType accessType,
     ExprNode optionalEvaluator)
 {
     this.underlyingType = underlyingType;
     this.accessType = accessType;
     this.optionalEvaluator = optionalEvaluator;
 }
 public AggregationMethodLinearFirstLastIndexForge(
     Type underlyingType,
     AggregationAccessorLinearType accessType,
     int? optionalConstant,
     ExprNode optionalIndexEval)
 {
     this.underlyingType = underlyingType;
     this.accessType = accessType;
     this.optionalConstant = optionalConstant;
     this.optionalIndexEval = optionalIndexEval;
 }
示例#5
0
 /// <summary>
 /// Gets the name.
 /// </summary>
 public static string GetName(this AggregationAccessorLinearType value)
 {
     switch (value)
     {
         case AggregationAccessorLinearType.FIRST:
             return "FIRST";
         case AggregationAccessorLinearType.LAST:
             return "LAST";
         case AggregationAccessorLinearType.WINDOW:
             return "WINDOW";
         default:
             throw new ArgumentOutOfRangeException(nameof(value), value, null);
     }
 }
示例#6
0
 private static String GetErrorPrefix(AggregationAccessorLinearType stateType)
 {
     return ExprAggMultiFunctionUtil.GetErrorPrefix(stateType.ToString().ToLowerInvariant());
 }