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-04-21 22:40:46 +00:00
|
|
|
//
|
|
|
|
// This file implements the "bridge" between Java and C++ for MemTables.
|
|
|
|
|
|
|
|
#include "include/org_rocksdb_HashLinkedListMemTableConfig.h"
|
2018-04-13 00:55:14 +00:00
|
|
|
#include "include/org_rocksdb_HashSkipListMemTableConfig.h"
|
2014-04-21 22:40:46 +00:00
|
|
|
#include "include/org_rocksdb_SkipListMemTableConfig.h"
|
2018-04-13 00:55:14 +00:00
|
|
|
#include "include/org_rocksdb_VectorMemTableConfig.h"
|
2014-04-21 22:40:46 +00:00
|
|
|
#include "rocksdb/memtablerep.h"
|
2022-03-01 17:02:15 +00:00
|
|
|
#include "rocksjni/cplusplus_to_java_convert.h"
|
2018-04-13 00:55:14 +00:00
|
|
|
#include "rocksjni/portal.h"
|
2014-04-21 22:40:46 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_HashSkipListMemTableConfig
|
|
|
|
* Method: newMemTableFactoryHandle
|
|
|
|
* Signature: (JII)J
|
|
|
|
*/
|
|
|
|
jlong Java_org_rocksdb_HashSkipListMemTableConfig_newMemTableFactoryHandle(
|
2018-04-13 00:55:14 +00:00
|
|
|
JNIEnv* env, jobject /*jobj*/, jlong jbucket_count, jint jheight,
|
|
|
|
jint jbranching_factor) {
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::Status s =
|
|
|
|
ROCKSDB_NAMESPACE::JniUtil::check_if_jlong_fits_size_t(jbucket_count);
|
2014-10-09 21:16:41 +00:00
|
|
|
if (s.ok()) {
|
2022-03-01 17:02:15 +00:00
|
|
|
return GET_CPLUSPLUS_POINTER(ROCKSDB_NAMESPACE::NewHashSkipListRepFactory(
|
2018-04-13 00:55:14 +00:00
|
|
|
static_cast<size_t>(jbucket_count), static_cast<int32_t>(jheight),
|
2014-10-09 21:16:41 +00:00
|
|
|
static_cast<int32_t>(jbranching_factor)));
|
|
|
|
}
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::IllegalArgumentExceptionJni::ThrowNew(env, s);
|
2014-10-09 21:16:41 +00:00
|
|
|
return 0;
|
2014-04-21 22:40:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_HashLinkedListMemTableConfig
|
|
|
|
* Method: newMemTableFactoryHandle
|
2014-10-16 18:39:26 +00:00
|
|
|
* Signature: (JJIZI)J
|
2014-04-21 22:40:46 +00:00
|
|
|
*/
|
|
|
|
jlong Java_org_rocksdb_HashLinkedListMemTableConfig_newMemTableFactoryHandle(
|
2018-04-13 00:55:14 +00:00
|
|
|
JNIEnv* env, jobject /*jobj*/, jlong jbucket_count,
|
|
|
|
jlong jhuge_page_tlb_size, jint jbucket_entries_logging_threshold,
|
2014-10-16 18:39:26 +00:00
|
|
|
jboolean jif_log_bucket_dist_when_flash, jint jthreshold_use_skiplist) {
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::Status statusBucketCount =
|
|
|
|
ROCKSDB_NAMESPACE::JniUtil::check_if_jlong_fits_size_t(jbucket_count);
|
|
|
|
ROCKSDB_NAMESPACE::Status statusHugePageTlb =
|
|
|
|
ROCKSDB_NAMESPACE::JniUtil::check_if_jlong_fits_size_t(
|
|
|
|
jhuge_page_tlb_size);
|
2014-10-16 18:39:26 +00:00
|
|
|
if (statusBucketCount.ok() && statusHugePageTlb.ok()) {
|
2022-03-01 17:02:15 +00:00
|
|
|
return GET_CPLUSPLUS_POINTER(ROCKSDB_NAMESPACE::NewHashLinkListRepFactory(
|
2014-10-16 18:39:26 +00:00
|
|
|
static_cast<size_t>(jbucket_count),
|
|
|
|
static_cast<size_t>(jhuge_page_tlb_size),
|
|
|
|
static_cast<int32_t>(jbucket_entries_logging_threshold),
|
|
|
|
static_cast<bool>(jif_log_bucket_dist_when_flash),
|
|
|
|
static_cast<int32_t>(jthreshold_use_skiplist)));
|
2014-10-09 21:16:41 +00:00
|
|
|
}
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::IllegalArgumentExceptionJni::ThrowNew(
|
2018-04-13 00:55:14 +00:00
|
|
|
env, !statusBucketCount.ok() ? statusBucketCount : statusHugePageTlb);
|
2014-10-09 21:16:41 +00:00
|
|
|
return 0;
|
2014-04-21 22:40:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_VectorMemTableConfig
|
|
|
|
* Method: newMemTableFactoryHandle
|
|
|
|
* Signature: (J)J
|
|
|
|
*/
|
|
|
|
jlong Java_org_rocksdb_VectorMemTableConfig_newMemTableFactoryHandle(
|
2018-04-13 00:55:14 +00:00
|
|
|
JNIEnv* env, jobject /*jobj*/, jlong jreserved_size) {
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::Status s =
|
|
|
|
ROCKSDB_NAMESPACE::JniUtil::check_if_jlong_fits_size_t(jreserved_size);
|
2014-10-09 21:16:41 +00:00
|
|
|
if (s.ok()) {
|
2022-03-01 17:02:15 +00:00
|
|
|
return GET_CPLUSPLUS_POINTER(new ROCKSDB_NAMESPACE::VectorRepFactory(
|
2020-02-20 20:07:53 +00:00
|
|
|
static_cast<size_t>(jreserved_size)));
|
2014-10-09 21:16:41 +00:00
|
|
|
}
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::IllegalArgumentExceptionJni::ThrowNew(env, s);
|
2014-10-09 21:16:41 +00:00
|
|
|
return 0;
|
2014-04-21 22:40:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_SkipListMemTableConfig
|
|
|
|
* Method: newMemTableFactoryHandle0
|
2014-10-16 18:39:26 +00:00
|
|
|
* Signature: (J)J
|
2014-04-21 22:40:46 +00:00
|
|
|
*/
|
|
|
|
jlong Java_org_rocksdb_SkipListMemTableConfig_newMemTableFactoryHandle0(
|
2018-04-13 00:55:14 +00:00
|
|
|
JNIEnv* env, jobject /*jobj*/, jlong jlookahead) {
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::Status s =
|
|
|
|
ROCKSDB_NAMESPACE::JniUtil::check_if_jlong_fits_size_t(jlookahead);
|
2014-10-16 18:39:26 +00:00
|
|
|
if (s.ok()) {
|
2022-03-01 17:02:15 +00:00
|
|
|
return GET_CPLUSPLUS_POINTER(new ROCKSDB_NAMESPACE::SkipListFactory(
|
2020-02-20 20:07:53 +00:00
|
|
|
static_cast<size_t>(jlookahead)));
|
2014-10-16 18:39:26 +00:00
|
|
|
}
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::IllegalArgumentExceptionJni::ThrowNew(env, s);
|
2014-10-16 18:39:26 +00:00
|
|
|
return 0;
|
2014-04-21 22:40:46 +00:00
|
|
|
}
|