pub struct VarBinBuilder<O: OffsetBuilderPType> { /* private fields */ }Expand description
Builder for VarBinArray values with O-typed offsets.
This is the offset-based counterpart to
VarBinViewBuilder: values are laid out contiguously in
a single byte buffer described by a monotonically increasing offsets buffer. An i32 or i64
builder can therefore be handed straight to Arrow as a Utf8/LargeUtf8/Binary/
LargeBinary array without re-laying out the bytes.
Encodings that can decode into this layout should specialize
append_to_builder with
match_each_varbin_builder!, which recovers the concrete
offset type from a &mut dyn ArrayBuilder so the decode loop is monomorphized over it.
Implementations§
Source§impl<O: OffsetBuilderPType> VarBinBuilder<O>
impl<O: OffsetBuilderPType> VarBinBuilder<O>
Sourcepub fn with_capacity(dtype: DType, capacity: usize) -> Self
pub fn with_capacity(dtype: DType, capacity: usize) -> Self
Creates a builder for dtype with room for capacity values.
Sourcepub fn with_capacity_bytes(dtype: DType, capacity: usize, bytes: usize) -> Self
pub fn with_capacity_bytes(dtype: DType, capacity: usize, bytes: usize) -> Self
Creates a builder for dtype with room for capacity values totalling bytes bytes.
Sourcepub fn reserve_data(&mut self, additional: usize)
pub fn reserve_data(&mut self, additional: usize)
Reserves room for additional value bytes.
reserve_exact takes a row count and so cannot size the
value bytes; callers that know the byte total should use this to size the buffer once
instead of letting it grow.
Sourcepub fn append(&mut self, value: Option<&[u8]>)
pub fn append(&mut self, value: Option<&[u8]>)
Appends one value, or a null when it is None.
§Panics
Panics if the resulting end offset does not fit in O. See
append_value.
Sourcepub fn append_value(&mut self, value: impl AsRef<[u8]>)
pub fn append_value(&mut self, value: impl AsRef<[u8]>)
Appends one non-null value.
§Panics
Panics if the resulting end offset does not fit in O. The bulk appends report that as an
error instead; use append_n_values for a fallible single append,
or an i64 builder for byte totals past i32::MAX.
Sourcepub fn append_n_values(
&mut self,
value: impl AsRef<[u8]>,
n: usize,
) -> VortexResult<()>
pub fn append_n_values( &mut self, value: impl AsRef<[u8]>, n: usize, ) -> VortexResult<()>
Appends the same non-null value n times.
§Errors
Returns an error, leaving the builder unchanged, if the resulting end offsets do not fit
in O.
Sourcepub fn push_null(&mut self)
pub fn push_null(&mut self)
Appends a null value.
Unlike append_null this does not check that the builder is
nullable; the offsets and validity stay consistent either way, and a non-nullable dtype
discards the validity bits on finish_into_varbin.
Sourcepub fn push_nulls(&mut self, n: usize)
pub fn push_nulls(&mut self, n: usize)
Appends n null values. See push_null.
Sourcepub fn append_scalar_repeated(
&mut self,
scalar: &Scalar,
n: usize,
) -> VortexResult<()>
pub fn append_scalar_repeated( &mut self, scalar: &Scalar, n: usize, ) -> VortexResult<()>
Appends the same UTF-8 or binary scalar n times.
§Errors
Returns an error if scalar has a different dtype than the builder, or if the resulting
end offsets do not fit in O.
Sourcepub fn append_values<P>(
&mut self,
values: &[u8],
end_offsets: impl Iterator<Item = P>,
validity: &Mask,
) -> VortexResult<()>
pub fn append_values<P>( &mut self, values: &[u8], end_offsets: impl Iterator<Item = P>, validity: &Mask, ) -> VortexResult<()>
Appends values from one contiguous byte buffer described by relative end offsets.
Each entry of end_offsets marks the end of one value relative to the start of values,
and there must be exactly one per entry in validity.
Sourcepub unsafe fn append_decoded<P>(
&mut self,
num_bytes: usize,
slack: usize,
lengths: &[P],
validity: &Mask,
decode: &mut dyn FnMut(&mut [MaybeUninit<u8>]) -> VortexResult<usize>,
) -> VortexResult<()>
pub unsafe fn append_decoded<P>( &mut self, num_bytes: usize, slack: usize, lengths: &[P], validity: &Mask, decode: &mut dyn FnMut(&mut [MaybeUninit<u8>]) -> VortexResult<usize>, ) -> VortexResult<()>
Appends values whose bytes decode writes straight into the builder’s byte storage.
decode is handed at least num_bytes + slack bytes of uninitialized storage and returns
the number of bytes it initialized, which must be exactly num_bytes. Each entry of
lengths is the byte length of one value — including nulls, which are zero-length — so
there must be one per entry in validity.
slack is spare headroom past the values themselves. It exists so that a decoder which
stores in wide fixed-size chunks can keep using them through the final value instead of
dropping into a byte-at-a-time tail; a decoder must still never write past the slice it is
handed, so 0 is correct for one that is already exact.
Decoding in place saves staging the decoded heap in a temporary buffer and copying it in.
decode is taken as a dyn reference so a caller that resolves the lengths type with
match_each_integer_ptype! can build the closure once
outside that match rather than inlining a whole decoder into each of its arms.
§Errors
Returns an error, leaving the builder unchanged, if num_bytes would push an offset past
what O can hold — checked before decode runs — or if decode reports a different byte
count than num_bytes, or if lengths does not describe those bytes.
§Safety
decode must initialize the first n bytes of the slice it is passed, where n is the
value it returns. Those bytes are published as initialized without ever being read first,
so a decode that over-reports leaves the builder holding uninitialized memory.
Sourcepub fn append_valid_slices<'a, F>(
&mut self,
num_bytes: usize,
validity: &Mask,
value: F,
) -> VortexResult<()>
pub fn append_valid_slices<'a, F>( &mut self, num_bytes: usize, validity: &Mask, value: F, ) -> VortexResult<()>
Appends validity.len() values, taking each valid row’s bytes from value.
value is called once per valid row in ascending row order and the slices it returns must
total num_bytes bytes. Null rows consume no bytes and repeat the preceding offset.
The valid rows are walked a u64 word at a time rather than pulled one at a time through
an iterator, and both buffers are sized once up front, so the copy loop costs one offset
store plus one memcpy per value. A caller whose values only exist as a stream can still
use this by pulling from the stream inside value: the rows are visited in ascending
order.
Sourcepub fn append_varbin(
&mut self,
array: ArrayView<'_, VarBin>,
ctx: &mut ExecutionCtx,
) -> VortexResult<()>where
usize: AsPrimitive<O>,
pub fn append_varbin(
&mut self,
array: ArrayView<'_, VarBin>,
ctx: &mut ExecutionCtx,
) -> VortexResult<()>where
usize: AsPrimitive<O>,
Appends a VarBinArray, reusing its offsets instead of walking its values.
Sourcepub fn append_varbinview(
&mut self,
array: ArrayView<'_, VarBinView>,
ctx: &mut ExecutionCtx,
) -> VortexResult<()>where
usize: AsPrimitive<O>,
pub fn append_varbinview(
&mut self,
array: ArrayView<'_, VarBinView>,
ctx: &mut ExecutionCtx,
) -> VortexResult<()>where
usize: AsPrimitive<O>,
Appends a VarBinViewArray, compacting its values.
Sourcepub fn finish_into_varbin(&mut self) -> VarBinArray
pub fn finish_into_varbin(&mut self) -> VarBinArray
Finishes the appended values into a VarBinArray and resets the builder.
Trait Implementations§
Source§impl<O: OffsetBuilderPType> ArrayBuilder for VarBinBuilder<O>
impl<O: OffsetBuilderPType> ArrayBuilder for VarBinBuilder<O>
fn as_any(&self) -> &dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
fn dtype(&self) -> &DType
fn len(&self) -> usize
Source§fn append_zeros(&mut self, n: usize)
fn append_zeros(&mut self, n: usize)
Source§unsafe fn append_nulls_unchecked(&mut self, n: usize)
unsafe fn append_nulls_unchecked(&mut self, n: usize)
append_nulls. Read moreSource§fn append_scalar(&mut self, scalar: &Scalar) -> VortexResult<()>
fn append_scalar(&mut self, scalar: &Scalar) -> VortexResult<()>
Source§fn reserve_exact(&mut self, additional: usize)
fn reserve_exact(&mut self, additional: usize)
additional itemsSource§unsafe fn set_validity_unchecked(&mut self, validity: Mask)
unsafe fn set_validity_unchecked(&mut self, validity: Mask)
Source§fn finish_into_canonical(&mut self, ctx: &mut ExecutionCtx) -> Canonical
fn finish_into_canonical(&mut self, ctx: &mut ExecutionCtx) -> Canonical
fn is_empty(&self) -> bool
Source§fn append_zero(&mut self)
fn append_zero(&mut self)
Source§fn append_null(&mut self)
fn append_null(&mut self)
Source§fn append_nulls(&mut self, n: usize)
fn append_nulls(&mut self, n: usize)
Source§fn append_default(&mut self)
fn append_default(&mut self)
Source§fn append_defaults(&mut self, n: usize)
fn append_defaults(&mut self, n: usize)
Source§fn set_validity(&mut self, validity: Mask)
fn set_validity(&mut self, validity: Mask)
Auto Trait Implementations§
impl<O> !RefUnwindSafe for VarBinBuilder<O>
impl<O> !UnwindSafe for VarBinBuilder<O>
impl<O> Freeze for VarBinBuilder<O>
impl<O> Send for VarBinBuilder<O>
impl<O> Sync for VarBinBuilder<O>
impl<O> Unpin for VarBinBuilder<O>where
O: Unpin,
impl<O> UnsafeUnpin for VarBinBuilder<O>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.