for (int i = 0; i < NUM_PAIRS_EXTERNAL + 1; i++) {
generator.next(rec);
readRec.read(inView);
Key k1 = rec.getField(0, Key.class);
Value v1 = rec.getField(1, Value.class);
Key k2 = readRec.getField(0, Key.class);
Value v2 = readRec.getField(1, Value.class);
Assert.assertTrue("The re-generated and the read record do not match.", k1.equals(k2) && v1.equals(v2));
}
Assert.fail("Read too much, expected EOFException.");
}
catch (EOFException eofex) {
// expected
}
// re-read the data
inView = outView.flip();
generator.reset();
// read and re-generate all records and compare them
for (int i = 0; i < NUM_PAIRS_EXTERNAL; i++) {
generator.next(rec);
readRec.read(inView);
Key k1 = rec.getField(0, Key.class);
Value v1 = rec.getField(1, Value.class);
Key k2 = readRec.getField(0, Key.class);
Value v2 = readRec.getField(1, Value.class);
Assert.assertTrue("The re-generated and the read record do not match.", k1.equals(k2) && v1.equals(v2));
}
this.memoryManager.release(outView.close());