The ability to specify a compaction filter via the Java API
This commit is contained in:
parent
62dec0e2b7
commit
3d00271e40
@ -1,4 +1,5 @@
|
|||||||
NATIVE_JAVA_CLASSES = org.rocksdb.AbstractComparator\
|
NATIVE_JAVA_CLASSES = org.rocksdb.AbstractCompactionFilter\
|
||||||
|
org.rocksdb.AbstractComparator\
|
||||||
org.rocksdb.AbstractSlice\
|
org.rocksdb.AbstractSlice\
|
||||||
org.rocksdb.BackupableDB\
|
org.rocksdb.BackupableDB\
|
||||||
org.rocksdb.BackupableDBOptions\
|
org.rocksdb.BackupableDBOptions\
|
||||||
|
24
java/rocksjni/compaction_filter.cc
Normal file
24
java/rocksjni/compaction_filter.cc
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright (c) 2015, 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.
|
||||||
|
//
|
||||||
|
// This file implements the "bridge" between Java and C++ for
|
||||||
|
// rocksdb::CompactionFilter.
|
||||||
|
|
||||||
|
#include <jni.h>
|
||||||
|
|
||||||
|
#include "rocksdb/compaction_filter.h"
|
||||||
|
|
||||||
|
// <editor-fold desc="org.rocksdb.AbstractCompactionFilter">
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: org_rocksdb_AbstractCompactionFilter
|
||||||
|
* Method: disposeInternal
|
||||||
|
* Signature: (J)V
|
||||||
|
*/
|
||||||
|
void Java_org_rocksdb_AbstractCompactionFilter_disposeInternal(
|
||||||
|
JNIEnv* env, jobject jobj, jlong handle) {
|
||||||
|
delete reinterpret_cast<rocksdb::CompactionFilter*>(handle);
|
||||||
|
}
|
||||||
|
// </editor-fold>
|
@ -2053,6 +2053,19 @@ void Java_org_rocksdb_ColumnFamilyOptions_setMergeOperator(
|
|||||||
(mergeOperatorHandle));
|
(mergeOperatorHandle));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: org_rocksdb_ColumnFamilyOptions
|
||||||
|
* Method: setCompactionFilterHandle
|
||||||
|
* Signature: (JJ)V
|
||||||
|
*/
|
||||||
|
void Java_org_rocksdb_ColumnFamilyOptions_setCompactionFilterHandle__JJ(
|
||||||
|
JNIEnv* env, jobject jobj, jlong jopt_handle,
|
||||||
|
jlong jcompactionfilter_handle) {
|
||||||
|
reinterpret_cast<rocksdb::ColumnFamilyOptions*>(jopt_handle)->
|
||||||
|
compaction_filter = reinterpret_cast<rocksdb::CompactionFilter*>
|
||||||
|
(jcompactionfilter_handle);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: org_rocksdb_ColumnFamilyOptions
|
* Class: org_rocksdb_ColumnFamilyOptions
|
||||||
* Method: setWriteBufferSize
|
* Method: setWriteBufferSize
|
||||||
|
29
java/src/main/java/org/rocksdb/AbstractCompactionFilter.java
Normal file
29
java/src/main/java/org/rocksdb/AbstractCompactionFilter.java
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright (c) 2015, 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A CompactionFilter allows an application to modify/delete a key-value at
|
||||||
|
* the time of compaction.
|
||||||
|
*
|
||||||
|
* At present we just permit an overriding Java class to wrap a C++ implementation
|
||||||
|
*/
|
||||||
|
public abstract class AbstractCompactionFilter<T extends AbstractSlice<?>>
|
||||||
|
extends RocksObject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes underlying C++ comparator pointer.
|
||||||
|
*
|
||||||
|
* Note that this function should be called only after all
|
||||||
|
* RocksDB instances referencing the comparator are closed.
|
||||||
|
* Otherwise an undefined behavior will occur.
|
||||||
|
*/
|
||||||
|
@Override protected void disposeInternal() {
|
||||||
|
assert(isInitialized());
|
||||||
|
disposeInternal(nativeHandle_);
|
||||||
|
}
|
||||||
|
|
||||||
|
private native void disposeInternal(long handle);
|
||||||
|
}
|
@ -145,6 +145,13 @@ public class ColumnFamilyOptions extends RocksObject
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ColumnFamilyOptions setCompactionFilter(
|
||||||
|
final AbstractCompactionFilter<? extends AbstractSlice<?>> compactionFilter) {
|
||||||
|
setCompactionFilterHandle(nativeHandle_, compactionFilter.nativeHandle_);
|
||||||
|
compactionFilter_ = compactionFilter;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ColumnFamilyOptions setWriteBufferSize(final long writeBufferSize) {
|
public ColumnFamilyOptions setWriteBufferSize(final long writeBufferSize) {
|
||||||
assert(isInitialized());
|
assert(isInitialized());
|
||||||
@ -680,6 +687,7 @@ public class ColumnFamilyOptions extends RocksObject
|
|||||||
long handle, String name);
|
long handle, String name);
|
||||||
private native void setMergeOperator(
|
private native void setMergeOperator(
|
||||||
long handle, long mergeOperatorHandle);
|
long handle, long mergeOperatorHandle);
|
||||||
|
private native void setCompactionFilterHandle(long handle, long compactionFilterHandle);
|
||||||
private native void setWriteBufferSize(long handle, long writeBufferSize)
|
private native void setWriteBufferSize(long handle, long writeBufferSize)
|
||||||
throws IllegalArgumentException;
|
throws IllegalArgumentException;
|
||||||
private native long writeBufferSize(long handle);
|
private native long writeBufferSize(long handle);
|
||||||
@ -803,4 +811,5 @@ public class ColumnFamilyOptions extends RocksObject
|
|||||||
MemTableConfig memTableConfig_;
|
MemTableConfig memTableConfig_;
|
||||||
TableFormatConfig tableFormatConfig_;
|
TableFormatConfig tableFormatConfig_;
|
||||||
AbstractComparator<? extends AbstractSlice<?>> comparator_;
|
AbstractComparator<? extends AbstractSlice<?>> comparator_;
|
||||||
|
AbstractCompactionFilter<? extends AbstractSlice<?>> compactionFilter_;
|
||||||
}
|
}
|
||||||
|
1
src.mk
1
src.mk
@ -246,6 +246,7 @@ JNI_NATIVE_SOURCES = \
|
|||||||
java/rocksjni/backupablejni.cc \
|
java/rocksjni/backupablejni.cc \
|
||||||
java/rocksjni/checkpoint.cc \
|
java/rocksjni/checkpoint.cc \
|
||||||
java/rocksjni/columnfamilyhandle.cc \
|
java/rocksjni/columnfamilyhandle.cc \
|
||||||
|
java/rocksjni/compaction_filter.cc \
|
||||||
java/rocksjni/comparator.cc \
|
java/rocksjni/comparator.cc \
|
||||||
java/rocksjni/comparatorjnicallback.cc \
|
java/rocksjni/comparatorjnicallback.cc \
|
||||||
java/rocksjni/env.cc \
|
java/rocksjni/env.cc \
|
||||||
|
Loading…
Reference in New Issue
Block a user