Пример #1
0
  /**
   * Step through all of the partially computed results, compute the intersections and remove the
   * intersections by priority.
   *
   * <p>Could be O(n^2) in worst case, but we expect that intersections are rare (?)
   *
   * <p>Uses the fact that the order of the list is also the priority order
   *
   * <p>FIXME :: come back and make this faster
   *
   * @param mergeList List of all FlowEntry's from matches(), including overlaps.
   * @return A pruned list of just the non-completely-overlapping matches
   */
  List<FlowIntersect> priorityMerge(List<FlowIntersect> mergeList) {
    List<FlowIntersect> results = new ArrayList<FlowIntersect>();
    boolean eclipsed;
    MatchType matchType;
    results.add(mergeList.get(0));
    mergeList.remove(0);

    for (FlowIntersect merge : mergeList) {
      eclipsed = false;
      for (FlowIntersect result : results) {
        /*
         * is this new match eclipsed by previous entries?
         *
         * with each successive matches() call, the part that over laps
         * result is removed, so that if a merge rule is not fully
         * eclipsed by any one result, but is fully eclipsed by a sum of
         * results, we will catch that to
         */
        FlowIntersect tmpIntersect =
            merge.getFlowEntry().matches(result.getDpid(), result.getMatch());
        matchType = tmpIntersect.getMatchType();

        if ((matchType == MatchType.EQUAL) || (matchType == MatchType.SUPERSET)) {
          eclipsed = true;
          break;
        } else if (matchType == MatchType.SUBSET) {
          merge = tmpIntersect; // then update with the intersection
        }
        // note: if matchtype == NONE, then tmpIntersect.getMatch() is
        // undefined
      }
      if (!eclipsed) // add this match to the list iff it's
      results.add(merge); // not complete eclipsed by something before
      // it
    }
    return results;
  }