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
main
Javeme Lee 7 years ago committed by Facebook Github Bot
parent c5302a8a58
commit f6156fb558
  1. 6
      java/rocksjni/merge_operator.cc
  2. 8
      java/src/main/java/org/rocksdb/StringAppendOperator.java
  3. 1
      utilities/merge_operators.h
  4. 4
      utilities/merge_operators/string_append/stringappend.cc

@ -26,12 +26,12 @@
/*
* Class: org_rocksdb_StringAppendOperator
* Method: newSharedStringAppendOperator
* Signature: ()J
* Signature: (C)J
*/
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>(
rocksdb::MergeOperators::CreateFromStringId("stringappend"));
rocksdb::MergeOperators::CreateStringAppendOperator((char) jdelim));
return reinterpret_cast<jlong>(sptr_string_append_op);
}

@ -11,9 +11,13 @@ package org.rocksdb;
*/
public class StringAppendOperator extends MergeOperator {
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);
}

@ -19,6 +19,7 @@ class MergeOperators {
static std::shared_ptr<MergeOperator> CreateDeprecatedPutOperator();
static std::shared_ptr<MergeOperator> CreateUInt64AddOperator();
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> CreateMaxOperator();
static std::shared_ptr<MergeOperator> CreateBytesXOROperator();

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

Loading…
Cancel
Save