jecsand838 commented on code in PR #9171:
URL: https://github.com/apache/arrow-rs/pull/9171#discussion_r2724706064
##########
arrow-avro/src/writer/mod.rs:
##########
@@ -322,25 +295,23 @@ impl EncodedRows {
/// let schema = Schema::new(vec![Field::new("x", DataType::Int32,
false)]);
/// let batch = RecordBatch::try_new(
/// Arc::new(schema.clone()),
- /// vec![Arc::new(Int32Array::from(vec![100])) as ArrayRef],
+ /// vec![Arc::new(Int32Array::from(vec![10, 20])) as ArrayRef],
/// )?;
///
/// let mut encoder =
WriterBuilder::new(schema).build_encoder::<AvroSoeFormat>()?;
/// encoder.encode(&batch)?;
/// let rows = encoder.flush();
///
- /// let vecs = rows.to_vecs()?;
- /// assert_eq!(vecs.len(), 1);
- /// assert!(!vecs[0].is_empty());
+ /// assert_eq!(rows.iter().count(), 2);
/// # Ok(())
/// # }
/// ```
- pub fn to_vecs(&self) -> Result<Vec<Vec<u8>>, ArrowError> {
- let mut out = Vec::with_capacity(self.len());
- for i in 0..self.len() {
- out.push(self.row(i)?.to_vec());
- }
- Ok(out)
+ #[inline]
+ pub fn iter(&self) -> impl ExactSizeIterator<Item = Bytes> + '_ {
+ self.offsets.windows(2).map(|w| {
+ debug_assert!(w[0] <= w[1] && w[1] <= self.data.len());
+ self.data.slice(w[0]..w[1])
Review Comment:
Ah yes, you are correct. I went ahead and removed the extra debug assert.
--
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]