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

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

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

Snappy.rawCompress介绍

[英]Zero-copy compress using memory addresses.
[中]

代码示例

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

/**
 * Compress the input char array
 *
 * @param input
 * @return the compressed data
 */
public static byte[] compress(char[] input)
    throws IOException
{
  return rawCompress(input, input.length * 2); // char uses 2 bytes
}

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

/**
 * Compress the input float array
 *
 * @param input
 * @return the compressed data
 */
public static byte[] compress(float[] input)
    throws IOException
{
  return rawCompress(input, input.length * 4); // float uses 4 bytes
}

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

/**
 * Compress the input double array
 *
 * @param input
 * @return the compressed data
 */
public static byte[] compress(double[] input)
    throws IOException
{
  return rawCompress(input, input.length * 8); // double uses 8 bytes
}

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

/**
 * Compress the input int array
 *
 * @param input
 * @return the compressed data
 */
public static byte[] compress(int[] input)
    throws IOException
{
  return rawCompress(input, input.length * 4); // int uses 4 bytes
}

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

/**
 * Compress the input short array
 *
 * @param input
 * @return the compressed data
 */
public static byte[] compress(short[] input)
    throws IOException
{
  return rawCompress(input, input.length * 2); // short uses 2 bytes
}

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

/**
 * Compress the input long array
 *
 * @param input
 * @return the compressed data
 */
public static byte[] compress(long[] input)
    throws IOException
{
  return rawCompress(input, input.length * 8); // long uses 8 bytes
}

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

/**
 * High-level API for compressing the input byte array. This method performs
 * array copy to generate the result. If you want to reduce the memory copy
 * cost, use {@link #compress(byte[], int, int, byte[], int)} or
 * {@link #compress(ByteBuffer, ByteBuffer)}.
 *
 * @param input the input data
 * @return the compressed byte array
 * @throws IOException
 */
public static byte[] compress(byte[] input)
    throws IOException
{
  return rawCompress(input, input.length);
}

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

/**
 * Compress the input buffer content in [inputOffset,
 * ...inputOffset+inputLength) then output to the specified output buffer.
 *
 * @param input
 * @param inputOffset
 * @param inputLength
 * @param output
 * @param outputOffset
 * @return byte size of the compressed data
 * @throws IOException when failed to access the input/output buffer
 */
public static int compress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset)
    throws IOException
{
  return rawCompress(input, inputOffset, inputLength, output, outputOffset);
}

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

@Override
protected void encode(ChannelHandlerContext ctx, FrameCodec.Frame msg, List<Object> out) throws Exception {
  // stay consistent with decoding party
  if (msg.size > MAX_SIZE) {
    logger.info("{}: outgoing frame size exceeds the limit ({} bytes), disconnect", channel, msg.size);
    channel.disconnect(ReasonCode.USELESS_PEER);
    return;
  }
  byte[] in = new byte[msg.size];
  msg.payload.read(in);
  byte[] compressed = Snappy.rawCompress(in, in.length);
  out.add(new FrameCodec.Frame((int) msg.type, compressed));
}

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

public int compress(byte[] input, int inputOffset, int inputLength, ICompressor.WrappedArray output, int outputOffset) throws IOException
{
  return Snappy.rawCompress(input, inputOffset, inputLength, output.buffer, outputOffset);
}

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

@Override public byte[] compressByte(byte[] unCompInput) {
 try {
  return Snappy.rawCompress(unCompInput, unCompInput.length);
 } catch (IOException e) {
  LOGGER.error(e.getMessage(), e);
  throw new RuntimeException(e);
 }
}

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

@Override public byte[] compressByte(byte[] unCompInput, int byteSize) {
 try {
  return Snappy.rawCompress(unCompInput, byteSize);
 } catch (IOException e) {
  LOGGER.error(e.getMessage(), 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

compressed = Snappy.rawCompress(testMsg.getBytes(), testMsg.length());

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

epromise.setRawBytes(msglen);
byte[] compressed = Snappy.rawCompress(chbuf.readBytes(msglen).array(), msglen);

相关文章