code: private int readWithinBlock(byte[] b, int off, int len) throws IOException {
      if (input.endOfBlock()) {
        final int available = input.available(); // this will read the next block, if there is one
        processedPosition = input.getPosition() >> 16;
        if (available == 0) { // end of stream
          return -1;
        }
        return END_OF_BLOCK;
      }
  
      // return up to end of block (at most)
      int available = input.available();
      return input.read(b, off, Math.min(available, len));
    }
docs: Read up to <code>len</code> bytes from the stream, but no further than the end of the
  compressed block. If at the end of the block then no bytes will be read and a return
  value of -2 will be returned; on the next call to read, bytes from the next block
  will be returned. This is the same contract as CBZip2InputStream in Hadoop.
  @return int The return value greater than 0 are the bytes read.  A value
  of -1 means end of stream while -2 represents end of block.