Ejemplo n.º 1
0
 public SubordIndexedTableLookupTableStrategy(
     SubordTableLookupStrategy inner,
     ILockable @lock)
 {
     this._inner = inner;
     this._lock = @lock;
 }
Ejemplo n.º 2
0
 public SubordIndexedTableLookupStrategyLocking(
     SubordTableLookupStrategy inner,
     IReaderWriterLock statementLock)
 {
     this._inner = inner;
     this._statementLock = statementLock;
 }
Ejemplo n.º 3
0
 public SubordWMatchExprLookupStrategyIndexedFiltered(
     ExprEvaluator joinExpr,
     SubordTableLookupStrategy tableLookupStrategy)
 {
     this.joinExpr = joinExpr;
     this.eventsPerStream = new EventBean[2];
     this.tableLookupStrategy = tableLookupStrategy;
 }
Ejemplo n.º 4
0
 public void AssignService(
     int num,
     SubordTableLookupStrategy subselectStrategy)
 {
     AIRegistryUtil.CheckExpand(num, strategies);
     strategies.Array[num] = subselectStrategy;
     InstanceCount++;
 }
Ejemplo n.º 5
0
 public SubSelectFactoryResult(
     ViewableActivationResult subselectActivationResult,
     SubSelectStrategyRealization realization,
     SubordTableLookupStrategy lookupStrategy)
 {
     this.subselectActivationResult = subselectActivationResult;
     this.lookupStrategy = lookupStrategy;
     this.subselectAggregationPreprocessor = realization.SubselectAggregationPreprocessor;
     this.aggregationService = realization.AggregationService;
     this.priorStrategy = realization.PriorStrategy;
     this.previousStrategy = realization.PreviousStrategy;
     this.subselectView = realization.SubselectView;
     this.indexes = realization.Indexes;
 }
Ejemplo n.º 6
0
        public void Assign(
            int agentInstanceId,
            SubordTableLookupStrategy lookupStrategy,
            AggregationService aggregationService,
            PriorEvalStrategy priorEvalStrategy,
            PreviousGetterStrategy previousGetterStrategy)
        {
            LookupStrategies.AssignService(agentInstanceId, lookupStrategy);
            AggregationServices?.AssignService(agentInstanceId, aggregationService);

            PriorEvalStrategies?.AssignService(agentInstanceId, priorEvalStrategy);

            PreviousGetterStrategies?.AssignService(agentInstanceId, previousGetterStrategy);
        }
Ejemplo n.º 7
0
 public SubSelectStrategyRealization(
     SubordTableLookupStrategy strategy,
     SubselectAggregationPreprocessorBase subselectAggregationPreprocessor,
     AggregationService subselectAggregationService,
     IDictionary <ExprPriorNode, ExprPriorEvalStrategy> priorNodeStrategies,
     IDictionary <ExprPreviousNode, ExprPreviousEvalStrategy> previousNodeStrategies,
     Viewable subselectView,
     StatementAgentInstancePostLoad postLoad)
 {
     Strategy = strategy;
     SubselectAggregationPreprocessor = subselectAggregationPreprocessor;
     SubselectAggregationService      = subselectAggregationService;
     PriorNodeStrategies    = priorNodeStrategies;
     PreviousNodeStrategies = previousNodeStrategies;
     SubselectView          = subselectView;
     PostLoad = postLoad;
 }
Ejemplo n.º 8
0
 public SubSelectStrategyRealization(
     SubordTableLookupStrategy lookupStrategy,
     SubselectAggregationPreprocessorBase subselectAggregationPreprocessor,
     AggregationService aggregationService,
     PriorEvalStrategy priorStrategy,
     PreviousGetterStrategy previousStrategy,
     Viewable subselectView,
     EventTable[] indexes)
 {
     this.lookupStrategy = lookupStrategy;
     this.subselectAggregationPreprocessor = subselectAggregationPreprocessor;
     this.aggregationService = aggregationService;
     this.priorStrategy = priorStrategy;
     this.previousStrategy = previousStrategy;
     this.subselectView = subselectView;
     this.indexes = indexes;
 }
        protected ICollection<EventBean> LookupInternal(
            EventBean[] events,
            ExprEvaluatorContext context,
            EventTableQuadTree index,
            SubordTableLookupStrategy strategy)
        {
            var x = Eval(factory.X, events, context, "x");
            var y = Eval(factory.Y, events, context, "y");
            var width = Eval(factory.Width, events, context, "width");
            var height = Eval(factory.Height, events, context, "height");

            if (context.InstrumentationProvider.Activated()) {
                context.InstrumentationProvider.QIndexSubordLookup(strategy, index, null);
                var result = this.index.QueryRange(x, y, width, height);
                context.InstrumentationProvider.AIndexSubordLookup(result, null);
                return result;
            }

            return this.index.QueryRange(x, y, width, height);
        }
Ejemplo n.º 10
0
 public void QIndexSubordLookup(SubordTableLookupStrategy subordTableLookupStrategy, EventTable optionalEventIndex, int[] keyStreamNums)
 {
 }
        public SubSelectStrategyRealization Instantiate(
            EPServicesContext services,
            Viewable viewableRoot,
            AgentInstanceContext agentInstanceContext,
            IList <StopCallback> stopCallbackList,
            int subqueryNumber,
            bool isRecoveringResilient)
        {
            IList <ViewFactory> viewFactoryChain = _subSelectHolder.ViewFactoryChain.FactoryChain;

            // add "prior" view factory
            var hasPrior = _viewResourceDelegate.PerStream[0].PriorRequests != null &&
                           !_viewResourceDelegate.PerStream[0].PriorRequests.IsEmpty();

            if (hasPrior)
            {
                var priorEventViewFactory = EPStatementStartMethodHelperPrior.GetPriorEventViewFactory(
                    agentInstanceContext.StatementContext, 1024 + _subqueryNumber, viewFactoryChain.IsEmpty(), true,
                    subqueryNumber);
                viewFactoryChain = new List <ViewFactory>(viewFactoryChain);
                viewFactoryChain.Add(priorEventViewFactory);
            }

            // create factory chain context to hold callbacks specific to "prior" and "prev"
            var viewFactoryChainContext = AgentInstanceViewFactoryChainContext.Create(
                viewFactoryChain, agentInstanceContext, _viewResourceDelegate.PerStream[0]);

            // make view
            var createResult = services.ViewService.CreateViews(
                viewableRoot, viewFactoryChain, viewFactoryChainContext, false);
            var subselectView = createResult.FinalViewable;

            // make aggregation service
            AggregationService aggregationService = null;

            if (_aggregationServiceFactory != null)
            {
                aggregationService = _aggregationServiceFactory.AggregationServiceFactory.MakeService(
                    agentInstanceContext, agentInstanceContext.StatementContext.EngineImportService, true,
                    subqueryNumber);
            }

            // handle "prior" nodes and their strategies
            var priorNodeStrategies = EPStatementStartMethodHelperPrior.CompilePriorNodeStrategies(
                _viewResourceDelegate, new AgentInstanceViewFactoryChainContext[]
            {
                viewFactoryChainContext
            });

            // handle "previous" nodes and their strategies
            var previousNodeStrategies =
                EPStatementStartMethodHelperPrevious.CompilePreviousNodeStrategies(
                    _viewResourceDelegate, new AgentInstanceViewFactoryChainContext[]
            {
                viewFactoryChainContext
            });

            // handle aggregated and non-correlated queries: there is no strategy or index
            if (_aggregationServiceFactory != null && !_correlatedSubquery)
            {
                View aggregatorView;
                if (_groupKeys == null)
                {
                    if (_filterExprEval == null)
                    {
                        aggregatorView = new SubselectAggregatorViewUnfilteredUngrouped(
                            aggregationService, _filterExprEval, agentInstanceContext, null);
                    }
                    else
                    {
                        aggregatorView = new SubselectAggregatorViewFilteredUngrouped(
                            aggregationService, _filterExprEval, agentInstanceContext, null, _filterExprNode);
                    }
                }
                else
                {
                    if (_filterExprEval == null)
                    {
                        aggregatorView = new SubselectAggregatorViewUnfilteredGrouped(
                            aggregationService, _filterExprEval, agentInstanceContext, _groupKeys);
                    }
                    else
                    {
                        aggregatorView = new SubselectAggregatorViewFilteredGrouped(
                            aggregationService, _filterExprEval, agentInstanceContext, _groupKeys, _filterExprNode);
                    }
                }
                subselectView.AddView(aggregatorView);

                if (services.EventTableIndexService.AllowInitIndex(isRecoveringResilient))
                {
                    Preload(services, null, aggregatorView, agentInstanceContext);
                }

                return(new SubSelectStrategyRealization(
                           NULL_ROW_STRATEGY, null, aggregationService, priorNodeStrategies, previousNodeStrategies,
                           subselectView, null));
            }

            // create index/holder table
            EventTable[] index =
                _pair.First.MakeEventTables(
                    new EventTableFactoryTableIdentAgentInstanceSubq(agentInstanceContext, _subqueryNumber));
            stopCallbackList.Add(new SubqueryStopCallback(index));

            // create strategy
            SubordTableLookupStrategy            strategy = _pair.Second.MakeStrategy(index, null);
            SubselectAggregationPreprocessorBase subselectAggregationPreprocessor = null;

            // handle unaggregated or correlated queries or
            if (_aggregationServiceFactory != null)
            {
                if (_groupKeys == 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, _groupKeys);
                    }
                    else
                    {
                        subselectAggregationPreprocessor =
                            new SubselectAggregationPreprocessorFilteredGrouped(
                                aggregationService, _filterExprEval, _groupKeys);
                    }
                }
            }

            // preload when allowed
            StatementAgentInstancePostLoad postLoad;

            if (services.EventTableIndexService.AllowInitIndex(isRecoveringResilient))
            {
                Preload(services, index, subselectView, agentInstanceContext);
                postLoad = new ProxyStatementAgentInstancePostLoad()
                {
                    ProcExecutePostLoad = () => Preload(services, index, subselectView, agentInstanceContext),

                    ProcAcceptIndexVisitor = visitor =>
                    {
                        foreach (var table in index)
                        {
                            visitor.Visit(table);
                        }
                    },
                };
            }
            else
            {
                postLoad = new ProxyStatementAgentInstancePostLoad
                {
                    ProcExecutePostLoad = () =>
                    {
                        // no post-load
                    },

                    ProcAcceptIndexVisitor = visitor =>
                    {
                        foreach (var table in index)
                        {
                            visitor.Visit(table);
                        }
                    },
                };
            }

            var bufferView = new BufferView(_subSelectHolder.StreamNumber);

            bufferView.Observer = new SubselectBufferObserver(index);
            subselectView.AddView(bufferView);

            return(new SubSelectStrategyRealization(
                       strategy, subselectAggregationPreprocessor, aggregationService, priorNodeStrategies,
                       previousNodeStrategies, subselectView, postLoad));
        }
Ejemplo n.º 12
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));
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="tableLookupStrategy">the strategy for looking up in an index the matching events using correlation</param>
 public SubordWMatchExprLookupStrategyIndexedUnfiltered(SubordTableLookupStrategy tableLookupStrategy)
 {
     _eventsPerStream     = new EventBean[2];
     _tableLookupStrategy = tableLookupStrategy;
 }
        public SubordWMatchExprLookupStrategy Realize(EventTable[] indexes, AgentInstanceContext agentInstanceContext, IEnumerable <EventBean> scanIterable, VirtualDWView virtualDataWindow)
        {
            SubordTableLookupStrategy strategy = _lookupStrategyFactory.MakeStrategy(indexes, virtualDataWindow);

            return(new SubordWMatchExprLookupStrategyIndexedUnfiltered(strategy));
        }
Ejemplo n.º 15
0
 public void AssignService(
     int num,
     SubordTableLookupStrategy subselectStrategy)
 {
     services.Put(num, subselectStrategy);
 }
Ejemplo n.º 16
0
 public void DeassignService(int num)
 {
     service = null;
 }