コード例 #1
0
ファイル: GroupByViewImpl.java プロジェクト: triplekill/esper
  private void handleEvent(EventBean theEvent, boolean isNew) {
    Object groupByValuesKey = getGroupKey(theEvent);

    // Get child views that belong to this group-by value combination
    Object subViews = this.subViewsPerKey.get(groupByValuesKey);

    // If this is a new group-by value, the list of subviews is null and we need to make clone
    // sub-views
    if (subViews == null) {
      subViews = makeSubViews(this, propertyNames, groupByValuesKey, agentInstanceContext);
      subViewsPerKey.put(groupByValuesKey, subViews);
    }

    // Construct a pair of lists to hold the events for the grouped value if not already there
    Pair<Object, Object> pair = groupedEvents.get(subViews);
    if (pair == null) {
      pair = new Pair<Object, Object>(null, null);
      groupedEvents.put(subViews, pair);
    }

    // Add event to a child view event list for later child update that includes new and old events
    if (isNew) {
      pair.setFirst(addUpgradeToDequeIfPopulated(pair.getFirst(), theEvent));
    } else {
      pair.setSecond(addUpgradeToDequeIfPopulated(pair.getSecond(), theEvent));
    }
  }