private AggregationMultiFunctionMethodDesc HandleMethodWindow( ExprNode[] childNodes, ExprValidationContext validationContext) { if (childNodes.Length == 0 || (childNodes.Length == 1 && childNodes[0] is ExprWildcard)) { var componentType = ContainedEventType.UnderlyingType; var forge = new AggregationMethodLinearWindowForge( TypeHelper.GetArrayType(componentType), null); return new AggregationMultiFunctionMethodDesc(forge, ContainedEventType, null, null); } if (childNodes.Length == 1) { // 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 paramNodeType = paramNode.Forge.EvaluationType.GetBoxedType(); var forge = new AggregationMethodLinearWindowForge(TypeHelper.GetArrayType(paramNodeType), paramNode); return new AggregationMultiFunctionMethodDesc(forge, null, paramNodeType, null); } throw new ExprValidationException("Invalid number of parameters"); }
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"); }