in src/main/java/com/hadoop/compression/lzo/LzoIndex.java [170:196]
public static LzoIndex readIndex(FileSystem fs, Path lzoFile) throws IOException {
FSDataInputStream indexIn = null;
Path indexFile = lzoFile.suffix(LZO_INDEX_SUFFIX);
try {
indexIn = fs.open(indexFile);
} catch (IOException fileNotFound) {
// return empty index, fall back to the unsplittable mode
return new LzoIndex();
}
int capacity = 16 * 1024 * 8; //size for a 4GB file (with 256KB lzo blocks)
DataOutputBuffer bytes = new DataOutputBuffer(capacity);
// copy indexIn and close it
IOUtils.copyBytes(indexIn, bytes, 4*1024, true);
ByteBuffer bytesIn = ByteBuffer.wrap(bytes.getData(), 0, bytes.getLength());
int blocks = bytesIn.remaining()/8;
LzoIndex index = new LzoIndex(blocks);
for (int i = 0; i < blocks; i++) {
index.set(i, bytesIn.getLong());
}
return index;
}