private void populateCache ( ) { if ( disableAllCaches || disablePopulateCache ) { return ; } // Populate Cache final long ts = System . currentTimeMillis ( ) ; for ( int index = 1 ; ( ( index < storageBlock ) && ( cacheInternalNodes . size ( ) < readCacheInternal ) && ( cacheLeafNodes . size ( ) < readCacheLeaf ) ) ; index ++ ) { if ( freeBlocks . get ( index ) ) { continue ; // skip free } try { final Node < K , V > node = getNodeFromStore ( index ) ; // read ( node . isLeaf ( ) ? cacheLeafNodes : cacheInternalNodes ) . put ( node . id , node ) ; } catch ( Node . InvalidNodeID e ) { freeBlocks . set ( index ) ; // mark index as free } } log . info ( "Populated read cache ts=" + ( System . currentTimeMillis ( ) - ts ) + " blocks=" + storageBlock + " elements=" + elements ) ; }
Populate read cache if cache is enabled