public override OnExprViewResult DetermineOnExprView(AgentInstanceContext agentInstanceContext, IList <StopCallback> stopCallbacks, bool isRecoveringResilient)
        {
            // get result set processor and aggregation services
            Pair <ResultSetProcessor, AggregationService> pair = EPStatementStartMethodHelperUtil.StartResultSetAndAggregation(_resultSetProcessorPrototype, agentInstanceContext, false, null);

            // get named window processor instance
            NamedWindowProcessorInstance processorInstance = _processor.GetProcessorInstance(agentInstanceContext);

            // obtain on-expr view
            EventTable[] indexes = null;
            if (_queryPlan.IndexDescs != null)
            {
                indexes = SubordinateQueryPlannerUtil.RealizeTables(
                    _queryPlan.IndexDescs,
                    _processor.NamedWindowType,
                    processorInstance.RootViewInstance.IndexRepository,
                    processorInstance.RootViewInstance.DataWindowContents,
                    processorInstance.TailViewInstance.AgentInstanceContext,
                    isRecoveringResilient);
            }
            SubordWMatchExprLookupStrategy strategy       = _queryPlan.Factory.Realize(indexes, agentInstanceContext, processorInstance.RootViewInstance.DataWindowContents, processorInstance.RootViewInstance.VirtualDataWindow);
            NamedWindowOnExprBaseView      onExprBaseView = _onExprFactory.Make(strategy, processorInstance.RootViewInstance, agentInstanceContext, pair.First);

            return(new OnExprViewResult(onExprBaseView, pair.Second));
        }
Ejemplo n.º 2
0
        public SubSelectStrategyRealization Instantiate(
            EPServicesContext services,
            Viewable viewableRoot,
            AgentInstanceContext agentInstanceContext,
            IList <StopCallback> stopCallbackList,
            int subqueryNumber,
            bool isRecoveringResilient)
        {
            SubselectAggregationPreprocessorBase subselectAggregationPreprocessor = null;

            AggregationService aggregationService = null;

            if (_aggregationServiceFactory != null)
            {
                aggregationService = _aggregationServiceFactory.AggregationServiceFactory.MakeService(
                    agentInstanceContext, agentInstanceContext.StatementContext.EngineImportService, true, subqueryNumber);
                if (_groupByKeys == null)
                {
                    if (_filterExprEval == null)
                    {
                        subselectAggregationPreprocessor =
                            new SubselectAggregationPreprocessorUnfilteredUngrouped(
                                aggregationService, _filterExprEval, null);
                    }
                    else
                    {
                        subselectAggregationPreprocessor =
                            new SubselectAggregationPreprocessorFilteredUngrouped(aggregationService, _filterExprEval, null);
                    }
                }
                else
                {
                    if (_filterExprEval == null)
                    {
                        subselectAggregationPreprocessor =
                            new SubselectAggregationPreprocessorUnfilteredGrouped(
                                aggregationService, _filterExprEval, _groupByKeys);
                    }
                    else
                    {
                        subselectAggregationPreprocessor =
                            new SubselectAggregationPreprocessorFilteredGrouped(
                                aggregationService, _filterExprEval, _groupByKeys);
                    }
                }
            }

            SubordTableLookupStrategy subqueryLookup;

            if (_optionalNamedWindowProcessor != null)
            {
                NamedWindowProcessorInstance instance =
                    _optionalNamedWindowProcessor.GetProcessorInstance(agentInstanceContext);
                if (_queryPlan == null)
                {
                    if (instance.RootViewInstance.IsQueryPlanLogging && NamedWindowRootView.QueryPlanLog.IsInfoEnabled)
                    {
                        NamedWindowRootView.QueryPlanLog.Info("shared, full table scan");
                    }
                    subqueryLookup =
                        new SubordFullTableScanLookupStrategyLocking(
                            instance.RootViewInstance.DataWindowContents,
                            agentInstanceContext.EpStatementAgentInstanceHandle.StatementAgentInstanceLock);
                }
                else
                {
                    EventTable[] tables = null;
                    if (!_optionalNamedWindowProcessor.IsVirtualDataWindow)
                    {
                        tables = SubordinateQueryPlannerUtil.RealizeTables(
                            _queryPlan.IndexDescs, instance.RootViewInstance.EventType,
                            instance.RootViewInstance.IndexRepository,
                            instance.RootViewInstance.DataWindowContents, agentInstanceContext,
                            isRecoveringResilient);
                    }
                    SubordTableLookupStrategy strategy = _queryPlan.LookupStrategyFactory.MakeStrategy(
                        tables, instance.RootViewInstance.VirtualDataWindow);
                    subqueryLookup = new SubordIndexedTableLookupStrategyLocking(
                        strategy, instance.TailViewInstance.AgentInstanceContext.AgentInstanceLock);
                }
            }
            else
            {
                TableStateInstance state = _tableService.GetState(
                    _optionalTableMetadata.TableName, agentInstanceContext.AgentInstanceId);
                ILockable iLock = agentInstanceContext.StatementContext.IsWritesToTables
                    ? state.TableLevelRWLock.WriteLock
                    : state.TableLevelRWLock.ReadLock;
                if (_queryPlan == null)
                {
                    subqueryLookup = new SubordFullTableScanTableLookupStrategy(iLock, state.IterableTableScan);
                }
                else
                {
                    EventTable[] indexes = new EventTable[_queryPlan.IndexDescs.Length];
                    for (int i = 0; i < indexes.Length; i++)
                    {
                        indexes[i] = state.IndexRepository.GetIndexByDesc(_queryPlan.IndexDescs[i].IndexMultiKey);
                    }
                    subqueryLookup = _queryPlan.LookupStrategyFactory.MakeStrategy(indexes, null);
                    subqueryLookup = new SubordIndexedTableLookupTableStrategy(subqueryLookup, iLock);
                }
            }

            return(new SubSelectStrategyRealization(
                       subqueryLookup, subselectAggregationPreprocessor, aggregationService,
                       Collections.GetEmptyMap <ExprPriorNode, ExprPriorEvalStrategy>(),
                       Collections.GetEmptyMap <ExprPreviousNode, ExprPreviousEvalStrategy>(),
                       null, null));
        }