/** * Uncompress the content in the input buffer. The uncompressed data is * written to the output buffer. * <p/> * Note that if you pass the wrong data or the range [inputOffset, * inputOffset + inputLength) that cannot be uncompressed, your JVM might * crash due to the access violation exception issued in the native code * written in C++. To avoid this type of crash, use * {@link #isValidCompressedBuffer(byte[], int, int)} first. * * @param input * @param inputOffset * @param inputLength * @param output * @param outputOffset * @return the byte size of the uncompressed data * @throws IOException */ public static int uncompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) throws IOException { return rawUncompress(input, inputOffset, inputLength, output, outputOffset); }
@Override protected void decode(ChannelHandlerContext ctx, FrameCodec.Frame msg, List<Object> out) throws Exception { byte[] in = new byte[msg.size]; msg.payload.read(in); long uncompressedLength = Snappy.uncompressedLength(in) & 0xFFFFFFFFL; if (uncompressedLength > MAX_SIZE) { logger.info("{}: uncompressed frame size exceeds the limit ({} bytes), drop the peer", channel, uncompressedLength); channel.disconnect(ReasonCode.BAD_PROTOCOL); return; } byte[] uncompressed = new byte[(int) uncompressedLength]; try { Snappy.rawUncompress(in, 0, in.length, uncompressed, 0); } catch (IOException e) { String detailMessage = e.getMessage(); // 5 - error code for framed snappy if (detailMessage.startsWith("FAILED_TO_UNCOMPRESS") && detailMessage.contains("5")) { logger.info("{}: Snappy frames are not allowed in DEVp2p protocol, drop the peer", channel); channel.disconnect(ReasonCode.BAD_PROTOCOL); return; } else { throw e; } } out.add(new FrameCodec.Frame((int) msg.type, uncompressed)); }
public int uncompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) throws IOException { return Snappy.rawUncompress(input, inputOffset, inputLength, output, outputOffset); } }
public int uncompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) throws IOException { return Snappy.rawUncompress(input, inputOffset, inputLength, output, outputOffset); }
public int uncompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) throws IOException { return Snappy.rawUncompress(input, inputOffset, inputLength, output, outputOffset); }
public int uncompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) throws IOException { return Snappy.rawUncompress(input, inputOffset, inputLength, output, outputOffset); }
public int uncompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) throws IOException { return Snappy.rawUncompress(input, inputOffset, inputLength, output, outputOffset); }
@Override public int rawUncompress(byte[] data, int offset, int length, byte[] output) { try { return Snappy.rawUncompress(data, offset, length, output, 0); } catch (IOException e) { throw new RuntimeException(e); } }
public static void initSnappy() { byte[] compressed = null; long startTime = System.currentTimeMillis(); try { String testMsg = "test"; compressed = Snappy.rawCompress(testMsg.getBytes(), testMsg.length()); } catch (UnsupportedEncodingException e) { LOGGER.error( "failed to compress using Snappy - " + e.toString()); } catch (IOException e) { LOGGER.error( "failed to compress using Snappy - " + e.toString()); } byte[] uncompressed = new byte[100]; int len = 0; try { len = Snappy.rawUncompress(compressed, 0, compressed.length, uncompressed, 0); } catch (Throwable t) { LOGGER.error( "failed to uncompress using Snappy - " + t.toString()); } }
len = Snappy.rawUncompress(compressed, 0, compressed.length, uncompressed, 0); } catch (Throwable t) { LOGGER.error( "failed to uncompress using Snappy - " + t.toString());
len = Snappy.rawUncompress(frame.readBytes(framelen).array(), 0, framelen, uncompressedbuf, 0);
int byteLengthUncompressed = Snappy.uncompressedLength(tempBuf, 0, byteLength); valueBuf = new byte[byteLengthUncompressed]; Snappy.rawUncompress(tempBuf, 0, byteLength, valueBuf, 0); } else { valueBuf = new byte[byteLength];
int byteLengthUncompressed = Snappy.uncompressedLength(tempBuf, 0, byteLength); valueBuf = new byte[byteLengthUncompressed]; Snappy.rawUncompress(tempBuf, 0, byteLength, valueBuf, 0); } else { valueBuf = new byte[byteLength];