alamb commented on code in PR #6096:
URL: https://github.com/apache/arrow-rs/pull/6096#discussion_r1773852333
##########
arrow-row/src/lib.rs:
##########
@@ -878,6 +914,50 @@ impl Rows {
+ self.buffer.len()
+ self.offsets.len() * std::mem::size_of::<usize>()
}
+
+ /// Create a [BinaryArray] from the [Rows] data without reallocating the
+ /// underlying bytes.
+ ///
+ ///
+ /// ```
+ /// # use std::sync::Arc;
+ /// # use std::collections::HashSet;
+ /// # use arrow_array::cast::AsArray;
+ /// # use arrow_array::StringArray;
+ /// # use arrow_row::{OwnedRow, Row, RowConverter, RowParser, SortField};
+ /// # use arrow_schema::DataType;
+ /// #
+ /// let converter =
RowConverter::new(vec![SortField::new(DataType::Utf8)]).unwrap();
+ /// let array = StringArray::from(vec!["hello", "world", "a", "a",
"hello"]);
+ /// let rows = converter.convert_columns(&[Arc::new(array)]).unwrap();
+ ///
+ /// // We can convert rows into binary format and back.
+ /// let values: Vec<OwnedRow> = rows.iter().map(|r| r.owned()).collect();
+ /// let binary = rows.try_into_binary().expect("small");
+ /// let parser = converter.parser();
+ /// let parsed: Vec<OwnedRow> =
+ /// binary.iter().flatten().map(|b| parser.parse(b).owned()).collect();
+ /// assert_eq!(values, parsed);
+ /// ```
Review Comment:
Maybe it is worth commenting here when this will return an error (aka when
the data is more than 2GB)?
##########
arrow-row/src/lib.rs:
##########
@@ -738,6 +738,42 @@ impl RowConverter {
}
}
+ /// Create a new [Rows] instance from the given binary data.
+ ///
+ /// ```
Review Comment:
I think it may also be worth adding a doc comment here about when this API
will panic (when the data passed in was invalid or empty)
--
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]