pub struct StrBuffer { /* private fields */ }Expand description
A contiguous UTF-8 string column buffer (Arrow LargeUtf8: i64 offsets).
Implementations§
Source§impl StrBuffer
impl StrBuffer
Sourcepub fn from_buffers(offsets: Buffer<i64>, data: Buffer<u8>) -> Self
pub fn from_buffers(offsets: Buffer<i64>, data: Buffer<u8>) -> Self
Zero-copy from foreign Arrow LargeUtf8 buffers (offsets + data + their guard).
Sourcepub fn buffers(&self) -> (&Buffer<i64>, &Buffer<u8>)
pub fn buffers(&self) -> (&Buffer<i64>, &Buffer<u8>)
The raw offset / data buffers (for a zero-copy Arrow export).
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn get(&self, i: usize) -> &str
pub fn get(&self, i: usize) -> &str
Cell i as &str (a borrow into the data buffer). Bounds-checked.
Sourcepub unsafe fn get_unchecked(&self, i: usize) -> &str
pub unsafe fn get_unchecked(&self, i: usize) -> &str
Cell i as &str, without bounds checks — the zero-overhead accessor for
the internal hot kernels (compare / sort / scan), mirroring arrow-rs
GenericStringArray::value_unchecked.
§Safety
i < self.len(). The offsets are a structural invariant — monotonic with
offsets[len] == data.len() — so i < len makes both offset reads and the
[s..e] data span in bounds; only the redundant checks are elided.
Sourcepub fn iter(&self) -> impl Iterator<Item = &str> + '_
pub fn iter(&self) -> impl Iterator<Item = &str> + '_
Iterate the cells as &str. The two backing slices are resolved once (a
single Buffer match each, hoisted out of the walk), then indexed without
bounds checks — so a sequential scan is one tight loop, matching a &[String]
walk with no per-element overhead.
Sourcepub fn to_vec(&self) -> Vec<String>
pub fn to_vec(&self) -> Vec<String>
Materialize owned Strings (only where a Vec<String> is genuinely needed).
Sourcepub fn slice(&self, start: usize, end: usize) -> StrBuffer
pub fn slice(&self, start: usize, end: usize) -> StrBuffer
A contiguous sub-range [start, end) as a fresh StrBuffer (re-packs the
bytes; Buffer borrowing of a sub-span is a future refinement).
Sourcepub fn extend<S: AsRef<str>>(&mut self, items: impl IntoIterator<Item = S>)
pub fn extend<S: AsRef<str>>(&mut self, items: impl IntoIterator<Item = S>)
Append the cells of items in place — the offset and data buffers grow via
copy-on-write rather than being rebuilt, so a live row-by-row append stays
amortised O(1) per cell instead of O(n) (which made repeated append O(n²)).
A borrowed (or shared) buffer materialises once on the first append.
Trait Implementations§
Source§impl<S: AsRef<str>> FromIterator<S> for StrBuffer
impl<S: AsRef<str>> FromIterator<S> for StrBuffer
Source§fn from_iter<I: IntoIterator<Item = S>>(it: I) -> Self
fn from_iter<I: IntoIterator<Item = S>>(it: I) -> Self
The single construction path: concatenate the cells’ UTF-8 into one data
buffer, recording the running byte boundary in offsets (n + 1 entries).