static long getMaxMetricID ( final TSDB tsdb ) { // first up, we need the max metric ID so we can split up the data table // amongst threads. final GetRequest get = new GetRequest ( tsdb . uidTable ( ) , new byte [ ] { 0 } ) ; get . family ( "id" . getBytes ( CHARSET ) ) ; get . qualifier ( "metrics" . getBytes ( CHARSET ) ) ; ArrayList < KeyValue > row ; try { row = tsdb . getClient ( ) . get ( get ) . joinUninterruptibly ( ) ; if ( row == null || row . isEmpty ( ) ) { return 0 ; } final byte [ ] id_bytes = row . get ( 0 ) . value ( ) ; if ( id_bytes . length != 8 ) { throw new IllegalStateException ( "Invalid metric max UID, wrong # of bytes" ) ; } return Bytes . getLong ( id_bytes ) ; } catch ( Exception e ) { throw new RuntimeException ( "Shouldn't be here" , e ) ; } }
Returns the max metric ID from the UID table