private static ContextControllerFactory BuildContextFactory(ContextControllerFactoryContext factoryContext, ContextDetail detail, IList <FilterSpecCompiled> optFiltersNested, ContextStateCache contextStateCache) { return(factoryContext.ServicesContext.ContextControllerFactoryFactorySvc.Make(factoryContext, detail, optFiltersNested, contextStateCache)); }
public ContextManager Make(ContextDetail contextDetail, ContextControllerFactoryServiceContext factoryServiceContext) { if (contextDetail is ContextDetailNested) { return(new ContextManagerNested(factoryServiceContext)); } return(new ContextManagerImpl(factoryServiceContext)); }
public ContextDescriptor(string contextName, bool singleInstanceContext, ContextPropertyRegistry contextPropertyRegistry, StatementAIResourceRegistryFactory aiResourceRegistryFactory, ContextEnumeratorHandler iteratorHandler, ContextDetail contextDetail) { _contextName = contextName; _singleInstanceContext = singleInstanceContext; _contextPropertyRegistry = contextPropertyRegistry; _aiResourceRegistryFactory = aiResourceRegistryFactory; _iteratorHandler = iteratorHandler; _contextDetail = contextDetail; }
private static ContextDetail WalkNested(IList <EsperEPL2GrammarParser.ContextContextNestedContext> nestedContexts, IDictionary <ITree, ExprNode> astExprNodeMap, IDictionary <ITree, EvalFactoryNode> astPatternNodeMap, PropertyEvalSpec propertyEvalSpec, FilterSpecRaw filterSpec) { IList <CreateContextDesc> contexts = new List <CreateContextDesc>(nestedContexts.Count); foreach (EsperEPL2GrammarParser.ContextContextNestedContext nestedctx in nestedContexts) { ContextDetail contextDetail = WalkChoice(nestedctx.createContextChoice(), astExprNodeMap, astPatternNodeMap, propertyEvalSpec, filterSpec); CreateContextDesc desc = new CreateContextDesc(nestedctx.name.Text, contextDetail); contexts.Add(desc); } return(new ContextDetailNested(contexts)); }
private static ContextControllerFactory BuildContextFactory( ContextControllerFactoryServiceContext serviceContext, String contextName, ContextDetail detail, int nestingLevel, IList <FilterSpecCompiled> optFiltersNested, ContextStateCache contextStateCache) { var factoryContext = new ContextControllerFactoryContext( serviceContext.ContextName, contextName, serviceContext.ServicesContext, serviceContext.AgentInstanceContextCreate, nestingLevel, serviceContext.IsRecoveringResilient); return(BuildContextFactory(factoryContext, detail, optFiltersNested, contextStateCache)); }
public ContextControllerFactoryServiceContext( String contextName, EPServicesContext servicesContext, ContextDetail detail, AgentInstanceContext agentInstanceContextCreate, bool isRecoveringResilient, EventType statementResultEventType) { ContextName = contextName; ServicesContext = servicesContext; Detail = detail; AgentInstanceContextCreate = agentInstanceContextCreate; IsRecoveringResilient = isRecoveringResilient; StatementResultEventType = statementResultEventType; }
public CreateContextDesc(String contextName, ContextDetail contextDetail) { ContextName = contextName; ContextDetail = contextDetail; }
private void ValidateContextDetail( EPServicesContext servicesContext, StatementContext statementContext, ISet <string> eventTypesReferenced, ContextDetail contextDetail, AgentInstanceContext agentInstanceContext) { if (contextDetail is ContextDetailPartitioned) { var segmented = (ContextDetailPartitioned)contextDetail; foreach (var partition in segmented.Items) { ValidateNotTable(servicesContext, partition.FilterSpecRaw.EventTypeName); var raw = new FilterStreamSpecRaw(partition.FilterSpecRaw, ViewSpec.EMPTY_VIEWSPEC_ARRAY, null, new StreamSpecOptions()); var compiled = raw.Compile(statementContext, eventTypesReferenced, false, Collections.GetEmptyList <int>(), false, true, false, null); if (!(compiled is FilterStreamSpecCompiled)) { throw new ExprValidationException("Partition criteria may not include named windows"); } var result = (FilterStreamSpecCompiled)compiled; partition.FilterSpecCompiled = result.FilterSpec; } } else if (contextDetail is ContextDetailCategory) { // compile filter var category = (ContextDetailCategory)contextDetail; ValidateNotTable(servicesContext, category.FilterSpecRaw.EventTypeName); var raw = new FilterStreamSpecRaw(category.FilterSpecRaw, ViewSpec.EMPTY_VIEWSPEC_ARRAY, null, new StreamSpecOptions()); var result = (FilterStreamSpecCompiled)raw.Compile(statementContext, eventTypesReferenced, false, Collections.GetEmptyList <int>(), false, true, false, null); category.FilterSpecCompiled = result.FilterSpec; servicesContext.StatementEventTypeRefService.AddReferences(statementContext.StatementName, CollectionUtil.ToArray(eventTypesReferenced)); // compile expressions foreach (var item in category.Items) { ValidateNotTable(servicesContext, category.FilterSpecRaw.EventTypeName); var filterSpecRaw = new FilterSpecRaw(category.FilterSpecRaw.EventTypeName, Collections.SingletonList(item.Expression), null); var rawExpr = new FilterStreamSpecRaw(filterSpecRaw, ViewSpec.EMPTY_VIEWSPEC_ARRAY, null, new StreamSpecOptions()); var compiled = (FilterStreamSpecCompiled)rawExpr.Compile(statementContext, eventTypesReferenced, false, Collections.GetEmptyList <int>(), false, true, false, null); item.SetCompiledFilter(compiled.FilterSpec, agentInstanceContext); } } else if (contextDetail is ContextDetailHash) { var hashed = (ContextDetailHash)contextDetail; foreach (var hashItem in hashed.Items) { var raw = new FilterStreamSpecRaw(hashItem.FilterSpecRaw, ViewSpec.EMPTY_VIEWSPEC_ARRAY, null, new StreamSpecOptions()); ValidateNotTable(servicesContext, hashItem.FilterSpecRaw.EventTypeName); var result = (FilterStreamSpecCompiled)raw.Compile(statementContext, eventTypesReferenced, false, Collections.GetEmptyList <int>(), false, true, false, null); hashItem.FilterSpecCompiled = result.FilterSpec; // validate parameters var streamTypes = new StreamTypeServiceImpl(result.FilterSpec.FilterForEventType, null, true, statementContext.EngineURI); var validationContext = new ExprValidationContext( streamTypes, statementContext.EngineImportService, statementContext.StatementExtensionServicesContext, null, statementContext.SchedulingService, statementContext.VariableService, statementContext.TableService, GetDefaultAgentInstanceContext(statementContext), statementContext.EventAdapterService, statementContext.StatementName, statementContext.StatementId, statementContext.Annotations, statementContext.ContextDescriptor, statementContext.ScriptingService, false, false, false, false, null, false); ExprNodeUtility.Validate(ExprNodeOrigin.CONTEXT, Collections.SingletonList(hashItem.Function), validationContext); } } else if (contextDetail is ContextDetailInitiatedTerminated) { var def = (ContextDetailInitiatedTerminated)contextDetail; var startCondition = ValidateRewriteContextCondition(servicesContext, statementContext, def.Start, eventTypesReferenced, new MatchEventSpec(), new LinkedHashSet <string>()); var endCondition = ValidateRewriteContextCondition(servicesContext, statementContext, def.End, eventTypesReferenced, startCondition.Matches, startCondition.AllTags); def.Start = startCondition.Condition; def.End = endCondition.Condition; if (def.DistinctExpressions != null) { if (!(startCondition.Condition is ContextDetailConditionFilter)) { throw new ExprValidationException("Distinct-expressions require a stream as the initiated-by condition"); } var distinctExpressions = def.DistinctExpressions; if (distinctExpressions.Length == 0) { throw new ExprValidationException("Distinct-expressions have not been provided"); } var filter = (ContextDetailConditionFilter)startCondition.Condition; if (filter.OptionalFilterAsName == null) { throw new ExprValidationException("Distinct-expressions require that a stream name is assigned to the stream using 'as'"); } var types = new StreamTypeServiceImpl(filter.FilterSpecCompiled.FilterForEventType, filter.OptionalFilterAsName, true, servicesContext.EngineURI); var validationContext = new ExprValidationContext( types, statementContext.EngineImportService, statementContext.StatementExtensionServicesContext, null, statementContext.SchedulingService, statementContext.VariableService, statementContext.TableService, GetDefaultAgentInstanceContext(statementContext), statementContext.EventAdapterService, statementContext.StatementName, statementContext.StatementId, statementContext.Annotations, statementContext.ContextDescriptor, statementContext.ScriptingService, false, false, true, false, null, false); for (var i = 0; i < distinctExpressions.Length; i++) { ExprNodeUtility.ValidatePlainExpression(ExprNodeOrigin.CONTEXTDISTINCT, ExprNodeUtility.ToExpressionStringMinPrecedenceSafe(distinctExpressions[i]), distinctExpressions[i]); distinctExpressions[i] = ExprNodeUtility.GetValidatedSubtree(ExprNodeOrigin.CONTEXTDISTINCT, distinctExpressions[i], validationContext); } } } else if (contextDetail is ContextDetailNested) { var nested = (ContextDetailNested)contextDetail; foreach (var nestedContext in nested.Contexts) { ValidateContextDetail(servicesContext, statementContext, eventTypesReferenced, nestedContext.ContextDetail, agentInstanceContext); } } else { throw new IllegalStateException("Unrecognized context detail " + contextDetail); } }
public ContextControllerFactory Make(ContextControllerFactoryContext factoryContext, ContextDetail detail, IList <FilterSpecCompiled> optFiltersNested, ContextStateCache contextStateCache) { ContextControllerFactory factory; if (detail is ContextDetailInitiatedTerminated) { factory = new ContextControllerInitTermFactory(factoryContext, (ContextDetailInitiatedTerminated)detail, contextStateCache); } else if (detail is ContextDetailPartitioned) { factory = new ContextControllerPartitionedFactory(factoryContext, (ContextDetailPartitioned)detail, optFiltersNested, contextStateCache); } else if (detail is ContextDetailCategory) { factory = new ContextControllerCategoryFactory(factoryContext, (ContextDetailCategory)detail, optFiltersNested, contextStateCache); } else if (detail is ContextDetailHash) { factory = new ContextControllerHashFactory(factoryContext, (ContextDetailHash)detail, optFiltersNested, contextStateCache); } else { throw new UnsupportedOperationException("Context detail " + detail + " is not yet supported in a nested context"); } return(factory); }