Support StringAppendOperator(delimiter_char) constructor in java-api

Summary:
Fixes #3336
Closes https://github.com/facebook/rocksdb/pull/3337

Differential Revision: D7196585

Pulled By: sagar0

fbshipit-source-id: a854f3fc906862ecba685b31946e4ef7c0b421c5
This commit is contained in:
Javeme Lee 2018-03-08 15:59:51 -08:00 committed by Facebook Github Bot
parent c5302a8a58
commit f6156fb558
4 changed files with 14 additions and 5 deletions

View File

@ -26,12 +26,12 @@
/* /*
* Class: org_rocksdb_StringAppendOperator * Class: org_rocksdb_StringAppendOperator
* Method: newSharedStringAppendOperator * Method: newSharedStringAppendOperator
* Signature: ()J * Signature: (C)J
*/ */
jlong Java_org_rocksdb_StringAppendOperator_newSharedStringAppendOperator jlong Java_org_rocksdb_StringAppendOperator_newSharedStringAppendOperator
(JNIEnv* env, jclass jclazz) { (JNIEnv* env, jclass jclazz, jchar jdelim) {
auto* sptr_string_append_op = new std::shared_ptr<rocksdb::MergeOperator>( auto* sptr_string_append_op = new std::shared_ptr<rocksdb::MergeOperator>(
rocksdb::MergeOperators::CreateFromStringId("stringappend")); rocksdb::MergeOperators::CreateStringAppendOperator((char) jdelim));
return reinterpret_cast<jlong>(sptr_string_append_op); return reinterpret_cast<jlong>(sptr_string_append_op);
} }

View File

@ -11,9 +11,13 @@ package org.rocksdb;
*/ */
public class StringAppendOperator extends MergeOperator { public class StringAppendOperator extends MergeOperator {
public StringAppendOperator() { public StringAppendOperator() {
super(newSharedStringAppendOperator()); this(',');
} }
private native static long newSharedStringAppendOperator(); public StringAppendOperator(char delim) {
super(newSharedStringAppendOperator(delim));
}
private native static long newSharedStringAppendOperator(final char delim);
@Override protected final native void disposeInternal(final long handle); @Override protected final native void disposeInternal(final long handle);
} }

View File

@ -19,6 +19,7 @@ class MergeOperators {
static std::shared_ptr<MergeOperator> CreateDeprecatedPutOperator(); static std::shared_ptr<MergeOperator> CreateDeprecatedPutOperator();
static std::shared_ptr<MergeOperator> CreateUInt64AddOperator(); static std::shared_ptr<MergeOperator> CreateUInt64AddOperator();
static std::shared_ptr<MergeOperator> CreateStringAppendOperator(); static std::shared_ptr<MergeOperator> CreateStringAppendOperator();
static std::shared_ptr<MergeOperator> CreateStringAppendOperator(char delim_char);
static std::shared_ptr<MergeOperator> CreateStringAppendTESTOperator(); static std::shared_ptr<MergeOperator> CreateStringAppendTESTOperator();
static std::shared_ptr<MergeOperator> CreateMaxOperator(); static std::shared_ptr<MergeOperator> CreateMaxOperator();
static std::shared_ptr<MergeOperator> CreateBytesXOROperator(); static std::shared_ptr<MergeOperator> CreateBytesXOROperator();

View File

@ -52,4 +52,8 @@ std::shared_ptr<MergeOperator> MergeOperators::CreateStringAppendOperator() {
return std::make_shared<StringAppendOperator>(','); return std::make_shared<StringAppendOperator>(',');
} }
std::shared_ptr<MergeOperator> MergeOperators::CreateStringAppendOperator(char delim_char) {
return std::make_shared<StringAppendOperator>(delim_char);
}
} // namespace rocksdb } // namespace rocksdb