2016-02-09 23:12:00 +00:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2014-06-06 00:09:25 +00:00
|
|
|
// This source code is licensed under the BSD-style license found in the
|
|
|
|
// LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
// of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
//
|
|
|
|
// This file implements the "bridge" between Java and C++ and enables
|
|
|
|
// calling c++ rocksdb::Env methods from Java side.
|
|
|
|
|
2015-03-22 17:30:51 +00:00
|
|
|
#include "include/org_rocksdb_Env.h"
|
2014-06-06 00:09:25 +00:00
|
|
|
#include "include/org_rocksdb_RocksEnv.h"
|
2015-03-22 17:30:51 +00:00
|
|
|
#include "include/org_rocksdb_RocksMemEnv.h"
|
2014-06-06 00:09:25 +00:00
|
|
|
#include "rocksdb/env.h"
|
|
|
|
|
|
|
|
/*
|
2015-03-22 17:30:51 +00:00
|
|
|
* Class: org_rocksdb_Env
|
2014-06-06 00:09:25 +00:00
|
|
|
* Method: getDefaultEnvInternal
|
|
|
|
* Signature: ()J
|
|
|
|
*/
|
2015-03-22 17:30:51 +00:00
|
|
|
jlong Java_org_rocksdb_Env_getDefaultEnvInternal(
|
2014-11-06 22:12:36 +00:00
|
|
|
JNIEnv* env, jclass jclazz) {
|
2014-06-06 00:09:25 +00:00
|
|
|
return reinterpret_cast<jlong>(rocksdb::Env::Default());
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2015-03-22 17:30:51 +00:00
|
|
|
* Class: org_rocksdb_Env
|
2014-06-06 00:09:25 +00:00
|
|
|
* Method: setBackgroundThreads
|
|
|
|
* Signature: (JII)V
|
|
|
|
*/
|
2015-03-22 17:30:51 +00:00
|
|
|
void Java_org_rocksdb_Env_setBackgroundThreads(
|
2014-06-06 00:09:25 +00:00
|
|
|
JNIEnv* env, jobject jobj, jlong jhandle,
|
|
|
|
jint num, jint priority) {
|
|
|
|
auto* rocks_env = reinterpret_cast<rocksdb::Env*>(jhandle);
|
|
|
|
switch (priority) {
|
2015-03-22 17:30:51 +00:00
|
|
|
case org_rocksdb_Env_FLUSH_POOL:
|
2014-06-06 00:09:25 +00:00
|
|
|
rocks_env->SetBackgroundThreads(num, rocksdb::Env::Priority::LOW);
|
|
|
|
break;
|
2015-03-22 17:30:51 +00:00
|
|
|
case org_rocksdb_Env_COMPACTION_POOL:
|
2014-06-06 00:09:25 +00:00
|
|
|
rocks_env->SetBackgroundThreads(num, rocksdb::Env::Priority::HIGH);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2015-03-22 17:30:51 +00:00
|
|
|
* Class: org_rocksdb_sEnv
|
2014-06-06 00:09:25 +00:00
|
|
|
* Method: getThreadPoolQueueLen
|
|
|
|
* Signature: (JI)I
|
|
|
|
*/
|
2015-03-22 17:30:51 +00:00
|
|
|
jint Java_org_rocksdb_Env_getThreadPoolQueueLen(
|
2014-06-06 00:09:25 +00:00
|
|
|
JNIEnv* env, jobject jobj, jlong jhandle, jint pool_id) {
|
|
|
|
auto* rocks_env = reinterpret_cast<rocksdb::Env*>(jhandle);
|
|
|
|
switch (pool_id) {
|
|
|
|
case org_rocksdb_RocksEnv_FLUSH_POOL:
|
|
|
|
return rocks_env->GetThreadPoolQueueLen(rocksdb::Env::Priority::LOW);
|
|
|
|
case org_rocksdb_RocksEnv_COMPACTION_POOL:
|
|
|
|
return rocks_env->GetThreadPoolQueueLen(rocksdb::Env::Priority::HIGH);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2015-03-22 17:30:51 +00:00
|
|
|
* Class: org_rocksdb_RocksMemEnv
|
|
|
|
* Method: createMemEnv
|
|
|
|
* Signature: ()J
|
|
|
|
*/
|
|
|
|
jlong Java_org_rocksdb_RocksMemEnv_createMemEnv(
|
|
|
|
JNIEnv* env, jclass jclazz) {
|
|
|
|
return reinterpret_cast<jlong>(rocksdb::NewMemEnv(
|
|
|
|
rocksdb::Env::Default()));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_RocksMemEnv
|
2014-06-06 00:09:25 +00:00
|
|
|
* Method: disposeInternal
|
|
|
|
* Signature: (J)V
|
|
|
|
*/
|
2015-03-22 17:30:51 +00:00
|
|
|
void Java_org_rocksdb_RocksMemEnv_disposeInternal(
|
2014-06-06 00:09:25 +00:00
|
|
|
JNIEnv* env, jobject jobj, jlong jhandle) {
|
|
|
|
delete reinterpret_cast<rocksdb::Env*>(jhandle);
|
|
|
|
}
|