public static void preloadUidCache ( final TSDB tsdb , final ByteMap < UniqueId > uid_cache_map ) throws HBaseException { int max_results = tsdb . getConfig ( ) . getInt ( "tsd.core.preload_uid_cache.max_entries" ) ; LOG . info ( "Preloading uid cache with max_results=" + max_results ) ; if ( max_results <= 0 ) { return ; } Scanner scanner = null ; try { int num_rows = 0 ; scanner = getSuggestScanner ( tsdb . getClient ( ) , tsdb . uidTable ( ) , "" , null , max_results ) ; for ( ArrayList < ArrayList < KeyValue > > rows = scanner . nextRows ( ) . join ( ) ; rows != null ; rows = scanner . nextRows ( ) . join ( ) ) { for ( final ArrayList < KeyValue > row : rows ) { for ( KeyValue kv : row ) { final String name = fromBytes ( kv . key ( ) ) ; final byte [ ] kind = kv . qualifier ( ) ; final byte [ ] id = kv . value ( ) ; LOG . debug ( "id='{}', name='{}', kind='{}'" , Arrays . toString ( id ) , name , fromBytes ( kind ) ) ; UniqueId uid_cache = uid_cache_map . get ( kind ) ; if ( uid_cache != null ) { uid_cache . cacheMapping ( name , id ) ; } } num_rows += row . size ( ) ; row . clear ( ) ; // free() if ( num_rows >= max_results ) { break ; } } } for ( UniqueId unique_id_table : uid_cache_map . values ( ) ) { LOG . info ( "After preloading, uid cache '{}' has {} ids and {} names." , unique_id_table . kind ( ) , unique_id_table . use_lru ? unique_id_table . lru_id_cache . size ( ) : unique_id_table . id_cache . size ( ) , unique_id_table . use_lru ? unique_id_table . lru_name_cache . size ( ) : unique_id_table . name_cache . size ( ) ) ; } } catch ( Exception e ) { if ( e instanceof HBaseException ) { throw ( HBaseException ) e ; } else if ( e instanceof RuntimeException ) { throw ( RuntimeException ) e ; } else { throw new RuntimeException ( "Error while preloading IDs" , e ) ; } } finally { if ( scanner != null ) { scanner . close ( ) ; } } }
Pre - load UID caches scanning up to tsd . core . preload_uid_cache . max_entries rows from the UID table .