public ByteBuffer getSerializedValue ( ByteBuffer serializedMap , ByteBuffer serializedKey , AbstractType keyType ) { try { ByteBuffer input = serializedMap . duplicate ( ) ; int n = readCollectionSize ( input , Server . VERSION_3 ) ; for ( int i = 0 ; i < n ; i ++ ) { ByteBuffer kbb = readValue ( input , Server . VERSION_3 ) ; ByteBuffer vbb = readValue ( input , Server . VERSION_3 ) ; int comparison = keyType . compare ( kbb , serializedKey ) ; if ( comparison == 0 ) return vbb ; else if ( comparison > 0 ) // since the map is in sorted order, we know we've gone too far and the element doesn't exist return null ; } return null ; } catch ( BufferUnderflowException e ) { throw new MarshalException ( "Not enough bytes to read a map" ) ; } }
Given a serialized map gets the value associated with a given key .