1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under the BSD-style license found in the
3 // LICENSE file in the root directory of this source tree. An additional grant
4 // of patent rights can be found in the PATENTS file in the same directory.
6 // This file implements the callback "bridge" between Java and C++ for
7 // rocksdb::WriteBatch::Handler.
9 #ifndef JAVA_ROCKSJNI_WRITEBATCHHANDLERJNICALLBACK_H_
10 #define JAVA_ROCKSJNI_WRITEBATCHHANDLERJNICALLBACK_H_
13 #include "rocksdb/write_batch.h"
17 * This class acts as a bridge between C++
18 * and Java. The methods in this class will be
19 * called back from the RocksDB storage engine (C++)
20 * which calls the appropriate Java method.
21 * This enables Write Batch Handlers to be implemented in Java.
23 class WriteBatchHandlerJniCallback
: public WriteBatch::Handler
{
25 WriteBatchHandlerJniCallback(
26 JNIEnv
* env
, jobject jWriteBackHandler
);
27 ~WriteBatchHandlerJniCallback();
28 void Put(const Slice
& key
, const Slice
& value
);
29 void Merge(const Slice
& key
, const Slice
& value
);
30 void Delete(const Slice
& key
);
31 void DeleteRange(const Slice
& beginKey
, const Slice
& endKey
);
32 void LogData(const Slice
& blob
);
37 jobject m_jWriteBatchHandler
;
38 jbyteArray
sliceToJArray(const Slice
& s
);
39 jmethodID m_jPutMethodId
;
40 jmethodID m_jMergeMethodId
;
41 jmethodID m_jDeleteMethodId
;
42 jmethodID m_jDeleteRangeMethodId
;
43 jmethodID m_jLogDataMethodId
;
44 jmethodID m_jContinueMethodId
;
46 } // namespace rocksdb
48 #endif // JAVA_ROCKSJNI_WRITEBATCHHANDLERJNICALLBACK_H_