org.xerial.snappy.Snappy.rawUncompress()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(149)

本文整理了Java中org.xerial.snappy.Snappy.rawUncompress()方法的一些代码示例,展示了Snappy.rawUncompress()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Snappy.rawUncompress()方法的具体详情如下:
包路径:org.xerial.snappy.Snappy
类名称:Snappy
方法名:rawUncompress

Snappy.rawUncompress介绍

[英]Zero-copy decompress using memory addresses.
[中]使用内存地址进行零拷贝解压缩。

代码示例

代码示例来源:origin: redisson/redisson

/**
 * 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);
}

代码示例来源:origin: ethereum/ethereumj

@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));
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-server

public int uncompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) throws IOException
  {
    return Snappy.rawUncompress(input, inputOffset, inputLength, output, outputOffset);
  }
}

代码示例来源:origin: jsevellec/cassandra-unit

public int uncompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) throws IOException
{
  return Snappy.rawUncompress(input, inputOffset, inputLength, output, outputOffset);
}

代码示例来源:origin: org.apache.cassandra/cassandra-all

public int uncompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) throws IOException
{
  return Snappy.rawUncompress(input, inputOffset, inputLength, output, outputOffset);
}

代码示例来源:origin: com.strapdata.cassandra/cassandra-all

public int uncompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) throws IOException
{
  return Snappy.rawUncompress(input, inputOffset, inputLength, output, outputOffset);
}

代码示例来源:origin: com.netflix.sstableadaptor/sstable-adaptor-cassandra

public int uncompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) throws IOException
{
  return Snappy.rawUncompress(input, inputOffset, inputLength, output, outputOffset);
}

代码示例来源:origin: org.apache.carbondata/carbondata-core

@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);
 }
}

代码示例来源:origin: com.ebay.jetstream/jetstreamcore

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());
  }
}

代码示例来源:origin: com.ebay.jetstream/jetstreamcore

len = Snappy.rawUncompress(compressed, 0, compressed.length, uncompressed, 0);
} catch (Throwable t) {
  LOGGER.error( "failed to uncompress using Snappy - " + t.toString());

代码示例来源:origin: com.ebay.jetstream/jetstreamcore

len = Snappy.rawUncompress(frame.readBytes(framelen).array(), 0, framelen, uncompressedbuf, 0);

代码示例来源:origin: skadistats/clarity

int byteLengthUncompressed = Snappy.uncompressedLength(tempBuf, 0, byteLength);
  valueBuf = new byte[byteLengthUncompressed];
  Snappy.rawUncompress(tempBuf, 0, byteLength, valueBuf, 0);
} else {
  valueBuf = new byte[byteLength];

代码示例来源:origin: com.skadistats/clarity

int byteLengthUncompressed = Snappy.uncompressedLength(tempBuf, 0, byteLength);
  valueBuf = new byte[byteLengthUncompressed];
  Snappy.rawUncompress(tempBuf, 0, byteLength, valueBuf, 0);
} else {
  valueBuf = new byte[byteLength];

相关文章