add support for capped prefix extractor in java
This commit is contained in:
parent
18ba58a943
commit
f0b5bcc7b5
@ -706,6 +706,17 @@ void Java_org_rocksdb_Options_useFixedLengthPrefixExtractor(
|
||||
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
|
||||
* Method: walTtlSeconds
|
||||
|
@ -191,6 +191,13 @@ public class ColumnFamilyOptions extends RocksObject
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ColumnFamilyOptions useCappedPrefixExtractor(final int n) {
|
||||
assert(isInitialized());
|
||||
useCappedPrefixExtractor(nativeHandle_, n);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ColumnFamilyOptions setCompressionType(final CompressionType compressionType) {
|
||||
setCompressionType(nativeHandle_, compressionType.getValue());
|
||||
@ -695,6 +702,8 @@ public class ColumnFamilyOptions extends RocksObject
|
||||
private native List<Byte> compressionPerLevel(long handle);
|
||||
private native void useFixedLengthPrefixExtractor(
|
||||
long handle, int prefixLength);
|
||||
private native void useCappedPrefixExtractor(
|
||||
long handle, int prefixLength);
|
||||
private native void setNumLevels(
|
||||
long handle, int numLevels);
|
||||
private native int numLevels(long handle);
|
||||
|
@ -229,6 +229,16 @@ public interface ColumnFamilyOptionsInterface {
|
||||
*/
|
||||
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
|
||||
* parameter can be changed dynamically.
|
||||
|
@ -667,6 +667,13 @@ public class Options extends RocksObject
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Options useCappedPrefixExtractor(final int n) {
|
||||
assert(isInitialized());
|
||||
useCappedPrefixExtractor(nativeHandle_, n);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompressionType compressionType() {
|
||||
return CompressionType.values()[compressionType(nativeHandle_)];
|
||||
@ -1214,6 +1221,8 @@ public class Options extends RocksObject
|
||||
private native List<Byte> compressionPerLevel(long handle);
|
||||
private native void useFixedLengthPrefixExtractor(
|
||||
long handle, int prefixLength);
|
||||
private native void useCappedPrefixExtractor(
|
||||
long handle, int prefixLength);
|
||||
private native void setNumLevels(
|
||||
long handle, int numLevels);
|
||||
private native int numLevels(long handle);
|
||||
|
@ -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
|
||||
public void compressionTypes() {
|
||||
ColumnFamilyOptions columnFamilyOptions = null;
|
||||
|
@ -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
|
||||
public void shouldTestMemTableFactoryName()
|
||||
throws RocksDBException {
|
||||
|
Loading…
x
Reference in New Issue
Block a user