public static int uncompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset, ICompressor compressor) throws IOException { int outputLength = readInt(input, inputOffset); inputOffset += 4; inputLength -= 4; if (output.length - outputOffset < outputLength) { String msg = String.format("buffer to uncompress into is not large enough; buf size = %d, buf offset = %d, target size = %s", output.length, outputOffset, outputLength); throw new IllegalStateException(msg); } return compressor.uncompress(input, inputOffset, inputLength, output, outputOffset); }
public static int uncompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset, ICompressor compressor) throws IOException { int outputLength = readInt(input, inputOffset); inputOffset += 4; inputLength -= 4; if (output.length - outputOffset < outputLength) { String msg = String.format("buffer to uncompress into is not large enough; buf size = %d, buf offset = %d, target size = %s", output.length, outputOffset, outputLength); throw new IllegalStateException(msg); } return compressor.uncompress(input, inputOffset, inputLength, output, outputOffset); }
/** * Uncompress the input data, as well as manage sizing of the {@code outputBuffer}; if the buffer is not big enough, * deallocate current, and allocate a large enough buffer. * * @return the byte buffer that was actaully written to; it may be the {@code outputBuffer} if it had enough capacity, * or it may be a new, larger instance. Callers should capture the return buffer (if calling multiple times). */ public static ByteBuffer uncompress(ByteBuffer inputBuffer, ByteBuffer outputBuffer, boolean allowBufferResize, ICompressor compressor) throws IOException { int outputLength = inputBuffer.getInt(); outputBuffer = ByteBufferUtil.ensureCapacity(outputBuffer, outputLength, allowBufferResize); compressor.uncompress(inputBuffer, outputBuffer); outputBuffer.position(0).limit(outputLength); return outputBuffer; }
public static int uncompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset, ICompressor compressor) throws IOException { int outputLength = readInt(input, inputOffset); inputOffset += 4; inputLength -= 4; if (output.length - outputOffset < outputLength) { String msg = String.format("buffer to uncompress into is not large enough; buf size = %d, buf offset = %d, target size = %s", output.length, outputOffset, outputLength); throw new IllegalStateException(msg); } return compressor.uncompress(input, inputOffset, inputLength, output, outputOffset); }
/** * Uncompress the input data, as well as manage sizing of the {@code outputBuffer}; if the buffer is not big enough, * deallocate current, and allocate a large enough buffer. * * @return the byte buffer that was actaully written to; it may be the {@code outputBuffer} if it had enough capacity, * or it may be a new, larger instance. Callers should capture the return buffer (if calling multiple times). */ public static ByteBuffer uncompress(ByteBuffer inputBuffer, ByteBuffer outputBuffer, boolean allowBufferResize, ICompressor compressor) throws IOException { int outputLength = inputBuffer.getInt(); outputBuffer = ByteBufferUtil.ensureCapacity(outputBuffer, outputLength, allowBufferResize); compressor.uncompress(inputBuffer, outputBuffer); outputBuffer.position(0).limit(outputLength); return outputBuffer; }
/** * Uncompress the input data, as well as manage sizing of the {@code outputBuffer}; if the buffer is not big enough, * deallocate current, and allocate a large enough buffer. * * @return the byte buffer that was actaully written to; it may be the {@code outputBuffer} if it had enough capacity, * or it may be a new, larger instance. Callers should capture the return buffer (if calling multiple times). */ public static ByteBuffer uncompress(ByteBuffer inputBuffer, ByteBuffer outputBuffer, boolean allowBufferResize, ICompressor compressor) throws IOException { int outputLength = inputBuffer.getInt(); outputBuffer = ByteBufferUtil.ensureCapacity(outputBuffer, outputLength, allowBufferResize); compressor.uncompress(inputBuffer, outputBuffer); outputBuffer.position(0).limit(outputLength); return outputBuffer; }
private void decompress(byte[] compressed) throws IOException { // uncompress validBufferBytes = info.parameters.getSstableCompressor().uncompress(compressed, 0, compressed.length - checksumBytes.length, buffer, 0); totalCompressedBytesRead += compressed.length; // validate crc randomly if (this.crcCheckChanceSupplier.get() >= 1d || this.crcCheckChanceSupplier.get() > ThreadLocalRandom.current().nextDouble()) { int checksum = (int) checksumType.of(compressed, 0, compressed.length - checksumBytes.length); System.arraycopy(compressed, compressed.length - checksumBytes.length, checksumBytes, 0, checksumBytes.length); if (Ints.fromByteArray(checksumBytes) != checksum) throw new IOException("CRC unmatched"); } // buffer offset is always aligned bufferOffset = current & ~(buffer.length - 1); }
private void decompress(byte[] compressed) throws IOException { // uncompress validBufferBytes = info.parameters.getSstableCompressor().uncompress(compressed, 0, compressed.length - checksumBytes.length, buffer, 0); totalCompressedBytesRead += compressed.length; // validate crc randomly if (this.crcCheckChanceSupplier.get() >= 1d || this.crcCheckChanceSupplier.get() > ThreadLocalRandom.current().nextDouble()) { int checksum = (int) checksumType.of(compressed, 0, compressed.length - checksumBytes.length); System.arraycopy(compressed, compressed.length - checksumBytes.length, checksumBytes, 0, checksumBytes.length); if (Ints.fromByteArray(checksumBytes) != checksum) throw new IOException("CRC unmatched"); } // buffer offset is always aligned bufferOffset = current & ~(buffer.length - 1); }
private void decompress(byte[] compressed) throws IOException { // uncompress validBufferBytes = info.parameters.getSstableCompressor().uncompress(compressed, 0, compressed.length - checksumBytes.length, buffer, 0); totalCompressedBytesRead += compressed.length; // validate crc randomly if (this.crcCheckChanceSupplier.get() >= 1d || this.crcCheckChanceSupplier.get() > ThreadLocalRandom.current().nextDouble()) { int checksum = (int) checksumType.of(compressed, 0, compressed.length - checksumBytes.length); System.arraycopy(compressed, compressed.length - checksumBytes.length, checksumBytes, 0, checksumBytes.length); if (Ints.fromByteArray(checksumBytes) != checksum) throw new IOException("CRC unmatched"); } // buffer offset is always aligned bufferOffset = current & ~(buffer.length - 1); }
private void decompress(byte[] compressed) throws IOException { // uncompress validBufferBytes = info.parameters.sstableCompressor.uncompress(compressed, 0, compressed.length - checksumBytes.length, buffer, 0); totalCompressedBytesRead += compressed.length; // validate crc randomly if (info.parameters.getCrcCheckChance() > ThreadLocalRandom.current().nextDouble()) { if (hasPostCompressionAdlerChecksums) { checksum.update(compressed, 0, compressed.length - checksumBytes.length); } else { checksum.update(buffer, 0, validBufferBytes); } System.arraycopy(compressed, compressed.length - checksumBytes.length, checksumBytes, 0, checksumBytes.length); if (Ints.fromByteArray(checksumBytes) != (int) checksum.getValue()) throw new IOException("CRC unmatched"); // reset checksum object back to the original (blank) state checksum.reset(); } // buffer offset is always aligned bufferOffset = current & ~(buffer.length - 1); }
try compressor.uncompress(compressedBuffer, buffer); buffer.flip();
try compressor.uncompress(compressedBuffer, buffer); buffer.flip();
try compressor.uncompress(compressedBuffer, buffer); buffer.flip();
metadata.compressor().uncompress(compressedChunk, uncompressed);
metadata.compressor().uncompress(compressed, uncompressed);
metadata.compressor().uncompress(compressedChunk, uncompressed);
metadata.compressor().uncompress(compressedChunk, uncompressed);
@SuppressWarnings("resource") public SyncSegment nextSegment(final int startPosition, final int nextSectionStartPosition) throws IOException { reader.seek(startPosition); int uncompressedLength = reader.readInt(); int compressedLength = nextSectionStartPosition - (int)reader.getPosition(); if (compressedLength > compressedBuffer.length) compressedBuffer = new byte[(int) (1.2 * compressedLength)]; reader.readFully(compressedBuffer, 0, compressedLength); if (uncompressedLength > uncompressedBuffer.length) uncompressedBuffer = new byte[(int) (1.2 * uncompressedLength)]; int count = compressor.uncompress(compressedBuffer, 0, compressedLength, uncompressedBuffer, 0); nextLogicalStart += SYNC_MARKER_SIZE; FileDataInput input = new FileSegmentInputStream(ByteBuffer.wrap(uncompressedBuffer, 0, count), reader.getPath(), nextLogicalStart); nextLogicalStart += uncompressedLength; return new SyncSegment(input, startPosition, nextSectionStartPosition, (int)nextLogicalStart, tolerateSegmentErrors(nextSectionStartPosition, reader.length())); } }
@SuppressWarnings("resource") public SyncSegment nextSegment(final int startPosition, final int nextSectionStartPosition) throws IOException { reader.seek(startPosition); int uncompressedLength = reader.readInt(); int compressedLength = nextSectionStartPosition - (int)reader.getPosition(); if (compressedLength > compressedBuffer.length) compressedBuffer = new byte[(int) (1.2 * compressedLength)]; reader.readFully(compressedBuffer, 0, compressedLength); if (uncompressedLength > uncompressedBuffer.length) uncompressedBuffer = new byte[(int) (1.2 * uncompressedLength)]; int count = compressor.uncompress(compressedBuffer, 0, compressedLength, uncompressedBuffer, 0); nextLogicalStart += SYNC_MARKER_SIZE; FileDataInput input = new FileSegmentInputStream(ByteBuffer.wrap(uncompressedBuffer, 0, count), reader.getPath(), nextLogicalStart); nextLogicalStart += uncompressedLength; return new SyncSegment(input, startPosition, nextSectionStartPosition, (int)nextLogicalStart, tolerateSegmentErrors(nextSectionStartPosition, reader.length())); } }
@SuppressWarnings("resource") public SyncSegment nextSegment(final int startPosition, final int nextSectionStartPosition) throws IOException { reader.seek(startPosition); int uncompressedLength = reader.readInt(); int compressedLength = nextSectionStartPosition - (int)reader.getPosition(); if (compressedLength > compressedBuffer.length) compressedBuffer = new byte[(int) (1.2 * compressedLength)]; reader.readFully(compressedBuffer, 0, compressedLength); if (uncompressedLength > uncompressedBuffer.length) uncompressedBuffer = new byte[(int) (1.2 * uncompressedLength)]; int count = compressor.uncompress(compressedBuffer, 0, compressedLength, uncompressedBuffer, 0); nextLogicalStart += SYNC_MARKER_SIZE; FileDataInput input = new FileSegmentInputStream(ByteBuffer.wrap(uncompressedBuffer, 0, count), reader.getPath(), nextLogicalStart); nextLogicalStart += uncompressedLength; return new SyncSegment(input, startPosition, nextSectionStartPosition, (int)nextLogicalStart, tolerateSegmentErrors(nextSectionStartPosition, reader.length())); } }