-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-4714: [C++][JAVA] Providing JNI interface to Read ORC file via Arrow C++ #4348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a1e80a6
e0d9c1f
1c0e0b2
3604c24
1b6a704
e932aa8
e4c0630
7a80fbd
ce30933
26d74db
4f89e34
f2a0c04
44505df
dd981af
9b13d7f
9b04b76
fc80175
de8529c
706c8dc
44b5420
41592bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,6 +77,7 @@ def lint_file(path): | |
| arrow/visitor_inline.h | ||
| gandiva/cache.h | ||
| gandiva/jni | ||
| jni/ | ||
| test | ||
| internal''') | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # 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. | ||
|
|
||
| # | ||
| # arrow_jni | ||
| # | ||
|
|
||
| if(ARROW_ORC) | ||
| add_subdirectory(orc) | ||
| endif() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # 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. | ||
|
|
||
| # | ||
| # arrow_orc_jni | ||
| # | ||
|
|
||
| project(arrow_orc_jni) | ||
|
|
||
| cmake_minimum_required(VERSION 3.11) | ||
|
|
||
| find_package(JNI REQUIRED) | ||
|
|
||
| add_custom_target(arrow_orc_jni) | ||
|
|
||
| set(JNI_HEADERS_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated") | ||
|
|
||
| add_subdirectory(../../../../java/adapter/orc ./java) | ||
|
|
||
| set(ARROW_BUILD_STATIC OFF) | ||
|
|
||
| add_arrow_lib(arrow_orc_jni | ||
| BUILD_SHARED | ||
| SOURCES | ||
| jni_wrapper.cpp | ||
| OUTPUTS | ||
| ARROW_ORC_JNI_LIBRARIES | ||
| SHARED_PRIVATE_LINK_LIBS | ||
| arrow_static | ||
| EXTRA_INCLUDES | ||
| ${JNI_HEADERS_DIR} | ||
| PRIVATE_INCLUDES | ||
| ${JNI_INCLUDE_DIRS} | ||
| ${CMAKE_CURRENT_BINARY_DIR} | ||
| DEPENDENCIES | ||
| arrow_static | ||
| arrow_orc_java | ||
| OUTPUT_PATH | ||
| ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
|
||
| add_dependencies(arrow_orc_jni ${ARROW_ORC_JNI_LIBRARIES}) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /* | ||
| * 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 | ||
| */ | ||
|
|
||
| #ifndef JNI_ID_TO_MODULE_MAP_H | ||
| #define JNI_ID_TO_MODULE_MAP_H | ||
|
|
||
| #include <memory> | ||
| #include <mutex> | ||
| #include <unordered_map> | ||
| #include <utility> | ||
|
|
||
| #include "arrow/util/macros.h" | ||
|
|
||
| namespace arrow { | ||
| namespace jni { | ||
|
|
||
| /** | ||
| * An utility class that map module id to module pointers. | ||
| * @tparam Holder class of the object to hold. | ||
| */ | ||
| template <typename Holder> | ||
| class ConcurrentMap { | ||
| public: | ||
| ConcurrentMap() : module_id_(init_module_id_) {} | ||
|
|
||
| jlong Insert(Holder holder) { | ||
| std::lock_guard<std::mutex> lock(mtx_); | ||
| jlong result = module_id_++; | ||
| map_.insert(std::pair<jlong, Holder>(result, holder)); | ||
| return result; | ||
| } | ||
|
|
||
| void Erase(jlong module_id) { | ||
| std::lock_guard<std::mutex> lock(mtx_); | ||
| map_.erase(module_id); | ||
| } | ||
|
|
||
| Holder Lookup(jlong module_id) { | ||
| std::lock_guard<std::mutex> lock(mtx_); | ||
yuruiz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| auto it = map_.find(module_id); | ||
| if (it != map_.end()) { | ||
| return it->second; | ||
| } | ||
| return NULLPTR; | ||
| } | ||
|
|
||
| void Clear() { | ||
| std::lock_guard<std::mutex> lock(mtx_); | ||
| map_.clear(); | ||
| } | ||
|
|
||
| private: | ||
| // Initialize the module id starting value to a number greater than zero | ||
| // to allow for easier debugging of uninitialized java variables. | ||
| static constexpr int init_module_id_ = 4; | ||
|
||
|
|
||
| int64_t module_id_; | ||
| std::mutex mtx_; | ||
| // map from module ids returned to Java and module pointers | ||
| std::unordered_map<jlong, Holder> map_; | ||
| }; | ||
|
|
||
| } // namespace jni | ||
| } // namespace arrow | ||
|
|
||
| #endif // JNI_ID_TO_MODULE_MAP_H | ||
Uh oh!
There was an error while loading. Please reload this page.