diff --git a/java/org/rocksdb/CompressionType.java b/java/org/rocksdb/CompressionType.java new file mode 100644 index 000000000..313a7813b --- /dev/null +++ b/java/org/rocksdb/CompressionType.java @@ -0,0 +1,25 @@ +// Copyright (c) 2014, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the root directory of this source tree. An additional grant +// of patent rights can be found in the PATENTS file in the same directory. + +package org.rocksdb; + +public enum CompressionType { + NO_COMPRESSION(0), + SNAPPY_COMPRESSION(1), + ZLIB_COMPRESSION(2), + BZLIB2_COMPRESSION(3), + LZ4_COMPRESSION(4), + LZ4HC_COMPRESSION(5); + + private final int value_; + + private CompressionType(int value) { + value_ = value; + } + + public int getValue() { + return value_; + } +} \ No newline at end of file diff --git a/java/org/rocksdb/Options.java b/java/org/rocksdb/Options.java index ea240966c..b441d49e4 100644 --- a/java/org/rocksdb/Options.java +++ b/java/org/rocksdb/Options.java @@ -1308,11 +1308,46 @@ public class Options extends RocksObject { private native void setBlockRestartInterval( long handle, int blockRestartInterval); + /** + * Compress blocks using the specified compression algorithm. This + parameter can be changed dynamically. + * + * Typical speeds of kSnappyCompression on an Intel(R) Core(TM)2 2.4GHz: + * ~200-500MB/s compression and ~400-800MB/s decompression. + * + * Note that these speeds are significantly faster than most + * persistent storage speeds, and therefore it is typically never + * worth switching to kNoCompression. Even if the input data is + * incompressible, the kSnappyCompression implementation will + * efficiently detect that and will switch to uncompressed mode. + * + * Default: kSnappyCompression, which gives lightweight but fast compression. + * + * @return Compression type. + */ public CompressionType compressionType() { return CompressionType.values()[compressionType(nativeHandle_)]; } private native int compressionType(long handle); + /** + * Compress blocks using the specified compression algorithm. This + parameter can be changed dynamically. + * + * Typical speeds of kSnappyCompression on an Intel(R) Core(TM)2 2.4GHz: + * ~200-500MB/s compression and ~400-800MB/s decompression. + * + * Note that these speeds are significantly faster than most + * persistent storage speeds, and therefore it is typically never + * worth switching to kNoCompression. Even if the input data is + * incompressible, the kSnappyCompression implementation will + * efficiently detect that and will switch to uncompressed mode. + * + * Default: kSnappyCompression, which gives lightweight but fast compression. + * + * @param compressionType Compression Type. + * @return the reference to the current option. + */ public Options setCompressionType(CompressionType compressionType) { setCompressionType(nativeHandle_, compressionType.getValue()); return this;