public long [ ] readLongs ( int length ) throws KryoException { long [ ] array = new long [ length ] ; if ( optional ( length << 3 ) == length << 3 ) { byte [ ] buffer = this . buffer ; int p = this . position ; for ( int i = 0 ; i < length ; i ++ , p += 8 ) { array [ i ] = buffer [ p ] & 0xFF // | ( buffer [ p + 1 ] & 0xFF ) << 8 // | ( buffer [ p + 2 ] & 0xFF ) << 16 // | ( long ) ( buffer [ p + 3 ] & 0xFF ) << 24 // | ( long ) ( buffer [ p + 4 ] & 0xFF ) << 32 // | ( long ) ( buffer [ p + 5 ] & 0xFF ) << 40 // | ( long ) ( buffer [ p + 6 ] & 0xFF ) << 48 // | ( long ) buffer [ p + 7 ] << 56 ; } position = p ; } else { for ( int i = 0 ; i < length ; i ++ ) array [ i ] = readLong ( ) ; } return array ; }
Reads a long array in bulk . This may be more efficient than reading them individually .