while ((n = decompressor.decompress(b, off, len)) == 0) { if (decompressor.finished() || decompressor.needsDictionary()) { if (noUncompressedBytes >= originalBlockSize) {
protected int decompress(byte[] b, int off, int len) throws IOException { int n; while ((n = decompressor.decompress(b, off, len)) == 0) { if (decompressor.needsDictionary()) { eof = true;
@Override public void decompress(ByteBuffer input, int compressedSize, ByteBuffer output, int uncompressedSize) throws IOException { decompressor.reset(); byte[] inputBytes = new byte[compressedSize]; input.position(0); input.get(inputBytes); decompressor.setInput(inputBytes, 0, inputBytes.length); byte[] outputBytes = new byte[uncompressedSize]; decompressor.decompress(outputBytes, 0, uncompressedSize); output.clear(); output.put(outputBytes); }
@Override public void decompress(ByteBuffer input, int compressedSize, ByteBuffer output, int uncompressedSize) throws IOException { decompressor.reset(); byte[] inputBytes = new byte[compressedSize]; input.position(0); input.get(inputBytes); decompressor.setInput(inputBytes, 0, inputBytes.length); byte[] outputBytes = new byte[uncompressedSize]; decompressor.decompress(outputBytes, 0, uncompressedSize); output.clear(); output.put(outputBytes); }
private boolean checkCompressArrayIndexOutOfBoundsException( Decompressor decompressor, byte[] rawData) { try { decompressor.setInput(rawData, 0, rawData.length); decompressor.decompress(new byte[rawData.length], 0, -1); } catch (ArrayIndexOutOfBoundsException e) { return true; } catch (Exception e) { logger.error(joiner.join(decompressor.getClass().getCanonicalName(), "checkCompressArrayIndexOutOfBoundsException error !!!")); } return false; }
private boolean checkCompressNullPointerException( Decompressor decompressor, byte[] rawData) { try { decompressor.setInput(rawData, 0, rawData.length); decompressor.decompress(null, 0, 1); } catch (NullPointerException npe) { return true; } catch (Exception ex) { logger.error(joiner.join(decompressor.getClass().getCanonicalName(), "checkCompressNullPointerException error !!!")); } return false; }
private boolean checkCompressArrayIndexOutOfBoundsException( Decompressor decompressor, byte[] rawData) { try { decompressor.setInput(rawData, 0, rawData.length); decompressor.decompress(new byte[rawData.length], 0, -1); } catch (ArrayIndexOutOfBoundsException e) { return true; } catch (Exception e) { logger.error(joiner.join(decompressor.getClass().getCanonicalName(), "checkCompressArrayIndexOutOfBoundsException error !!!")); } return false; }
private boolean checkCompressNullPointerException( Decompressor decompressor, byte[] rawData) { try { decompressor.setInput(rawData, 0, rawData.length); decompressor.decompress(null, 0, 1); } catch (NullPointerException npe) { return true; } catch (Exception ex) { logger.error(joiner.join(decompressor.getClass().getCanonicalName(), "checkCompressNullPointerException error !!!")); } return false; }
@Override public BytesInput decompress(BytesInput bytes, int uncompressedSize) throws IOException { decompressor.reset(); byte[] inputBytes = bytes.toByteArray(); decompressor.setInput(inputBytes, 0, inputBytes.length); byte[] output = new byte[uncompressedSize]; decompressor.decompress(output, 0, uncompressedSize); return BytesInput.from(output); }
@Override public BytesInput decompress(BytesInput bytes, int uncompressedSize) throws IOException { decompressor.reset(); byte[] inputBytes = bytes.toByteArray(); decompressor.setInput(inputBytes, 0, inputBytes.length); byte[] output = new byte[uncompressedSize]; decompressor.decompress(output, 0, uncompressedSize); return BytesInput.from(output); }
private void fetchBlock(int blockId) throws IOException { long position = _blockPositions[blockId]; int length = _blockLengths[blockId]; _indexInput.seek(position); _indexInput.readBytes(_decompressionBuffer, 0, length); synchronized (_decompressor) { _decompressor.reset(); _decompressor.setInput(_decompressionBuffer, 0, length); _blockBufferLength = _decompressor.decompress(_blockBuffer, 0, _blockBuffer.length); } _currentBlockId = blockId; }
protected int decompress(byte[] b, int off, int len) throws IOException { int n = 0; while ((n = decompressor.decompress(b, off, len)) == 0) { if (decompressor.finished() || decompressor.needsDictionary()) { eof = true; return -1; } if (decompressor.needsInput()) { getCompressedData(); } } return n; }
int decompress(byte[] b, int off, int len) throws IOException { int n = 0; while ((n = decompressor.decompress(b, off, len)) == 0) { if (decompressor.finished() || decompressor.needsDictionary()) { eof = true; return -1; } if (decompressor.needsInput()) { getCompressedData(); } } return n; }
@Override public int read(byte[] b, int off, int len) throws IOException { if (!inputHandled) { // Send all the compressed input to the decompressor. while (true) { int compressedBytes = getCompressedData(); if (compressedBytes == -1) break; decompressor.setInput(buffer, 0, compressedBytes); } inputHandled = true; } int decompressedBytes = decompressor.decompress(b, off, len); if (decompressor.finished()) { decompressor.reset(); } return decompressedBytes; } }
@Override public int read(byte[] b, int off, int len) throws IOException { if (!inputHandled) { // Send all the compressed input to the decompressor. while (true) { int compressedBytes = getCompressedData(); if (compressedBytes == -1) break; decompressor.setInput(buffer, 0, compressedBytes); } inputHandled = true; } int decompressedBytes = decompressor.decompress(b, off, len); if (decompressor.finished()) { decompressor.reset(); } return decompressedBytes; } }
@Override public int read(byte[] b, int off, int len) throws IOException { if (!inputHandled) { // Send all the compressed input to the decompressor. while (true) { int compressedBytes = getCompressedData(); if (compressedBytes == -1) break; decompressor.setInput(buffer, 0, compressedBytes); } inputHandled = true; } int decompressedBytes = decompressor.decompress(b, off, len); if (decompressor.finished()) { decompressor.reset(); } return decompressedBytes; } }
private void fetchBlock(int blockId) throws IOException { long position = getBlockPosition(blockId); int length = getBlockLength(blockId); _indexInput.seek(position); _indexInput.readBytes(_decompressionBuffer, 0, length); synchronized (_decompressor) { _decompressor.reset(); _decompressor.setInput(_decompressionBuffer, 0, length); _blockBufferLength = _decompressor.decompress(_blockBuffer, 0, _blockBuffer.length); } _currentBlockId = blockId; }
@Override public int decompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset, int maxOutputLength) throws MalformedInputException { checkArgument(maxOutputLength < MAX_OUTPUT_BUFFER_SIZE, "output size " + maxOutputLength + " exceed maximum size : " + maxOutputLength); // nothing decompress to nothing if (inputLength == 0) { return 0; } decompressor.reset(); decompressor.setInput(input, inputOffset, inputLength); int offset = outputOffset; int outputLimit = outputOffset + maxOutputLength; while (!decompressor.finished() && offset < outputLimit) { try { offset += decompressor.decompress(output, offset, outputLimit - offset); } catch (IOException e) { throw new RuntimeException(e); } } return offset - outputOffset; }
int decompress(byte[] b, int off, int len) throws IOException { // Check if we are the beginning of a block if (noUncompressedBytes == originalBlockSize) { // Get original data size try { originalBlockSize = rawReadInt(); } catch (IOException ioe) { return -1; } noUncompressedBytes = 0; } int n = 0; while ((n = decompressor.decompress(b, off, len)) == 0) { if (decompressor.finished() || decompressor.needsDictionary()) { if (noUncompressedBytes >= originalBlockSize) { eof = true; return -1; } } if (decompressor.needsInput()) { getCompressedData(); } } // Note the no. of decompressed bytes read from 'current' block noUncompressedBytes += n; return n; }
while ((n = decompressor.decompress(b, off, len)) == 0) { if (decompressor.finished() || decompressor.needsDictionary()) { if (noUncompressedBytes >= originalBlockSize) {