From 54d7a2c0c512e6d47e2dc3de6d327d43a810bf80 Mon Sep 17 00:00:00 2001 From: Ankit Gupta Date: Mon, 7 Jul 2014 09:58:54 -0700 Subject: [PATCH] Add compression type to options --- java/RocksDBSample.java | 4 +++- java/org/rocksdb/Options.java | 11 +++++++++++ java/rocksjni/options.cc | 21 +++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/java/RocksDBSample.java b/java/RocksDBSample.java index 1493977a9..5c4b70001 100644 --- a/java/RocksDBSample.java +++ b/java/RocksDBSample.java @@ -43,7 +43,8 @@ public class RocksDBSample { .setDisableSeekCompaction(true) .setBlockSize(64 * SizeUnit.KB) .setMaxBackgroundCompactions(10) - .setFilter(filter); + .setFilter(filter) + .setCompressionType(CompressionType.SNAPPY_COMPRESSION); Statistics stats = options.statisticsPtr(); assert(options.createIfMissing() == true); @@ -52,6 +53,7 @@ public class RocksDBSample { assert(options.disableSeekCompaction() == true); assert(options.blockSize() == 64 * SizeUnit.KB); assert(options.maxBackgroundCompactions() == 10); + assert(options.compressionType() == CompressionType.SNAPPY_COMPRESSION); assert(options.memTableFactoryName().equals("SkipListFactory")); options.setMemTableConfig( diff --git a/java/org/rocksdb/Options.java b/java/org/rocksdb/Options.java index 0bf7a9aa9..ea240966c 100644 --- a/java/org/rocksdb/Options.java +++ b/java/org/rocksdb/Options.java @@ -1307,6 +1307,17 @@ public class Options extends RocksObject { } private native void setBlockRestartInterval( long handle, int blockRestartInterval); + + public CompressionType compressionType() { + return CompressionType.values()[compressionType(nativeHandle_)]; + } + private native int compressionType(long handle); + + public Options setCompressionType(CompressionType compressionType) { + setCompressionType(nativeHandle_, compressionType.getValue()); + return this; + } + private native void setCompressionType(long handle, int compressionType); /** * If true, place whole keys in the filter (not just prefixes). diff --git a/java/rocksjni/options.cc b/java/rocksjni/options.cc index 003d353e6..16d13f8c9 100644 --- a/java/rocksjni/options.cc +++ b/java/rocksjni/options.cc @@ -935,6 +935,27 @@ void Java_org_rocksdb_Options_setBlockRestartInterval( static_cast(jblock_restart_interval); } +/* + * Class: org_rocksdb_Options + * Method: setCompressionType + * Signature: (JI)V + */ +void Java_org_rocksdb_Options_setCompressionType( + JNIEnv* env, jobject jobj, jlong jhandle, jint compression) { + reinterpret_cast(jhandle)->compression = + static_cast(compression); +} + +/* + * Class: org_rocksdb_Options + * Method: compressionType + * Signature: (J)I + */ +jint Java_org_rocksdb_Options_compressionType( + JNIEnv* env, jobject jobj, jlong jhandle) { + return reinterpret_cast(jhandle)->compression; +} + /* * Class: org_rocksdb_Options * Method: wholeKeyFiltering