use of org.apache.hadoop.mapred.nativetask.handlers.BufferPullee in project hadoop by apache.
the class TestBufferPushPull method testPull.
@Test
public void testPull() throws Exception {
final byte[] buff = new byte[BUFFER_LENGTH];
final InputBuffer input = new InputBuffer(buff);
final OutputBuffer out = new OutputBuffer(buff);
final Class<BytesWritable> iKClass = BytesWritable.class;
final Class<BytesWritable> iVClass = BytesWritable.class;
final NativeHandlerForPull handler = new NativeHandlerForPull(input, out);
final KeyValueIterator iter = new KeyValueIterator();
final BufferPullee pullee = new BufferPullee(iKClass, iVClass, iter, handler);
handler.setDataLoader(pullee);
final BufferPuller puller = new BufferPuller(handler);
handler.setDataReceiver(puller);
int count = 0;
while (puller.next()) {
final DataInputBuffer key = puller.getKey();
final DataInputBuffer value = puller.getValue();
final BytesWritable keyBytes = new BytesWritable();
final BytesWritable valueBytes = new BytesWritable();
keyBytes.readFields(key);
valueBytes.readFields(value);
Assert.assertEquals(dataInput[count].key.toString(), keyBytes.toString());
Assert.assertEquals(dataInput[count].value.toString(), valueBytes.toString());
count++;
}
puller.close();
pullee.close();
}
Aggregations