Skip to content

Commit dad28e5

Browse files
committed
Add JNI binding
1 parent 240069d commit dad28e5

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

java/rocksjni/ribbon_filter.cc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
#include <jni.h>
7+
8+
#include "include/org_rocksdb_RibbonFilter.h"
9+
#include "rocksdb/filter_policy.h"
10+
#include "rocksjni/cplusplus_to_java_convert.h"
11+
12+
/*
13+
* Class: org_rocksdb_RibbonFilter
14+
* Method: createNewRibbonFilter
15+
* Signature: (DI)J
16+
*/
17+
jlong Java_org_rocksdb_RibbonFilter_createNewRibbonFilter(
18+
JNIEnv* /*env*/, jclass /*jcls*/, jdouble jbits_per_key,
19+
jint jbloom_before_level) {
20+
auto* filter_policy =
21+
new std::shared_ptr<const ROCKSDB_NAMESPACE::FilterPolicy>(
22+
ROCKSDB_NAMESPACE::NewRibbonFilterPolicy(
23+
static_cast<double>(jbits_per_key),
24+
static_cast<int>(jbloom_before_level)));
25+
return GET_CPLUSPLUS_POINTER(filter_policy);
26+
}

0 commit comments

Comments
 (0)