2016-02-10 00:12:00 +01:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2017-07-16 01:03:42 +02:00
|
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
|
|
// (found in the LICENSE.Apache file in the root directory).
|
2014-10-23 17:19:38 +02:00
|
|
|
//
|
|
|
|
// This file implements the callback "bridge" between Java and C++ for
|
|
|
|
// rocksdb::WriteBatch::Handler.
|
|
|
|
|
|
|
|
#ifndef JAVA_ROCKSJNI_WRITEBATCHHANDLERJNICALLBACK_H_
|
|
|
|
#define JAVA_ROCKSJNI_WRITEBATCHHANDLERJNICALLBACK_H_
|
|
|
|
|
|
|
|
#include <jni.h>
|
2017-10-12 20:06:51 +02:00
|
|
|
#include "rocksjni/jnicallback.h"
|
2014-10-23 17:19:38 +02:00
|
|
|
#include "rocksdb/write_batch.h"
|
|
|
|
|
|
|
|
namespace rocksdb {
|
|
|
|
/**
|
|
|
|
* This class acts as a bridge between C++
|
|
|
|
* and Java. The methods in this class will be
|
|
|
|
* called back from the RocksDB storage engine (C++)
|
2014-11-05 19:56:45 +01:00
|
|
|
* which calls the appropriate Java method.
|
|
|
|
* This enables Write Batch Handlers to be implemented in Java.
|
2014-10-23 17:19:38 +02:00
|
|
|
*/
|
2017-10-12 20:06:51 +02:00
|
|
|
class WriteBatchHandlerJniCallback : public JniCallback, public WriteBatch::Handler {
|
2014-10-23 17:19:38 +02:00
|
|
|
public:
|
|
|
|
WriteBatchHandlerJniCallback(
|
|
|
|
JNIEnv* env, jobject jWriteBackHandler);
|
|
|
|
void Put(const Slice& key, const Slice& value);
|
|
|
|
void Merge(const Slice& key, const Slice& value);
|
|
|
|
void Delete(const Slice& key);
|
2017-03-07 07:13:53 +01:00
|
|
|
void DeleteRange(const Slice& beginKey, const Slice& endKey);
|
2014-10-23 17:19:38 +02:00
|
|
|
void LogData(const Slice& blob);
|
|
|
|
bool Continue();
|
|
|
|
|
|
|
|
private:
|
2014-11-05 19:56:45 +01:00
|
|
|
JNIEnv* m_env;
|
2014-10-23 17:19:38 +02:00
|
|
|
jbyteArray sliceToJArray(const Slice& s);
|
|
|
|
jmethodID m_jPutMethodId;
|
|
|
|
jmethodID m_jMergeMethodId;
|
|
|
|
jmethodID m_jDeleteMethodId;
|
2017-03-07 07:13:53 +01:00
|
|
|
jmethodID m_jDeleteRangeMethodId;
|
2014-10-23 17:19:38 +02:00
|
|
|
jmethodID m_jLogDataMethodId;
|
|
|
|
jmethodID m_jContinueMethodId;
|
|
|
|
};
|
|
|
|
} // namespace rocksdb
|
|
|
|
|
|
|
|
#endif // JAVA_ROCKSJNI_WRITEBATCHHANDLERJNICALLBACK_H_
|