return String.format("%s%010d", prefix, value);
}
void checkRecNums() throws IOException {
long fileLen = fs.getFileStatus(path).getLen();
Reader reader = new Reader(fs.open(path), fileLen, conf);
long totalRecs = reader.getEntryCount();
long begin = random.nextLong() % (totalRecs / 2);
if (begin < 0)
begin += (totalRecs / 2);
long end = random.nextLong() % (totalRecs / 2);
if (end < 0)
end += (totalRecs / 2);
end += (totalRecs / 2) + 1;
assertEquals("RecNum for offset=0 should be 0", 0, reader
.getRecordNumNear(0));
for (long x : new long[] { fileLen, fileLen + 1, 2 * fileLen }) {
assertEquals("RecNum for offset>=fileLen should be total entries",
totalRecs, reader.getRecordNumNear(x));
}
for (long i = 0; i < 100; ++i) {
assertEquals("Locaton to RecNum conversion not symmetric", i, reader
.getRecordNumByLocation(reader.getLocationByRecordNum(i)));
}
for (long i = 1; i < 100; ++i) {
long x = totalRecs - i;
assertEquals("Locaton to RecNum conversion not symmetric", x, reader
.getRecordNumByLocation(reader.getLocationByRecordNum(x)));
}
for (long i = begin; i < end; ++i) {
assertEquals("Locaton to RecNum conversion not symmetric", i, reader
.getRecordNumByLocation(reader.getLocationByRecordNum(i)));
}
for (int i = 0; i < 1000; ++i) {
long x = random.nextLong() % totalRecs;
if (x < 0) x += totalRecs;
assertEquals("Locaton to RecNum conversion not symmetric", x, reader
.getRecordNumByLocation(reader.getLocationByRecordNum(x)));
}
}