Ejemplo n.º 1
0
        public NamedWindowProcessorInstance GetProcessorInstance(AgentInstanceContext agentInstanceContext)
        {
            if (_contextName == null)
            {
                return(ProcessorInstanceNoContext);
            }

            if (agentInstanceContext.StatementContext.ContextDescriptor == null)
            {
                return(null);
            }

            if (_contextName.Equals(agentInstanceContext.StatementContext.ContextDescriptor.ContextName))
            {
                return(GetProcessorInstance(agentInstanceContext.AgentInstanceId));
            }

            return(null);
        }
Ejemplo n.º 2
0
        public void TestCanReuse()
        {
            StatementContext context = SupportStatementContextFactory.MakeContext(_container);

            AgentInstanceContext agentInstanceContext = SupportStatementContextFactory.MakeAgentInstanceContext(_container);

            _factory.SetViewParameters(null, TestViewSupport.ToExprListMD(new Object[] { 100, "Price" }));
            _factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportMarketDataBean)), SupportStatementContextFactory.MakeContext(_container), null, null);
            Assert.IsFalse(_factory.CanReuse(new FirstElementView(null), agentInstanceContext));
            Assert.IsTrue(_factory.CanReuse(new SortWindowView(_factory, SupportExprNodeFactory.MakeIdentNodesMD("Price"), new ExprEvaluator[0], new bool[] { false }, 100, null, false, null), agentInstanceContext));
            Assert.IsFalse(_factory.CanReuse(new SortWindowView(_factory, SupportExprNodeFactory.MakeIdentNodesMD("Volume"), new ExprEvaluator[0], new bool[] { true }, 100, null, false, null), agentInstanceContext));
            Assert.IsFalse(_factory.CanReuse(new SortWindowView(_factory, SupportExprNodeFactory.MakeIdentNodesMD("Price"), new ExprEvaluator[0], new bool[] { false }, 99, null, false, null), agentInstanceContext));
            Assert.IsFalse(_factory.CanReuse(new SortWindowView(_factory, SupportExprNodeFactory.MakeIdentNodesMD("Symbol"), new ExprEvaluator[0], new bool[] { false }, 100, null, false, null), agentInstanceContext));

            _factory.SetViewParameters(null, TestViewSupport.ToExprListMD(new Object[] { 100, "Price", "Volume" }));
            _factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportMarketDataBean)), SupportStatementContextFactory.MakeContext(_container), null, null);
            Assert.IsTrue(_factory.CanReuse(new SortWindowView(_factory, SupportExprNodeFactory.MakeIdentNodesMD("Price", "Volume"), new ExprEvaluator[0], new bool[] { false, false }, 100, null, false, null), agentInstanceContext));
            Assert.IsFalse(_factory.CanReuse(new SortWindowView(_factory, SupportExprNodeFactory.MakeIdentNodesMD("Price", "Symbol"), new ExprEvaluator[0], new bool[] { true, false }, 100, null, false, null), agentInstanceContext));
        }
Ejemplo n.º 3
0
        public bool CanReuse(View view, AgentInstanceContext agentInstanceContext)
        {
            if (!(view is SortWindowView))
            {
                return(false);
            }

            var other          = (SortWindowView)view;
            var sortWindowSize = ViewFactorySupport.EvaluateSizeParam(ViewName, _sizeEvaluator, agentInstanceContext);

            if ((other.SortWindowSize != sortWindowSize) ||
                (!Compare(other.IsDescendingValues, _isDescendingValues)) ||
                (!ExprNodeUtility.DeepEquals(other.SortCriteriaExpressions, _sortCriteriaExpressions, false)))
            {
                return(false);
            }

            return(other.IsEmpty());
        }
Ejemplo n.º 4
0
        public bool CanReuse(View view, AgentInstanceContext agentInstanceContext)
        {
            if (!(view is TimeBatchView))
            {
                return(false);
            }

            TimeBatchView myView = (TimeBatchView)view;
            ExprTimePeriodEvalDeltaConst timeDeltaComputation = timeDeltaComputationFactory.Make(
                ViewName, "view", agentInstanceContext);

            if (!timeDeltaComputation.EqualsTimePeriod(myView.TimeDeltaComputation))
            {
                return(false);
            }

            if ((myView.InitialReferencePoint != null) && (_optionalReferencePoint != null))
            {
                if (!myView.InitialReferencePoint.Equals(_optionalReferencePoint.Value))
                {
                    return(false);
                }
            }
            if (((myView.InitialReferencePoint == null) && (_optionalReferencePoint != null)) ||
                ((myView.InitialReferencePoint != null) && (_optionalReferencePoint == null)))
            {
                return(false);
            }

            if (myView.IsForceOutput != IsForceUpdate)
            {
                return(false);
            }

            if (myView.IsStartEager)
            {
                // since it's already started
                return(false);
            }

            return(myView.IsEmpty());
        }
        public TableStateInstanceGroupedImpl(
            TableMetadata tableMetadata,
            AgentInstanceContext agentInstanceContext,
            IReaderWriterLockManager rwLockManager)
            : base(tableMetadata, agentInstanceContext, rwLockManager)
        {
            IList <EventPropertyGetter> indexGetters = new List <EventPropertyGetter>();
            IList <string> keyNames = new List <string>();

            foreach (var entry in tableMetadata.TableColumns)
            {
                if (entry.Value.IsKey)
                {
                    keyNames.Add(entry.Key);
                    indexGetters.Add(tableMetadata.InternalEventType.GetGetter(entry.Key));
                }
            }

            var tableName    = "primary-" + tableMetadata.TableName;
            var organization = new EventTableOrganization(tableName, true, false, 0, Collections.GetEmptyList <string>(), EventTableOrganizationType.HASH);

            EventTable table;

            if (indexGetters.Count == 1)
            {
                var tableMap = new TransformDictionary <object, EventBean, object, ObjectArrayBackedEventBean>(
                    _rows, k => k, v => v, k => k, v => v as ObjectArrayBackedEventBean);
                table = new PropertyIndexedEventTableSingleUnique(indexGetters[0], organization, tableMap);
            }
            else
            {
                var getters  = indexGetters.ToArrayOrNull();
                var tableMap = new TransformDictionary <MultiKeyUntyped, EventBean, object, ObjectArrayBackedEventBean>(
                    _rows, k => k as MultiKeyUntyped, v => v, k => k, v => v as ObjectArrayBackedEventBean);
                table = new PropertyIndexedEventTableUnique(getters, organization, tableMap);
            }

            var pair = TableServiceUtil.GetIndexMultikeyForKeys(tableMetadata.TableColumns, tableMetadata.InternalEventType);

            _primaryIndexKey = pair.Second;
            _indexRepository.AddIndex(_primaryIndexKey, new EventTableIndexRepositoryEntry(tableName, table));
        }
        public OutputProcessViewConditionLastAllUnord(
            ResultSetProcessor resultSetProcessor,
            long? afterConditionTime,
            int? afterConditionNumberOfEvents,
            bool afterConditionSatisfied,
            OutputProcessViewConditionFactory parent,
            AgentInstanceContext agentInstanceContext)
            : base(
                agentInstanceContext,
                resultSetProcessor,
                afterConditionTime,
                afterConditionNumberOfEvents,
                afterConditionSatisfied)
        {
            _parent = parent;

            var outputCallback = GetCallbackToLocal(parent.StreamCount);
            OptionalOutputCondition =
                parent.OutputConditionFactory.InstantiateOutputCondition(agentInstanceContext, outputCallback);
        }
 public StatementAgentInstanceFactoryCreateTableResult(
     Viewable finalView,
     AgentInstanceMgmtCallback stopCallback,
     AgentInstanceContext agentInstanceContext,
     TableInstance tableInstance)
     : base(
         finalView,
         stopCallback,
         agentInstanceContext,
         null,
         Collections.GetEmptyMap<int, SubSelectFactoryResult>(),
         null,
         null,
         null,
         Collections.GetEmptyMap<int, ExprTableEvalStrategy>(),
         Collections.GetEmptyList<StatementAgentInstancePreload>(),
         null)
 {
     TableInstance = tableInstance;
 }
Ejemplo n.º 8
0
        public bool CanReuse(View view, AgentInstanceContext agentInstanceContext)
        {
            if (!(view is WeightedAverageView))
            {
                return(false);
            }
            if (_additionalProps != null)
            {
                return(false);
            }

            var myView = (WeightedAverageView)view;

            if ((!ExprNodeUtility.DeepEquals(_fieldNameWeight, myView.FieldNameWeight)) ||
                (!ExprNodeUtility.DeepEquals(_fieldNameX, myView.FieldNameX)))
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 9
0
        public bool TryIncreaseCount(AgentInstanceContext agentInstanceContext)
        {
            // test pool max
            var newMax = poolCount.IncrementAndGet();
            if (newMax > maxPoolCountConfigured && maxPoolCountConfigured >= 0) {
                IDictionary<DeploymentIdNamePair, long> counts = GetCounts();
                agentInstanceContext.StatementContext.ExceptionHandlingService.HandleCondition(
                    new ConditionMatchRecognizeStatesMax(maxPoolCountConfigured, counts),
                    agentInstanceContext.StatementContext);

                if (preventStart) {
                    poolCount.DecrementAndGet();
                    return false;
                }

                return true;
            }

            return true;
        }
Ejemplo n.º 10
0
        public LookupInstructionExec MakeExec(
            AgentInstanceContext agentInstanceContext,
            IDictionary<TableLookupIndexReqKey, EventTable>[] indexesPerStream,
            EventType[] streamTypes,
            Viewable[] streamViews,
            VirtualDWView[] viewExternal)
        {
            var strategies = new JoinExecTableLookupStrategy[LookupPlans.Length];
            for (var i = 0; i < LookupPlans.Length; i++) {
                if (LookupPlans[i] != null) {
                    strategies[i] = LookupPlans[i]
                        .MakeStrategy(agentInstanceContext, indexesPerStream, streamTypes, viewExternal);
                }
                else {
                    strategies[i] = historicalPlans[i].MakeOuterJoinStategy(streamViews);
                }
            }

            return new LookupInstructionExec(FromStream, FromStreamName, ToStreams, strategies, RequiredPerStream);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Returns the values for the filter, using the supplied result events to ask filter parameters for the value to filter for.
        /// </summary>
        /// <param name="matchedEvents">contains the result events to use for determining filter values</param>
        /// <param name="agentInstanceContext">The agent instance context.</param>
        /// <param name="addendum">The addendum.</param>
        /// <returns>
        /// filter values
        /// </returns>
        public FilterValueSet GetValueSet(
            MatchedEventMap matchedEvents,
            AgentInstanceContext agentInstanceContext,
            FilterValueSetParam[][] addendum)
        {
            var valueList = new FilterValueSetParam[Parameters.Length][];

            for (int i = 0; i < Parameters.Length; i++)
            {
                valueList[i] = new FilterValueSetParam[Parameters[i].Length];
                PopulateValueSet(valueList[i], matchedEvents, agentInstanceContext, Parameters[i]);
            }

            if (addendum != null)
            {
                valueList = ContextControllerAddendumUtil.MultiplyAddendum(addendum, valueList);
            }

            return(new FilterValueSetImpl(_filterForEventType, valueList));
        }
Ejemplo n.º 12
0
        public static IDictionary<int, ExprTableEvalStrategy> StartTableAccess(
            IDictionary<int, ExprTableEvalStrategyFactory> tableAccesses,
            AgentInstanceContext agentInstanceContext)
        {
            if (tableAccesses == null || tableAccesses.IsEmpty()) {
                return EmptyDictionary<int, ExprTableEvalStrategy>.Instance;
            }

            var writesToTables = agentInstanceContext.StatementContext.StatementInformationals.IsWritesToTables;
            IDictionary<int, ExprTableEvalStrategy> evals =
                new Dictionary<int, ExprTableEvalStrategy>(tableAccesses.Count);
            foreach (var entry in tableAccesses) {
                var table = entry.Value.Table;
                var provider = table.GetStateProvider(agentInstanceContext.AgentInstanceId, writesToTables);
                var strategy = entry.Value.MakeStrategy(provider);
                evals.Put(entry.Key, strategy);
            }

            return evals;
        }
        /// <summary>
        /// The ValidateAddExplicitIndex
        /// </summary>
        /// <param name="explicitIndexName">The <see cref="string"/></param>
        /// <param name="explicitIndexDesc">The <see cref="QueryPlanIndexItem"/></param>
        /// <param name="eventType">The <see cref="EventType"/></param>
        /// <param name="dataWindowContents">The <see cref="IEnumerable{EventBean}"/></param>
        /// <param name="agentInstanceContext">The <see cref="AgentInstanceContext"/></param>
        /// <param name="allowIndexExists">The <see cref="bool"/></param>
        /// <param name="optionalSerde">The <see cref="object"/></param>
        public void ValidateAddExplicitIndex(
            string explicitIndexName,
            QueryPlanIndexItem explicitIndexDesc,
            EventType eventType,
            IEnumerable <EventBean> dataWindowContents,
            AgentInstanceContext agentInstanceContext,
            bool allowIndexExists,
            object optionalSerde)
        {
            if (_explicitIndexes.ContainsKey(explicitIndexName))
            {
                if (allowIndexExists)
                {
                    return;
                }
                throw new ExprValidationException("Index by name '" + explicitIndexName + "' already exists");
            }

            AddExplicitIndex(explicitIndexName, explicitIndexDesc, eventType, dataWindowContents, agentInstanceContext, optionalSerde);
        }
Ejemplo n.º 14
0
        public NamedWindowProcessorInstance GetProcessorInstance(AgentInstanceContext agentInstanceContext)
        {
            if (_contextName == null)
            {
                StatementResourceHolder holder = _statementResourceService.Unpartitioned;
                return(holder == null ? null : holder.NamedWindowProcessorInstance);
            }

            if (agentInstanceContext.StatementContext.ContextDescriptor == null)
            {
                return(null);
            }

            if (_contextName.Equals(agentInstanceContext.StatementContext.ContextDescriptor.ContextName))
            {
                StatementResourceHolder holder = _statementResourceService.GetPartitioned(agentInstanceContext.AgentInstanceId);
                return(holder == null ? null : holder.NamedWindowProcessorInstance);
            }
            return(null);
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="agentInstanceContext">statement services and statement information such as statement name, statement id, EPL expression</param>
 /// <param name="eventType">the event type that the named window is declared to hold.</param>
 /// <param name="parameters">the parameters passed when declaring the named window, for example "create window ABC.my:vdw("10.0.0.1")" passes one paramater here.</param>
 /// <param name="parameterExpressions">parameter expressions passed to the virtual data window</param>
 /// <param name="eventFactory">factory for converting row objects to EventBean instances</param>
 /// <param name="outputStream">forward the input and output stream received from the Update method here</param>
 /// <param name="namedWindowName">the name of the named window</param>
 /// <param name="viewFactoryContext">context of services</param>
 /// <param name="customConfiguration">additional configuration</param>
 public VirtualDataWindowContext(AgentInstanceContext agentInstanceContext,
                                 EventType eventType,
                                 Object[] parameters,
                                 ExprNode[] parameterExpressions,
                                 EventBeanFactory eventFactory,
                                 VirtualDataWindowOutStream outputStream,
                                 String namedWindowName,
                                 ViewFactoryContext viewFactoryContext,
                                 Object customConfiguration)
 {
     AgentInstanceContext = agentInstanceContext;
     EventType            = eventType;
     Parameters           = parameters;
     ParameterExpressions = parameterExpressions;
     EventFactory         = eventFactory;
     OutputStream         = outputStream;
     NamedWindowName      = namedWindowName;
     ViewFactoryContext   = viewFactoryContext;
     CustomConfiguration  = customConfiguration;
 }
Ejemplo n.º 16
0
        public OutputProcessViewConditionDefault(
            ResultSetProcessorHelperFactory resultSetProcessorHelperFactory,
            ResultSetProcessor resultSetProcessor,
            long?afterConditionTime,
            int?afterConditionNumberOfEvents,
            bool afterConditionSatisfied,
            OutputProcessViewConditionFactory parent,
            AgentInstanceContext agentInstanceContext,
            bool isJoin)
            : base(
                resultSetProcessorHelperFactory, agentInstanceContext, resultSetProcessor, afterConditionTime,
                afterConditionNumberOfEvents, afterConditionSatisfied)
        {
            _parent = parent;

            OutputCallback outputCallback = GetCallbackToLocal(parent.StreamCount);

            _outputCondition = parent.OutputConditionFactory.Make(agentInstanceContext, outputCallback);
            _deltaSet        = resultSetProcessorHelperFactory.MakeOutputConditionChangeSet(isJoin, agentInstanceContext);
        }
Ejemplo n.º 17
0
 public StatementAgentInstanceFactoryCreateDataflowResult(
     Viewable finalView,
     AgentInstanceMgmtCallback stopCallback,
     AgentInstanceContext agentInstanceContext,
     DataflowDesc dataflow)
     : base(
         finalView,
         stopCallback,
         agentInstanceContext,
         null,
         EmptyDictionary<int, SubSelectFactoryResult>.Instance,
         null,
         null,
         null,
         null,
         EmptyList<StatementAgentInstancePreload>.Instance,
         null)
 {
     Dataflow = dataflow;
 }
Ejemplo n.º 18
0
        /// <summary>
        ///     NOTE: Code-generation-invoked method, method name and parameter order matters
        /// </summary>
        /// <param name="resultSetProcessorHelperFactory">helper factory</param>
        /// <param name="agentInstanceContext">context</param>
        /// <param name="groupKeyTypes">types</param>
        /// <param name="groupByRollupDesc">rollup into</param>
        /// <param name="outputConditionPolledFactory">condition factory</param>
        /// <returns>helpers</returns>
        public static ResultSetProcessorGroupedOutputFirstHelper[] InitializeOutputFirstHelpers(
            ResultSetProcessorHelperFactory resultSetProcessorHelperFactory,
            AgentInstanceContext agentInstanceContext,
            Type[] groupKeyTypes,
            AggregationGroupByRollupDesc groupByRollupDesc,
            OutputConditionPolledFactory outputConditionPolledFactory)
        {
            var outputFirstHelpers = new ResultSetProcessorGroupedOutputFirstHelper[groupByRollupDesc.Levels.Length];
            for (var i = 0; i < groupByRollupDesc.Levels.Length; i++) {
                outputFirstHelpers[i] = resultSetProcessorHelperFactory.MakeRSGroupedOutputFirst(
                    agentInstanceContext,
                    groupKeyTypes,
                    outputConditionPolledFactory,
                    groupByRollupDesc,
                    i,
                    null);
            }

            return outputFirstHelpers;
        }
Ejemplo n.º 19
0
        public void AddContextSpec(EPServicesContext servicesContext, AgentInstanceContext agentInstanceContext, CreateContextDesc contextDesc, bool isRecoveringResilient, EventType statementResultEventType)
        {
            var mgr = _contexts.Get(contextDesc.ContextName);

            if (mgr != null)
            {
                if (_destroyedContexts.Contains(contextDesc.ContextName))
                {
                    throw new ExprValidationException("Context by name '" + contextDesc.ContextName + "' is still referenced by statements and may not be changed");
                }
                throw new ExprValidationException("Context by name '" + contextDesc.ContextName + "' already exists");
            }

            var factoryServiceContext = new ContextControllerFactoryServiceContext(contextDesc.ContextName, servicesContext, contextDesc.ContextDetail, agentInstanceContext, isRecoveringResilient, statementResultEventType);
            var contextManager        = servicesContext.ContextManagerFactoryService.Make(contextDesc.ContextDetail, factoryServiceContext);

            factoryServiceContext.AgentInstanceContextCreate.EpStatementAgentInstanceHandle.FilterFaultHandler = contextManager;

            _contexts.Put(contextDesc.ContextName, new ContextManagerEntry(contextManager));
        }
        public bool CanReuse(View view, AgentInstanceContext agentInstanceContext)
        {
            if (!(view is UnivariateStatisticsView))
            {
                return(false);
            }
            if (_additionalProps != null)
            {
                return(false);
            }

            var other = (UnivariateStatisticsView)view;

            if (!ExprNodeUtility.DeepEquals(other.FieldExpression, _fieldExpression, false))
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 21
0
        public EPPreparedQueryResult Execute(
            FAFQueryMethodSelect select,
            ContextPartitionSelector[] contextPartitionSelectors,
            FAFQueryMethodAssignerSetter assignerSetter,
            ContextManagementService contextManagementService)
        {
            FireAndForgetProcessor processor = select.Processors[0];

            ContextPartitionSelector singleSelector =
                contextPartitionSelectors != null && contextPartitionSelectors.Length > 0
                    ? contextPartitionSelectors[0]
                    : null;
            ICollection<int> agentInstanceIds = AgentInstanceIds(processor, singleSelector, contextManagementService);

            ICollection<EventBean> events = new ArrayDeque<EventBean>();
            AgentInstanceContext agentInstanceContext = null;
            foreach (int agentInstanceId in agentInstanceIds) {
                FireAndForgetInstance processorInstance = processor.GetProcessorInstanceContextById(agentInstanceId);
                if (processorInstance != null) {
                    agentInstanceContext = processorInstance.AgentInstanceContext;
                    ICollection<EventBean> coll = processorInstance.SnapshotBestEffort(
                        select.QueryGraph,
                        select.Annotations);
                    events.AddAll(coll);
                }
            }

            // get RSP
            ResultSetProcessor resultSetProcessor = ProcessorWithAssign(
                select.ResultSetProcessorFactoryProvider,
                agentInstanceContext,
                assignerSetter,
                select.TableAccesses,
                select.Subselects);

            if (select.WhereClause != null) {
                events = Filtered(events, select.WhereClause, agentInstanceContext);
            }

            return ProcessedNonJoin(resultSetProcessor, events, select.DistinctKeyGetter);
        }
Ejemplo n.º 22
0
        private static ICollection<EventBean> FafTableLookup(
            VirtualDWView virtualDataWindow,
            IndexMultiKey indexMultiKey,
            EventTable eventTable,
            object[] keyValues,
            RangeIndexLookupValue[] rangeValues,
            Attribute[] annotations,
            AgentInstanceContext agentInstanceContext)
        {
            if (virtualDataWindow != null) {
                return virtualDataWindow.GetFireAndForgetData(eventTable, keyValues, rangeValues, annotations);
            }

            ISet<EventBean> result;
            if (indexMultiKey.HashIndexedProps.Length > 0 && indexMultiKey.RangeIndexedProps.Length == 0) {
                var table = (PropertyHashedEventTable) eventTable;
                if (indexMultiKey.HashIndexedProps.Length == 1) {
                    result = table.Lookup(keyValues[0]);
                }
                else {
                    result = table.Lookup(new HashableMultiKey(keyValues));
                }
            }
            else if (indexMultiKey.HashIndexedProps.Length == 0 && indexMultiKey.RangeIndexedProps.Length == 1) {
                var table = (PropertySortedEventTable) eventTable;
                result = table.LookupConstants(rangeValues[0]);
            }
            else {
                var table = (PropertyCompositeEventTable) eventTable;
                var rangeCoercion = table.OptRangeCoercedTypes;
                var lookup = CompositeIndexLookupFactory.Make(keyValues, rangeValues, rangeCoercion);
                result = new HashSet<EventBean>();
                lookup.Lookup(table.Index, result, table.PostProcessor);
            }

            if (result != null) {
                return result;
            }

            return new EmptyList<EventBean>();
        }
Ejemplo n.º 23
0
        public static EventTable[] RealizeTables(
            SubordinateQueryIndexDesc[] indexDescriptors,
            EventType eventType,
            EventTableIndexRepository indexRepository,
            IEnumerable<EventBean> contents,
            AgentInstanceContext agentInstanceContext,
            bool isRecoveringResilient)
        {
            var tables = new EventTable[indexDescriptors.Length];
            for (var i = 0; i < tables.Length; i++) {
                var desc = indexDescriptors[i];
                var table = indexRepository.GetIndexByDesc(desc.IndexMultiKey);
                if (table == null) {
                    table = EventTableUtil.BuildIndex(
                        agentInstanceContext,
                        0,
                        desc.QueryPlanIndexItem,
                        eventType,
                        true,
                        desc.QueryPlanIndexItem.IsUnique,
                        desc.IndexName,
                        null,
                        false);

                    // fill table since its new
                    if (!isRecoveringResilient) {
                        var events = new EventBean[1];
                        foreach (EventBean prefilledEvent in contents) {
                            events[0] = prefilledEvent;
                            table.Add(events, agentInstanceContext);
                        }
                    }

                    indexRepository.AddIndex(desc.IndexMultiKey, new EventTableIndexRepositoryEntry(null, null, table));
                }

                tables[i] = table;
            }

            return tables;
        }
Ejemplo n.º 24
0
        public override OnExprViewResult DetermineOnExprView(
            AgentInstanceContext agentInstanceContext,
            IList <StopCallback> stopCallbacks,
            bool isRecoveringReslient)
        {
            var processors = new ResultSetProcessor[_items.Length];

            for (int i = 0; i < processors.Length; i++)
            {
                ResultSetProcessorFactoryDesc factory   = _items[i].FactoryDesc;
                ResultSetProcessor            processor = factory.ResultSetProcessorFactory.Instantiate(
                    null, null, agentInstanceContext);
                processors[i] = processor;
            }

            var tableStateInstances = new TableStateInstance[processors.Length];

            for (int i = 0; i < _items.Length; i++)
            {
                string tableName = _items[i].InsertIntoTableNames;
                if (tableName != null)
                {
                    tableStateInstances[i] = agentInstanceContext.StatementContext.TableService.GetState(
                        tableName, agentInstanceContext.AgentInstanceId);
                }
            }

            var whereClauseEvals = new ExprEvaluator[_items.Length];

            for (int i = 0; i < _items.Length; i++)
            {
                whereClauseEvals[i] = _items[i].WhereClause == null ? null : _items[i].WhereClause.ExprEvaluator;
            }

            var desc = (OnTriggerSplitStreamDesc)base.StatementSpec.OnTriggerDesc;
            var view = new RouteResultView(
                desc.IsFirst, _activatorResultEventType, base.StatementContext.EpStatementHandle, base.Services.InternalEventRouter,
                tableStateInstances, _items, processors, whereClauseEvals, agentInstanceContext);

            return(new OnExprViewResult(view, null));
        }
Ejemplo n.º 25
0
        public bool CanReuse(View view, AgentInstanceContext agentInstanceContext)
        {
            if (!(view is GroupByView))
            {
                return(false);
            }

            if (IsReclaimAged)
            {
                return(false);
            }

            GroupByView myView = (GroupByView)view;

            if (!ExprNodeUtility.DeepEquals(myView.CriteriaExpressions, _criteriaExpressions))
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 26
0
 public GraphSourceRunnable(
     AgentInstanceContext agentInstanceContext,
     DataFlowSourceOperator graphSource,
     string dataFlowName,
     string instanceId,
     string operatorName,
     int operatorNumber,
     string operatorPrettyPrint,
     EPDataFlowExceptionHandler optionalExceptionHandler,
     bool audit)
 {
     _agentInstanceContext = agentInstanceContext;
     _graphSource = graphSource;
     _dataFlowName = dataFlowName;
     _instanceId = instanceId;
     _operatorName = operatorName;
     _operatorNumber = operatorNumber;
     _operatorPrettyPrint = operatorPrettyPrint;
     _optionalExceptionHandler = optionalExceptionHandler;
     _audit = audit;
 }
Ejemplo n.º 27
0
 public ResultSetProcessorRowForAll(
     ResultSetProcessorRowForAllFactory prototype,
     SelectExprProcessor selectExprProcessor,
     OrderByProcessor orderByProcessor,
     AggregationService aggregationService,
     AgentInstanceContext agentInstanceContext)
 {
     _prototype            = prototype;
     _selectExprProcessor  = selectExprProcessor;
     _orderByProcessor     = orderByProcessor;
     _aggregationService   = aggregationService;
     _exprEvaluatorContext = agentInstanceContext;
     if (prototype.IsOutputLast)
     {
         _outputLastHelper = prototype.ResultSetProcessorHelperFactory.MakeRSRowForAllOutputLast(this, prototype, agentInstanceContext);
     }
     else if (prototype.IsOutputAll)
     {
         _outputAllHelper = prototype.ResultSetProcessorHelperFactory.MakeRSRowForAllOutputAll(this, prototype, agentInstanceContext);
     }
 }
        public void SetUp()
        {
            _agentInstanceContext = SupportStatementContextFactory.MakeAgentInstanceContext();
    
            var selectExprEventTypeRegistry = new SelectExprEventTypeRegistry("abc", new StatementEventTypeRefImpl());
            var factory = new SelectExprProcessorHelper(
                Collections.GetEmptyList<int>(), SupportSelectExprFactory.MakeSelectListFromIdent("TheString", "s0"),
                Collections.GetEmptyList<SelectExprStreamDesc>(), null, null, false, new SupportStreamTypeSvc1Stream(),
                SupportEventAdapterService.Service, null, selectExprEventTypeRegistry,
                _agentInstanceContext.StatementContext.MethodResolutionService,
                null, null, new Configuration(), null, new TableServiceImpl());
            var selectProcessor = factory.Evaluator;
            _supportAggregationService = new SupportAggregationService();
    
            var groupKeyNodes = new ExprEvaluator[2];
            groupKeyNodes[0] = SupportExprNodeFactory.MakeIdentNode("IntPrimitive", "s0").ExprEvaluator;
            groupKeyNodes[1] = SupportExprNodeFactory.MakeIdentNode("IntBoxed", "s0").ExprEvaluator;

            var prototype = new ResultSetProcessorRowPerGroupFactory(selectProcessor, null, groupKeyNodes, null, true, false, null, false, false, false, false);
            _processor = (ResultSetProcessorRowPerGroup) prototype.Instantiate(null, _supportAggregationService, _agentInstanceContext);
        }
Ejemplo n.º 29
0
 public void SetScheduleCallback(
     AgentInstanceContext agentInstanceContext,
     RowRecogNFAViewScheduleCallback scheduleCallback)
 {
     this.agentInstanceContext = agentInstanceContext;
     scheduleSlot = agentInstanceContext.StatementContext.ScheduleBucket.AllocateSlot();
     ScheduleHandleCallback callback = new ProxyScheduleHandleCallback {
         ProcScheduledTrigger = () => {
             agentInstanceContext.AuditProvider.ScheduleFire(
                 agentInstanceContext,
                 ScheduleObjectType.matchrecognize,
                 NAME_AUDITPROVIDER_SCHEDULE);
             agentInstanceContext.InstrumentationProvider.QRegExScheduledEval();
             scheduleCallback.Triggered();
             agentInstanceContext.InstrumentationProvider.ARegExScheduledEval();
         }
     };
     handle = new EPStatementHandleCallbackSchedule(
         agentInstanceContext.EpStatementAgentInstanceHandle,
         callback);
 }
Ejemplo n.º 30
0
        public override object GetFilterValue(MatchedEventMap matchedEvents, AgentInstanceContext agentInstanceContext)
        {
            EventBean theEvent = matchedEvents.GetMatchingEventByTag(_resultEventAsName);
            Object    value    = null;

            if (theEvent == null)
            {
                Log.Warn("Matching events for tag '" + _resultEventAsName + "' returned a null result, using null value in filter criteria, for statement '" + _statementName + "'");
            }
            else
            {
                value = theEvent.Get(_resultEventProperty);
            }

            // Coerce if necessary
            if (_isMustCoerce)
            {
                value = _numberCoercer.Invoke(value);
            }
            return(value);
        }