]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/java/rocksjni/writebatchhandlerjnicallback.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / rocksdb / java / rocksjni / writebatchhandlerjnicallback.h
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.
5 //
6 // This file implements the callback "bridge" between Java and C++ for
7 // rocksdb::WriteBatch::Handler.
8
9 #ifndef JAVA_ROCKSJNI_WRITEBATCHHANDLERJNICALLBACK_H_
10 #define JAVA_ROCKSJNI_WRITEBATCHHANDLERJNICALLBACK_H_
11
12 #include <jni.h>
13 #include "rocksdb/write_batch.h"
14
15 namespace rocksdb {
16 /**
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.
22 */
23 class WriteBatchHandlerJniCallback : public WriteBatch::Handler {
24 public:
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);
33 bool Continue();
34
35 private:
36 JNIEnv* m_env;
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;
45 };
46 } // namespace rocksdb
47
48 #endif // JAVA_ROCKSJNI_WRITEBATCHHANDLERJNICALLBACK_H_