Merge pull request #194 from ankgup87/master

Add compression type to options
main
Igor Canadi 10 years ago
commit 862227769a
  1. 4
      java/RocksDBSample.java
  2. 25
      java/org/rocksdb/CompressionType.java
  3. 28
      java/org/rocksdb/Options.java
  4. 21
      java/rocksjni/options.cc

@ -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(

@ -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((byte) 0),
SNAPPY_COMPRESSION((byte) 1),
ZLIB_COMPRESSION((byte) 2),
BZLIB2_COMPRESSION((byte) 3),
LZ4_COMPRESSION((byte) 4),
LZ4HC_COMPRESSION((byte) 5);
private final byte value_;
private CompressionType(byte value) {
value_ = value;
}
public byte getValue() {
return value_;
}
}

@ -1307,6 +1307,34 @@ 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.
*
* Default: SNAPPY_COMPRESSION, which gives lightweight but fast compression.
*
* @return Compression type.
*/
public CompressionType compressionType() {
return CompressionType.values()[compressionType(nativeHandle_)];
}
private native byte compressionType(long handle);
/**
* Compress blocks using the specified compression algorithm. This
parameter can be changed dynamically.
*
* Default: SNAPPY_COMPRESSION, 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;
}
private native void setCompressionType(long handle, byte compressionType);
/**
* If true, place whole keys in the filter (not just prefixes).

@ -935,6 +935,27 @@ void Java_org_rocksdb_Options_setBlockRestartInterval(
static_cast<int>(jblock_restart_interval);
}
/*
* Class: org_rocksdb_Options
* Method: setCompressionType
* Signature: (JB)V
*/
void Java_org_rocksdb_Options_setCompressionType(
JNIEnv* env, jobject jobj, jlong jhandle, jbyte compression) {
reinterpret_cast<rocksdb::Options*>(jhandle)->compression =
static_cast<rocksdb::CompressionType>(compression);
}
/*
* Class: org_rocksdb_Options
* Method: compressionType
* Signature: (J)B
*/
jbyte Java_org_rocksdb_Options_compressionType(
JNIEnv* env, jobject jobj, jlong jhandle) {
return reinterpret_cast<rocksdb::Options*>(jhandle)->compression;
}
/*
* Class: org_rocksdb_Options
* Method: wholeKeyFiltering

Loading…
Cancel
Save