public DataFlowOpForgeInitializeResult InitializeForge(DataFlowOpForgeInitializeContext context) { if (context.InputPorts.Count != 1) { throw new ExprValidationException("Filter requires single input port"); } if (filter == null) { throw new ExprValidationException( "Required parameter 'filter' providing the filter expression is not provided"); } if (context.OutputPorts.IsEmpty() || context.OutputPorts.Count > 2) { throw new ArgumentException( "Filter operator requires one or two output stream(s) but produces " + context.OutputPorts.Count + " streams"); } eventType = context.InputPorts[0].TypeDesc.EventType; singleOutputPort = context.OutputPorts.Count == 1; filter = DataFlowParameterValidation.Validate("filter", filter, eventType, typeof(bool?), context); GraphTypeDesc[] typesPerPort = new GraphTypeDesc[context.OutputPorts.Count]; for (int i = 0; i < typesPerPort.Length; i++) { typesPerPort[i] = new GraphTypeDesc(false, true, eventType); } return new DataFlowOpForgeInitializeResult(typesPerPort); }
public DataFlowOpForgeInitializeResult InitializeForge(DataFlowOpForgeInitializeContext context) { if (context.OutputPorts.Count != 1) { throw new ArgumentException( "EPStatementSource operator requires one output stream but produces " + context.OutputPorts.Count + " streams"); } if (statementName != null && statementFilter != null) { throw new ExprValidationException( "Both 'statementName' or 'statementFilter' parameters were provided, only either one is expected"); } if ((statementDeploymentId == null && statementName != null) | (statementDeploymentId != null && statementName == null)) { throw new ExprValidationException( "Both 'statementDeploymentId' and 'statementName' are required when either of these are specified"); } DataFlowOpOutputPort portZero = context.OutputPorts[0]; if (portZero != null && portZero.OptionalDeclaredType != null && portZero.OptionalDeclaredType.IsWildcard) { submitEventBean = true; } return null; }
public DataFlowOpForgeInitializeResult InitializeForge(DataFlowOpForgeInitializeContext context) { _outputEventType = context.OutputPorts.Get(0).OptionalDeclaredType != null?context.OutputPorts.Get(0).OptionalDeclaredType.EventType : null; if (_outputEventType == null) { throw new ExprValidationException("No event type provided for output, please provide an event type name"); } _outputPortTypes = new EventType[context.OutputPorts.Count]; foreach (var entry in context.OutputPorts) { _outputPortTypes[entry.Key] = entry.Value.OptionalDeclaredType.EventType; } _file = DataFlowParameterValidation.Validate("file", _file, typeof(string), context); _classpathFile = DataFlowParameterValidation.Validate("classpathFile", _classpathFile, typeof(bool), context); _hasHeaderLine = DataFlowParameterValidation.Validate("hasHeaderLine", _hasHeaderLine, typeof(bool), context); _hasTitleLine = DataFlowParameterValidation.Validate("hasTitleLine", _hasTitleLine, typeof(bool), context); _numLoops = DataFlowParameterValidation.Validate("numLoops", _numLoops, typeof(int?), context); _format = DataFlowParameterValidation.Validate("format", _format, typeof(string), context); _propertyNameLine = DataFlowParameterValidation.Validate("propertyNameLine", _propertyNameLine, typeof(string), context); _propertyNameFile = DataFlowParameterValidation.Validate("propertyNameFile", _propertyNameFile, typeof(string), context); _dateFormat = DataFlowParameterValidation.Validate("dateFormat", _dateFormat, typeof(string), context); return(null); }
/// <summary> /// Validate the provided expression. /// </summary> /// <param name="name">parameter name</param> /// <param name="expr">expression</param> /// <param name="expectedReturnType">expected result type</param> /// <param name="context">forge initialization context</param> /// <returns>validated expression node</returns> /// <throws>ExprValidationException when validation failed</throws> public static ExprNode Validate( string name, ExprNode expr, Type expectedReturnType, DataFlowOpForgeInitializeContext context) { if (expr == null) { return null; } return Validate(name, expr, null, expectedReturnType, context); }
public DataFlowOpForgeInitializeResult InitializeForge(DataFlowOpForgeInitializeContext context) { if (!context.OutputPorts.IsEmpty()) { throw new ArgumentException("EventBusSink operator does not provide an output stream"); } eventTypes = new EventType[context.InputPorts.Count]; for (var i = 0; i < eventTypes.Length; i++) { eventTypes[i] = context.InputPorts[i].TypeDesc.EventType; } return null; }
public DataFlowOpForgeInitializeResult InitializeForge(DataFlowOpForgeInitializeContext context) { if (context.OutputPorts.Count != 1) { throw new ArgumentException( "EventBusSource operator requires one output stream but produces " + context.OutputPorts.Count + " streams"); } var portZero = context.OutputPorts[0]; if (portZero.OptionalDeclaredType == null || portZero.OptionalDeclaredType.EventType == null) { throw new ArgumentException( "EventBusSource operator requires an event type declated for the output stream"); } var eventType = portZero.OptionalDeclaredType.EventType; if (!portZero.OptionalDeclaredType.IsUnderlying) { submitEventBean = true; } DataFlowParameterValidation.Validate("filter", filter, eventType, typeof(bool), context); try { IList<ExprNode> filters = EmptyList<ExprNode>.Instance; if (filter != null) { filters = Collections.SingletonList(filter); } var streamTypeService = new StreamTypeServiceImpl(eventType, eventType.Name, true); var compiledDesc = FilterSpecCompiler.MakeFilterSpec( eventType, eventType.Name, filters, null, null, null, null, streamTypeService, null, context.StatementRawInfo, context.Services); FilterSpecCompiled = compiledDesc.FilterSpecCompiled; } catch (ExprValidationException ex) { throw new ExprValidationException("Failed to obtain filter parameters: " + ex.Message, ex); } return null; }
private DataFlowOpForgeInitializeResult InitializeTypeUndeclared(DataFlowOpForgeInitializeContext context) { // No type has been declared, we can create one var types = new LinkedHashMap<string, object>(); var props = allProperties.Keys; props.RemoveAll(PARAMETER_PROPERTIES); var count = 0; evaluatorForges = new ExprForge[props.Count]; foreach (var propertyName in props) { var exprNode = allProperties.Get(propertyName); var validated = EPLValidationUtil.ValidateSimpleGetSubtree( ExprNodeOrigin.DATAFLOWBEACON, exprNode, null, false, context.StatementRawInfo, context.Services); types.Put(propertyName, validated.Forge.EvaluationType); evaluatorForges[count] = validated.Forge; count++; } var eventTypeName = context.Services.EventTypeNameGeneratorStatement.GetDataflowOperatorTypeName(context.OperatorNumber); var metadata = new EventTypeMetadata( eventTypeName, context.Base.ModuleName, EventTypeTypeClass.DBDERIVED, EventTypeApplicationType.OBJECTARR, NameAccessModifier.TRANSIENT, EventTypeBusModifier.NONBUS, false, EventTypeIdPair.Unassigned()); outputEventType = BaseNestableEventUtil.MakeOATypeCompileTime( metadata, types, null, null, null, null, context.Services.BeanEventTypeFactoryPrivate, context.Services.EventTypeCompileTimeResolver); context.Services.EventTypeCompileTimeRegistry.NewType(outputEventType); return new DataFlowOpForgeInitializeResult(new[] {new GraphTypeDesc(false, true, outputEventType)}); }
public DataFlowOpForgeInitializeResult InitializeForge(DataFlowOpForgeInitializeContext context) { if (context.InputPorts.Count != 1) { throw new EPException(GetType().Name + " expected a single input port"); } eventType = context.InputPorts.Get(0).TypeDesc.EventType; if (eventType == null) { throw new EPException("No event type defined for input port"); } file = DataFlowParameterValidation.Validate("file", file, typeof(string), context); append = DataFlowParameterValidation.Validate("append", append, typeof(bool), context); return(null); }
public DataFlowOpForgeInitializeResult InitializeForge(DataFlowOpForgeInitializeContext context) { if (!context.OutputPorts.IsEmpty()) { throw new ArgumentException("LogSink operator does not provide an output stream"); } eventTypes = new EventType[context.InputPorts.Count]; foreach (KeyValuePair<int, DataFlowOpInputPort> entry in context.InputPorts) { eventTypes[entry.Key] = entry.Value.TypeDesc.EventType; } title = DataFlowParameterValidation.Validate("title", title, typeof(string), context); layout = DataFlowParameterValidation.Validate("layout", layout, typeof(string), context); format = DataFlowParameterValidation.Validate("format", format, typeof(string), context); log = DataFlowParameterValidation.Validate("log", log, typeof(bool), context); linefeed = DataFlowParameterValidation.Validate("linefeed", linefeed, typeof(bool), context); return null; }
/// <summary> /// Validate the provided expression. /// </summary> /// <param name="name">parameter name</param> /// <param name="eventType">event type</param> /// <param name="expr">expression</param> /// <param name="expectedReturnType">expected result type</param> /// <param name="context">forge initialization context</param> /// <returns>validated expression node</returns> /// <throws>ExprValidationException when validation failed</throws> public static ExprNode Validate( string name, ExprNode expr, EventType eventType, Type expectedReturnType, DataFlowOpForgeInitializeContext context) { if (expr == null) { return null; } ExprNode validated = EPLValidationUtil.ValidateSimpleGetSubtree( ExprNodeOrigin.DATAFLOWFILTER, expr, eventType, false, context.StatementRawInfo, context.Services); ValidateReturnType(name, validated, expectedReturnType); return validated; }
public DataFlowOpForgeInitializeResult InitializeForge(DataFlowOpForgeInitializeContext context) { iterations = DataFlowParameterValidation.Validate("iterations", iterations, typeof(object), context); initialDelay = DataFlowParameterValidation.Validate("initialDelay", initialDelay, typeof(object), context); interval = DataFlowParameterValidation.Validate("interval", interval, typeof(object), context); if (context.OutputPorts.Count != 1) { throw new ArgumentException( "BeaconSource operator requires one output stream but produces " + context.OutputPorts.Count + " streams"); } var port = context.OutputPorts[0]; // Check if a type is declared if (port.OptionalDeclaredType == null || port.OptionalDeclaredType.EventType == null) { return InitializeTypeUndeclared(context); } return InitializeTypeDeclared(port, context); }
#pragma warning restore 649 public DataFlowOpForgeInitializeResult InitializeForge(DataFlowOpForgeInitializeContext context) { return null; }
public DataFlowOpForgeInitializeResult InitializeForge(DataFlowOpForgeInitializeContext context) { throw new EPException("Failed-Here"); }
private DataFlowOpForgeInitializeResult InitializeTypeDeclared( DataFlowOpOutputPort port, DataFlowOpForgeInitializeContext context) { produceEventBean = port.OptionalDeclaredType != null && !port.OptionalDeclaredType.IsUnderlying; // compile properties to populate outputEventType = port.OptionalDeclaredType.EventType; var props = allProperties.Keys; props.RemoveAll(PARAMETER_PROPERTIES); var writables = SetupProperties(props.ToArray(), outputEventType); try { eventBeanManufacturer = EventTypeUtility.GetManufacturer( outputEventType, writables, context.Services.ImportServiceCompileTime, false, context.Services.EventTypeAvroHandler); } catch (EventBeanManufactureException e) { throw new ExprValidationException( "Cannot manufacture event for the provided type '" + outputEventType.Name + "': " + e.Message, e); } var index = 0; evaluatorForges = new ExprForge[writables.Length]; var typeWidenerCustomizer = context.Services.EventTypeAvroHandler.GetTypeWidenerCustomizer(outputEventType); foreach (var writable in writables) { object providedProperty = allProperties.Get(writable.PropertyName); var exprNode = (ExprNode) providedProperty; var validated = EPLValidationUtil.ValidateSimpleGetSubtree( ExprNodeOrigin.DATAFLOWBEACON, exprNode, null, false, context.Base.StatementRawInfo, context.Services); TypeWidenerSPI widener; try { widener = TypeWidenerFactory.GetCheckPropertyAssignType( ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(validated), validated.Forge.EvaluationType, writable.PropertyType, writable.PropertyName, false, typeWidenerCustomizer, context.Base.StatementName); } catch (TypeWidenerException e) { throw new ExprValidationException("Failed for property '" + writable.PropertyName + "'", e); } if (widener != null) { evaluatorForges[index] = new ExprEvalWithTypeWidener(widener, validated, writable.PropertyType); } else { evaluatorForges[index] = validated.Forge; } index++; } return null; }
public DataFlowOpForgeInitializeResult InitializeForge(DataFlowOpForgeInitializeContext context) { if (context.InputPorts.IsEmpty()) { throw new ArgumentException("Select operator requires at least one input stream"); } if (context.OutputPorts.Count != 1) { throw new ArgumentException( "Select operator requires one output stream but produces " + context.OutputPorts.Count + " streams"); } var portZero = context.OutputPorts[0]; if (portZero.OptionalDeclaredType != null && !portZero.OptionalDeclaredType.IsUnderlying) { submitEventBean = true; } // determine adapter factories for each type var numStreams = context.InputPorts.Count; eventTypes = new EventType[numStreams]; for (var i = 0; i < numStreams; i++) { eventTypes[i] = context.InputPorts.Get(i).TypeDesc.EventType; } // validate if (select.InsertIntoDesc != null) { throw new ExprValidationException("Insert-into clause is not supported"); } if (select.SelectStreamSelectorEnum != SelectClauseStreamSelectorEnum.ISTREAM_ONLY) { throw new ExprValidationException("Selecting remove-stream is not supported"); } ExprNodeSubselectDeclaredDotVisitor visitor = StatementSpecRawWalkerSubselectAndDeclaredDot.WalkSubselectAndDeclaredDotExpr(select); GroupByClauseExpressions groupByExpressions = GroupByExpressionHelper.GetGroupByRollupExpressions( select.GroupByExpressions, select.SelectClauseSpec, select.WhereClause, select.OrderByList, null); if (!visitor.Subselects.IsEmpty()) { throw new ExprValidationException("Subselects are not supported"); } IDictionary<int, FilterStreamSpecRaw> streams = new Dictionary<int, FilterStreamSpecRaw>(); for (var streamNum = 0; streamNum < select.StreamSpecs.Count; streamNum++) { StreamSpecRaw rawStreamSpec = select.StreamSpecs[streamNum]; if (!(rawStreamSpec is FilterStreamSpecRaw)) { throw new ExprValidationException( "From-clause must contain only streams and cannot contain patterns or other constructs"); } streams.Put(streamNum, (FilterStreamSpecRaw) rawStreamSpec); } // compile offered streams IList<StreamSpecCompiled> streamSpecCompileds = new List<StreamSpecCompiled>(); originatingStreamToViewableStream = new int[select.StreamSpecs.Count]; for (var streamNum = 0; streamNum < select.StreamSpecs.Count; streamNum++) { var filter = streams.Get(streamNum); var inputPort = FindInputPort(filter.RawFilterSpec.EventTypeName, context.InputPorts); if (inputPort == null) { throw new ExprValidationException( "Failed to find stream '" + filter.RawFilterSpec.EventTypeName + "' among input ports, input ports are " + CompatExtensions.RenderAny(GetInputPortNames(context.InputPorts))); } var inputPortValue = inputPort.Value; var eventType = inputPortValue.Value.TypeDesc.EventType; originatingStreamToViewableStream[inputPortValue.Key] = streamNum; var streamAlias = filter.OptionalStreamName; var filterSpecCompiled = new FilterSpecCompiled( eventType, streamAlias, new IList<FilterSpecParamForge>[] { new EmptyList<FilterSpecParamForge>() }, null); ViewSpec[] viewSpecs = select.StreamSpecs[streamNum].ViewSpecs; var filterStreamSpecCompiled = new FilterStreamSpecCompiled( filterSpecCompiled, viewSpecs, streamAlias, StreamSpecOptions.DEFAULT); streamSpecCompileds.Add(filterStreamSpecCompiled); } // create compiled statement spec var selectClauseCompiled = StatementLifecycleSvcUtil.CompileSelectClause(select.SelectClauseSpec); Attribute[] mergedAnnotations = AnnotationUtil.MergeAnnotations( context.StatementRawInfo.Annotations, context.OperatorAnnotations); mergedAnnotations = AddObjectArrayRepresentation(mergedAnnotations); var streamSpecArray = streamSpecCompileds.ToArray(); // determine if snapshot output is needed var outputLimitSpec = select.OutputLimitSpec; if (iterate) { if (outputLimitSpec != null) { throw new ExprValidationException("Output rate limiting is not supported with 'iterate'"); } outputLimitSpec = new OutputLimitSpec(OutputLimitLimitType.SNAPSHOT, OutputLimitRateType.TERM); select.OutputLimitSpec = outputLimitSpec; } // override the statement spec var compiled = new StatementSpecCompiled( select, streamSpecArray, selectClauseCompiled, mergedAnnotations, groupByExpressions, new EmptyList<ExprSubselectNode>(), new EmptyList<ExprDeclaredNode>(), new EmptyList<ExprTableAccessNode>()); var dataflowClassPostfix = context.CodegenEnv.ClassPostfix + "__dfo" + context.OperatorNumber; var containerStatement = context.Base.StatementSpec; context.Base.StatementSpec = compiled; // make forgable var forablesResult = StmtForgeMethodSelectUtil.Make( context.Container, true, context.CodegenEnv.Namespace, dataflowClassPostfix, context.Base, context.Services); // return the statement spec context.Base.StatementSpec = containerStatement; EventType outputEventType = forablesResult.EventType; var initializeResult = new DataFlowOpForgeInitializeResult(); initializeResult.TypeDescriptors = new[] {new GraphTypeDesc(false, true, outputEventType)}; initializeResult.AdditionalForgables = forablesResult.ForgeResult; foreach (StmtClassForgable forgable in forablesResult.ForgeResult.Forgables) { if (forgable.ForgableType == StmtClassForgableType.AIFACTORYPROVIDER) { classNameAIFactoryProvider = forgable.ClassName; } else if (forgable.ForgableType == StmtClassForgableType.FIELDS) { classNameFieldsFactoryProvider = forgable.ClassName; } } return initializeResult; }