pub struct Rows {
pub(crate) buffer: Vec<u8>,
pub(crate) offsets: Vec<usize>,
pub(crate) config: RowConfig,
}Expand description
A row-oriented representation of arrow data, that is normalized for comparison.
See the module level documentation and RowConverter for more details.
Fields§
§buffer: Vec<u8>Underlying row bytes
offsets: Vec<usize>Row i has data &buffer[offsets[i]..offsets[i+1]]
config: RowConfigThe config for these rows
Implementations§
Source§impl Rows
impl Rows
Sourcepub fn reserve(&mut self, row_capacity: usize, data_capacity: usize)
pub fn reserve(&mut self, row_capacity: usize, data_capacity: usize)
Reserve capacity for row_capacity rows with a total length of data_capacity
Sourcepub unsafe fn row_unchecked(&self, index: usize) -> Row<'_>
pub unsafe fn row_unchecked(&self, index: usize) -> Row<'_>
Returns the row at index without bounds checking
§Safety
Caller must ensure that index is less than the number of offsets (#rows + 1)
Sourcepub fn row_len(&self, row: usize) -> usize
pub fn row_len(&self, row: usize) -> usize
Returns the number of bytes the row at index row is occupying,
that is, what is the length of the returned Row::data will be.
Sourcepub fn lengths(&self) -> RowLengthIter<'_>
pub fn lengths(&self) -> RowLengthIter<'_>
Get an iterator over the lengths of each row in this Rows
Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Returns the size of this instance in bytes
Includes the size of Self.
Sourcepub fn try_into_binary(self) -> Result<BinaryArray, ArrowError>
pub fn try_into_binary(self) -> Result<BinaryArray, ArrowError>
Create a [BinaryArray] from the Rows data without reallocating the underlying bytes.
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("known-small array");
let parser = converter.parser();
let parsed: Vec<OwnedRow> =
binary.iter().flatten().map(|b| parser.parse(b).owned()).collect();
assert_eq!(values, parsed);§Errors
This function will return an error if there is more data than can be stored in a [BinaryArray] – i.e. if the total data size is more than 2GiB.