public void addValue ( ByteBuffer key , ByteBuffer value ) { if ( isFull ) { throw new IllegalArgumentException ( "Already full" ) ; } if ( value . remaining ( ) + key . remaining ( ) + POINTER_SIZE_BYTES > memoryBuffer . remaining ( ) ) { leftover = new KeyValue <> ( key , value ) ; isFull = true ; } else { int keyPos = spliceIn ( key , memoryBuffer ) ; int valuePos = spliceIn ( value , memoryBuffer ) ; addPointer ( keyPos , key . remaining ( ) , valuePos , value . remaining ( ) ) ; } }
Add a new key and value to the in memory buffer .