Esempio n. 1
0
        public override InfraOnExprBaseViewResult MakeNamedWindow(
            SubordWMatchExprLookupStrategy lookupStrategy,
            NamedWindowRootViewInstance namedWindowRootViewInstance,
            AgentInstanceContext agentInstanceContext)
        {
            var pair = StatementAgentInstanceFactoryUtil.StartResultSetAndAggregation(
                resultSetProcessorPrototype,
                agentInstanceContext,
                false,
                null);

            var audit = AuditEnum.INSERT.GetAudit(agentInstanceContext.Annotations) != null;
            TableInstance tableInstanceInsertInto = null;
            if (optionalInsertIntoTable != null) {
                tableInstanceInsertInto =
                    optionalInsertIntoTable.GetTableInstance(agentInstanceContext.AgentInstanceId);
            }

            var selectView = new OnExprViewNamedWindowSelect(
                lookupStrategy,
                namedWindowRootViewInstance,
                agentInstanceContext,
                this,
                pair.First,
                audit,
                IsSelectAndDelete,
                tableInstanceInsertInto);
            return new InfraOnExprBaseViewResult(selectView, pair.Second);
        }
Esempio n. 2
0
        public override void HandleMatching(
            EventBean[] triggerEvents,
            EventBean[] matchingEvents)
        {
            agentInstanceContext.InstrumentationProvider.QInfraOnAction(
                OnTriggerType.ON_SELECT,
                triggerEvents,
                matchingEvents);

            // clear state from prior results
            resultSetProcessor.Clear();

            // build join result
            // use linked hash set to retain order of join results for last/first/window to work most intuitively
            ISet<MultiKeyArrayOfKeys<EventBean>> newEvents =
                OnExprViewNamedWindowSelect.BuildJoinResult(triggerEvents, matchingEvents);

            // process matches
            UniformPair<EventBean[]> pair = resultSetProcessor.ProcessJoinResult(
                newEvents,
                Collections.GetEmptySet<MultiKeyArrayOfKeys<EventBean>>(),
                false);
            EventBean[] newData = pair?.First;

            // handle distinct and insert
            newData = InfraOnSelectUtil.HandleDistintAndInsert(
                newData,
                parent,
                agentInstanceContext,
                tableInstanceInsertInto,
                audit);

            // The on-select listeners receive the events selected
            if ((newData != null) && (newData.Length > 0)) {
                // And post only if we have listeners/subscribers that need the data
                StatementResultService statementResultService = agentInstanceContext.StatementResultService;
                if (statementResultService.IsMakeNatural || statementResultService.IsMakeSynthetic) {
                    Child.Update(newData, null);
                }
            }

            // clear state from prior results
            resultSetProcessor.Clear();

            // Events to delete are indicated via old data
            if (deleteAndSelect) {
                foreach (EventBean @event in matchingEvents) {
                    tableInstance.DeleteEvent(@event);
                }
            }

            agentInstanceContext.InstrumentationProvider.AInfraOnAction();
        }