transaction_notifier.cc 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 "bridge" between Java and C++
  7. // for ROCKSDB_NAMESPACE::TransactionNotifier.
  8. #include <jni.h>
  9. #include "include/org_rocksdb_AbstractTransactionNotifier.h"
  10. #include "rocksjni/transaction_notifier_jnicallback.h"
  11. /*
  12. * Class: org_rocksdb_AbstractTransactionNotifier
  13. * Method: createNewTransactionNotifier
  14. * Signature: ()J
  15. */
  16. jlong Java_org_rocksdb_AbstractTransactionNotifier_createNewTransactionNotifier(
  17. JNIEnv* env, jobject jobj) {
  18. auto* transaction_notifier =
  19. new ROCKSDB_NAMESPACE::TransactionNotifierJniCallback(env, jobj);
  20. auto* sptr_transaction_notifier =
  21. new std::shared_ptr<ROCKSDB_NAMESPACE::TransactionNotifierJniCallback>(
  22. transaction_notifier);
  23. return reinterpret_cast<jlong>(sptr_transaction_notifier);
  24. }
  25. /*
  26. * Class: org_rocksdb_AbstractTransactionNotifier
  27. * Method: disposeInternal
  28. * Signature: (J)V
  29. */
  30. void Java_org_rocksdb_AbstractTransactionNotifier_disposeInternal(
  31. JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
  32. // TODO(AR) refactor to use JniCallback::JniCallback
  33. // when https://github.com/facebook/rocksdb/pull/1241/ is merged
  34. std::shared_ptr<ROCKSDB_NAMESPACE::TransactionNotifierJniCallback>* handle =
  35. reinterpret_cast<
  36. std::shared_ptr<ROCKSDB_NAMESPACE::TransactionNotifierJniCallback>*>(
  37. jhandle);
  38. delete handle;
  39. }