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