-
Notifications
You must be signed in to change notification settings - Fork 919
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…0380) Fixes #9109. This commit adds a `map` abstraction over a `column_view` of type `LIST<STRUCT<K,V>>`, where `K` and `V` are key and value types. A list column of structs with two members may thus be viewed as a `map` column. `maps_column_view` is to a `LIST<STRUCT<K,V>>` column what `lists_column_view` is to a `LIST` column. The `maps_column_view` abstraction provides methods to fetch lists of keys and values (as `LIST<K>` and `LIST<V>` respectively). It also provides map lookup methods to find the values corresponding to a specified key, for each row in the "map" column. E.g. ```c++ auto input_column = get_list_of_structs_col(); // input_column == [ {1:10, 2:20}, {1:100, 3:300}, {2:2000, 3:3000, 4:4000} ]; auto maps_view = cudf::jni::maps_column_view{input_column->view()}; auto keys = maps_view.keys(); // keys == [ {1,2}, {1,3}, {2,3,4} ]; auto values = maps_view.values(); // values == [ {10,20}, {100, 300}, {2000, 3000, 4000} ]; auto lookup_1 = maps_view.get_values_for( *make_numeric_scalar(1) ); // lookup_1 = [ {10, 100, null} ]; ``` This abstraction should help replace the Java/JNI `map_lookup` and `map_contains` kernels, which only handles `MAP<STRING, STRING>`. Authors: - MithunR (https://github.com/mythrocks) Approvers: - Jason Lowe (https://github.com/jlowe) - AJ Schmidt (https://github.com/ajschmidt8) - Nghia Truong (https://github.com/ttnghia) - Jake Hemstad (https://github.com/jrhemstad) URL: #10380
- Loading branch information
Showing
11 changed files
with
495 additions
and
66 deletions.
There are no files selected for viewing
This file contains 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 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,78 @@ | ||
/* | ||
* Copyright (c) 2022, 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. | ||
*/ | ||
#pragma once | ||
|
||
#include <cudf/lists/contains.hpp> | ||
#include <cudf/lists/lists_column_view.hpp> | ||
|
||
namespace cudf { | ||
namespace lists { | ||
namespace detail { | ||
|
||
/** | ||
* @copydoc cudf::lists::index_of(cudf::lists_column_view const&, | ||
* cudf::scalar const&, | ||
* duplicate_find_option, | ||
* rmm::mr::device_memory_resource*) | ||
* @param stream CUDA stream used for device memory operations and kernel launches. | ||
*/ | ||
std::unique_ptr<column> index_of( | ||
cudf::lists_column_view const& lists, | ||
cudf::scalar const& search_key, | ||
cudf::lists::duplicate_find_option find_option, | ||
rmm::cuda_stream_view stream, | ||
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); | ||
|
||
/** | ||
* @copydoc cudf::lists::index_of(cudf::lists_column_view const&, | ||
* cudf::column_view const&, | ||
* duplicate_find_option, | ||
* rmm::mr::device_memory_resource*) | ||
* @param stream CUDA stream used for device memory operations and kernel launches. | ||
*/ | ||
std::unique_ptr<column> index_of( | ||
cudf::lists_column_view const& lists, | ||
cudf::column_view const& search_keys, | ||
cudf::lists::duplicate_find_option find_option, | ||
rmm::cuda_stream_view stream, | ||
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); | ||
|
||
/** | ||
* @copydoc cudf::lists::contains(cudf::lists_column_view const&, | ||
* cudf::scalar const&, | ||
* rmm::mr::device_memory_resource*) | ||
* @param stream CUDA stream used for device memory operations and kernel launches. | ||
*/ | ||
std::unique_ptr<column> contains( | ||
cudf::lists_column_view const& lists, | ||
cudf::scalar const& search_key, | ||
rmm::cuda_stream_view stream, | ||
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); | ||
|
||
/** | ||
* @copydoc cudf::lists::contains(cudf::lists_column_view const&, | ||
* cudf::column_view const&, | ||
* rmm::mr::device_memory_resource*) | ||
* @param stream CUDA stream used for device memory operations and kernel launches. | ||
*/ | ||
std::unique_ptr<column> contains( | ||
cudf::lists_column_view const& lists, | ||
cudf::column_view const& search_keys, | ||
rmm::cuda_stream_view stream, | ||
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); | ||
} // namespace detail | ||
} // namespace lists | ||
} // namespace cudf |
This file contains 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,49 @@ | ||
/* | ||
* Copyright (c) 2022, 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. | ||
*/ | ||
#pragma once | ||
|
||
#include <cudf/lists/extract.hpp> | ||
#include <cudf/lists/lists_column_view.hpp> | ||
|
||
namespace cudf { | ||
namespace lists { | ||
namespace detail { | ||
|
||
/** | ||
* @copydoc cudf::lists::extract_list_element(lists_column_view, size_type, | ||
* rmm::mr::device_memory_resource*) | ||
* @param stream CUDA stream used for device memory operations and kernel launches. | ||
*/ | ||
std::unique_ptr<column> extract_list_element( | ||
lists_column_view lists_column, | ||
size_type const index, | ||
rmm::cuda_stream_view stream, | ||
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); | ||
|
||
/** | ||
* @copydoc cudf::lists::extract_list_element(lists_column_view, column_view const&, | ||
* rmm::mr::device_memory_resource*) | ||
* @param stream CUDA stream used for device memory operations and kernel launches. | ||
*/ | ||
std::unique_ptr<column> extract_list_element( | ||
lists_column_view lists_column, | ||
column_view const& indices, | ||
rmm::cuda_stream_view stream, | ||
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); | ||
|
||
} // namespace detail | ||
} // namespace lists | ||
} // namespace cudf |
This file contains 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 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 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 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
Oops, something went wrong.