transaction_notifier_jnicallback.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
  2. // This source code is licensed under both the GPLv2 (found in the
  3. // COPYING file in the root directory) and Apache 2.0 License
  4. // (found in the LICENSE.Apache file in the root directory).
  5. //
  6. // This file implements the callback "bridge" between Java and C++ for
  7. // ROCKSDB_NAMESPACE::TransactionNotifier.
  8. #ifndef JAVA_ROCKSJNI_TRANSACTION_NOTIFIER_JNICALLBACK_H_
  9. #define JAVA_ROCKSJNI_TRANSACTION_NOTIFIER_JNICALLBACK_H_
  10. #include <jni.h>
  11. #include "rocksdb/utilities/transaction.h"
  12. #include "rocksjni/jnicallback.h"
  13. namespace ROCKSDB_NAMESPACE {
  14. /**
  15. * This class acts as a bridge between C++
  16. * and Java. The methods in this class will be
  17. * called back from the RocksDB TransactionDB or OptimisticTransactionDB (C++),
  18. * we then callback to the appropriate Java method
  19. * this enables TransactionNotifier to be implemented in Java.
  20. *
  21. * Unlike RocksJava's Comparator JNI Callback, we do not attempt
  22. * to reduce Java object allocations by caching the Snapshot object
  23. * presented to the callback. This could be revisited in future
  24. * if performance is lacking.
  25. */
  26. class TransactionNotifierJniCallback: public JniCallback,
  27. public TransactionNotifier {
  28. public:
  29. TransactionNotifierJniCallback(JNIEnv* env, jobject jtransaction_notifier);
  30. virtual void SnapshotCreated(const Snapshot* newSnapshot);
  31. private:
  32. jmethodID m_jsnapshot_created_methodID;
  33. };
  34. } // namespace ROCKSDB_NAMESPACE
  35. #endif // JAVA_ROCKSJNI_TRANSACTION_NOTIFIER_JNICALLBACK_H_