2016-02-09 23:12:00 +00:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2017-07-15 23:03:42 +00:00
|
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
|
|
// (found in the LICENSE.Apache file in the root directory).
|
2014-10-13 08:34:52 +00:00
|
|
|
//
|
2018-03-02 18:22:38 +00:00
|
|
|
// This file implements the "bridge" between Java and C++ for
|
2020-02-20 20:07:53 +00:00
|
|
|
// ROCKSDB_NAMESPACE::ColumnFamilyHandle.
|
2014-10-13 08:34:52 +00:00
|
|
|
|
2018-04-13 00:55:14 +00:00
|
|
|
#include <jni.h>
|
2014-10-13 08:34:52 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "include/org_rocksdb_ColumnFamilyHandle.h"
|
|
|
|
#include "rocksjni/portal.h"
|
|
|
|
|
2018-03-02 18:22:38 +00:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_ColumnFamilyHandle
|
|
|
|
* Method: getName
|
|
|
|
* Signature: (J)[B
|
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
jbyteArray Java_org_rocksdb_ColumnFamilyHandle_getName(JNIEnv* env,
|
2024-01-25 20:36:30 +00:00
|
|
|
jclass /*jobj*/,
|
2018-04-13 00:55:14 +00:00
|
|
|
jlong jhandle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* cfh = reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(jhandle);
|
2018-03-02 18:22:38 +00:00
|
|
|
std::string cf_name = cfh->GetName();
|
2020-02-20 20:07:53 +00:00
|
|
|
return ROCKSDB_NAMESPACE::JniUtil::copyBytes(env, cf_name);
|
2018-03-02 18:22:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2018-04-13 00:55:14 +00:00
|
|
|
* Class: org_rocksdb_ColumnFamilyHandle
|
|
|
|
* Method: getID
|
|
|
|
* Signature: (J)I
|
|
|
|
*/
|
2024-01-25 20:36:30 +00:00
|
|
|
jint Java_org_rocksdb_ColumnFamilyHandle_getID(JNIEnv* /*env*/, jclass /*jcls*/,
|
2018-04-13 00:55:14 +00:00
|
|
|
jlong jhandle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* cfh = reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(jhandle);
|
2018-03-02 18:22:38 +00:00
|
|
|
const int32_t id = cfh->GetID();
|
|
|
|
return static_cast<jint>(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_ColumnFamilyHandle
|
|
|
|
* Method: getDescriptor
|
|
|
|
* Signature: (J)Lorg/rocksdb/ColumnFamilyDescriptor;
|
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
jobject Java_org_rocksdb_ColumnFamilyHandle_getDescriptor(JNIEnv* env,
|
2024-01-25 20:36:30 +00:00
|
|
|
jclass /*jcls*/,
|
2018-04-13 00:55:14 +00:00
|
|
|
jlong jhandle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* cfh = reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(jhandle);
|
|
|
|
ROCKSDB_NAMESPACE::ColumnFamilyDescriptor desc;
|
|
|
|
ROCKSDB_NAMESPACE::Status s = cfh->GetDescriptor(&desc);
|
2018-03-02 18:22:38 +00:00
|
|
|
if (s.ok()) {
|
2020-02-20 20:07:53 +00:00
|
|
|
return ROCKSDB_NAMESPACE::ColumnFamilyDescriptorJni::construct(env, &desc);
|
2018-03-02 18:22:38 +00:00
|
|
|
} else {
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
|
2018-03-02 18:22:38 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-13 08:34:52 +00:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_ColumnFamilyHandle
|
|
|
|
* Method: disposeInternal
|
|
|
|
* Signature: (J)V
|
|
|
|
*/
|
2024-01-25 20:36:30 +00:00
|
|
|
void Java_org_rocksdb_ColumnFamilyHandle_disposeInternalJni(JNIEnv* /*env*/,
|
|
|
|
jclass /*jobj*/,
|
|
|
|
jlong jhandle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* cfh = reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(jhandle);
|
2017-02-28 00:26:12 +00:00
|
|
|
assert(cfh != nullptr);
|
|
|
|
delete cfh;
|
2014-10-13 08:34:52 +00:00
|
|
|
}
|