private byte [ ] toCookedBytes ( ) { // Allocate for a int pair per token/partition ID entry, plus a size. ByteBuffer buf = ByteBuffer . allocate ( 4 + ( m_tokenCount * 8 ) ) ; buf . putInt ( m_tokenCount ) ; // Keep tokens and partition ids separate to aid compression. for ( int zz = 3 ; zz >= 0 ; zz -- ) { int lastToken = Integer . MIN_VALUE ; for ( int ii = 0 ; ii < m_tokenCount ; ii ++ ) { int token = Bits . unsafe . getInt ( m_tokens + ( ii * 8 ) ) ; Preconditions . checkArgument ( token >= lastToken ) ; lastToken = token ; token = token >>> ( zz * 8 ) ; token = token & 0xFF ; buf . put ( ( byte ) token ) ; } } for ( int ii = 0 ; ii < m_tokenCount ; ii ++ ) { buf . putInt ( Bits . unsafe . getInt ( m_tokens + ( ii * 8 ) + 4 ) ) ; } try { return CompressionService . gzipBytes ( buf . array ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( "Failed to compress bytes" , e ) ; } }
Returns compressed config bytes .