-
Notifications
You must be signed in to change notification settings - Fork 4k
[C++] Add Extend and ExtendMasked to the converter interface #8886
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,7 +52,15 @@ class Converter { | |
| return Init(pool); | ||
| } | ||
|
|
||
| virtual Status Append(InputType value) = 0; | ||
| virtual Status Append(InputType value) { return Status::NotImplemented("Append"); } | ||
|
|
||
| virtual Status Extend(InputType values, int64_t size) { | ||
| return Status::NotImplemented("Extend"); | ||
| } | ||
|
|
||
| virtual Status ExtendMasked(InputType values, InputType mask, int64_t size) { | ||
| return Status::NotImplemented("ExtendMasked"); | ||
| } | ||
|
|
||
| const std::shared_ptr<ArrayBuilder>& builder() const { return builder_; } | ||
|
|
||
|
|
@@ -294,6 +302,34 @@ class Chunker { | |
| return status; | ||
| } | ||
|
|
||
| // we could get bit smarter here since the whole batch of appendable values | ||
| // will be rejected if a capacity error is raised | ||
| Status Extend(InputType values, int64_t size) { | ||
|
Member
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. The chunker's extend wrapper is untested since we use We could improve this logic but would require details about the iteration.
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 think adding a |
||
| auto status = converter_->Extend(values, size); | ||
| if (ARROW_PREDICT_FALSE(status.IsCapacityError())) { | ||
| if (converter_->builder()->length() == 0) { | ||
| return status; | ||
| } | ||
| ARROW_RETURN_NOT_OK(FinishChunk()); | ||
| return Extend(values, size); | ||
| } | ||
| length_ += size; | ||
| return status; | ||
| } | ||
|
|
||
| Status ExtendMasked(InputType values, InputType mask, int64_t size) { | ||
| auto status = converter_->ExtendMasked(values, mask, size); | ||
| if (ARROW_PREDICT_FALSE(status.IsCapacityError())) { | ||
| if (converter_->builder()->length() == 0) { | ||
| return status; | ||
| } | ||
| ARROW_RETURN_NOT_OK(FinishChunk()); | ||
| return ExtendMasked(values, mask, size); | ||
| } | ||
| length_ += size; | ||
| return status; | ||
| } | ||
|
|
||
| Status FinishChunk() { | ||
| ARROW_ASSIGN_OR_RAISE(auto chunk, converter_->ToArray(length_)); | ||
| chunks_.push_back(chunk); | ||
|
|
||
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.
@bkietz I think we should keep both
AppendandExtendsince we wrap the converter object with theChunker, so if one implementation (like the python one) choose to useAppendthen we don't need to subclass the chunker class.