/// <summary> /// Ctor. /// </summary> /// <param name="statementSpec">is a container for the definition of all statement constructs thatmay have been used in the statement, i.e. if defines the select clauses, insert into, outer joins etc. /// </param> /// <param name="services">is the service instances for dependency injection</param> /// <param name="statementContext">is statement-level information and statement services</param> /// <throws>com.espertech.esper.epl.expression.core.ExprValidationException if the preparation failed</throws> public EPPreparedExecuteIUDSingleStream( StatementSpecCompiled statementSpec, EPServicesContext services, StatementContext statementContext) { var queryPlanLogging = services.ConfigSnapshot.EngineDefaults.LoggingConfig.IsEnableQueryPlan; if (queryPlanLogging) { QueryPlanLog.Info("Query plans for Fire-and-forget query '" + statementContext.Expression + "'"); } HasTableAccess = statementSpec.IntoTableSpec != null || (statementSpec.TableNodes != null && statementSpec.TableNodes.Length > 0); if (statementSpec.InsertIntoDesc != null && services.TableService.GetTableMetadata(statementSpec.InsertIntoDesc.EventTypeName) != null) { HasTableAccess = true; } if (statementSpec.FireAndForgetSpec is FireAndForgetSpecUpdate || statementSpec.FireAndForgetSpec is FireAndForgetSpecDelete) { HasTableAccess |= statementSpec.StreamSpecs[0] is TableQueryStreamSpec; } StatementSpec = statementSpec; Services = services; StatementContext = statementContext; // validate general FAF criteria EPPreparedExecuteMethodHelper.ValidateFAFQuery(statementSpec); // obtain processor var streamSpec = statementSpec.StreamSpecs[0]; Processor = FireAndForgetProcessorFactory.ValidateResolveProcessor(streamSpec, services); // obtain name and type var processorName = Processor.NamedWindowOrTableName; var eventType = Processor.EventTypeResultSetProcessor; // determine alias var aliasName = processorName; if (streamSpec.OptionalStreamName != null) { aliasName = streamSpec.OptionalStreamName; } // compile filter to optimize access to named window var typeService = new StreamTypeServiceImpl(new EventType[] { eventType }, new string[] { aliasName }, new bool[] { true }, services.EngineURI, true); FilterSpecCompiled filter; if (statementSpec.FilterRootNode != null) { var tagged = new LinkedHashMap <string, Pair <EventType, string> >(); FilterSpecCompiled filterCompiled; try { filterCompiled = FilterSpecCompiler.MakeFilterSpec(eventType, aliasName, Collections.SingletonList(statementSpec.FilterRootNode), null, tagged, tagged, typeService, null, statementContext, Collections.SingletonList(0)); } catch (Exception ex) { Log.Warn("Unexpected exception analyzing filter paths: " + ex.Message, ex); filterCompiled = null; } filter = filterCompiled; } else { filter = null; } // validate expressions EPStatementStartMethodHelperValidate.ValidateNodes(statementSpec, statementContext, typeService, null); // get executor Executor = GetExecutor(filter, aliasName); }
/// <summary> /// Ctor. /// </summary> /// <param name="statementSpec">is a container for the definition of all statement constructs thatmay have been used in the statement, i.e. if defines the select clauses, insert into, outer joins etc. /// </param> /// <param name="services">is the service instances for dependency injection</param> /// <param name="statementContext">is statement-level information and statement services</param> /// <throws>com.espertech.esper.epl.expression.core.ExprValidationException if the preparation failed</throws> public EPPreparedExecuteIUDSingleStream( StatementSpecCompiled statementSpec, EPServicesContext services, StatementContext statementContext) { var queryPlanLogging = services.ConfigSnapshot.EngineDefaults.Logging.IsEnableQueryPlan; if (queryPlanLogging) { QueryPlanLog.Info("Query plans for Fire-and-forget query '" + statementContext.Expression + "'"); } HasTableAccess = statementSpec.IntoTableSpec != null || (statementSpec.TableNodes != null && statementSpec.TableNodes.Length > 0); if (statementSpec.InsertIntoDesc != null && services.TableService.GetTableMetadata(statementSpec.InsertIntoDesc.EventTypeName) != null) { HasTableAccess = true; } if (statementSpec.FireAndForgetSpec is FireAndForgetSpecUpdate || statementSpec.FireAndForgetSpec is FireAndForgetSpecDelete) { HasTableAccess |= statementSpec.StreamSpecs[0] is TableQueryStreamSpec; } StatementSpec = statementSpec; Services = services; StatementContext = statementContext; // validate general FAF criteria EPPreparedExecuteMethodHelper.ValidateFAFQuery(statementSpec); // obtain processor var streamSpec = statementSpec.StreamSpecs[0]; Processor = FireAndForgetProcessorFactory.ValidateResolveProcessor(streamSpec, services); // obtain name and type var processorName = Processor.NamedWindowOrTableName; var eventType = Processor.EventTypeResultSetProcessor; // determine alias var aliasName = processorName; if (streamSpec.OptionalStreamName != null) { aliasName = streamSpec.OptionalStreamName; } // compile filter to optimize access to named window var typeService = new StreamTypeServiceImpl(new EventType[] { eventType }, new string[] { aliasName }, new bool[] { true }, services.EngineURI, true); var excludePlanHint = ExcludePlanHint.GetHint(typeService.StreamNames, statementContext); var queryGraph = new QueryGraph(1, excludePlanHint, false); if (statementSpec.FilterRootNode != null) { ExprNodeUtility.ValidateFilterWQueryGraphSafe( queryGraph, statementSpec.FilterRootNode, statementContext, typeService); } // validate expressions EPStatementStartMethodHelperValidate.ValidateNodes(statementSpec, statementContext, typeService, null); // get executor Executor = GetExecutor(queryGraph, aliasName); }