}
@Test
public void testSerializeLazy2() throws IOException {
Int2FloatOpenHashMapWritable.setLazyDecodeFlag(true);
Int2FloatOpenHashMapWritable m1 = new Int2FloatOpenHashMapWritable();
m1.put(3, 5);
m1.put(4, 22);
// Object m2 should not have been decoded, size lazy decode flag is
// true.
Int2FloatOpenHashMapWritable m2 = Int2FloatOpenHashMapWritable.create(m1.serialize());
// Even though m2 hasn't be decoded, we should be able to properly
// serialize it.
Int2FloatOpenHashMapWritable m3 = Int2FloatOpenHashMapWritable.create(m2.serialize());
assertEquals(0, m3.size());
assertFalse(m3.hasBeenDecoded());
int[] keys = m3.getKeys();
float[] values = m3.getValues();
assertEquals(3, keys[0]);
assertEquals(4, keys[1]);
assertEquals(5.0f, values[0], 10e-6);
assertEquals(22.0f, values[1], 10e-6);
m3.decode();
assertTrue(m3.hasBeenDecoded());
float value;
assertEquals(2, m3.size());
value = m3.get(3);
assertEquals(5.0f, value, 10e-6);
value = m3.remove(3);
assertEquals(1, m3.size());
value = m3.get(4);
assertEquals(22.0f, value, 10e-6);
}