private static OrcTail getOrcTailFromLlapBuffers(LlapBufferOrBuffers tailBuffers) throws IOException {
    MemoryBuffer tailBuffer = tailBuffers.getSingleBuffer();
    ByteBuffer bb = null;
    if (tailBuffer != null) {
      bb = tailBuffer.getByteBufferDup();
      // TODO: remove the copy after ORC-158 and ORC-197
      // if (bb.isDirect()) {
      ByteBuffer dupBb = tailBuffer.getByteBufferDup(); // Don't mess with the cached object.
      bb = ByteBuffer.allocate(dupBb.remaining());
      bb.put(dupBb);
      bb.flip();
      // }
    } else {
      // TODO: add the ability to extractFileTail to read from multiple buffers?
      MemoryBuffer[] tailBufferArray = tailBuffers.getMultipleBuffers();
      int totalSize = 0;
      for (MemoryBuffer buf : tailBufferArray) {
        totalSize += buf.getByteBufferRaw().remaining();
      }
      bb = ByteBuffer.allocate(totalSize);
      for (MemoryBuffer buf : tailBufferArray) {
        bb.put(buf.getByteBufferDup());
      }
      bb.flip();
    }
    return ReaderImpl.extractFileTail(bb);
  }
Utility function to produce a deseralized OrcTail instance from LLAP buffers retrieved from metadata cache.
Expects buffers are already locked before invocation, and caller releases them thereafter.
@param tailBuffers
@return
@throws IOException
llap-server/src/java/org/apache/hadoop/hive/llap/io/encoded/OrcEncodedDataReader.java