void decompressUsing(Codec c) throws IOException { ByteBuffer result = c.decompress(getAsByteBuffer()); data = result.array(); blockSize = result.remaining(); }
void decompressUsing(Codec c) throws IOException { ByteBuffer result = c.decompress(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 decompressUsing(Codec c) throws IOException { ByteBuffer result = c.decompress(getAsByteBuffer()); data = result.array(); blockSize = result.remaining(); }
void decompressUsing(Codec c) throws IOException { ByteBuffer result = c.decompress(getAsByteBuffer()); data = result.array(); blockSize = result.remaining(); }
void decompressUsing(Codec c) throws IOException { ByteBuffer result = c.decompress(getAsByteBuffer()); data = result.array(); blockSize = result.remaining(); }
/** True if more entries remain in this file. */ public boolean hasNext() { try { if (blockRemaining == 0) { // check that the previous block was finished if (null != datumIn) { boolean atEnd = datumIn.isEnd(); if (!atEnd) { throw new IOException("Block read partially, the data may be corrupt"); } } if (hasNextBlock()) { block = nextBlock(block); ByteBuffer blockBuffer = ByteBuffer.wrap(block.data, 0, block.blockSize); blockBuffer = codec.decompress(blockBuffer); datumIn = DecoderFactory.defaultFactory().createBinaryDecoder( blockBuffer.array(), blockBuffer.arrayOffset() + blockBuffer.position(), blockBuffer.remaining(), datumIn); } } return blockRemaining != 0; } catch (EOFException e) { // at EOF return false; } catch (IOException e) { throw new AvroRuntimeException(e); } }
while(otherFile.hasNextBlock()) { nextBlockRaw = otherFile.nextBlock(nextBlockRaw); ByteBuffer uncompressedData = otherCodec.decompress(ByteBuffer.wrap( nextBlockRaw.data, 0, nextBlockRaw.blockSize)); ByteBuffer compressed = codec.compress(uncompressedData);