-
Notifications
You must be signed in to change notification settings - Fork 1k
JNI: Function to copy and set validity from bool column. #9901
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /* | ||
| * Copyright (c) 2021, NVIDIA CORPORATION. | ||
| * | ||
| * Licensed 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 <cudf/column/column_device_view.cuh> | ||
| #include <cudf/detail/iterator.cuh> | ||
| #include <cudf/detail/valid_if.cuh> | ||
|
|
||
| #include "ColumnViewJni.hpp" | ||
|
|
||
| namespace cudf::jni { | ||
|
|
||
| std::unique_ptr<cudf::column> | ||
| new_column_with_boolean_column_as_validity(cudf::column_view const &exemplar, | ||
| cudf::column_view const &validity_column) { | ||
| CUDF_EXPECTS(validity_column.type().id() == type_id::BOOL8, | ||
| "Validity column must be of type bool"); | ||
| CUDF_EXPECTS(validity_column.size() == exemplar.size(), | ||
| "Exemplar and validity columns must have the same size"); | ||
|
|
||
| auto validity_device_view = cudf::column_device_view::create(validity_column); | ||
| auto validity_begin = cudf::detail::make_optional_iterator<bool>( | ||
| *validity_device_view, cudf::nullate::DYNAMIC{validity_column.has_nulls()}); | ||
| auto validity_end = validity_begin + validity_device_view->size(); | ||
| auto [null_mask, null_count] = | ||
| cudf::detail::valid_if(validity_begin, validity_end, [] __device__(auto optional_bool) { | ||
| return optional_bool.value_or(false); | ||
| }); | ||
| auto const exemplar_without_null_mask = cudf::column_view{ | ||
| exemplar.type(), | ||
| exemplar.size(), | ||
| exemplar.head<void>(), | ||
| nullptr, | ||
| 0, | ||
| exemplar.offset(), | ||
| std::vector<cudf::column_view>{exemplar.child_begin(), exemplar.child_end()}}; | ||
| auto deep_copy = std::make_unique<cudf::column>(exemplar_without_null_mask); | ||
| deep_copy->set_null_mask(std::move(null_mask), null_count); | ||
| return deep_copy; | ||
| } | ||
|
|
||
| } // namespace cudf::jni | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * Copyright (c) 2021, NVIDIA CORPORATION. | ||
| * | ||
| * Licensed 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 <cudf/column/column.hpp> | ||
|
|
||
| namespace cudf::jni { | ||
|
|
||
| /** | ||
| * @brief Creates a deep copy of the exemplar column, with its validity set to the equivalent | ||
| * of the boolean `validity` column's value. | ||
| * | ||
| * The bool_column must have the same number of rows as the exemplar column. | ||
| * The result column will have the same number of rows as the exemplar. | ||
| * For all indices `i` where the boolean column is `true`, the result column will have a valid value | ||
| * at index i. For all other values (i.e. `false` or `null`), the result column will have nulls. | ||
| * | ||
| * @param exemplar The column to be deep copied. | ||
| * @param bool_column bool column whose value is to be used as the validity. | ||
| * @return Deep copy of the exemplar, with the replaced validity. | ||
| */ | ||
| std::unique_ptr<cudf::column> | ||
| new_column_with_boolean_column_as_validity(cudf::column_view const &exemplar, | ||
| cudf::column_view const &bool_column); | ||
|
|
||
| } // namespace cudf::jni |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.