src/main/java/org/apache/hadoop/util/VirtualINodeTree.java
public void addElement(String path) {
    if (paths.contains(path)) {
      return;
    }

    String[] elements = path.split("/");
    // Avoid first element that can be an empty string if you split a string that has a starting /
    while (elements[0] == null || elements[0].equals("")) {
      elements = Arrays.copyOfRange(elements, 1, elements.length);
    }

    VirtualINode currParent = root;
    for (String element : elements) {
      VirtualINode nextParent = currParent.getChild(element);
      if (nextParent != null) {
        currParent = nextParent;
      } else {
        VirtualINode newChild = new VirtualINode(currParent, element);
        if (!currParent.getChildren().isEmpty()) {
          currParent.incrementScore();
        }
        currParent.addChild(newChild);
        currParent = newChild;
      }
    }

    paths.add(path);
  }
/**
   * This will add a path to the virtual tree. The path is broken up into its elements by splitting
   * on the '/' separator and adding all non-existing VirtualINodes along the way. If any
   * VirtualINodes along the way already exists, its "score" is incremented.
   *
   * @param path - The full path to add to the tree.
   */
This will add a path to the virtual tree. The path is broken up into its elements by splitting
on the '/' separator and adding all non-existing VirtualINodes along the way. If any
VirtualINodes along the way already exists, its "score" is incremented.

@param path - The full path to add to the tree.
This will add a path to the virtual tree . The path is broken up into its elements by splitting on the ' / ' separator and adding all non - existing VirtualINodes along the way . If any VirtualINodes along the way already exists its " score " is incremented . @param path - The full path to add to the tree .
public void addElement(String path) {
    if (paths.contains(path)) {
      return;
    }
    String[] elements = path.split("/");
    while (elements[0] == null || elements[0].equals("")) {
      elements = Arrays.copyOfRange(elements, 1, elements.length);
    }
    VirtualINode currParent = root;
    for (String element : elements) {
      VirtualINode nextParent = currParent.getChild(element);
      if (nextParent != null) {
        currParent = nextParent;
      } else {
        VirtualINode newChild = new VirtualINode(currParent, element);
        if (!currParent.getChildren().isEmpty()) {
          currParent.incrementScore();
        }
        currParent.addChild(newChild);
        currParent = newChild;
      }
    }
    paths.add(path);
  }
public void addElement ( String path ) { if ( paths . contains ( path ) ) { return ; } String [ ] elements = path . split ( "/" ) ; while ( elements [ 0 ] == null || elements [ 0 ] . equals ( "" ) ) { elements = Arrays . copyOfRange ( elements , 1 , elements . length ) ; } VirtualINode currParent = root ; for ( String element : elements ) { VirtualINode nextParent = currParent . getChild ( element ) ; if ( nextParent != null ) { currParent = nextParent ; } else { VirtualINode newChild = new VirtualINode ( currParent , element ) ; if ( ! currParent . getChildren ( ) . isEmpty ( ) ) { currParent . incrementScore ( ) ; } currParent . addChild ( newChild ) ; currParent = newChild ; } } paths . add ( path ) ; }
This will add a path to the virtual tree.
This will add a path to the virtual tree .
// Avoid first element that can be an empty string if you split a string that has a starting /