public ContextManagerNested(ContextControllerFactoryServiceContext factoryServiceContext) { _contextName = factoryServiceContext.ContextName; _servicesContext = factoryServiceContext.ServicesContext; _contextPartitionIdManager = factoryServiceContext.AgentInstanceContextCreate.StatementContext.ContextControllerFactoryService.AllocatePartitionIdMgr( _contextName, factoryServiceContext.AgentInstanceContextCreate.StatementContext.StatementId); _nestedContextFactories = factoryServiceContext.AgentInstanceContextCreate.StatementContext.ContextControllerFactoryService.GetFactory( factoryServiceContext); StatementAIResourceRegistryFactory resourceRegistryFactory = () => new StatementAIResourceRegistry(new AIRegistryAggregationMap(), new AIRegistryExprMap()); var contextProps = ContextPropertyEventType.GetNestedTypeBase(); foreach (var factory in _nestedContextFactories) { contextProps.Put(factory.FactoryContext.ContextName, factory.ContextBuiltinProps); } var contextPropsType = _servicesContext.EventAdapterService.CreateAnonymousMapType( _contextName, contextProps, true); var registry = new ContextPropertyRegistryImpl( Collections.GetEmptyList <ContextDetailPartitionItem>(), contextPropsType); _contextDescriptor = new ContextDescriptor( _contextName, false, registry, resourceRegistryFactory, this, factoryServiceContext.Detail); }
public static ExprDeclaredNodeImpl GetExistsDeclaredExpr( IContainer container, String name, IList <ExprNode> parameters, ICollection <ExpressionDeclItem> expressionDeclarations, ExprDeclaredService exprDeclaredService, ContextDescriptor contextDescriptor) { // Find among local expressions if (expressionDeclarations.IsNotEmpty()) { foreach (ExpressionDeclItem declNode in expressionDeclarations) { if (declNode.Name.Equals(name)) { return(new ExprDeclaredNodeImpl( container, declNode, parameters, contextDescriptor)); } } } // find among global expressions ExpressionDeclItem found = exprDeclaredService.GetExpression(name); if (found != null) { return(new ExprDeclaredNodeImpl( container, found, parameters, contextDescriptor)); } return(null); }
public FilterSpecCompilerArgs( IDictionary<string, Pair<EventType, string>> taggedEventTypes, IDictionary<string, Pair<EventType, string>> arrayEventTypes, ExprEvaluatorContext exprEvaluatorContext, string statementName, string statementId, StreamTypeService streamTypeService, MethodResolutionService methodResolutionService, TimeProvider timeProvider, VariableService variableService, TableService tableService, EventAdapterService eventAdapterService, ScriptingService scriptingService, Attribute[] annotations, ContextDescriptor contextDescriptor, ConfigurationInformation configurationInformation) { TaggedEventTypes = taggedEventTypes; ArrayEventTypes = arrayEventTypes; ExprEvaluatorContext = exprEvaluatorContext; StatementName = statementName; StatementId = statementId; StreamTypeService = streamTypeService; MethodResolutionService = methodResolutionService; TimeProvider = timeProvider; VariableService = variableService; TableService = tableService; EventAdapterService = eventAdapterService; ScriptingService = scriptingService; Annotations = annotations; ContextDescriptor = contextDescriptor; ConfigurationInformation = configurationInformation; }
/// <summary> /// Ctor. /// </summary> /// <param name="container">The container.</param> /// <param name="engineImportService">engine imports</param> /// <param name="variableService">variable names</param> /// <param name="configuration">the configuration</param> /// <param name="schedulingService">The scheduling service.</param> /// <param name="engineURI">The engine URI.</param> /// <param name="patternNodeFactory">The pattern node factory.</param> /// <param name="namedWindowMgmtService">The named window service.</param> /// <param name="contextManagementService">The context management service.</param> /// <param name="exprDeclaredService">The expr declared service.</param> /// <param name="contextDescriptor">optional context description</param> /// <param name="tableService">The table service.</param> public StatementSpecMapContext( IContainer container, EngineImportService engineImportService, VariableService variableService, ConfigurationInformation configuration, SchedulingService schedulingService, string engineURI, PatternNodeFactory patternNodeFactory, NamedWindowMgmtService namedWindowMgmtService, ContextManagementService contextManagementService, ExprDeclaredService exprDeclaredService, ContextDescriptor contextDescriptor, TableService tableService) { Container = container; PlugInAggregations = new LazyAllocatedMap <ConfigurationPlugInAggregationMultiFunction, PlugInAggregationMultiFunctionFactory>(); TableExpressions = new HashSet <ExprTableAccessNode>(); EngineImportService = engineImportService; VariableService = variableService; Configuration = configuration; VariableNames = new HashSet <string>(); SchedulingService = schedulingService; EngineURI = engineURI; PatternNodeFactory = patternNodeFactory; NamedWindowMgmtService = namedWindowMgmtService; ContextManagementService = contextManagementService; ExprDeclaredService = exprDeclaredService; ContextDescriptor = contextDescriptor; TableService = tableService; }
/// <summary>Ctor. </summary> /// <param name="contextName">context name</param> /// <param name="descriptor">context dimension descriptor</param> public CreateContextClause( string contextName, ContextDescriptor descriptor) { ContextName = contextName; Descriptor = descriptor; }
// settable for view-sharing /// <summary> /// Constructor. /// </summary> /// <param name="stmtEngineServices">is the engine services for the statement</param> /// <param name="schedulingService">implementation for schedule registration</param> /// <param name="scheduleBucket">is for ordering scheduled callbacks within the view statements</param> /// <param name="epStatementHandle">is the statements-own handle for use in registering callbacks with services</param> /// <param name="viewResultionService">is a service for resolving view namespace and name to a view factory</param> /// <param name="patternResolutionService">is the service that resolves pattern objects for the statement</param> /// <param name="statementExtensionSvcContext">provide extension points for custom statement resources</param> /// <param name="statementStopService">for registering a callback invoked when a statement is stopped</param> /// <param name="methodResolutionService">is a service for resolving static methods and aggregation functions</param> /// <param name="patternContextFactory">is the pattern-level services and context information factory</param> /// <param name="filterService">is the filtering service</param> /// <param name="statementResultService">handles awareness of listeners/subscriptions for a statement customizing output produced</param> /// <param name="internalEventEngineRouteDest">routing destination</param> /// <param name="annotations">The annotations.</param> /// <param name="statementAgentInstanceRegistry">The statement agent instance registry.</param> /// <param name="defaultAgentInstanceLock">The default agent instance lock.</param> /// <param name="contextDescriptor">The context descriptor.</param> /// <param name="patternSubexpressionPoolSvc">The pattern subexpression pool SVC.</param> /// <param name="matchRecognizeStatePoolStmtSvc">The match recognize state pool statement SVC.</param> /// <param name="statelessSelect">if set to <c>true</c> [stateless select].</param> /// <param name="contextControllerFactoryService">The context controller factory service.</param> /// <param name="defaultAgentInstanceScriptContext">The default agent instance script context.</param> /// <param name="aggregationServiceFactoryService">The aggregation service factory service.</param> /// <param name="scriptingService">The scripting service.</param> /// <param name="writesToTables">if set to <c>true</c> [writes to tables].</param> /// <param name="statementUserObject">The statement user object.</param> /// <param name="statementSemiAnonymousTypeRegistry">The statement semi anonymous type registry.</param> /// <param name="priority">The priority.</param> public StatementContext( StatementContextEngineServices stmtEngineServices, SchedulingService schedulingService, ScheduleBucket scheduleBucket, EPStatementHandle epStatementHandle, ViewResolutionService viewResultionService, PatternObjectResolutionService patternResolutionService, StatementExtensionSvcContext statementExtensionSvcContext, StatementStopService statementStopService, MethodResolutionService methodResolutionService, PatternContextFactory patternContextFactory, FilterService filterService, StatementResultService statementResultService, InternalEventRouteDest internalEventEngineRouteDest, Attribute[] annotations, StatementAIResourceRegistry statementAgentInstanceRegistry, IReaderWriterLock defaultAgentInstanceLock, ContextDescriptor contextDescriptor, PatternSubexpressionPoolStmtSvc patternSubexpressionPoolSvc, MatchRecognizeStatePoolStmtSvc matchRecognizeStatePoolStmtSvc, bool statelessSelect, ContextControllerFactoryService contextControllerFactoryService, AgentInstanceScriptContext defaultAgentInstanceScriptContext, AggregationServiceFactoryService aggregationServiceFactoryService, ScriptingService scriptingService, bool writesToTables, object statementUserObject, StatementSemiAnonymousTypeRegistry statementSemiAnonymousTypeRegistry, int priority) { _stmtEngineServices = stmtEngineServices; SchedulingService = schedulingService; ScheduleBucket = scheduleBucket; EpStatementHandle = epStatementHandle; ViewResolutionService = viewResultionService; PatternResolutionService = patternResolutionService; StatementExtensionServicesContext = statementExtensionSvcContext; StatementStopService = statementStopService; MethodResolutionService = methodResolutionService; PatternContextFactory = patternContextFactory; FilterService = filterService; _statementResultService = statementResultService; InternalEventEngineRouteDest = internalEventEngineRouteDest; ScheduleAdjustmentService = stmtEngineServices.ConfigSnapshot.EngineDefaults.ExecutionConfig.IsAllowIsolatedService ? new ScheduleAdjustmentService() : null; Annotations = annotations; StatementAgentInstanceRegistry = statementAgentInstanceRegistry; DefaultAgentInstanceLock = defaultAgentInstanceLock; ContextDescriptor = contextDescriptor; PatternSubexpressionPoolSvc = patternSubexpressionPoolSvc; MatchRecognizeStatePoolStmtSvc = matchRecognizeStatePoolStmtSvc; IsStatelessSelect = statelessSelect; ContextControllerFactoryService = contextControllerFactoryService; DefaultAgentInstanceScriptContext = defaultAgentInstanceScriptContext; AggregationServiceFactoryService = aggregationServiceFactoryService; ScriptingService = scriptingService; IsWritesToTables = writesToTables; StatementUserObject = statementUserObject; StatementSemiAnonymousTypeRegistry = statementSemiAnonymousTypeRegistry; Priority = priority; }
public ExprValidationContext(StreamTypeService streamTypeService, EngineImportService engineImportService, StatementExtensionSvcContext statementExtensionSvcContext, ViewResourceDelegateUnverified viewResourceDelegate, TimeProvider timeProvider, VariableService variableService, TableService tableService, ExprEvaluatorContext exprEvaluatorContext, EventAdapterService eventAdapterService, string statementName, int statementId, Attribute[] annotations, ContextDescriptor contextDescriptor, ScriptingService scriptingService, bool disablePropertyExpressionEventCollCache, bool allowRollupFunctions, bool allowBindingConsumption, bool isUnidirectionalJoin, string intoTableName, bool isFilterExpression) { StreamTypeService = streamTypeService; EngineImportService = engineImportService; StatementExtensionSvcContext = statementExtensionSvcContext; ViewResourceDelegate = viewResourceDelegate; TimeProvider = timeProvider; VariableService = variableService; TableService = tableService; ExprEvaluatorContext = exprEvaluatorContext; EventAdapterService = eventAdapterService; StatementName = statementName; StatementId = statementId; Annotations = annotations; ContextDescriptor = contextDescriptor; ScriptingService = scriptingService; IsDisablePropertyExpressionEventCollCache = disablePropertyExpressionEventCollCache; IsAllowRollupFunctions = allowRollupFunctions; IsAllowBindingConsumption = allowBindingConsumption; IsResettingAggregations = isUnidirectionalJoin; IntoTableName = intoTableName; IsFilterExpression = isFilterExpression; IsExpressionAudit = AuditEnum.EXPRESSION.GetAudit(annotations) != null; IsExpressionNestedAudit = AuditEnum.EXPRESSION_NESTED.GetAudit(annotations) != null; }
public static String CheckVariableContextName(ContextDescriptor contextDescriptor, VariableMetaData variableMetaData) { if (contextDescriptor == null) { return(CheckVariableContextName((String)null, variableMetaData)); } return(CheckVariableContextName(contextDescriptor.ContextName, variableMetaData)); }
public ContextManagerImpl(ContextControllerFactoryServiceContext factoryServiceContext) { _uLock = LockManager.CreateLock(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); _contextName = factoryServiceContext.ContextName; _servicesContext = factoryServiceContext.ServicesContext; _factory = factoryServiceContext.AgentInstanceContextCreate.StatementContext.ContextControllerFactoryService.GetFactory(factoryServiceContext)[0]; _rootContext = _factory.CreateNoCallback(0, this); // single instance: created here and activated/deactivated later _contextPartitionIdManager = factoryServiceContext.AgentInstanceContextCreate.StatementContext.ContextControllerFactoryService.AllocatePartitionIdMgr(_contextName, factoryServiceContext.AgentInstanceContextCreate.StatementContext.StatementId); var resourceRegistryFactory = _factory.StatementAIResourceRegistryFactory; var contextProps = _factory.ContextBuiltinProps; var contextPropsType = _servicesContext.EventAdapterService.CreateAnonymousMapType(_contextName, contextProps, true); var registry = new ContextPropertyRegistryImpl(_factory.ContextDetailPartitionItems, contextPropsType); _contextDescriptor = new ContextDescriptor(_contextName, _factory.IsSingleInstanceContext, registry, resourceRegistryFactory, this, _factory.ContextDetail); }
public ExprDeclaredNodeImpl( IContainer container, ExpressionDeclItem prototype, IList <ExprNode> chainParameters, ContextDescriptor contextDescriptor) { _prototype = prototype; _chainParameters = chainParameters; // copy expression - we do it at this time and not later try { _expressionBodyCopy = (ExprNode)SerializableObjectCopier.Copy(container, prototype.Inner); } catch (Exception e) { throw new Exception("Internal error providing expression tree: " + e.Message, e); } // replace context-properties where they are currently identifiers if (contextDescriptor == null) { return; } var visitorWParent = new ExprNodeIdentVisitorWParent(); _expressionBodyCopy.Accept(visitorWParent); foreach (var pair in visitorWParent.IdentNodes) { var streamOrProp = pair.Second.StreamOrPropertyName; if (streamOrProp != null && contextDescriptor.ContextPropertyRegistry.IsContextPropertyPrefix(streamOrProp)) { var context = new ExprContextPropertyNode(pair.Second.UnresolvedPropertyName); if (pair.First == null) { _expressionBodyCopy = context; } else { ExprNodeUtility.ReplaceChildNode(pair.First, pair.Second, context); } } } }
public FilterSpecCompilerArgs( IContainer container, IDictionary<string, Pair<EventType, string>> taggedEventTypes, IDictionary<string, Pair<EventType, string>> arrayEventTypes, ExprEvaluatorContext exprEvaluatorContext, string statementName, int statementId, StreamTypeService streamTypeService, EngineImportService engineImportService, TimeProvider timeProvider, VariableService variableService, TableService tableService, EventAdapterService eventAdapterService, FilterBooleanExpressionFactory filterBooleanExpressionFactory, ScriptingService scriptingService, Attribute[] annotations, ContextDescriptor contextDescriptor, ConfigurationInformation configurationInformation, StatementExtensionSvcContext statementExtensionSvcContext) { Container = container; TaggedEventTypes = taggedEventTypes; ArrayEventTypes = arrayEventTypes; ExprEvaluatorContext = exprEvaluatorContext; StatementName = statementName; StatementId = statementId; StreamTypeService = streamTypeService; EngineImportService = engineImportService; TimeProvider = timeProvider; VariableService = variableService; TableService = tableService; EventAdapterService = eventAdapterService; FilterBooleanExpressionFactory = filterBooleanExpressionFactory; ScriptingService = scriptingService; Annotations = annotations; ContextDescriptor = contextDescriptor; ConfigurationInformation = configurationInformation; StatementExtensionSvcContext = statementExtensionSvcContext; }
public NamedWindowConsumerView AddConsumer(NamedWindowConsumerDesc consumerDesc, bool isSubselect) { StatementResourceService statementResourceService = _statementContextCreateWindow.StatementExtensionServicesContext.StmtResources; // handle same-context consumer if (_contextName != null) { ContextDescriptor contextDescriptor = consumerDesc.AgentInstanceContext.StatementContext.ContextDescriptor; if (contextDescriptor != null && _contextName.Equals(contextDescriptor.ContextName)) { StatementResourceHolder holder = statementResourceService.GetPartitioned(consumerDesc.AgentInstanceContext.AgentInstanceId); return(holder.NamedWindowProcessorInstance.TailViewInstance.AddConsumer(consumerDesc, isSubselect)); } else { // consumer is out-of-context return(_tailView.AddConsumer(consumerDesc)); // non-context consumers } } // handle no context associated return(statementResourceService.ResourcesUnpartitioned.NamedWindowProcessorInstance.TailViewInstance.AddConsumer(consumerDesc, isSubselect)); }
public void QContextScheduledEval(ContextDescriptor contextDescriptor) { }
public override void EnteringContext(ContextDescriptor context) { _currentContext = context ?? new NullContextDescriptor(); base.EnteringContext(_currentContext); }
public static void AddCloudy(this IServiceCollection services, Action <CloudyConfigurator> cloudy) { services.Configure <RouteOptions>(options => { options.ConstraintMap.Add("contentroute", typeof(ContentRouteConstraint)); }); var options = new CloudyOptions(); var configurator = new CloudyConfigurator(services, options); cloudy(configurator); configurator.AddComponent <CloudyAssemblyHandle>(); if (Assembly.GetCallingAssembly() != Assembly.GetExecutingAssembly()) { configurator.AddComponentAssembly(Assembly.GetCallingAssembly()); } var AssemblyProvider = new AssemblyProvider(options.Assemblies.Select(a => new AssemblyWrapper(a))); services.AddSingleton <IAssemblyProvider>(AssemblyProvider); services.AddSingleton <IContextDescriptorProvider>(new ContextDescriptorProvider(ContextDescriptor.CreateFrom(options.Contexts))); foreach (var injector in new DependencyInjectorProvider(new DependencyInjectorCreator(AssemblyProvider)).GetAll()) { injector.InjectDependencies(services); } services.AddTransient <IStartupFilter, InitializerBootstrapper>(); }
public StatementContext MakeContext( int statementId, string statementName, string expression, StatementType statementType, EPServicesContext engineServices, IDictionary <string, object> optAdditionalContext, bool isFireAndForget, Attribute[] annotations, EPIsolationUnitServices isolationUnitServices, bool stateless, StatementSpecRaw statementSpecRaw, IList <ExprSubselectNode> subselectNodes, bool writesToTables, object statementUserObject) { // Allocate the statement's schedule bucket which stays constant over it's lifetime. // The bucket allows callbacks for the same time to be ordered (within and across statements) and thus deterministic. var scheduleBucket = engineServices.SchedulingMgmtService.AllocateBucket(); // Create a lock for the statement IReaderWriterLock defaultStatementAgentInstanceLock; // For on-delete statements, use the create-named-window statement lock var optCreateWindowDesc = statementSpecRaw.CreateWindowDesc; var optOnTriggerDesc = statementSpecRaw.OnTriggerDesc; if ((optOnTriggerDesc != null) && (optOnTriggerDesc is OnTriggerWindowDesc)) { var windowName = ((OnTriggerWindowDesc)optOnTriggerDesc).WindowName; if (engineServices.TableService.GetTableMetadata(windowName) == null) { defaultStatementAgentInstanceLock = engineServices.NamedWindowMgmtService.GetNamedWindowLock(windowName); if (defaultStatementAgentInstanceLock == null) { throw new EPStatementException("Named window or table '" + windowName + "' has not been declared", expression); } } else { defaultStatementAgentInstanceLock = engineServices.StatementLockFactory.GetStatementLock(statementName, annotations, stateless); } } // For creating a named window, save the lock for use with on-delete/on-merge/on-Update etc. statements else if (optCreateWindowDesc != null) { defaultStatementAgentInstanceLock = engineServices.NamedWindowMgmtService.GetNamedWindowLock(optCreateWindowDesc.WindowName); if (defaultStatementAgentInstanceLock == null) { defaultStatementAgentInstanceLock = engineServices.StatementLockFactory.GetStatementLock( statementName, annotations, false); engineServices.NamedWindowMgmtService.AddNamedWindowLock( optCreateWindowDesc.WindowName, defaultStatementAgentInstanceLock, statementName); } } else { defaultStatementAgentInstanceLock = engineServices.StatementLockFactory.GetStatementLock( statementName, annotations, stateless); } StatementMetricHandle stmtMetric = null; if (!isFireAndForget) { stmtMetric = engineServices.MetricsReportingService.GetStatementHandle(statementId, statementName); } var annotationData = AnnotationAnalysisResult.AnalyzeAnnotations(annotations); var hasVariables = statementSpecRaw.HasVariables || (statementSpecRaw.CreateContextDesc != null); var hasTableAccess = StatementContextFactoryUtil.DetermineHasTableAccess(subselectNodes, statementSpecRaw, engineServices); var epStatementHandle = new EPStatementHandle( statementId, statementName, expression, statementType, expression, hasVariables, stmtMetric, annotationData.Priority, annotationData.IsPremptive, hasTableAccess, engineServices.MultiMatchHandlerFactory.GetDefaultHandler()); var patternContextFactory = new PatternContextFactoryDefault(); var optionalCreateNamedWindowName = statementSpecRaw.CreateWindowDesc != null ? statementSpecRaw.CreateWindowDesc.WindowName : null; var viewResolutionService = new ViewResolutionServiceImpl( _viewRegistry, optionalCreateNamedWindowName, _systemVirtualDwViewFactory); var patternResolutionService = new PatternObjectResolutionServiceImpl(_patternObjectClasses); var schedulingService = engineServices.SchedulingService; var filterService = engineServices.FilterService; if (isolationUnitServices != null) { filterService = isolationUnitServices.FilterService; schedulingService = isolationUnitServices.SchedulingService; } var scheduleAudit = AuditEnum.SCHEDULE.GetAudit(annotations); if (scheduleAudit != null) { schedulingService = new SchedulingServiceAudit( engineServices.EngineURI, statementName, schedulingService); } StatementAIResourceRegistry statementAgentInstanceRegistry = null; ContextDescriptor contextDescriptor = null; var optionalContextName = statementSpecRaw.OptionalContextName; if (optionalContextName != null) { contextDescriptor = engineServices.ContextManagementService.GetContextDescriptor(optionalContextName); // allocate a per-instance registry of aggregations and prev/prior/subselect if (contextDescriptor != null) { statementAgentInstanceRegistry = contextDescriptor.AiResourceRegistryFactory.Invoke(); } } var countSubexpressions = engineServices.ConfigSnapshot.EngineDefaults.PatternsConfig.MaxSubexpressions != null; PatternSubexpressionPoolStmtSvc patternSubexpressionPoolStmtSvc = null; if (countSubexpressions) { var stmtCounter = new PatternSubexpressionPoolStmtHandler(); patternSubexpressionPoolStmtSvc = new PatternSubexpressionPoolStmtSvc(engineServices.PatternSubexpressionPoolSvc, stmtCounter); engineServices.PatternSubexpressionPoolSvc.AddPatternContext(statementName, stmtCounter); } var countMatchRecogStates = engineServices.ConfigSnapshot.EngineDefaults.MatchRecognizeConfig.MaxStates != null; MatchRecognizeStatePoolStmtSvc matchRecognizeStatePoolStmtSvc = null; if (countMatchRecogStates && statementSpecRaw.MatchRecognizeSpec != null) { var stmtCounter = new MatchRecognizeStatePoolStmtHandler(); matchRecognizeStatePoolStmtSvc = new MatchRecognizeStatePoolStmtSvc(engineServices.MatchRecognizeStatePoolEngineSvc, stmtCounter); engineServices.MatchRecognizeStatePoolEngineSvc.AddPatternContext(statementName, stmtCounter); } AgentInstanceScriptContext defaultAgentInstanceScriptContext = null; if (statementSpecRaw.ScriptExpressions != null && !statementSpecRaw.ScriptExpressions.IsEmpty()) { defaultAgentInstanceScriptContext = new AgentInstanceScriptContext(); } // allow a special context controller factory for testing var contextControllerFactoryService = GetContextControllerFactoryService(annotations); // may use resource tracking var statementResourceService = new StatementResourceService(optionalContextName != null); StatementExtensionSvcContext extensionSvcContext = new ProxyStatementExtensionSvcContext { ProcStmtResources = () => statementResourceService, ProcExtractStatementResourceHolder = resultOfStart => StatementResourceHolderUtil.PopulateHolder(resultOfStart) }; // Create statement context return(new StatementContext( _stmtEngineServices, schedulingService, scheduleBucket, epStatementHandle, viewResolutionService, patternResolutionService, extensionSvcContext, new StatementStopServiceImpl(), patternContextFactory, filterService, new StatementResultServiceImpl( statementName, engineServices.StatementLifecycleSvc, engineServices.MetricsReportingService, engineServices.ThreadingService), engineServices.InternalEventEngineRouteDest, annotations, statementAgentInstanceRegistry, defaultStatementAgentInstanceLock, contextDescriptor, patternSubexpressionPoolStmtSvc, matchRecognizeStatePoolStmtSvc, stateless, contextControllerFactoryService, defaultAgentInstanceScriptContext, AggregationServiceFactoryServiceImpl.DEFAULT_FACTORY, engineServices.ScriptingService, writesToTables, statementUserObject, StatementSemiAnonymousTypeRegistryImpl.INSTANCE, annotationData.Priority)); }
public virtual void EnteringContext(ContextDescriptor context) { Contexts.Add(context ?? new NullContextDescriptor()); }
public static void HandleLibFunc( CommonTokenStream tokenStream, EsperEPL2GrammarParser.LibFunctionContext ctx, ConfigurationInformation configurationInformation, EngineImportService engineImportService, IDictionary <ITree, ExprNode> astExprNodeMap, LazyAllocatedMap <ConfigurationPlugInAggregationMultiFunction, PlugInAggregationMultiFunctionFactory> plugInAggregations, string engineURI, ExpressionDeclDesc expressionDeclarations, ExprDeclaredService exprDeclaredService, IList <ExpressionScriptProvided> scriptExpressions, ContextDescriptor contextDescriptor, TableService tableService, StatementSpecRaw statementSpec, VariableService variableService) { var model = GetModel(ctx, tokenStream); var duckType = configurationInformation.EngineDefaults.ExpressionConfig.IsDuckTyping; var udfCache = configurationInformation.EngineDefaults.ExpressionConfig.IsUdfCache; // handle "some.xyz(...)" or "some.other.xyz(...)" if (model.ChainElements.Count == 1 && model.OptionalClassIdent != null && ASTTableExprHelper.CheckTableNameGetExprForProperty(tableService, model.OptionalClassIdent) == null) { var chainSpec = GetLibFunctionChainSpec(model.ChainElements[0], astExprNodeMap); var declaredNodeX = ExprDeclaredHelper.GetExistsDeclaredExpr(model.OptionalClassIdent, Collections.GetEmptyList <ExprNode>(), expressionDeclarations.Expressions, exprDeclaredService, contextDescriptor); if (declaredNodeX != null) { ExprNode exprNode = new ExprDotNode(Collections.SingletonList(chainSpec), duckType, udfCache); exprNode.AddChildNode(declaredNodeX); ASTExprHelper.ExprCollectAddSubNodesAddParentNode(exprNode, ctx, astExprNodeMap); return; } IList <ExprChainedSpec> chainX = new List <ExprChainedSpec>(2); chainX.Add(new ExprChainedSpec(model.OptionalClassIdent, Collections.GetEmptyList <ExprNode>(), true)); chainX.Add(chainSpec); var dotNodeX = new ExprDotNode(chainX, configurationInformation.EngineDefaults.ExpressionConfig.IsDuckTyping, configurationInformation.EngineDefaults.ExpressionConfig.IsUdfCache); if (dotNodeX.IsVariableOp(variableService)) { statementSpec.HasVariables = true; } ASTExprHelper.ExprCollectAddSubNodesAddParentNode(dotNodeX, ctx, astExprNodeMap); return; } // try additional built-in single-row function ExprNode singleRowExtNode = engineImportService.ResolveSingleRowExtendedBuiltin(model.ChainElements[0].FuncName); if (singleRowExtNode != null) { if (model.ChainElements.Count == 1) { ASTExprHelper.ExprCollectAddSubNodesAddParentNode(singleRowExtNode, ctx, astExprNodeMap); return; } var spec = new List <ExprChainedSpec>(); EsperEPL2GrammarParser.LibFunctionArgsContext firstArgs = model.ChainElements[0].Args; var childExpressions = ASTLibFunctionHelper.GetExprNodesLibFunc(firstArgs, astExprNodeMap); singleRowExtNode.AddChildNodes(childExpressions); AddChainRemainderFromOffset(model.ChainElements, 1, spec, astExprNodeMap); var dotNodeX = new ExprDotNode(spec, configurationInformation.EngineDefaults.ExpressionConfig.IsDuckTyping, configurationInformation.EngineDefaults.ExpressionConfig.IsUdfCache); dotNodeX.AddChildNode(singleRowExtNode); ASTExprHelper.ExprCollectAddSubNodesAddParentNode(dotNodeX, ctx, astExprNodeMap); return; } // try plug-in single-row function try { var firstFunctionX = model.ChainElements[0].FuncName; var firstFunctionIsProperty = !model.ChainElements[0].HasLeftParen; var classMethodPair = engineImportService.ResolveSingleRow(firstFunctionX); IList <ExprChainedSpec> spec = new List <ExprChainedSpec>(); var firstArgs = model.ChainElements[0].Args; var childExpressions = ASTLibFunctionHelper.GetExprNodesLibFunc(firstArgs, astExprNodeMap); spec.Add(new ExprChainedSpec(classMethodPair.Second.MethodName, childExpressions, firstFunctionIsProperty)); AddChainRemainderFromOffset(model.ChainElements, 1, spec, astExprNodeMap); var plugin = new ExprPlugInSingleRowNode(firstFunctionX, classMethodPair.First, spec, classMethodPair.Second); ASTExprHelper.ExprCollectAddSubNodesAddParentNode(plugin, ctx, astExprNodeMap); return; } catch (EngineImportUndefinedException e) { // Not an single-row function } catch (EngineImportException e) { throw new IllegalStateException("Error resolving single-row function: " + e.Message, e); } // special case for min,max var firstFunction = model.ChainElements[0].FuncName; if ((firstFunction.ToLower().Equals("max")) || (firstFunction.ToLower().Equals("min")) || (firstFunction.ToLower().Equals("fmax")) || (firstFunction.ToLower().Equals("fmin"))) { var firstArgs = model.ChainElements[0].Args; HandleMinMax(firstFunction, firstArgs, astExprNodeMap); return; } // obtain chain with actual expressions IList <ExprChainedSpec> chain = new List <ExprChainedSpec>(); AddChainRemainderFromOffset(model.ChainElements, 0, chain, astExprNodeMap); // add chain element for class info, if any var distinct = model.ChainElements[0].Args != null && model.ChainElements[0].Args.DISTINCT() != null; if (model.OptionalClassIdent != null) { chain.Insert(0, new ExprChainedSpec(model.OptionalClassIdent, Collections.GetEmptyList <ExprNode>(), true)); distinct = false; } firstFunction = chain[0].Name; // try plug-in aggregation function var aggregationNode = ASTAggregationHelper.TryResolveAsAggregation(engineImportService, distinct, firstFunction, plugInAggregations, engineURI); if (aggregationNode != null) { var firstSpec = chain.Pluck(0); aggregationNode.AddChildNodes(firstSpec.Parameters); ExprNode exprNode; if (chain.IsEmpty()) { exprNode = aggregationNode; } else { exprNode = new ExprDotNode(chain, duckType, udfCache); exprNode.AddChildNode(aggregationNode); } ASTExprHelper.ExprCollectAddSubNodesAddParentNode(exprNode, ctx, astExprNodeMap); return; } // try declared or alias expression var declaredNode = ExprDeclaredHelper.GetExistsDeclaredExpr(firstFunction, chain[0].Parameters, expressionDeclarations.Expressions, exprDeclaredService, contextDescriptor); if (declaredNode != null) { chain.RemoveAt(0); ExprNode exprNode; if (chain.IsEmpty()) { exprNode = declaredNode; } else { exprNode = new ExprDotNode(chain, duckType, udfCache); exprNode.AddChildNode(declaredNode); } ASTExprHelper.ExprCollectAddSubNodesAddParentNode(exprNode, ctx, astExprNodeMap); return; } // try script var scriptNode = ExprDeclaredHelper.GetExistsScript(configurationInformation.EngineDefaults.ScriptsConfig.DefaultDialect, chain[0].Name, chain[0].Parameters, scriptExpressions, exprDeclaredService); if (scriptNode != null) { chain.RemoveAt(0); ExprNode exprNode; if (chain.IsEmpty()) { exprNode = scriptNode; } else { exprNode = new ExprDotNode(chain, duckType, udfCache); exprNode.AddChildNode(scriptNode); } ASTExprHelper.ExprCollectAddSubNodesAddParentNode(exprNode, ctx, astExprNodeMap); return; } // try table var tableInfo = ASTTableExprHelper.CheckTableNameGetLibFunc(tableService, engineImportService, plugInAggregations, engineURI, firstFunction, chain); if (tableInfo != null) { ASTTableExprHelper.AddTableExpressionReference(statementSpec, tableInfo.First); chain = tableInfo.Second; ExprNode exprNode; if (chain.IsEmpty()) { exprNode = tableInfo.First; } else { exprNode = new ExprDotNode(chain, duckType, udfCache); exprNode.AddChildNode(tableInfo.First); } ASTExprHelper.ExprCollectAddSubNodesAddParentNode(exprNode, ctx, astExprNodeMap); return; } // Could be a mapped property with an expression-parameter "mapped(expr)" or array property with an expression-parameter "array(expr)". ExprDotNode dotNode; if (chain.Count == 1) { dotNode = new ExprDotNode(chain, false, false); } else { dotNode = new ExprDotNode(chain, duckType, udfCache); } ASTExprHelper.ExprCollectAddSubNodesAddParentNode(dotNode, ctx, astExprNodeMap); }
public static FilterSpecCompiled BuildNoStmtCtx( IList <ExprNode> validatedFilterNodes, EventType eventType, string eventTypeName, PropertyEvalSpec optionalPropertyEvalSpec, IDictionary <string, Pair <EventType, string> > taggedEventTypes, IDictionary <string, Pair <EventType, string> > arrayEventTypes, StreamTypeService streamTypeService, string optionalStreamName, ICollection <int> assignedTypeNumberStack, ExprEvaluatorContext exprEvaluatorContext, string statementId, string statementName, Attribute[] annotations, ContextDescriptor contextDescriptor, MethodResolutionService methodResolutionService, EventAdapterService eventAdapterService, TimeProvider timeProvider, VariableService variableService, ScriptingService scriptingService, TableService tableService, ConfigurationInformation configurationInformation, NamedWindowService namedWindowService) { var args = new FilterSpecCompilerArgs( taggedEventTypes, arrayEventTypes, exprEvaluatorContext, statementName, statementId, streamTypeService, methodResolutionService, timeProvider, variableService, tableService, eventAdapterService, scriptingService, annotations, contextDescriptor, configurationInformation); var parameters = FilterSpecCompilerPlanner.PlanFilterParameters(validatedFilterNodes, args); PropertyEvaluator optionalPropertyEvaluator = null; if (optionalPropertyEvalSpec != null) { optionalPropertyEvaluator = PropertyEvaluatorFactory.MakeEvaluator( optionalPropertyEvalSpec, eventType, optionalStreamName, eventAdapterService, methodResolutionService, timeProvider, variableService, scriptingService, tableService, streamTypeService.EngineURIQualifier, statementId, statementName, annotations, assignedTypeNumberStack, configurationInformation, namedWindowService); } var spec = new FilterSpecCompiled(eventType, eventTypeName, parameters, optionalPropertyEvaluator); if (Log.IsDebugEnabled) { Log.Debug(".makeFilterSpec spec=" + spec); } return(spec); }