public StatementAgentInstanceFactoryOnTriggerNamedWindow(StatementContext statementContext, StatementSpecCompiled statementSpec, EPServicesContext services, ViewableActivator activator, SubSelectStrategyCollection subSelectStrategyCollection, ResultSetProcessorFactoryDesc resultSetProcessorPrototype, ExprNode validatedJoin, ResultSetProcessorFactoryDesc outputResultSetProcessorPrototype, NamedWindowOnExprFactory onExprFactory, OutputProcessViewFactory outputProcessViewFactory, EventType activatorResultEventType, NamedWindowProcessor processor, IList <StopCallback> stopCallbacks) : base(statementContext, statementSpec, services, activator, subSelectStrategyCollection) { _resultSetProcessorPrototype = resultSetProcessorPrototype; _outputResultSetProcessorPrototype = outputResultSetProcessorPrototype; _onExprFactory = onExprFactory; _outputProcessViewFactory = outputProcessViewFactory; _processor = processor; IndexHintPair pair = GetIndexHintPair(statementContext, statementSpec); IndexHint indexHint = pair.IndexHint; ExcludePlanHint excludePlanHint = pair.ExcludePlanHint; _queryPlan = SubordinateQueryPlanner.PlanOnExpression( validatedJoin, activatorResultEventType, indexHint, processor.IsEnableSubqueryIndexShare, -1, excludePlanHint, processor.IsVirtualDataWindow, processor.EventTableIndexMetadataRepo, processor.NamedWindowType, processor.OptionalUniqueKeyProps, false, statementContext.StatementName, statementContext.StatementId, statementContext.Annotations); if (_queryPlan.IndexDescs != null) { SubordinateQueryPlannerUtil.AddIndexMetaAndRef(_queryPlan.IndexDescs, processor.EventTableIndexMetadataRepo, statementContext.StatementName); stopCallbacks.Add(new ProxyStopCallback(() => { for (int i = 0; i < _queryPlan.IndexDescs.Length; i++) { bool last = processor.EventTableIndexMetadataRepo.RemoveIndexReference(_queryPlan.IndexDescs[i].IndexMultiKey, statementContext.StatementName); if (last) { processor.EventTableIndexMetadataRepo.RemoveIndex(_queryPlan.IndexDescs[i].IndexMultiKey); processor.RemoveAllInstanceIndexes(_queryPlan.IndexDescs[i].IndexMultiKey); } } })); } SubordinateQueryPlannerUtil.QueryPlanLogOnExpr(processor.RootView.IsQueryPlanLogging, NamedWindowRootView.QueryPlanLog, _queryPlan, statementContext.Annotations, statementContext.EngineImportService); }
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); }