private static Slice decompressSnappy(Slice input, int uncompressedSize) { byte[] buffer = new byte[uncompressedSize]; decompress(new SnappyDecompressor(), input, 0, input.length(), buffer, 0); return wrappedBuffer(buffer); }
@Override public int decompress(byte[] input, int offset, int length, OutputBuffer output) throws OrcCorruptionException { try { int uncompressedLength = SnappyDecompressor.getUncompressedLength(input, offset); if (uncompressedLength > maxBufferSize) { throw new OrcCorruptionException(orcDataSourceId, "Snappy requires buffer (%s) larger than max size (%s)", uncompressedLength, maxBufferSize); } // Snappy decompressor is more efficient if there's at least a long's worth of extra space // in the output buffer byte[] buffer = output.initialize(uncompressedLength + SIZE_OF_LONG); return decompressor.decompress(input, offset, length, buffer, 0, buffer.length); } catch (MalformedInputException e) { throw new OrcCorruptionException(e, orcDataSourceId, "Invalid compressed stream"); } }
@Override public int decompress(byte[] input, int offset, int length, OutputBuffer output) throws OrcCorruptionException { try { int uncompressedLength = SnappyDecompressor.getUncompressedLength(input, offset); if (uncompressedLength > maxBufferSize) { throw new OrcCorruptionException(orcDataSourceId, "Snappy requires buffer (%s) larger than max size (%s)", uncompressedLength, maxBufferSize); } // Snappy decompressor is more efficient if there's at least a long's worth of extra space // in the output buffer byte[] buffer = output.initialize(uncompressedLength + SIZE_OF_LONG); return decompressor.decompress(input, offset, length, buffer, 0, buffer.length); } catch (MalformedInputException e) { throw new OrcCorruptionException(e, orcDataSourceId, "Invalid compressed stream"); } }
@Override protected Decompressor getDecompressor() { return new SnappyDecompressor(); }
@Override public int decompress(byte[] input, int offset, int length, OutputBuffer output) throws OrcCorruptionException { try { int uncompressedLength = SnappyDecompressor.getUncompressedLength(input, offset); if (uncompressedLength > maxBufferSize) { throw new OrcCorruptionException(orcDataSourceId, "Snappy requires buffer (%s) larger than max size (%s)", uncompressedLength, maxBufferSize); } // Snappy decompressor is more efficient if there's at least a long's worth of extra space // in the output buffer byte[] buffer = output.initialize(uncompressedLength + SIZE_OF_LONG); return decompressor.decompress(input, offset, length, buffer, 0, buffer.length); } catch (MalformedInputException e) { throw new OrcCorruptionException(e, orcDataSourceId, "Invalid compressed stream"); } }
SnappyCodec() { super(new SnappyCompressor(), new SnappyDecompressor()); }
@Override public int decompress(byte[] input, int offset, int length, OutputBuffer output) throws OrcCorruptionException { try { int uncompressedLength = SnappyDecompressor.getUncompressedLength(input, offset); if (uncompressedLength > maxBufferSize) { throw new OrcCorruptionException(orcDataSourceId, "Snappy requires buffer (%s) larger than max size (%s)", uncompressedLength, maxBufferSize); } // Snappy decompressor is more efficient if there's at least a long's worth of extra space // in the output buffer byte[] buffer = output.initialize(uncompressedLength + SIZE_OF_LONG); return decompressor.decompress(input, offset, length, buffer, 0, buffer.length); } catch (MalformedInputException e) { throw new OrcCorruptionException(e, orcDataSourceId, "Invalid compressed stream"); } }
private static Slice decompressSnappy(Slice input, int uncompressedSize) { byte[] buffer = new byte[uncompressedSize]; decompress(new SnappyDecompressor(), input, 0, input.length(), buffer, 0); return wrappedBuffer(buffer); }
uncompressedChunkLength = SnappyDecompressor.getUncompressedLength(compressed, 0); if (uncompressedChunkLength > uncompressedBlockLength) { throw new IOException("Chunk uncompressed size is greater than block size"); int bytes = decompressor.decompress(compressed, 0, compressedChunkLength, userBuffer, userOffset, userLength); if (uncompressedChunkLength != bytes) { throw new IOException("Expected to read " + uncompressedChunkLength + " bytes, but data only contained " + bytes + " bytes");
private static Slice decompressSnappy(Slice input, int uncompressedSize) { byte[] buffer = new byte[uncompressedSize]; decompress(new SnappyDecompressor(), input, 0, input.length(), buffer, 0); return wrappedBuffer(buffer); }
uncompressedChunkLength = SnappyDecompressor.getUncompressedLength(compressed, 0); if (uncompressedChunkLength > uncompressedBlockLength) { throw new IOException("Chunk uncompressed size is greater than block size"); int bytes = decompressor.decompress(compressed, 0, compressedChunkLength, userBuffer, userOffset, userLength); if (uncompressedChunkLength != bytes) { throw new IOException("Expected to read " + uncompressedChunkLength + " bytes, but data only contained " + bytes + " bytes");
int uncompressedLength = SnappyDecompressor.getUncompressedLength(input, frameData.offset); this.valid = decompressor.decompress(input, frameData.offset, actualRead - frameData.offset, uncompressed, 0, uncompressed.length); this.buffer = uncompressed; this.position = 0;
int uncompressedLength = SnappyDecompressor.getUncompressedLength(input, frameData.offset); this.valid = decompressor.decompress(input, frameData.offset, actualRead - frameData.offset, uncompressed, 0, uncompressed.length); this.buffer = uncompressed; this.position = 0;