protected ExpressionViewBase( ViewUpdatedCollection viewUpdatedCollection, ExprEvaluator expiryExpression, AggregationServiceFactoryDesc aggregationServiceFactoryDesc, ObjectArrayEventBean builtinEventProps, ISet <String> variableNames, AgentInstanceViewFactoryChainContext agentInstanceContext) { ViewUpdatedCollection = viewUpdatedCollection; ExpiryExpression = expiryExpression; BuiltinEventProps = builtinEventProps; EventsPerStream = new EventBean[] { null, builtinEventProps }; VariableNames = variableNames; AgentInstanceContext = agentInstanceContext; if (variableNames != null && !variableNames.IsEmpty()) { foreach (String variable in variableNames) { var variableName = variable; var agentInstanceId = agentInstanceContext.AgentInstanceId; var variableService = agentInstanceContext.StatementContext.VariableService; agentInstanceContext.StatementContext.VariableService.RegisterCallback(variable, agentInstanceId, Update); agentInstanceContext.AddTerminationCallback( new ProxyStopCallback(() => variableService.UnregisterCallback(variableName, agentInstanceId, Update))); } ScheduleHandleCallback callback = new ProxyScheduleHandleCallback { ProcScheduledTrigger = extensionServicesContext => Instrument.With( i => i.QViewScheduledEval(this, ViewName), i => i.AViewScheduledEval(), ScheduleCallback) }; ScheduleSlot = agentInstanceContext.StatementContext.ScheduleBucket.AllocateSlot(); ScheduleHandle = new EPStatementHandleCallback(agentInstanceContext.EpStatementAgentInstanceHandle, callback); agentInstanceContext.AddTerminationCallback(this); } else { ScheduleSlot = -1; ScheduleHandle = null; } if (aggregationServiceFactoryDesc != null) { AggregationService = aggregationServiceFactoryDesc.AggregationServiceFactory.MakeService( agentInstanceContext.AgentInstanceContext, agentInstanceContext.AgentInstanceContext.StatementContext.EngineImportService, false, null); AggregateNodes = aggregationServiceFactoryDesc.Expressions; } else { AggregationService = null; AggregateNodes = Collections.GetEmptyList <AggregationServiceAggExpressionDesc>(); } }
/// <summary> /// Constructor creates a moving window extending the specified number of elements into the past. /// </summary> /// <param name="dataWindowViewFactory">for copying this view in a group-by</param> /// <param name="viewUpdatedCollection">is a collection that the view must update when receiving events</param> /// <param name="expiryExpression">The expiry expression.</param> /// <param name="AggregationServiceFactoryDesc">The aggregation service factory desc.</param> /// <param name="builtinEventProps">The builtin event props.</param> /// <param name="variableNames">variable names</param> /// <param name="AgentInstanceContext">The agent instance context.</param> public ExpressionWindowView(ExpressionWindowViewFactory dataWindowViewFactory, ViewUpdatedCollection viewUpdatedCollection, ExprEvaluator expiryExpression, AggregationServiceFactoryDesc AggregationServiceFactoryDesc, ObjectArrayEventBean builtinEventProps, ISet <String> variableNames, AgentInstanceViewFactoryChainContext AgentInstanceContext) : base(viewUpdatedCollection, expiryExpression, AggregationServiceFactoryDesc, builtinEventProps, variableNames, AgentInstanceContext) { _dataWindowViewFactory = dataWindowViewFactory; }
public SubSelectStrategyFactoryLocalViewPreloaded(int subqueryNumber, SubSelectActivationHolder subSelectHolder, Pair <EventTableFactory, SubordTableLookupStrategyFactory> pair, ExprNode filterExprNode, ExprEvaluator filterExprEval, bool correlatedSubquery, AggregationServiceFactoryDesc aggregationServiceFactory, ViewResourceDelegateVerified viewResourceDelegate, ExprEvaluator[] groupKeys) { _subqueryNumber = subqueryNumber; _subSelectHolder = subSelectHolder; _pair = pair; _filterExprNode = filterExprNode; _filterExprEval = filterExprEval; _correlatedSubquery = correlatedSubquery; _aggregationServiceFactory = aggregationServiceFactory; _viewResourceDelegate = viewResourceDelegate; _groupKeys = groupKeys; }
public SubSelectStrategyFactoryDesc(SubSelectActivationHolder subSelectActivationHolder, SubSelectStrategyFactory factory, AggregationServiceFactoryDesc aggregationServiceFactoryDesc, IList <ExprPriorNode> priorNodesList, IList <ExprPreviousNode> prevNodesList) { SubSelectActivationHolder = subSelectActivationHolder; Factory = factory; AggregationServiceFactoryDesc = aggregationServiceFactoryDesc; PriorNodesList = priorNodesList; PrevNodesList = prevNodesList; }
public SubSelectStrategyFactoryIndexShare( string statementName, int statementId, int subqueryNum, EventType[] outerEventTypesSelect, NamedWindowProcessor optionalNamedWindowProcessor, TableMetadata optionalTableMetadata, bool fullTableScan, IndexHint optionalIndexHint, SubordPropPlan joinedPropPlan, ExprEvaluator filterExprEval, AggregationServiceFactoryDesc aggregationServiceFactory, ExprEvaluator[] groupByKeys, TableService tableService, Attribute[] annotations, StatementStopService statementStopService) { _optionalNamedWindowProcessor = optionalNamedWindowProcessor; _optionalTableMetadata = optionalTableMetadata; _filterExprEval = filterExprEval; _aggregationServiceFactory = aggregationServiceFactory; _groupByKeys = groupByKeys; _tableService = tableService; bool isLogging; ILog log; if (optionalTableMetadata != null) { isLogging = optionalTableMetadata.IsQueryPlanLogging; log = TableServiceImpl.QueryPlanLog; _queryPlan = SubordinateQueryPlanner.PlanSubquery(outerEventTypesSelect, joinedPropPlan, false, fullTableScan, optionalIndexHint, true, subqueryNum, false, optionalTableMetadata.EventTableIndexMetadataRepo, optionalTableMetadata.UniqueKeyProps, true, statementName, statementId, annotations); if (_queryPlan != null) { for (int i = 0; i < _queryPlan.IndexDescs.Length; i++) { optionalTableMetadata.AddIndexReference(_queryPlan.IndexDescs[i].IndexName, statementName); } } } else { isLogging = optionalNamedWindowProcessor.RootView.IsQueryPlanLogging; log = NamedWindowRootView.QueryPlanLog; _queryPlan = SubordinateQueryPlanner.PlanSubquery(outerEventTypesSelect, joinedPropPlan, false, fullTableScan, optionalIndexHint, true, subqueryNum, optionalNamedWindowProcessor.IsVirtualDataWindow, optionalNamedWindowProcessor.EventTableIndexMetadataRepo, optionalNamedWindowProcessor.OptionalUniqueKeyProps, false, statementName, statementId, annotations); if (_queryPlan != null && _queryPlan.IndexDescs != null) { SubordinateQueryPlannerUtil.AddIndexMetaAndRef(_queryPlan.IndexDescs, optionalNamedWindowProcessor.EventTableIndexMetadataRepo, statementName); statementStopService.StatementStopped += () => { for (int i = 0; i < _queryPlan.IndexDescs.Length; i++) { bool last = optionalNamedWindowProcessor.EventTableIndexMetadataRepo.RemoveIndexReference(_queryPlan.IndexDescs[i].IndexMultiKey, statementName); if (last) { optionalNamedWindowProcessor.EventTableIndexMetadataRepo.RemoveIndex(_queryPlan.IndexDescs[i].IndexMultiKey); optionalNamedWindowProcessor.RemoveAllInstanceIndexes(_queryPlan.IndexDescs[i].IndexMultiKey); } } }; } } SubordinateQueryPlannerUtil.QueryPlanLogOnSubq(isLogging, log, _queryPlan, subqueryNum, annotations); }
public void Attach(EventType parentEventType, StatementContext statementContext, ViewFactory optionalParentFactory, IList <ViewFactory> parentViewFactories) { _eventType = parentEventType; // define built-in fields var builtinTypeDef = ExpressionViewOAFieldEnumExtensions.AsMapOfTypes(_eventType); _builtinMapType = statementContext.EventAdapterService.CreateAnonymousObjectArrayType( statementContext.StatementId + "_exprview", builtinTypeDef); StreamTypeService streamTypeService = new StreamTypeServiceImpl(new EventType[] { _eventType, _builtinMapType }, new String[2], new bool[2], statementContext.EngineURI, false); // validate expression ExpiryExpression = ViewFactorySupport.ValidateExpr(ViewName, statementContext, ExpiryExpression, streamTypeService, 0); var summaryVisitor = new ExprNodeSummaryVisitor(); ExpiryExpression.Accept(summaryVisitor); if (summaryVisitor.HasSubselect || summaryVisitor.HasStreamSelect || summaryVisitor.HasPreviousPrior) { throw new ViewParameterException("Invalid expiry expression: Sub-select, previous or prior functions are not supported in this context"); } var returnType = ExpiryExpression.ExprEvaluator.ReturnType; if (returnType.GetBoxedType() != typeof(bool?)) { throw new ViewParameterException("Invalid return value for expiry expression, expected a bool return value but received " + returnType.GetParameterAsString()); } // determine variables used, if any var visitor = new ExprNodeVariableVisitor(); ExpiryExpression.Accept(visitor); VariableNames = visitor.VariableNames; // determine aggregation nodes, if any var aggregateNodes = new List <ExprAggregateNode>(); ExprAggregateNodeUtil.GetAggregatesBottomUp(ExpiryExpression, aggregateNodes); if (aggregateNodes.IsNotEmpty()) { try { AggregationServiceFactoryDesc = AggregationServiceFactoryFactory.GetService( Collections.GetEmptyList <ExprAggregateNode>(), Collections.GetEmptyMap <ExprNode, String>(), Collections.GetEmptyList <ExprDeclaredNode>(), null, aggregateNodes, Collections.GetEmptyList <ExprAggregateNode>(), Collections.GetEmptyList <ExprAggregateNodeGroupKey>(), false, statementContext.Annotations, statementContext.VariableService, false, false, null, null, AggregationServiceFactoryServiceImpl.DEFAULT_FACTORY, streamTypeService.EventTypes, statementContext.MethodResolutionService, null, statementContext.ContextName, null, null); } catch (ExprValidationException ex) { throw new ViewParameterException(ex.Message, ex); } } }
public ResultSetProcessorFactoryDesc(ResultSetProcessorFactory resultSetProcessorFactory, OrderByProcessorFactory orderByProcessorFactory, AggregationServiceFactoryDesc aggregationServiceFactoryDesc) { ResultSetProcessorFactory = resultSetProcessorFactory; OrderByProcessorFactory = orderByProcessorFactory; AggregationServiceFactoryDesc = aggregationServiceFactoryDesc; }