提交 f0b5bcc7 编写于 作者: A ashishn 提交者: Yueh-Hsuan Chiang

add support for capped prefix extractor in java

上级 18ba58a9
...@@ -706,6 +706,17 @@ void Java_org_rocksdb_Options_useFixedLengthPrefixExtractor( ...@@ -706,6 +706,17 @@ void Java_org_rocksdb_Options_useFixedLengthPrefixExtractor(
static_cast<int>(jprefix_length))); static_cast<int>(jprefix_length)));
} }
/*
* Method: useCappedPrefixExtractor
* Signature: (JI)V
*/
void Java_org_rocksdb_Options_useCappedPrefixExtractor(
JNIEnv* env, jobject jobj, jlong jhandle, jint jprefix_length) {
reinterpret_cast<rocksdb::Options*>(jhandle)->prefix_extractor.reset(
rocksdb::NewCappedPrefixTransform(
static_cast<int>(jprefix_length)));
}
/* /*
* Class: org_rocksdb_Options * Class: org_rocksdb_Options
* Method: walTtlSeconds * Method: walTtlSeconds
......
...@@ -191,6 +191,13 @@ public class ColumnFamilyOptions extends RocksObject ...@@ -191,6 +191,13 @@ public class ColumnFamilyOptions extends RocksObject
return this; return this;
} }
@Override
public ColumnFamilyOptions useCappedPrefixExtractor(final int n) {
assert(isInitialized());
useCappedPrefixExtractor(nativeHandle_, n);
return this;
}
@Override @Override
public ColumnFamilyOptions setCompressionType(final CompressionType compressionType) { public ColumnFamilyOptions setCompressionType(final CompressionType compressionType) {
setCompressionType(nativeHandle_, compressionType.getValue()); setCompressionType(nativeHandle_, compressionType.getValue());
...@@ -695,6 +702,8 @@ public class ColumnFamilyOptions extends RocksObject ...@@ -695,6 +702,8 @@ public class ColumnFamilyOptions extends RocksObject
private native List<Byte> compressionPerLevel(long handle); private native List<Byte> compressionPerLevel(long handle);
private native void useFixedLengthPrefixExtractor( private native void useFixedLengthPrefixExtractor(
long handle, int prefixLength); long handle, int prefixLength);
private native void useCappedPrefixExtractor(
long handle, int prefixLength);
private native void setNumLevels( private native void setNumLevels(
long handle, int numLevels); long handle, int numLevels);
private native int numLevels(long handle); private native int numLevels(long handle);
......
...@@ -229,6 +229,16 @@ public interface ColumnFamilyOptionsInterface { ...@@ -229,6 +229,16 @@ public interface ColumnFamilyOptionsInterface {
*/ */
Object useFixedLengthPrefixExtractor(int n); Object useFixedLengthPrefixExtractor(int n);
/**
* Same as fixed length prefix extractor, except that when slice is
* shorter than the fixed length, it will use the full key.
*
* @param n use the first n bytes of a key as its prefix.
* @return the reference to the current option.
*/
Object useCappedPrefixExtractor(int n);
/** /**
* Compress blocks using the specified compression algorithm. This * Compress blocks using the specified compression algorithm. This
* parameter can be changed dynamically. * parameter can be changed dynamically.
......
...@@ -667,6 +667,13 @@ public class Options extends RocksObject ...@@ -667,6 +667,13 @@ public class Options extends RocksObject
return this; return this;
} }
@Override
public Options useCappedPrefixExtractor(final int n) {
assert(isInitialized());
useCappedPrefixExtractor(nativeHandle_, n);
return this;
}
@Override @Override
public CompressionType compressionType() { public CompressionType compressionType() {
return CompressionType.values()[compressionType(nativeHandle_)]; return CompressionType.values()[compressionType(nativeHandle_)];
...@@ -1214,6 +1221,8 @@ public class Options extends RocksObject ...@@ -1214,6 +1221,8 @@ public class Options extends RocksObject
private native List<Byte> compressionPerLevel(long handle); private native List<Byte> compressionPerLevel(long handle);
private native void useFixedLengthPrefixExtractor( private native void useFixedLengthPrefixExtractor(
long handle, int prefixLength); long handle, int prefixLength);
private native void useCappedPrefixExtractor(
long handle, int prefixLength);
private native void setNumLevels( private native void setNumLevels(
long handle, int numLevels); long handle, int numLevels);
private native int numLevels(long handle); private native int numLevels(long handle);
......
...@@ -615,6 +615,21 @@ public class ColumnFamilyOptionsTest { ...@@ -615,6 +615,21 @@ public class ColumnFamilyOptionsTest {
} }
} }
@Test
public void shouldSetTestCappedPrefixExtractor() {
ColumnFamilyOptions options = null;
try {
options = new ColumnFamilyOptions();
options.useCappedPrefixExtractor(100);
options.useCappedPrefixExtractor(10);
} finally {
if (options != null) {
options.dispose();
}
}
}
@Test @Test
public void compressionTypes() { public void compressionTypes() {
ColumnFamilyOptions columnFamilyOptions = null; ColumnFamilyOptions columnFamilyOptions = null;
......
...@@ -1149,6 +1149,21 @@ public class OptionsTest { ...@@ -1149,6 +1149,21 @@ public class OptionsTest {
} }
} }
@Test
public void shouldSetTestCappedPrefixExtractor() {
Options options = null;
try {
options = new Options();
options.useCappedPrefixExtractor(100);
options.useCappedPrefixExtractor(10);
} finally {
if (options != null) {
options.dispose();
}
}
}
@Test @Test
public void shouldTestMemTableFactoryName() public void shouldTestMemTableFactoryName()
throws RocksDBException { throws RocksDBException {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册