scovich commented on code in PR #7092:
URL: https://github.com/apache/arrow-rs/pull/7092#discussion_r1945502698
##########
arrow-json/src/reader/tape.rs:
##########
@@ -545,6 +545,16 @@ impl TapeDecoder {
Ok(())
}
+ /// The number of buffered rows, including the partially decoded row (if
any).
+ pub fn num_buffered_rows(&self) -> usize {
Review Comment:
For whatever reason, `TapeDecoder` seems to call them "rows" while `Decoder`
calls them "records" so I named the new methods to match.
##########
arrow-json/src/reader/mod.rs:
##########
@@ -615,11 +615,27 @@ impl Decoder {
self.tape_decoder.serialize(rows)
}
+ /// True if the decoder is currently part way through decoding a record.
+ pub fn has_partial_record(&self) -> bool {
+ self.tape_decoder.has_partial_row()
+ }
+
+ /// The number of unflushed records, including the partially decoded
record (if any).
+ pub fn len(&self) -> usize {
+ self.tape_decoder.num_buffered_rows()
+ }
+
+ /// True if there are no records to flush, i.e. [`len`] is zero.
+ pub fn is_empty(&self) -> bool {
Review Comment:
Clippy prefers `is_empty()` over `len() == 0`, so I added both methods. I
debated just exposing `num_buffered_records` instead, but len+is_empty seemed
more rustic.
Happy to adjust the approach based on feedback.
--
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]