snappy-java-1.1.0-M1 release

112 views
Skip to first unread message

Taro L. Saito

unread,
Mar 27, 2013, 9:15:56 AM3/27/13
to xer...@googlegroups.com
Hi,

I released a new version of snappy-java-1.1.0-M1:

This version is already available in the Maven central repository.

This update slightly improves the compression performance. For details see:

From this version, I dropped 32-bit Mac OS X support (since java6 is not easily available in this OS). 

Currently it includes native libraries of: 
 Windows. 32bit(x86), 64bit(amd64) 
 Mac 64bit (x86_64)
 Linux 32bit(i386), 64bit(amd64), arm, armhf

Your feedback is welcome. 


Feng Wang

unread,
Sep 25, 2013, 4:33:08 AM9/25/13
to xer...@googlegroups.com
I used snappy-java-1.1.0-M1. but the exception was thrown:

java.io.IOException: FAILED_TO_UNCOMPRESS(5)

at org.xerial.snappy.SnappyNative.throw_error(SnappyNative.java:84)

at org.xerial.snappy.SnappyNative.rawUncompress(Native Method)

at org.xerial.snappy.Snappy.rawUncompress(Snappy.java:444)

at org.xerial.snappy.Snappy.uncompress(Snappy.java:480)

at org.xerial.snappy.Snappy.uncompress(Snappy.java:456)


the code:

String input = "/Users/wangfeng/Downloads/202fe31644d440480ac82795b70a585a.jpg";

FileInputStream is=LocalFileService.getFileInputSteam(input);

System.out.println("raw:"+new File(input).length());

String output="/Users/wangfeng/Downloads/202fe31644d440480ac82795b70a585a.jpg.snappy";

FileOutputStream os=new FileOutputStream(output);

byte[] buffer=new byte[1*1024*1024];

byte[] snappy=null;

while(is.read(buffer)!=-1){

snappy=Snappy.compress(buffer);

buffer=new byte[1*1024*1024];

os.write(snappy);

os.flush();

}

is.close();

os.close();

System.out.println("compressed:"+new File(output).length());

input="/Users/wangfeng/Downloads/202fe31644d440480ac82795b70a585a.jpg.snappy";

output="/Users/wangfeng/Downloads/2222.jpg";

is=LocalFileService.getFileInputSteam(input);

System.out.println("compressed:"+new File(input).length());

os=new FileOutputStream(output);

buffer=new byte[1*1024*1024];

snappy=null;

while(is.read(buffer)!=-1){

snappy=Snappy.uncompress(buffer);// exception thrown

buffer=new byte[1*1024*1024];

os.write(snappy);

os.flush();

}

is.close();

os.close();

System.out.println("uncompressed:"+new File(output).length());




在 2013年3月27日星期三UTC+8下午9时15分56秒,Taro L. Saito写道:

Taro L. Saito

unread,
Sep 25, 2013, 4:44:27 AM9/25/13
to xerial
Hi, 

You are uncompressing an invalid range since the compressed data produced by Snappy.compress cannot be 
concatenated in the form that can be uncompressed.

Instead use SnappyOutputStream and SnappyInputStream that help you to write a similar code.



--
Taro L. Saito
<l...@xerial.org>
University of Tokyo
http://www.xerial.org/leo
Tel. +81-47-136-4065 (64065)


--
You received this message because you are subscribed to the Google Groups "Xerial" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xerial+un...@googlegroups.com.
To post to this group, send email to xer...@googlegroups.com.
Visit this group at http://groups.google.com/group/xerial.

For more options, visit https://groups.google.com/groups/opt_out.

wangfeng

unread,
Sep 25, 2013, 4:46:20 AM9/25/13
to xer...@googlegroups.com
thanks  I  just found the cause!  
You received this message because you are subscribed to a topic in the Google Groups "Xerial" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/xerial/Qt2E-CG57qk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to xerial+un...@googlegroups.com.

wangfeng

unread,
Sep 26, 2013, 6:01:33 AM9/26/13
to xer...@googlegroups.com
how to check if the compress result was valid and the process was successful? thanks

在 2013-9-25,下午4:44,Taro L. Saito <l...@xerial.org> 写道:

You received this message because you are subscribed to a topic in the Google Groups "Xerial" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/xerial/Qt2E-CG57qk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to xerial+un...@googlegroups.com.

Taro L. Saito

unread,
Sep 26, 2013, 9:05:52 PM9/26/13
to xerial
For the data compressed by Snappy.compress, you can use Snappy.isValidCompressedData.

Currently no API is provided for validating the compressed data generated by SnappyOutputStream.
But the output format of SnappyOutputStream is:
(snappy header) ((compressed data length), (compressed data))+

The 'compressed data' part can be validated via isValidCompressedData. 
So you can write your own validator. See the javadoc of SnappyOutputStream for the detail.

Regards,


--
Taro L. Saito
<l...@xerial.org>
University of Tokyo
http://www.xerial.org/leo
Tel. +81-47-136-4065 (64065)


wangfeng

unread,
Sep 26, 2013, 10:20:05 PM9/26/13
to xer...@googlegroups.com
thanks
Reply all
Reply to author
Forward
0 new messages