diff --git a/README.md b/README.md index 66f02051..7709cc80 100644 --- a/README.md +++ b/README.md @@ -172,3 +172,11 @@ factory.destroy(new File("example"), options); * [ActiveMQ Apollo](http://activemq.apache.org/apollo/): Defaults to using leveldbjni, but falls back to this port if the jni port is not available on your platform. + +## Notes +### Snappy compression + +In order to use this library with leveldb databases using Snappy compression, +you need to also include one of the following libraries: +* `org.xerial.snappy:snappy-java:1.1.8.4` +* `org.iq80.snappy:snappy:0.4` diff --git a/leveldb/src/main/java/org/iq80/leveldb/util/Snappy.java b/leveldb/src/main/java/org/iq80/leveldb/util/Snappy.java index acc05faa..96d23017 100644 --- a/leveldb/src/main/java/org/iq80/leveldb/util/Snappy.java +++ b/leveldb/src/main/java/org/iq80/leveldb/util/Snappy.java @@ -231,6 +231,10 @@ public static boolean available() public static void uncompress(ByteBuffer compressed, ByteBuffer uncompressed) throws IOException { + if (SNAPPY == null) { + throw new RuntimeException("This is a compressed database, and snappy library is not found in your classpath!" + + "See more: https://github.com/dain/leveldb/#snappy-compression"); + } SNAPPY.uncompress(compressed, uncompressed); }