String fileName = System.getProperty("java.io.tmpdir")
+ File.separatorChar + "testSpillInputStream.txt";
Configuration conf = new HamaConfiguration();
SpilledDataProcessor processor = new WriteSpilledDataProcessor(fileName);
processor.init(conf);
SpillingDataOutputBuffer outputBuffer = new SpillingDataOutputBuffer(2,
1024, 1024, true, processor);
Text text = new Text("Testing the spillage of spilling buffer");
for (int i = 0; i < 100; ++i) {
text.write(outputBuffer);
outputBuffer.markRecordEnd();
}
assertTrue(outputBuffer != null);
assertTrue(outputBuffer.size() == 4000);
assertTrue(outputBuffer.hasSpilled());
f = new File(fileName);
assertTrue(f.exists());
outputBuffer.close();
assertTrue(f.length() == 4000);// + (4000 / 1024 + 1) * 4));
SpilledDataInputBuffer inputBuffer = outputBuffer
.getInputStreamToRead(fileName);
for (int i = 0; i < 100; ++i) {
text.readFields(inputBuffer);
assertTrue("Testing the spillage of spilling buffer".equals(text