private void getCounts ( String path , Counts counts ) { DataNode node = getNode ( path ) ; if ( node == null ) { return ; } String [ ] children = null ; int len = 0 ; synchronized ( node ) { Set < String > childs = node . getChildren ( ) ; if ( childs != null ) { children = childs . toArray ( new String [ childs . size ( ) ] ) ; } len = ( node . data == null ? 0 : node . data . length ) ; } // add itself counts . count += 1 ; counts . bytes += len ; if ( children == null || children . length == 0 ) { return ; } for ( String child : children ) { getCounts ( path + "/" + child , counts ) ; } }
this method gets the count of nodes and the bytes under a subtree