public static Path compressAndIndex(Path file, Configuration conf) throws IOException { Configuration tmpConfig = new Configuration(conf); tmpConfig.setLong("dfs.block.size", 512); tmpConfig.setInt(LzoCodec.LZO_BUFFER_SIZE_KEY, 512); Path compressedFile = LzopFileReadWrite.compress(file, tmpConfig); compressedFile.getFileSystem(tmpConfig).delete(new Path( compressedFile.toString() + LzoIndex.LZO_INDEX_SUFFIX), false); new LzoIndexer(tmpConfig).index(compressedFile); LzoIndex index = LzoIndex .readIndex(compressedFile.getFileSystem(tmpConfig), compressedFile); for (int i = 0; i < index.getNumberOfBlocks(); i++) { System.out.println("block[" + i + "] = " + index.getPosition(i)); } Job job = new Job(conf); job.setInputFormatClass(LzoTextInputFormat.class); LzoTextInputFormat inputFormat = new LzoTextInputFormat(); TextInputFormat.setInputPaths(job, compressedFile); List<InputSplit> is = inputFormat.getSplits(job); System.out.println("input splits = " + is.size()); return compressedFile; }