Skip to main content

StrBuffer

Struct StrBuffer 

Source
pub struct StrBuffer { /* private fields */ }
Expand description

A contiguous UTF-8 string column buffer (Arrow LargeUtf8: i64 offsets).

Implementations§

Source§

impl StrBuffer

Source

pub fn from_vec(v: Vec<String>) -> Self

Build from owned Strings.

Examples found in repository?
examples/asm_probe_string.rs (line 16)
15fn main() {
16    let sb = StrBuffer::from_vec(vec!["ab".into(), "cd".into(), "ef".into()]);
17    println!("{}", probe_str_eq_scan(black_box(&sb), black_box("cd")));
18}
Source

pub fn from_buffers(offsets: Buffer<i64>, data: Buffer<u8>) -> Self

Zero-copy from foreign Arrow LargeUtf8 buffers (offsets + data + their guard).

Source

pub fn buffers(&self) -> (&Buffer<i64>, &Buffer<u8>)

The raw offset / data buffers (for a zero-copy Arrow export).

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn get(&self, i: usize) -> &str

Cell i as &str (a borrow into the data buffer). Bounds-checked.

Source

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.

Source

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.

Examples found in repository?
examples/asm_probe_string.rs (line 12)
11pub fn probe_str_eq_scan(s: &StrBuffer, target: &str) -> usize {
12    s.iter().filter(|&x| x == target).count()
13}
Source

pub fn to_vec(&self) -> Vec<String>

Materialize owned Strings (only where a Vec<String> is genuinely needed).

Source

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).

Source

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 Clone for StrBuffer

Source§

fn clone(&self) -> StrBuffer

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StrBuffer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: AsRef<str>> FromIterator<S> for StrBuffer

Source§

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).

Source§

impl PartialEq for StrBuffer

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.