kou commented on code in PR #37970:
URL: https://github.com/apache/arrow/pull/37970#discussion_r1344878886
##########
cpp/src/arrow/ipc/reader.h:
##########
@@ -425,6 +425,37 @@ class ARROW_EXPORT StreamDecoder {
/// \return Status
Status Consume(std::shared_ptr<Buffer> buffer);
+ /// \brief Reset the internal status.
+ ///
+ /// You can reuse this decoder for new stream after calling
+ /// this. For example, you can implement endless decoder with this:
Review Comment:
OK. I'll remove this example.
See #37429 for a use case of the endless decoder. It reads multiple streams
with one decoder instance.
FYI: We can implement the use case by using `next_required_size()` instead
but we need to recreate decoder instances manually:
```cpp
while (true) {
auto buffer = get_data(decoder->next_required_size());
if (!buffer) {
break;
}
decoder->Consume(buffer);
if (listener->status() == EOS) {
decoder = create_decoder(listener);
}
}
```
##########
cpp/src/arrow/ipc/reader.cc:
##########
@@ -2032,6 +2036,11 @@ Status StreamDecoder::Consume(const uint8_t* data,
int64_t size) {
Status StreamDecoder::Consume(std::shared_ptr<Buffer> buffer) {
return impl_->Consume(std::move(buffer));
}
+Status StreamDecoder::Reset() {
+ impl_ =
+ std::make_unique<StreamDecoderImpl>(std::move(impl_->listener()),
impl_->options());
Review Comment:
Oh, sorry. I'll remove it.
--
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]