Update README.md

This commit is contained in:
Takeshi YAMAMURO 2017-01-23 23:04:10 +09:00
parent eb25832561
commit ebabccc829
1 changed files with 27 additions and 4 deletions

View File

@ -9,6 +9,7 @@ snappy-java is a Java port of the snappy
* JNI-based implementation to achieve comparable performance to the native C++ version.
* Although snappy-java uses JNI, it can be used safely with multiple class loaders (e.g. Tomcat, etc.).
* Compression/decompression of Java primitive arrays (`float[]`, `double[]`, `int[]`, `short[]`, `long[]`, etc.)
* To improve the compression ratios of these arrays, you can use a fast data-rearrangement implementation ([`BitShuffle`](https://github.com/kiyo-masui/bitshuffle)) before compression
* Portable across various operating systems; Snappy-java contains native libraries built for Window/Mac/Linux (64-bit). snappy-java loads one of these libraries according to your machine environment (It looks system properties, `os.name` and `os.arch`).
* Simple usage. Add the snappy-java-(version).jar file to your classpath. Then call compression/decompression methods in `org.xerial.snappy.Snappy`.
* [Framing-format support](https://github.com/google/snappy/blob/master/framing_format.txt) (Since 1.1.0 version)
@ -41,7 +42,7 @@ Add the following dependency to your pom.xml:
<dependency>
<groupId>org.xerial.snappy</groupId>
<artifactId>snappy-java</artifactId>
<version>1.1.2.6</version>
<version>1.1.3-M1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
@ -49,7 +50,7 @@ Add the following dependency to your pom.xml:
### Using with sbt
```
libraryDependencies += "org.xerial.snappy" % "snappy-java" % "1.1.2.6"
libraryDependencies += "org.xerial.snappy" % "snappy-java" % "1.1.3-M1"
```
@ -77,7 +78,7 @@ In addition, high-level methods (`Snappy.compress(String)`, `Snappy.compress(flo
### Stream-based API
Stream-based compressor/decompressor `SnappyOutputStream`/`SnappyInputStream` are also available for reading/writing large data sets. `SnappyFramedOutputStream`/`SnappyFramedInputStream` can be used for the [framing format](https://github.com/google/snappy/blob/master/framing_format.txt).
* See also [Javadoc API](https://oss.sonatype.org/service/local/repositories/releases/archive/org/xerial/snappy/snappy-java/1.1.2.6/snappy-java-1.1.2.6-javadoc.jar/!/index.html)
* See also [Javadoc API](https://oss.sonatype.org/service/local/repositories/releases/archive/org/xerial/snappy/snappy-java/1.1.3-M1/snappy-java-1.1.3-M1-javadoc.jar/!/index.html)
#### Compatibility Notes
* `SnappyOutputStream` and `SnappyInputStream` use `[magic header:16 bytes]([block size:int32][compressed data:byte array])*` format. You can read the result of `Snappy.compress` with `SnappyInputStream`, but you cannot read the compressed data generated by `SnappyOutputStream` with `Snappy.uncompress`. Here is the data format compatibility matrix:
@ -88,6 +89,28 @@ Stream-based compressor/decompressor `SnappyOutputStream`/`SnappyInputStream` ar
| `SnappyOutputStream` | x | ok | x |
| `SnappyFramedOutputStream` | x | x | ok |
### BitShuffle API
To use BitShuffle routines, you need to import `org.xerial.snapy.BitShuffle` in your Java code:
```java
import org.xerial.snappy.BitShuffle;
```
Then use them like this:
```java
int[] data = new int[] {1, 3, 34, 43, 34};
byte[] shuffledByteArray = BitShuffle.bitShuffle(data);
byte[] compressed = Snappy.compress(shuffledByteArray);
byte[] uncompressed = Snappy.uncompress(compressed);
int[] result = BitShuffle.bitUnShuffleIntArray(uncompress);
System.out.println(result);
```
You can also shuffle and unshuffle the other primitive arrays (`short[]`, `long[]`, `float[]`, and `double[]`) and
the other routines can be found in [Javadoc](http://static.javadoc.io/org.xerial.snappy/snappy-java/1.1.3-M1/org/xerial/snappy/BitShuffle.html).
### Setting classpath
If you have snappy-java-(VERSION).jar in the current directory, use `-classpath` option as follows: