transaction_notifier.cc 1.6 KB

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