code: public static void createIndex(FileSystem fs, Path lzoFile)
        throws IOException {
  
      Configuration conf = fs.getConf();
      CompressionCodecFactory factory = new CompressionCodecFactory(fs.getConf());
      CompressionCodec codec = factory.getCodec(lzoFile);
      ((Configurable) codec).setConf(conf);
  
      InputStream lzoIs = null;
      FSDataOutputStream os = null;
      Path outputFile = new Path(lzoFile.toString()
          + LzoTextInputFormat.LZO_INDEX_SUFFIX);
      Path tmpOutputFile = outputFile.suffix(".tmp");
      
      try {
        FSDataInputStream is = fs.open(lzoFile);
        os = fs.create(tmpOutputFile);
        LzopDecompressor decompressor = (LzopDecompressor) codec
            .createDecompressor();
        // for reading the header
        lzoIs = codec.createInputStream(is, decompressor);
  
        int numChecksums = decompressor.getChecksumsCount();
  
        while (true) {
          // read and ignore, we just want to get to the next int
          int uncompressedBlockSize = is.readInt();
          if (uncompressedBlockSize == 0) {
            break;
          } else if (uncompressedBlockSize < 0) {
            throw new EOFException();
          }
  
          int compressedBlockSize = is.readInt();
          if (compressedBlockSize <= 0) {
            throw new IOException("Could not read compressed block size");
          }
  
          long pos = is.getPos();
          // write the pos of the block start
          os.writeLong(pos - 8);
          // seek to the start of the next block, skip any checksums
          is.seek(pos + compressedBlockSize + (4 * numChecksums));
        }
      } finally {
        if (lzoIs != null) {
          lzoIs.close();
        }
  
        if (os != null) {
          os.close();
        }
      }
      
      fs.rename(tmpOutputFile, outputFile);
    }
docs: Index an lzo file to allow the input format to split them into separate map
  jobs.
  
  @param fs
  File system that contains the file.
  @param lzoFile
  the lzo file to index.
  @throws IOException