public AggregationMethodFactoryPluginMethod( ExprPlugInAggNode parent, AggregationFunctionForge aggregationFunctionForge, AggregationFunctionMode mode) { this.parent = parent; this.aggregationFunctionForge = aggregationFunctionForge; this.mode = mode; }
public AggregationForgeFactoryPlugin( ExprPlugInAggNode parent, AggregationFunctionForge aggregationFunctionForge, AggregationFunctionMode mode, Type aggregatedValueType, DataInputOutputSerdeForge distinctSerde) { this.parent = parent; this.aggregationFunctionForge = aggregationFunctionForge; this.mode = mode; this.aggregatedValueType = aggregatedValueType; this.distinctSerde = distinctSerde; }
public override AggregationForgeFactory ValidateAggregationChild(ExprValidationContext validationContext) { Type[] parameterTypes = new Type[positionalParams.Length]; object[] constant = new object[positionalParams.Length]; bool[] isConstant = new bool[positionalParams.Length]; ExprNode[] expressions = new ExprNode[positionalParams.Length]; int count = 0; bool hasDataWindows = true; foreach (ExprNode child in positionalParams) { if (child.Forge.ForgeConstantType == ExprForgeConstantType.COMPILETIMECONST) { isConstant[count] = true; constant[count] = child.Forge.ExprEvaluator.Evaluate(null, true, null); } parameterTypes[count] = child.Forge.EvaluationType; expressions[count] = child; if (!ExprNodeUtilityAggregation.HasRemoveStreamForAggregations( child, validationContext.StreamTypeService, validationContext.IsResettingAggregations)) { hasDataWindows = false; } if (child is ExprWildcard) { ExprAggMultiFunctionUtil.CheckWildcardNotJoinOrSubquery( validationContext.StreamTypeService, functionName); parameterTypes[count] = validationContext.StreamTypeService.EventTypes[0].UnderlyingType; isConstant[count] = false; constant[count] = null; } count++; } LinkedHashMap<string, IList<ExprNode>> namedParameters = null; if (optionalFilter != null) { namedParameters = new LinkedHashMap<string, IList<ExprNode>>(); namedParameters.Put("filter", Collections.SingletonList(optionalFilter)); positionalParams = ExprNodeUtilityMake.AddExpression(positionalParams, optionalFilter); } AggregationFunctionValidationContext context = new AggregationFunctionValidationContext( parameterTypes, isConstant, constant, base.IsDistinct, hasDataWindows, expressions, namedParameters); try { // the aggregation function factory is transient, obtain if not provided if (aggregationFunctionForge == null) { aggregationFunctionForge = validationContext.ImportService.ResolveAggregationFunction(functionName); } aggregationFunctionForge.Validate(context); } catch (Exception ex) { throw new ExprValidationException( "Plug-in aggregation function '" + functionName + "' failed validation: " + ex.Message, ex); } AggregationFunctionMode mode = aggregationFunctionForge.AggregationFunctionMode; if (mode == null) { throw new ExprValidationException("Aggregation function forge returned a null value for mode"); } if (mode is AggregationFunctionModeManaged) { if (positionalParams.Length > 2) { throw new ExprValidationException( "Aggregation function forge single-value mode requires zero, one or two parameters"); } } else if (mode is AggregationFunctionModeMultiParam || mode is AggregationFunctionModeCodeGenerated) { } else { throw new ExprValidationException("Aggregation function forge returned an unrecognized mode " + mode); } return new AggregationMethodFactoryPluginMethod(this, aggregationFunctionForge, mode); }