From 91bf1b80ef7d3a4f719e3f815c2d8c202855ebee Mon Sep 17 00:00:00 2001 From: Adam Retter Date: Tue, 14 Jul 2015 17:48:16 +0100 Subject: [PATCH] Java facility to use the RemoveEmptyValueCompactionFilter --- java/Makefile | 1 + .../remove_emptyvalue_compactionfilterjni.cc | 27 +++++++++++++++++++ .../RemoveEmptyValueCompactionFilter.java | 18 +++++++++++++ src.mk | 1 + 4 files changed, 47 insertions(+) create mode 100644 java/rocksjni/remove_emptyvalue_compactionfilterjni.cc create mode 100644 java/src/main/java/org/rocksdb/RemoveEmptyValueCompactionFilter.java diff --git a/java/Makefile b/java/Makefile index fcd441ca4..dd678f5c3 100644 --- a/java/Makefile +++ b/java/Makefile @@ -24,6 +24,7 @@ NATIVE_JAVA_CLASSES = org.rocksdb.AbstractCompactionFilter\ org.rocksdb.Options\ org.rocksdb.PlainTableConfig\ org.rocksdb.ReadOptions\ + org.rocksdb.RemoveEmptyValueCompactionFilter\ org.rocksdb.RestoreBackupableDB\ org.rocksdb.RestoreOptions\ org.rocksdb.RocksDB\ diff --git a/java/rocksjni/remove_emptyvalue_compactionfilterjni.cc b/java/rocksjni/remove_emptyvalue_compactionfilterjni.cc new file mode 100644 index 000000000..e442d8daf --- /dev/null +++ b/java/rocksjni/remove_emptyvalue_compactionfilterjni.cc @@ -0,0 +1,27 @@ +// 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. + +#include + +#include "include/org_rocksdb_RemoveEmptyValueCompactionFilter.h" +#include "utilities/compaction_filters/remove_emptyvalue_compactionfilter.h" + + +/* + * Class: org_rocksdb_RemoveEmptyValueCompactionFilter + * Method: createNewRemoveEmptyValueCompactionFilter0 + * Signature: ()V + */ +void Java_org_rocksdb_RemoveEmptyValueCompactionFilter_createNewRemoveEmptyValueCompactionFilter0( + JNIEnv* env, jobject jobj) { + const rocksdb::RemoveEmptyValueCompactionFilter* compaction_filter = + new rocksdb::RemoveEmptyValueCompactionFilter(); + + // set the native handle to our native compaction filter + static jclass jclazz = + env->FindClass("org/rocksdb/RemoveEmptyValueCompactionFilter"); + static jfieldID fid = env->GetFieldID(jclazz, "nativeHandle_", "J"); + env->SetLongField(jobj, fid, reinterpret_cast(compaction_filter)); +} diff --git a/java/src/main/java/org/rocksdb/RemoveEmptyValueCompactionFilter.java b/java/src/main/java/org/rocksdb/RemoveEmptyValueCompactionFilter.java new file mode 100644 index 000000000..61c46131b --- /dev/null +++ b/java/src/main/java/org/rocksdb/RemoveEmptyValueCompactionFilter.java @@ -0,0 +1,18 @@ +// 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; + +/** + * Just a Java wrapper around EmptyValueCompactionFilter implemented in C++ + */ +public class RemoveEmptyValueCompactionFilter extends AbstractCompactionFilter { + public RemoveEmptyValueCompactionFilter() { + super(); + createNewRemoveEmptyValueCompactionFilter0(); + } + + private native void createNewRemoveEmptyValueCompactionFilter0(); +} diff --git a/src.mk b/src.mk index 6fc690f32..6d60743b6 100644 --- a/src.mk +++ b/src.mk @@ -257,6 +257,7 @@ JNI_NATIVE_SOURCES = \ java/rocksjni/merge_operator.cc \ java/rocksjni/options.cc \ java/rocksjni/ratelimiterjni.cc \ + java/rocksjni/remove_emptyvalue_compactionfilterjni.cc \ java/rocksjni/restorejni.cc \ java/rocksjni/rocksjni.cc \ java/rocksjni/slice.cc \