private long[] computeContentSummary(long[] summary, Set<Long> visitedCtx) {  
    if (children != null) { 
      for (INode child : children) {
        if (child.isDirectory()) {
          // Process the directory with the visited hard link context 
          ((INodeDirectory)child).computeContentSummary(summary, visitedCtx); 
        } else {  
          // Process the file 
          if (child instanceof INodeHardLinkFile) {
            // Get the current hard link ID 
            long hardLinkID = ((INodeHardLinkFile) child).getHardLinkID();  
            if (visitedCtx.contains(hardLinkID)) {
              // The current hard link file has been visited, so only increase the file count.
              summary[1] ++;
              continue; 
            } else {
              // Add the current hard link file to the visited set  
              visitedCtx.add(hardLinkID);
              // Compute the current hardlink file  
              child.computeContentSummary(summary); 
            } 
          } else {
            // compute the current child for non hard linked files
            child.computeContentSummary(summary); 
          }

        } 
      } 
    } 
    summary[2]++; 
    return summary; 
  }
private long [ ] computeContentSummary ( long [ ] summary , Set < Long > visitedCtx ) { if ( children != null ) { for ( INode child : children ) { if ( child . isDirectory ( ) ) { ( ( INodeDirectory ) child ) . computeContentSummary ( summary , visitedCtx ) ; } else { if ( child instanceof INodeHardLinkFile ) { long hardLinkID = ( ( INodeHardLinkFile ) child ) . getHardLinkID ( ) ; if ( visitedCtx . contains ( hardLinkID ) ) { summary [ 1 ] ++ ; continue ; } else { visitedCtx . add ( hardLinkID ) ; child . computeContentSummary ( summary ) ; } } else { child . computeContentSummary ( summary ) ; } } } } summary [ 2 ] ++ ; return summary ; }
Compute the content summary and skip calculating the visited hard link file.