当前位置: 首页>>代码示例>>Java>>正文


Java Snappy.uncompress方法代码示例

本文整理汇总了Java中org.iq80.snappy.Snappy.uncompress方法的典型用法代码示例。如果您正苦于以下问题:Java Snappy.uncompress方法的具体用法?Java Snappy.uncompress怎么用?Java Snappy.uncompress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.iq80.snappy.Snappy的用法示例。


在下文中一共展示了Snappy.uncompress方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readCompressedWithoutOriginalBufferLength

import org.iq80.snappy.Snappy; //导入方法依赖的package包/类
@NotNull
public static byte[] readCompressedWithoutOriginalBufferLength(@NotNull DataInput in) throws IOException {
  int size = DataInputOutputUtil.readINT(in);

  byte[] bytes = spareBufferLocal.getBuffer(size);
  in.readFully(bytes, 0, size);

  int decompressedRequests = myDecompressionRequests.incrementAndGet();
  long started = DUMP_COMPRESSION_STATS ? System.nanoTime() : 0;

  byte[] decompressedResult = Snappy.uncompress(bytes, 0, size);

  long doneTime = (DUMP_COMPRESSION_STATS ? System.nanoTime() : 0) - started;
  long decompressedSize = myDecompressedSize.addAndGet(size);
  long decompressedTime = myDecompressionTime.addAndGet(doneTime);
  if (DUMP_COMPRESSION_STATS && decompressedRequests % 1000 == 0) {
    System.out.println("Decompressed " + decompressedRequests + " times, size: " + decompressedSize  + " for " + (decompressedTime / 1000000) + "ms");
  }

  return decompressedResult;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:CompressionUtil.java

示例2: decompressBytes

import org.iq80.snappy.Snappy; //导入方法依赖的package包/类
public static byte[] decompressBytes(byte[] bytesArray) throws ClientException  { 
	
	byte[] checkSumBuf = new byte[8];
	checkSumBuf[0] = bytesArray[bytesArray.length-8];
	checkSumBuf[1] = bytesArray[bytesArray.length-7];
	checkSumBuf[2] = bytesArray[bytesArray.length-6];
	checkSumBuf[3] = bytesArray[bytesArray.length-5];
	checkSumBuf[4] = bytesArray[bytesArray.length-4];
	checkSumBuf[5] = bytesArray[bytesArray.length-3];
	checkSumBuf[6] = bytesArray[bytesArray.length-2];
	checkSumBuf[7] = bytesArray[bytesArray.length-1];
	
	
	ByteBuffer buffer = ByteBuffer.allocate(Long.SIZE / Byte.SIZE);
    buffer.put(checkSumBuf);
    buffer.flip();//need flip 
    long checkSum = buffer.getLong();
    
    Adler32 adler32 = new Adler32();
	adler32.update(bytesArray, 0, bytesArray.length-8);
	if(checkSum !=adler32.getValue())
		throw new ClientException("Data corruption detected - checksum failure. Please, try again.");
    
	return Snappy.uncompress(bytesArray, 0, bytesArray.length -8 );
}
 
开发者ID:PortfolioEffect,项目名称:PE-HFT-Java,代码行数:26,代码来源:ArrayUtil.java

示例3: shouldCompressSmallContent

import org.iq80.snappy.Snappy; //导入方法依赖的package包/类
@Test
public void shouldCompressSmallContent() {
    String text = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo " +
        "ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient " +
        "montes, nascetur ridiculus mus.";

    channel.pipeline().addFirst(new SnappyFeatureHandler());

    ByteBuf content = Unpooled.copiedBuffer(text, CharsetUtil.UTF_8);

    UpsertRequest request = new UpsertRequest("key", content.copy(), "bucket");
    request.partition((short) 512);
    channel.writeOutbound(request);
    FullBinaryMemcacheRequest outbound = (FullBinaryMemcacheRequest) channel.readOutbound();
    assertNotNull(outbound);

    assertEquals(KeyValueHandler.DATATYPE_SNAPPY, outbound.getDataType());

    byte[] compressed = new byte[outbound.content().readableBytes()];
    outbound.content().getBytes(0, compressed);
    byte[] uncompressed = Snappy.uncompress(compressed, 0, compressed.length);
    assertArrayEquals(text.getBytes(CharsetUtil.UTF_8), uncompressed);
}
 
开发者ID:couchbase,项目名称:couchbase-jvm-core,代码行数:24,代码来源:KeyValueHandlerTest.java

示例4: decompress

import org.iq80.snappy.Snappy; //导入方法依赖的package包/类
public void decompress(byte[] value, int offset, int len) {
	if (value[offset] == 0) {
		grow(Snappy.getUncompressedLength(value, offset + 1));
		end = Snappy.uncompress(value, offset + 1, len - 1, buffer, 0);
	} else {
		int s = Utils.decodeInt(value, offset + 1);
		// Calculate uncompress size
		offset += 5;
		len -= 5;
		int un_s = Snappy.getUncompressedLength(value, offset);
		un_s += Snappy.getUncompressedLength(value, offset + s);
		grow(un_s);

		end = Snappy.uncompress(value, offset, s, buffer, 0);
		end += Snappy.uncompress(value, offset + s, len - s, buffer, end);
	}
}
 
开发者ID:jrbn,项目名称:ajira,代码行数:18,代码来源:ByteArray.java

示例5: readCompressedWithoutOriginalBufferLength

import org.iq80.snappy.Snappy; //导入方法依赖的package包/类
@Nonnull
public static byte[] readCompressedWithoutOriginalBufferLength(@Nonnull DataInput in) throws IOException {
  int size = DataInputOutputUtil.readINT(in);

  byte[] bytes = spareBufferLocal.getBuffer(size);
  in.readFully(bytes, 0, size);

  int decompressedRequests = myDecompressionRequests.incrementAndGet();
  long started = System.nanoTime();

  byte[] decompressedResult = Snappy.uncompress(bytes, 0, size);

  long doneTime = System.nanoTime() - started;
  long decompressedSize = myDecompressedSize.addAndGet(size);
  long decompressedTime = myDecompressionTime.addAndGet(doneTime);
  if (DUMP_COMPRESSION_STATS && decompressedRequests % 1000 == 0) {
    System.out.println("Decompressed " + decompressedRequests + " times, size: " + decompressedSize  + " for " + (decompressedTime / 1000000) + "ms");
  }

  return decompressedResult;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:22,代码来源:CompressionUtil.java

示例6: decompress

import org.iq80.snappy.Snappy; //导入方法依赖的package包/类
@Override
public byte[] decompress(byte[] input) {
  try {
    return Snappy.uncompress(input, 0, input.length);
  } catch (CorruptionException e) {
    throw new CompressionException(e);
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:9,代码来源:SnappyCompressor.java

示例7: getMaybeUncompressedBytes

import org.iq80.snappy.Snappy; //导入方法依赖的package包/类
private byte[] getMaybeUncompressedBytes(@Nullable byte[] bytes) throws SingularityTranscoderException {

    if (bytes == null || bytes.length == 0) {
      return bytes;
    }

    try {
      return compressLargeDataObjects ? Snappy.uncompress(bytes, 0, bytes.length) : bytes;
    } catch (CorruptionException ce) {
      throw new SingularityTranscoderException(ce);
    }
  }
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:13,代码来源:CompressingTranscoder.java

示例8: uncompressCharSequence

import org.iq80.snappy.Snappy; //导入方法依赖的package包/类
@NotNull
public static CharSequence uncompressCharSequence(@NotNull Object string, @NotNull Charset charset) {
  if (string instanceof CharSequence) return (CharSequence)string;
  byte[] b = (byte[])string;
  try {
    int uncompressedLength = Snappy.getUncompressedLength(b, 0);
    byte[] bytes = spareBufferLocal.getBuffer(uncompressedLength);
    int bytesLength = Snappy.uncompress(b, 0, b.length, bytes, 0);
    return new String(bytes, 0, bytesLength, charset);
  }
  catch (CorruptionException ex) {
    throw new RuntimeException(ex);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:CompressionUtil.java

示例9: uncompressStringRawBytes

import org.iq80.snappy.Snappy; //导入方法依赖的package包/类
@NotNull
public static CharSequence uncompressStringRawBytes(@NotNull Object compressed) {
  if (compressed instanceof CharSequence) return (CharSequence)compressed;
  byte[] b = (byte[])compressed;
  try {
    int uncompressedLength = Snappy.getUncompressedLength(b, 0);
    byte[] bytes = spareBufferLocal.getBuffer(uncompressedLength);
    int bytesLength = Snappy.uncompress(b, 0, b.length, bytes, 0);
    ByteArrayInputStream byteStream = new ByteArrayInputStream(bytes, 0, bytesLength);
    @NotNull DataInput in = new DataInputStream(byteStream);

    int len = DataInputOutputUtil.readINT(in);
    char[] chars = new char[len];

    for (int i=0; i<len; i++) {
      int c = DataInputOutputUtil.readINT(in);
      chars[i] = (char)c;
    }
    return StringFactory.createShared(chars);
  }
  catch (CorruptionException ex) {
    throw new RuntimeException(ex);
  }
  catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:CompressionUtil.java

示例10: decompressSnappy

import org.iq80.snappy.Snappy; //导入方法依赖的package包/类
private int decompressSnappy(Slice in)
        throws IOException
{
    byte[] inArray = (byte[]) in.getBase();
    int inOffset = (int) (in.getAddress() - ARRAY_BYTE_BASE_OFFSET);
    int inLength = in.length();

    int uncompressedLength = Snappy.getUncompressedLength(inArray, inOffset);
    checkArgument(uncompressedLength <= maxBufferSize, "Snappy requires buffer (%s) larger than max size (%s)", uncompressedLength, maxBufferSize);
    allocateOrGrowBuffer(uncompressedLength, false);

    return Snappy.uncompress(inArray, inOffset, inLength, buffer, 0);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:14,代码来源:OrcInputStream.java

示例11: decompress

import org.iq80.snappy.Snappy; //导入方法依赖的package包/类
@Override
public ByteBuffer decompress(ByteBuffer in) throws IOException {
  ByteBuffer out = ByteBuffer.allocate
      (Snappy.getUncompressedLength(in.array(),in.position()));
  int size = Snappy.uncompress(in.array(),in.position(),in.remaining()-4,
      out.array(), 0);
  out.limit(size);

  crc32.reset();
  crc32.update(out.array(), 0, size);
  if (in.getInt(in.limit()-4) != (int)crc32.getValue())
    throw new IOException("Checksum failure");

  return out;
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:16,代码来源:AvroJavaSnappyCodec.java

示例12: inflate

import org.iq80.snappy.Snappy; //导入方法依赖的package包/类
@Override
public byte[] inflate(InputStream data) throws CompressionException
{
  try
  {
    byte[] temp = IOUtils.toByteArray(data);
    return Snappy.uncompress(temp, 0, temp.length);
  }
  catch (IOException e)
  {
    throw new CompressionException(CompressionConstants.DECODING_ERROR + getContentEncodingName(), e);
  }

}
 
开发者ID:ppdai,项目名称:rest4j,代码行数:15,代码来源:SnappyCompressor.java

示例13: decompress

import org.iq80.snappy.Snappy; //导入方法依赖的package包/类
/**
 * Decompress the given array of bytes.
 *
 * @return null if the bytes cannot be decompressed
 */
protected byte[] decompress(byte[] in) {
    byte[] decompressed = null;
    if (in != null) {
        try {
            decompressed = Snappy.uncompress(in, 0, in.length);
        } catch (Exception e) {
            getLogger().warn("Failed to decompress data", e);
            return null;
        }
    }
    return decompressed;
}
 
开发者ID:tootedom,项目名称:spray-cache-spymemcached,代码行数:18,代码来源:BaseSerializingTranscoder.java

示例14: decode

import org.iq80.snappy.Snappy; //导入方法依赖的package包/类
public Object decode(CachedData d) {
    byte[] data = d.getData();
    if ((d.getFlags() & COMPRESSED) != 0) {
        try {
            return Snappy.uncompress(data,0,data.length);
        } catch (Exception e) {
            getLogger().warn("Unable to Uncompress");
            data = null;
        }
    }
    return data;
}
 
开发者ID:tootedom,项目名称:tomcat-memcached-response-filter,代码行数:13,代码来源:SerializingTranscoder.java

示例15: decompress

import org.iq80.snappy.Snappy; //导入方法依赖的package包/类
@Override
public void decompress(ByteBuffer in, ByteBuffer out) throws IOException {
  int inOffset = in.position();
  int uncompressLen =
      Snappy.uncompress(in.array(), in.arrayOffset() + inOffset,
      in.limit() - inOffset, out.array(), out.arrayOffset() + out.position());
  out.position(uncompressLen + out.position());
  out.flip();
}
 
开发者ID:facebookarchive,项目名称:hive-dwrf,代码行数:10,代码来源:SnappyCodec.java


注:本文中的org.iq80.snappy.Snappy.uncompress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。