Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ljz2051 committed Mar 19, 2024
1 parent 78476cc commit e950ff5
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 19 deletions.
2 changes: 2 additions & 0 deletions java/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ set(JAVA_MAIN_CLASSES
src/main/java/org/rocksdb/Filter.java
src/main/java/org/rocksdb/FileOperationInfo.java
src/main/java/org/rocksdb/FlinkCompactionFilter.java
src/main/java/org/rocksdb/FlinkEnv.java
src/main/java/org/rocksdb/FlushJobInfo.java
src/main/java/org/rocksdb/FlushReason.java
src/main/java/org/rocksdb/FlushOptions.java
Expand Down Expand Up @@ -460,6 +461,7 @@ if(${CMAKE_VERSION} VERSION_LESS "3.11.4")
org.rocksdb.EnvOptions
org.rocksdb.Filter
org.rocksdb.FlinkCompactionFilter
org.rocksdb.FlinkEnv
org.rocksdb.FlushOptions
org.rocksdb.HashLinkedListMemTableConfig
org.rocksdb.HashSkipListMemTableConfig
Expand Down
32 changes: 21 additions & 11 deletions java/rocksjni/env_flink.cc
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
// 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).
//
// This file implements the "bridge" between Java and C++ and enables
// calling c++ ROCKSDB_NAMESPACE::Env methods from Java side.
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "env/flink/env_flink.h"

Expand All @@ -21,17 +31,17 @@
* Signature: (Ljava/lang/String;)J
*/
jlong Java_org_rocksdb_FlinkEnv_createFlinkEnv(JNIEnv* env, jclass,
jstring j_fs_name) {
jstring base_path) {
jboolean has_exception = JNI_FALSE;
auto fs_name =
ROCKSDB_NAMESPACE::JniUtil::copyStdString(env, j_fs_name, &has_exception);
auto path =
ROCKSDB_NAMESPACE::JniUtil::copyStdString(env, base_path, &has_exception);
if (has_exception == JNI_TRUE) {
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(
env, "Could not copy jstring to std::string");
return 0;
}
std::unique_ptr<ROCKSDB_NAMESPACE::Env> flink_env;
auto status = ROCKSDB_NAMESPACE::NewFlinkEnv(fs_name, &flink_env);
auto status = ROCKSDB_NAMESPACE::NewFlinkEnv(path, &flink_env);
if (!status.ok()) {
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, status);
return 0;
Expand Down
30 changes: 22 additions & 8 deletions java/src/main/java/org/rocksdb/FlinkEnv.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
// 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).
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.rocksdb;

Expand All @@ -15,13 +28,14 @@ public class FlinkEnv extends Env {
* <p>The caller must delete the result when it is
* no longer needed.</p>
*
* @param fsName the filesystem name as a string in the form "flink://hostname:port/"
* @param basePath the base path string for the given Flink file system,
* formatted as "{fs-schema-supported-by-flink}://xxx"
*/
public FlinkEnv(final String fsName) {
super(createFlinkEnv(fsName));
public FlinkEnv(final String basePath) {
super(createFlinkEnv(basePath));
}

private static native long createFlinkEnv(final String fsName);
private static native long createFlinkEnv(final String basePath);

@Override protected final native void disposeInternal(final long handle);
}

0 comments on commit e950ff5

Please sign in to comment.