private static Slice decompressGzip(Slice input, int uncompressedSize) throws IOException { if (uncompressedSize == 0) { return EMPTY_SLICE; } DynamicSliceOutput sliceOutput = new DynamicSliceOutput(uncompressedSize); byte[] buffer = new byte[uncompressedSize]; try (InputStream gzipInputStream = new GZIPInputStream(input.getInput(), GZIP_BUFFER_SIZE)) { int bytesRead; while ((bytesRead = gzipInputStream.read(buffer)) != -1) { sliceOutput.write(buffer, 0, bytesRead); } return sliceOutput.getUnderlyingSlice(); } }
@Override public DynamicSliceOutput appendBytes(byte[] source, int sourceIndex, int length) { write(source, sourceIndex, length); return this; }
@Override public DynamicSliceOutput appendBytes(byte[] source, int sourceIndex, int length) { write(source, sourceIndex, length); return this; }
private static Slice decompressGzip(Slice input, int uncompressedSize) throws IOException { if (uncompressedSize == 0) { return EMPTY_SLICE; } DynamicSliceOutput sliceOutput = new DynamicSliceOutput(uncompressedSize); byte[] buffer = new byte[uncompressedSize]; try (InputStream gzipInputStream = new GZIPInputStream(input.getInput(), GZIP_BUFFER_SIZE)) { int bytesRead; while ((bytesRead = gzipInputStream.read(buffer)) != -1) { sliceOutput.write(buffer, 0, bytesRead); } return sliceOutput.getUnderlyingSlice(); } }
private static Slice decompressGzip(Slice input, int uncompressedSize) throws IOException { if (uncompressedSize == 0) { return EMPTY_SLICE; } DynamicSliceOutput sliceOutput = new DynamicSliceOutput(uncompressedSize); byte[] buffer = new byte[uncompressedSize]; try (InputStream gzipInputStream = new GZIPInputStream(input.getInput(), GZIP_BUFFER_SIZE)) { int bytesRead; while ((bytesRead = gzipInputStream.read(buffer)) != -1) { sliceOutput.write(buffer, 0, bytesRead); } return sliceOutput.getUnderlyingSlice(); } }