@Override public Tuple<CompressionBlock, Integer> performReadAhead(int bufferBudget) throws IOException { byte[] compressedBuffer = mFreeCompressedBlockBuffers.poll(); if (compressedBuffer == null) { compressedBuffer = new byte[BlockCompressedStreamConstants.MAX_COMPRESSED_BLOCK_SIZE]; } CompressionBlock block = readNextBlock(compressedBuffer); if (block != null) { // since the buffer we allocate is BlockCompressedStreamConstants.MAX_COMPRESSED_BLOCK_SIZE // we use this as the consumed size as opposed to the actual size block.getBlockCompressedSize() return new Tuple<>(block, BlockCompressedStreamConstants.MAX_COMPRESSED_BLOCK_SIZE); } return null; }