KVSerializer implements IKVSerializer { @Override public void updateLength(SizedWritable<?> key, SizedWritable<?> value) throws IOException { key.length = keySerializer.getLength(key.v); value.length = valueSerializer.getLength(value.v); return; } KVSerializer(Class<K> kclass, Class<V> vclass); @Override void updateLength(SizedWritable<?> key, SizedWritable<?> value); @Override int serializeKV(DataOutputStream out, SizedWritable<?> key, SizedWritable<?> value); @Override int serializePartitionKV(DataOutputStream out, int partitionId,
      SizedWritable<?> key, SizedWritable<?> value); @Override int deserializeKV(DataInputStream in, SizedWritable<?> key,
      SizedWritable<?> value); static final int KV_HEAD_LENGTH; }
@Test public void testUpdateLength() throws IOException { Mockito.mock(DataOutputStream.class); int kvLength = 0; for (int i = 0; i < inputArraySize; i++) { key.reset(inputArray[i].key); value.reset(inputArray[i].value); serializer.updateLength(key, value); Assert.assertTrue(key.length + value.length > kvLength); kvLength = key.length + value.length; } }