setup(onTriggerDesc, triggeringEventType, triggeringStreamName, statementContext);
}
public void handleMatching(EventBean[] triggerEvents, EventBean[] matchingEvents)
{
OneEventCollection newData = new OneEventCollection();
OneEventCollection oldData = null;
EventBean[] eventsPerStream = new EventBean[2];
if ((matchingEvents == null) || (matchingEvents.length == 0)){
for (EventBean triggerEvent : triggerEvents) {
eventsPerStream[1] = triggerEvent;
for (NamedWindowOnMergeMatch action : unmatched) {
if (!action.isApplies(eventsPerStream, super.getExprEvaluatorContext())) {
continue;
}
action.apply(null, eventsPerStream, newData, oldData, super.getExprEvaluatorContext());
break; // apply no other actions
}
}
}
else {
// handle update/
oldData = new OneEventCollection();
for (EventBean triggerEvent : triggerEvents) {
eventsPerStream[1] = triggerEvent;
for (EventBean matchingEvent : matchingEvents) {
eventsPerStream[0] = matchingEvent;
for (NamedWindowOnMergeMatch action : matched) {
if (!action.isApplies(eventsPerStream, super.getExprEvaluatorContext())) {
continue;
}
action.apply(matchingEvent, eventsPerStream, newData, oldData, super.getExprEvaluatorContext());
break; // apply no other actions
}
}
}
}
if (!newData.isEmpty() || (oldData != null && !oldData.isEmpty()))
{
if ((MetricReportingPath.isMetricsEnabled) && (createWindowStatementHandle.getMetricsHandle().isEnabled()) && !newData.isEmpty())
{
metricReportingService.accountTime(createWindowStatementHandle.getMetricsHandle(), 0, 0, newData.toArray().length);
}
// Events to delete are indicated via old data
// The on-merge listeners receive the events deleted, but only if there is interest
if (statementResultService.isMakeNatural()) {
EventBean[] eventsPerStreamNaturalNew = newData.isEmpty() ? null : newData.toArray();
EventBean[] eventsPerStreamNaturalOld = (oldData == null || oldData.isEmpty()) ? null : oldData.toArray();
this.rootView.update(EventBeanUtility.denaturalize(eventsPerStreamNaturalNew), EventBeanUtility.denaturalize(eventsPerStreamNaturalOld));
updateChildren(eventsPerStreamNaturalNew, eventsPerStreamNaturalOld);
}
else {
EventBean[] eventsPerStreamNew = newData.isEmpty() ? null : newData.toArray();
EventBean[] eventsPerStreamOld = (oldData == null || oldData.isEmpty()) ? null : oldData.toArray();
this.rootView.update(eventsPerStreamNew, eventsPerStreamOld);
if (statementResultService.isMakeSynthetic()) {
updateChildren(eventsPerStreamNew, eventsPerStreamOld);
}
}