private int decompressRaw(ByteBuff output, ByteBuff input, int inputLen) throws IOException {
    if (output instanceof SingleByteBuff && input instanceof SingleByteBuff) {
      ByteBuffer nioOutput = output.nioByteBuffers()[0];
      ByteBuffer nioInput = input.nioByteBuffers()[0];
      int origOutputPos = nioOutput.position();
      int n;
      if (nioOutput.isDirect() && nioInput.isDirect()) {
        n = ctx.decompressDirectByteBuffer(nioOutput, nioOutput.position(),
          nioOutput.limit() - nioOutput.position(), nioInput, nioInput.position(), inputLen);
      } else if (!nioOutput.isDirect() && !nioInput.isDirect()) {
        n = ctx.decompressByteArray(nioOutput.array(),
          nioOutput.arrayOffset() + nioOutput.position(), nioOutput.limit() - nioOutput.position(),
          nioInput.array(), nioInput.arrayOffset() + nioInput.position(), inputLen);
      } else if (nioOutput.isDirect() && !nioInput.isDirect()) {
        n = ctx.decompressByteArrayToDirectByteBuffer(nioOutput, nioOutput.position(),
          nioOutput.limit() - nioOutput.position(), nioInput.array(),
          nioInput.arrayOffset() + nioInput.position(), inputLen);
      } else if (!nioOutput.isDirect() && nioInput.isDirect()) {
        n = ctx.decompressDirectByteBufferToByteArray(nioOutput.array(),
          nioOutput.arrayOffset() + nioOutput.position(), nioOutput.limit() - nioOutput.position(),
          nioInput, nioInput.position(), inputLen);
      } else {
        throw new IllegalStateException("Unreachable line");
      }

      nioOutput.position(origOutputPos + n);
      nioInput.position(input.position() + inputLen);

      return n;
    } else {
      throw new IllegalStateException(
        "At least one buffer is not a SingleByteBuff, this is not supported");
    }
  }
Glue for ByteBuffDecompressor on top of zstd-jni
hbase-compression/hbase-compression-zstd/src/main/java/org/apache/hadoop/hbase/io/compress/zstd/ZstdByteBuffDecompressor.java