Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
a1e80a6e0d9c1f1c0e0b23604c241b6a704e932aa8e4c06307a80fbdce3093326d74db4f89e34f2a0c0444505dfdd981af9b13d7f9b04b76fc80175de8529c706c8dc44b542041592bfFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
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
Uh oh!There was an error while loading. Please reload this page. | ||
| 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; | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why the change back, the kInitiModuleId is what should be used for constants (also static shouldn't be required. Author There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. non-static data member cannot be constexpr Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which naming convention are you referring to? As as I know constants are generally of the form kInitModuleId (non-static members follow the convention you have here). Author There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am a little confused about the naming convention in ARROW c++. In type.h I can find a lot static constexpr members follow my current convention like "type_id" so I thought this maybe a more consistent convention? Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I think at times were weren't consistent with our own conventions. Theoretically we follow the google style guide with only a few exceptions Author There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At least for now let's follow the way like init_module_id_ to be consistent with rest of the codebase. Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I might have confused the point. Old code has both styles, New code should (and mostly does) follow the kInitModuleId style. At this point it would be counter-productive to change it back (I'd like to merge once CI passes) but in the future please use what is proscribed in the style guide. Author There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good! Thank you! | ||
| 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.
Uh oh!
There was an error while loading. Please reload this page.