void compressUsing(Codec c) throws IOException { ByteBuffer result = c.compress(getAsByteBuffer()); data = result.array(); blockSize = result.remaining(); }
void compressUsing(Codec c) throws IOException { ByteBuffer result = c.compress(getAsByteBuffer()); data = result.array(); blockSize = result.remaining(); }
/** * Codecs must implement an equals() method. Two codecs, A and B are equal * if: the result of A and B decompressing content compressed by A is the same * AND the result of A and B decompressing content compressed by B is the same */ private boolean compareDecompress(Codec other, ByteBuffer original) throws IOException { ByteBuffer compressedA = this.compress(original); original.rewind(); ByteBuffer compressedB = other.compress(original); if (this.decompress(compressedA).equals(other.decompress((ByteBuffer) compressedA.rewind())) && this.decompress(compressedB).equals(other.decompress((ByteBuffer) compressedB.rewind())) ) { return true; } return false; }
void compressUsing(Codec c) throws IOException { ByteBuffer result = c.compress(getAsByteBuffer()); data = result.array(); blockSize = result.remaining(); }
void compressUsing(Codec c) throws IOException { ByteBuffer result = c.compress(getAsByteBuffer()); data = result.array(); blockSize = result.remaining(); }
void compressUsing(Codec c) throws IOException { ByteBuffer result = c.compress(getAsByteBuffer()); data = result.array(); blockSize = result.remaining(); }
private void writeBlock() throws IOException { if (blockCount > 0) { vout.writeLong(blockCount); ByteBuffer uncompressed = buffer.getByteArrayAsByteBuffer(); ByteBuffer block = codec.compress(uncompressed); vout.writeLong(block.remaining()); vout.writeFixed(block.array(), block.position() + block.arrayOffset(), block.remaining()); buffer.reset(); blockCount = 0; vout.writeFixed(sync); } }
ByteBuffer uncompressedData = otherCodec.decompress(ByteBuffer.wrap( nextBlockRaw.data, 0, nextBlockRaw.blockSize)); ByteBuffer compressed = codec.compress(uncompressedData); nextBlockRaw.data = compressed.array(); nextBlockRaw.blockSize = compressed.remaining();