fork of https://github.com/oxigraph/rocksdb and https://github.com/facebook/rocksdb for nextgraph and oxigraph
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.3 KiB
43 lines
1.3 KiB
10 years ago
|
// Copyright (c) 2014, Facebook, Inc. All rights reserved.
|
||
|
// 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::TtlDB methods.
|
||
|
// from Java side.
|
||
|
|
||
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <jni.h>
|
||
|
#include <string>
|
||
|
#include <vector>
|
||
|
|
||
|
#include "include/org_rocksdb_TtlDB.h"
|
||
|
#include "rocksjni/portal.h"
|
||
|
#include "rocksdb/utilities/db_ttl.h"
|
||
|
|
||
|
/*
|
||
|
* Class: org_rocksdb_TtlDB
|
||
|
* Method: open
|
||
|
* Signature: (JJ)V
|
||
|
*/
|
||
|
void Java_org_rocksdb_TtlDB_open(JNIEnv* env, jobject jttldb,
|
||
|
jlong joptions_handle, jstring jdb_path, jint jttl,
|
||
|
jboolean jread_only) {
|
||
|
auto opt = reinterpret_cast<rocksdb::Options*>(joptions_handle);
|
||
|
rocksdb::DBWithTTL* db = nullptr;
|
||
|
const char* db_path = env->GetStringUTFChars(jdb_path, 0);
|
||
|
rocksdb::Status s = rocksdb::DBWithTTL::Open(*opt, db_path, &db,
|
||
|
jttl, jread_only);
|
||
|
env->ReleaseStringUTFChars(jdb_path, db_path);
|
||
|
|
||
|
// as TTLDB extends RocksDB on the java side, we can reuse
|
||
|
// the RocksDB portal here.
|
||
|
if (s.ok()) {
|
||
|
rocksdb::RocksDBJni::setHandle(env, jttldb, db);
|
||
|
return;
|
||
|
}
|
||
|
rocksdb::RocksDBExceptionJni::ThrowNew(env, s);
|
||
|
}
|