}
}
};
}
SimpleSeekableFormatInputStream in = new SimpleSeekableFormatInputStream(fileForRead);
DataInputStream dataIn = new DataInputStream(in);
long seekedPosition = in.seekForward();
{
// We should not be at the beginning of the stream any more.
InterleavedInputStream interleavedIn = in.getInterleavedIn();
long blocks = interleavedIn.getRawOffset() / interleavedIn.getCompleteBlockSize();
long blocksAvailable = (availableBytes - interleavedIn.getMetaDataBlockSize()) / interleavedIn.getCompleteBlockSize();
blocksAvailable = Math.max(0, blocksAvailable);
Assert.assertTrue(blocks >= blocksAvailable);
}
long currentUncompressedPosition = 0;
for (int r = 0; r < numRecord; r++) {
// Regenerate the same random bytes
byte[] b = new byte[dataRandom2.nextInt(maxRecordSize)];
UtilsForTests.nextBytes(dataRandom2, b, 16);
if (currentUncompressedPosition >= seekedPosition) {
// Read from the file
byte[] b2 = new byte[b.length];
dataIn.readFully(b2);
UtilsForTests.assertArrayEquals("record " + r + " with length " + b.length,
b, b2);
}
currentUncompressedPosition += b.length;
}
// Verify EOF
Assert.assertEquals(-1, in.read());
byte[] temp = new byte[100];
Assert.assertEquals(-1, in.read(temp));
}