sst_partitioner.cc 1.5 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++ and enables
  7. // calling C++ ROCKSDB_NAMESPACE::SstFileManager methods
  8. // from Java side.
  9. #include "rocksdb/sst_partitioner.h"
  10. #include <jni.h>
  11. #include <memory>
  12. #include "include/org_rocksdb_SstPartitionerFixedPrefixFactory.h"
  13. #include "rocksdb/sst_file_manager.h"
  14. #include "rocksjni/cplusplus_to_java_convert.h"
  15. #include "rocksjni/portal.h"
  16. /*
  17. * Class: org_rocksdb_SstPartitionerFixedPrefixFactory
  18. * Method: newSstPartitionerFixedPrefixFactory0
  19. * Signature: (J)J
  20. */
  21. jlong Java_org_rocksdb_SstPartitionerFixedPrefixFactory_newSstPartitionerFixedPrefixFactory0(
  22. JNIEnv*, jclass, jlong prefix_len) {
  23. auto* ptr = new std::shared_ptr<ROCKSDB_NAMESPACE::SstPartitionerFactory>(
  24. ROCKSDB_NAMESPACE::NewSstPartitionerFixedPrefixFactory(prefix_len));
  25. return GET_CPLUSPLUS_POINTER(ptr);
  26. }
  27. /*
  28. * Class: org_rocksdb_SstPartitionerFixedPrefixFactory
  29. * Method: disposeInternal
  30. * Signature: (J)V
  31. */
  32. void Java_org_rocksdb_SstPartitionerFixedPrefixFactory_disposeInternalJni(
  33. JNIEnv*, jclass, jlong jhandle) {
  34. auto* ptr = reinterpret_cast<
  35. std::shared_ptr<ROCKSDB_NAMESPACE::SstPartitionerFactory>*>(jhandle);
  36. delete ptr; // delete std::shared_ptr
  37. }