public AggregationMethodFactoryPlugIn(ExprPlugInAggNode parent, AggregationFunctionFactory aggregationFunctionFactory, Type aggregatedValueType) { _parent = parent; _aggregationFunctionFactory = aggregationFunctionFactory; _aggregatedValueType = aggregatedValueType; }
public AggregationMethodFactory MakePlugInMethod( StatementExtensionSvcContext statementExtensionSvcContext, ExprPlugInAggNode expr, AggregationFunctionFactory factory, Type childType) { return(new AggregationMethodFactoryPlugIn(expr, factory, childType)); }
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; }
// Since static method calls such as "Class.method('a')" and mapped properties "Stream.property('key')" // look the same, however as the validation could not resolve "Stream.property('key')" before calling this method, // this method tries to resolve the mapped property as a static method. // Assumes that this is an ExprIdentNode. private static ExprNode ResolveStaticMethodOrField( ExprIdentNode identNode, ExprValidationException propertyException, ExprValidationContext validationContext) { // Reconstruct the original string StringBuilder mappedProperty = new StringBuilder(identNode.UnresolvedPropertyName); if (identNode.StreamOrPropertyName != null) { mappedProperty.Insert(0, identNode.StreamOrPropertyName + '.'); } // Parse the mapped property format into a class name, method and single string parameter MappedPropertyParseResult parse = ParseMappedProperty(mappedProperty.ToString()); if (parse == null) { ExprConstantNode constNode = ResolveIdentAsEnumConst( mappedProperty.ToString(), validationContext.ImportService); if (constNode == null) { throw propertyException; } else { return constNode; } } // If there is a class name, assume a static method is possible. if (parse.ClassName != null) { IList<ExprNode> parameters = Collections.SingletonList((ExprNode) new ExprConstantNodeImpl(parse.ArgString)); IList<ExprChainedSpec> chain = new List<ExprChainedSpec>(); chain.Add(new ExprChainedSpec(parse.ClassName, Collections.GetEmptyList<ExprNode>(), false)); chain.Add(new ExprChainedSpec(parse.MethodName, parameters, false)); ConfigurationCompilerExpression exprConfig = validationContext.StatementCompileTimeService.Configuration.Compiler.Expression; ExprNode result = new ExprDotNodeImpl(chain, exprConfig.IsDuckTyping, exprConfig.IsUdfCache); // Validate try { result.Validate(validationContext); } catch (ExprValidationException e) { throw new ExprValidationException( $"Failed to resolve enumeration method, date-time method or mapped property '{mappedProperty}': {e.Message}", e); } return result; } // There is no class name, try a single-row function string functionName = parse.MethodName; try { Pair<Type, ImportSingleRowDesc> classMethodPair = validationContext.ImportService.ResolveSingleRow(functionName); IList<ExprNode> parameters = Collections.SingletonList((ExprNode) new ExprConstantNodeImpl(parse.ArgString)); IList<ExprChainedSpec> chain = Collections.SingletonList( new ExprChainedSpec(classMethodPair.Second.MethodName, parameters, false)); ExprNode result = new ExprPlugInSingleRowNode( functionName, classMethodPair.First, chain, classMethodPair.Second); // Validate try { result.Validate(validationContext); } catch (EPException) { throw; } catch (Exception ex) { throw new ExprValidationException( "Plug-in aggregation function '" + parse.MethodName + "' failed validation: " + ex.Message); } return result; } catch (ImportUndefinedException) { // Not an single-row function } catch (ImportException e) { throw new IllegalStateException("Error resolving single-row function: " + e.Message, e); } // Try an aggregation function factory try { AggregationFunctionForge aggregationForge = validationContext.ImportService.ResolveAggregationFunction(parse.MethodName); ExprNode result = new ExprPlugInAggNode(false, aggregationForge, parse.MethodName); result.AddChildNode(new ExprConstantNodeImpl(parse.ArgString)); // Validate try { result.Validate(validationContext); } catch (EPException) { throw; } catch (Exception e) { throw new ExprValidationException( "Plug-in aggregation function '" + parse.MethodName + "' failed validation: " + e.Message); } return result; } catch (ImportUndefinedException) { // Not an aggregation function } catch (ImportException e) { throw new IllegalStateException("Error resolving aggregation: " + e.Message, e); } // absolutely cannot be resolved throw propertyException; }