use of org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable in project flink by apache.
the class ReusingBlockResettableIteratorTest method testSerialBlockResettableIterator.
@Test
public void testSerialBlockResettableIterator() throws Exception {
final AbstractInvokable memOwner = new DummyInvokable();
// create the resettable Iterator
final ReusingBlockResettableIterator<Record> iterator = new ReusingBlockResettableIterator<Record>(this.memman, this.reader, this.serializer, 1, memOwner);
// open the iterator
iterator.open();
// now test walking through the iterator
int lower = 0;
int upper = 0;
do {
lower = upper;
upper = lower;
// find the upper bound
while (iterator.hasNext()) {
Record target = iterator.next();
int val = target.getField(0, IntValue.class).getValue();
Assert.assertEquals(upper++, val);
}
// now reset the buffer a few times
for (int i = 0; i < 5; ++i) {
iterator.reset();
int count = 0;
while (iterator.hasNext()) {
Record target = iterator.next();
int val = target.getField(0, IntValue.class).getValue();
Assert.assertEquals(lower + (count++), val);
}
Assert.assertEquals(upper - lower, count);
}
} while (iterator.nextBlock());
Assert.assertEquals(NUM_VALUES, upper);
// close the iterator
iterator.close();
}
Aggregations