Exemplo n.º 1
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();
        }
Exemplo 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
            var newEvents = BuildJoinResult(triggerEvents, matchingEvents);

            // process matches
            var pair = resultSetProcessor.ProcessJoinResult(newEvents, oldEvents, false);
            var newData = pair != null ? pair.First : null;

            // 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) {
                if (Child != null) {
                    // And post only if we have listeners/subscribers that need the data
                    var 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 (isDelete) {
                rootView.Update(null, matchingEvents);
            }

            agentInstanceContext.InstrumentationProvider.AInfraOnAction();
        }