pitrou commented on code in PR #41352:
URL: https://github.com/apache/arrow/pull/41352#discussion_r1598475736
##########
cpp/src/arrow/compute/row/grouper.cc:
##########
@@ -419,6 +414,14 @@ struct GrouperImpl : public Grouper {
return std::move(impl);
}
+ Status Reset() override {
+ map_.clear();
+ offsets_.clear();
+ key_bytes_.clear();
+ num_groups_ = 0;
Review Comment:
What about `encoders_`?
##########
cpp/src/arrow/compute/row/grouper.h:
##########
@@ -109,6 +109,10 @@ class ARROW_EXPORT Grouper {
static Result<std::unique_ptr<Grouper>> Make(const std::vector<TypeHolder>&
key_types,
ExecContext* ctx =
default_exec_context());
+ /// Reset all intermidiate state, make the grouper logically as just
`Make`ed.
Review Comment:
```suggestion
/// Reset all intermediate state, make the grouper logically as just
`Make`ed.
```
##########
cpp/src/arrow/compute/row/grouper.cc:
##########
@@ -223,12 +223,11 @@ struct AnyKeysSegmenter : public BaseRowSegmenter {
AnyKeysSegmenter(const std::vector<TypeHolder>& key_types, ExecContext* ctx)
: BaseRowSegmenter(key_types),
- ctx_(ctx),
- grouper_(nullptr),
+ grouper_(Grouper::Make(key_types, ctx).ValueOrDie()),
Review Comment:
Is there a reasonable possibility that this might fail, for example due to
input types?
##########
cpp/src/arrow/compute/row/grouper.cc:
##########
@@ -595,7 +598,13 @@ struct GrouperFastImpl : public Grouper {
return std::move(impl);
}
- ~GrouperFastImpl() { map_.cleanup(); }
+ Status Reset() override {
+ rows_.Clean();
+ rows_minibatch_.Clean();
+ map_.cleanup();
+ RETURN_NOT_OK(map_.init(encode_ctx_.hardware_flags, ctx_->memory_pool()));
Review Comment:
What about `dictionaries_`, `map_equal_impl_` and `map_append_impl_`? Do
they need resetting as well?
##########
cpp/src/arrow/compute/row/grouper.cc:
##########
@@ -595,7 +598,13 @@ struct GrouperFastImpl : public Grouper {
return std::move(impl);
}
- ~GrouperFastImpl() { map_.cleanup(); }
+ Status Reset() override {
+ rows_.Clean();
+ rows_minibatch_.Clean();
+ map_.cleanup();
+ RETURN_NOT_OK(map_.init(encode_ctx_.hardware_flags, ctx_->memory_pool()));
+ return Status::OK();
Review Comment:
Can you add a DCHECK that the `temp_stack_` is empty, then?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]