int entryCount = matches.size();
for (int i = 0; i < entryCount; i++)
{
EPStatementHandleCallback handleCallback = (EPStatementHandleCallback) matchArray[i];
EPStatementAgentInstanceHandle handle = handleCallback.getAgentInstanceHandle();
// Self-joins require that the internal dispatch happens after all streams are evaluated.
// Priority or preemptive settings also require special ordering.
if (handle.isCanSelfJoin() || isPrioritized)
{
Object callbacks = stmtCallbacks.get(handle);
if (callbacks == null) {
stmtCallbacks.put(handle, handleCallback.getFilterCallback());
}
else if (callbacks instanceof ArrayDeque) {
ArrayDeque<FilterHandleCallback> q = (ArrayDeque<FilterHandleCallback>) callbacks;
q.add(handleCallback.getFilterCallback());
}
else {
ArrayDeque<FilterHandleCallback> q = new ArrayDeque<FilterHandleCallback>(4);
q.add((FilterHandleCallback) callbacks);
q.add(handleCallback.getFilterCallback());
stmtCallbacks.put(handle, q);
}
continue;
}
if ((MetricReportingPath.isMetricsEnabled) && (handle.getStatementHandle().getMetricsHandle().isEnabled()))
{
long cpuTimeBefore = MetricUtil.getCPUCurrentThread();
long wallTimeBefore = MetricUtil.getWall();
processStatementFilterSingle(handle, handleCallback, theEvent, version);
long wallTimeAfter = MetricUtil.getWall();
long cpuTimeAfter = MetricUtil.getCPUCurrentThread();
long deltaCPU = cpuTimeAfter - cpuTimeBefore;
long deltaWall = wallTimeAfter - wallTimeBefore;
services.getMetricsReportingService().accountTime(handle.getStatementHandle().getMetricsHandle(), deltaCPU, deltaWall, 1);
}
else
{
if ((ThreadingOption.isThreadingEnabled) && (services.getThreadingService().isRouteThreading()))
{
services.getThreadingService().submitRoute(new RouteUnitSingle(this, handleCallback, theEvent, version));
}
else
{
processStatementFilterSingle(handle, handleCallback, theEvent, version);
}
}
}
matches.clear();
if (stmtCallbacks.isEmpty())
{
return;
}
for (Map.Entry<EPStatementAgentInstanceHandle, Object> entry : stmtCallbacks.entrySet())
{
EPStatementAgentInstanceHandle handle = entry.getKey();
Object callbackList = entry.getValue();
if ((MetricReportingPath.isMetricsEnabled) && (handle.getStatementHandle().getMetricsHandle().isEnabled()))
{
long cpuTimeBefore = MetricUtil.getCPUCurrentThread();
long wallTimeBefore = MetricUtil.getWall();
processStatementFilterMultiple(handle, callbackList, theEvent, version);
long wallTimeAfter = MetricUtil.getWall();
long cpuTimeAfter = MetricUtil.getCPUCurrentThread();
long deltaCPU = cpuTimeAfter - cpuTimeBefore;
long deltaWall = wallTimeAfter - wallTimeBefore;
int size = 1;
if (callbackList instanceof Collection) {
size = ((Collection) callbackList).size();
}
services.getMetricsReportingService().accountTime(handle.getStatementHandle().getMetricsHandle(), deltaCPU, deltaWall, size);
}
else
{
if ((ThreadingOption.isThreadingEnabled) && (services.getThreadingService().isRouteThreading()))
{
services.getThreadingService().submitRoute(new RouteUnitMultiple(this, callbackList, theEvent, handle, version));
}
else
{
processStatementFilterMultiple(handle, callbackList, theEvent, version);
}
if ((isPrioritized) && (handle.isPreemptive()))
{
break;
}
}
}