private static void decompressChunk(
      ByteBuffer src, CompressionCodec codec, ByteBuffer dest) throws IOException {
    int startPos = dest.position(), startLim = dest.limit();
    int startSrcPos = src.position(), startSrcLim = src.limit();
    if (LOG.isTraceEnabled()) {
      LOG.trace("Decompressing " + src.remaining() + " bytes to dest buffer pos "
          + dest.position() + ", limit " + dest.limit());
    }
    codec.reset(); // We always need to call reset on the codec.
    codec.decompress(src, dest);

    dest.position(startPos);
    int newLim = dest.limit();
    if (newLim > startLim) {
      throw new AssertionError("After codec, buffer [" + startPos + ", " + startLim
          + ") became [" + dest.position() + ", " + newLim + ")");
    }
    if (dest.remaining() == 0) {
      throw new IOException("The codec has produced 0 bytes for {" + src.isDirect() + ", "
        + src.position() + ", " + src.remaining() + "} into {" + dest.isDirect() + ", "
        + dest.position()  + ", " + dest.remaining() + "}");
    }
  }
To achieve some sort of consistent cache boundaries, we will cache streams deterministically;
in segments starting w/stream start, and going for either stream size or some fixed size.
If we are not reading the entire segment's worth of data, then we will not cache the partial
RGs; the breakage of cache assumptions (no interleaving blocks, etc.) is way too much PITA
to handle just for this case.
We could avoid copy in non-zcr case and manage the buffer that was not allocated by our
allocator. Uncompressed case is not mainline though so let's not complicate it.
@param kind
ql/src/java/org/apache/hadoop/hive/ql/io/orc/encoded/EncodedReaderImpl.java