cache.cc 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  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++ for
  7. // ROCKSDB_NAMESPACE::Cache.
  8. #include <jni.h>
  9. #include "include/org_rocksdb_Cache.h"
  10. #include "rocksdb/advanced_cache.h"
  11. /*
  12. * Class: org_rocksdb_Cache
  13. * Method: getUsage
  14. * Signature: (J)J
  15. */
  16. jlong Java_org_rocksdb_Cache_getUsage(JNIEnv*, jclass, jlong jhandle) {
  17. auto* sptr_cache =
  18. reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Cache>*>(jhandle);
  19. return static_cast<jlong>(sptr_cache->get()->GetUsage());
  20. }
  21. /*
  22. * Class: org_rocksdb_Cache
  23. * Method: getPinnedUsage
  24. * Signature: (J)J
  25. */
  26. jlong Java_org_rocksdb_Cache_getPinnedUsage(JNIEnv*, jclass, jlong jhandle) {
  27. auto* sptr_cache =
  28. reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Cache>*>(jhandle);
  29. return static_cast<jlong>(sptr_cache->get()->GetPinnedUsage());
  30. }