-
Notifications
You must be signed in to change notification settings - Fork 917
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
[REVIEW] Add COLLECT
groupby aggregation
#5874
Merged
Merged
Changes from 30 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
a6664fb
Add group_collect groupby aggregation
shwina b532d0b
Need only grouped_values(), not sorted_values() for a collect
shwina e81f18a
Add group collect tests
shwina d182833
Collect() is the only supported agg for lists
shwina 4e2e040
Merge branch 'branch-0.15' of https://github.com/rapidsai/cudf into g…
shwina 46544fe
Fix is_numerical_dtype to check for categoricals and lists first
shwina d0672b7
Merge branch 'branch-0.15' of https://github.com/rapidsai/cudf into g…
shwina 0819151
Merge branch 'branch-0.16' of https://github.com/rapidsai/cudf into g…
shwina b61ae7d
Add and pass first groupby-list pytest
shwina 3f39b02
Remove stale files
shwina a344d53
Duplicate changelog entry
shwina 63cedea
More groupby-list tests
shwina 6ec72ad
Doc
shwina 6fa14de
Changelog
shwina 901e6e7
Merge branch 'branch-0.16' of https://github.com/rapidsai/cudf into g…
shwina 8465d4a
Undo unintended changelog change
shwina 566ff58
Merge branch 'branch-0.16' of https://github.com/rapidsai/cudf into g…
shwina fd42010
Fix group collect tests
shwina bb923cc
Additional groupby collect testing
shwina 94f0e35
Update cpp/src/aggregation/aggregation.cpp
shwina 8cdcdd4
Update cpp/src/groupby/sort/group_collect.cu
shwina de79a05
Update cpp/src/groupby/sort/group_collect.cu
shwina d610e89
Don't reference group_labels
shwina fd51b06
Merge branch 'groupby-collect' of github.com:shwina/cudf into groupby…
shwina 48ebc07
We are collecting, not summing
shwina c657fce
ROW->COLLECT
shwina 87f1ed1
Merge branch 'branch-0.16' into groupby-collect
shwina e9ce1b0
Update cpp/src/groupby/sort/group_collect.cu
shwina bf942af
Construct and pass empty null mask directly
shwina 5008f9b
Merge branch 'groupby-collect' of github.com:shwina/cudf into groupby…
shwina 6e1531e
Merge branch 'branch-0.16' of https://github.com/rapidsai/cudf into g…
shwina 5259dee
Fix dtype arg to column constructor
shwina 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 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
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,48 @@ | ||
/* | ||
* Copyright (c) 2020, 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_factories.hpp> | ||
#include <cudf/column/column_view.hpp> | ||
#include <cudf/detail/aggregation/aggregation.hpp> | ||
#include <cudf/detail/gather.cuh> | ||
#include <cudf/types.hpp> | ||
|
||
namespace cudf { | ||
namespace groupby { | ||
namespace detail { | ||
std::unique_ptr<column> group_collect(column_view const &values, | ||
rmm::device_vector<size_type> const &group_offsets, | ||
size_type num_groups, | ||
rmm::mr::device_memory_resource *mr, | ||
cudaStream_t stream) | ||
{ | ||
rmm::device_buffer offsets_data( | ||
group_offsets.data().get(), group_offsets.size() * sizeof(cudf::size_type), stream, mr); | ||
|
||
auto offsets = std::make_unique<cudf::column>( | ||
cudf::type_to_id<size_type>, num_groups + 1, std::move(offsets_data)); | ||
|
||
return make_lists_column(num_groups, | ||
std::move(offsets), | ||
std::make_unique<cudf::column>(values, stream, mr), | ||
0, | ||
rmm::device_buffer{0, stream, mr}, | ||
stream, | ||
mr); | ||
} | ||
} // namespace detail | ||
} // namespace groupby | ||
} // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Copyright (c) 2020, 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 <tests/groupby/groupby_test_util.hpp> | ||
|
||
#include <tests/utilities/base_fixture.hpp> | ||
#include <tests/utilities/column_wrapper.hpp> | ||
#include <tests/utilities/type_lists.hpp> | ||
|
||
#include <cudf/detail/aggregation/aggregation.hpp> | ||
|
||
namespace cudf { | ||
namespace test { | ||
|
||
template <typename V> | ||
struct groupby_collect_test : public cudf::test::BaseFixture { | ||
}; | ||
|
||
using FixedWidthTypesNotBool = cudf::test::Concat<cudf::test::IntegralTypesNotBool, | ||
cudf::test::FloatingPointTypes, | ||
cudf::test::TimestampTypes>; | ||
TYPED_TEST_CASE(groupby_collect_test, FixedWidthTypesNotBool); | ||
|
||
TYPED_TEST(groupby_collect_test, CollectWithoutNulls) | ||
{ | ||
using K = int32_t; | ||
using V = TypeParam; | ||
|
||
fixed_width_column_wrapper<K, int32_t> keys{1, 1, 1, 2, 2, 2}; | ||
fixed_width_column_wrapper<V, int32_t> values{1, 2, 3, 4, 5, 6}; | ||
|
||
fixed_width_column_wrapper<K, int32_t> expect_keys{1, 2}; | ||
lists_column_wrapper<V, int32_t> expect_vals{{1, 2, 3}, {4, 5, 6}}; | ||
|
||
auto agg = cudf::make_collect_aggregation(); | ||
test_single_agg(keys, values, expect_keys, expect_vals, std::move(agg)); | ||
} | ||
|
||
TYPED_TEST(groupby_collect_test, CollectWithNulls) | ||
{ | ||
using K = int32_t; | ||
using V = TypeParam; | ||
|
||
fixed_width_column_wrapper<K, int32_t> keys{1, 1, 2, 2, 3, 3}; | ||
fixed_width_column_wrapper<V, int32_t> values{{1, 2, 3, 4, 5, 6}, | ||
{true, false, true, false, true, false}}; | ||
|
||
fixed_width_column_wrapper<K, int32_t> expect_keys{1, 2, 3}; | ||
|
||
std::vector<int32_t> validity({true, false}); | ||
lists_column_wrapper<V, int32_t> expect_vals{ | ||
{{1, 2}, validity.begin()}, {{3, 4}, validity.begin()}, {{5, 6}, validity.begin()}}; | ||
|
||
auto agg = cudf::make_collect_aggregation(); | ||
test_single_agg(keys, values, expect_keys, expect_vals, std::move(agg)); | ||
} | ||
|
||
TYPED_TEST(groupby_collect_test, CollectLists) | ||
{ | ||
using K = int32_t; | ||
using V = TypeParam; | ||
|
||
using LCW = cudf::test::lists_column_wrapper<TypeParam, int32_t>; | ||
|
||
fixed_width_column_wrapper<K, int32_t> keys{1, 1, 2, 2, 3, 3}; | ||
lists_column_wrapper<V, int32_t> values{{1, 2}, {3, 4}, {5, 6, 7}, LCW{}, {9, 10}, {11}}; | ||
|
||
fixed_width_column_wrapper<K, int32_t> expect_keys{1, 2, 3}; | ||
|
||
lists_column_wrapper<V, int32_t> expect_vals{ | ||
{{1, 2}, {3, 4}}, {{5, 6, 7}, LCW{}}, {{9, 10}, {11}}}; | ||
|
||
auto agg = cudf::make_collect_aggregation(); | ||
test_single_agg(keys, values, expect_keys, expect_vals, std::move(agg)); | ||
} | ||
|
||
} // namespace test | ||
} // 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this actually needed? The
target_type
logic is for determining the type to use for an accumulator for ops like sum/min/max. I wouldn't think it would be needed forCOLLECT
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes -- otherwise we fail this check: https://github.com/rapidsai/cudf/blob/branch-0.16/cpp/src/groupby/groupby.cu#L102
which eventually calls:
cudf/cpp/include/cudf/detail/aggregation/aggregation.hpp
Line 528 in 5fbffb6