src/main/java/org/apache/hadoop/util/VirtualINodeTree.java
private Set<VirtualINode> prunedAncestors(Set<VirtualINode> commonAncestors) {
    Map<String, VirtualINode> ancestorPaths =
        commonAncestors.stream().collect(Collectors.toMap(VirtualINode::path, Function.identity()));
    Set<String> toRemove = new HashSet<>();
    for (String ancestorPath : ancestorPaths.keySet()) {
      for (String compare : ancestorPaths.keySet()) {
        if (compare.startsWith(ancestorPath) && compare.length() > ancestorPath.length()) {
          toRemove.add(compare);
        }
      }
    }
    toRemove.forEach(ancestorPaths::remove);
    ancestorPaths.values().forEach(VirtualINode::unmark);
    return new HashSet<>(ancestorPaths.values());
  }
/*
   * O(n^2) implementation for removing longer ancestors.
   * This is used in the case that /A and /A/B show up as ancestors.
   * It is assumed that the total number of added elements for analysis will be small.
   */
O(n^2) implementation for removing longer ancestors.
This is used in the case that /A and /A/B show up as ancestors.
It is assumed that the total number of added elements for analysis will be small.
O ( n^2 ) implementation for removing longer ancestors . This is used in the case that / A and / A / B show up as ancestors . It is assumed that the total number of added elements for analysis will be small .
private Set<VirtualINode> prunedAncestors(Set<VirtualINode> commonAncestors) {
    Map<String, VirtualINode> ancestorPaths =
        commonAncestors.stream().collect(Collectors.toMap(VirtualINode::path, Function.identity()));
    Set<String> toRemove = new HashSet<>();
    for (String ancestorPath : ancestorPaths.keySet()) {
      for (String compare : ancestorPaths.keySet()) {
        if (compare.startsWith(ancestorPath) && compare.length() > ancestorPath.length()) {
          toRemove.add(compare);
        }
      }
    }
    toRemove.forEach(ancestorPaths::remove);
    ancestorPaths.values().forEach(VirtualINode::unmark);
    return new HashSet<>(ancestorPaths.values());
  }
private Set < VirtualINode > prunedAncestors ( Set < VirtualINode > commonAncestors ) { Map < String , VirtualINode > ancestorPaths = commonAncestors . stream ( ) . collect ( Collectors . toMap ( VirtualINode :: path , Function . identity ( ) ) ) ; Set < String > toRemove = new HashSet < > ( ) ; for ( String ancestorPath : ancestorPaths . keySet ( ) ) { for ( String compare : ancestorPaths . keySet ( ) ) { if ( compare . startsWith ( ancestorPath ) && compare . length ( ) > ancestorPath . length ( ) ) { toRemove . add ( compare ) ; } } } toRemove . forEach ( ancestorPaths :: remove ) ; ancestorPaths . values ( ) . forEach ( VirtualINode :: unmark ) ; return new HashSet < > ( ancestorPaths . values ( ) ) ; }
O(n^2) implementation for removing longer ancestors.
O ( n^2 ) implementation for removing longer ancestors .