pub struct RowArena { /* private fields */ }Expand description
RowArena is used to hold on to temporary Rows for functions like eval that need to create complex Datums but don’t have a Row to put them in yet.
Implementations§
Source§impl RowArena
impl RowArena
pub fn new() -> Self
Sourcepub fn with_budget(budget: usize) -> Self
pub fn with_budget(budget: usize) -> Self
Creates a RowArena that reports itself RowArena::over_budget once it holds more than
budget bytes.
The budget is advisory to the arena itself: pushes still succeed, because handing back a
truncated value would corrupt the datum. It is the caller’s job to poll over_budget at a
point where it can fail, so the bytes an arena actually reaches is budget plus whatever the
operation in flight at the time added.
NOTE: a budget bounds a single ad-hoc evaluation in a shared process (see
mz_adapter::webhook). It must not be given to an arena that feeds a compute dataflow. A
dataflow re-evaluates the same expression against the same input and must return the same
result every time. Whether an evaluation is over budget depends on what else the arena has
accumulated, and the webhook budget is a runtime dyncfg, so a budgeted dataflow arena would
make the result depend on when it ran. Differential then turns a changed-but-not-retracted
result into non-accumulating diffs that corrupt the collection. A dataflow that ever needs a
budget must fix it for the lifetime of a cluster replica.
Sourcepub fn allocated_bytes(&self) -> usize
pub fn allocated_bytes(&self) -> usize
Bytes this arena currently holds.
Sourcepub fn over_budget(&self) -> bool
pub fn over_budget(&self) -> bool
Whether this arena holds more than its budget. Always false without one.
Sourcepub fn budget_remaining(&self) -> usize
pub fn budget_remaining(&self) -> usize
Bytes this arena can still take before it is RowArena::over_budget, or usize::MAX
without a budget.
Intended for an operation that can predict its own size and would rather fail than build a value it is about to be told is too big.
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a RowArena with an initial region sized to hold capacity bytes, to avoid
reallocations as the first datums are created in the arena.
Sourcepub fn reserve(&self, additional: usize)
pub fn reserve(&self, additional: usize)
Ensures the active region can hold at least additional more bytes without allocating a
new region. Call this when you expect to push roughly additional bytes next.
Sourcepub fn push_bytes<'a, B: Deref<Target = [u8]>>(&'a self, bytes: B) -> &'a [u8] ⓘ
pub fn push_bytes<'a, B: Deref<Target = [u8]>>(&'a self, bytes: B) -> &'a [u8] ⓘ
Copies bytes into the arena and returns a reference valid for its lifetime.
Accepts anything that derefs to [u8] (e.g. Vec<u8>, &[u8]); the bytes are copied, so
the caller’s allocation is not retained.
Sourcepub fn push_owned_bytes<'a>(&'a self, bytes: Vec<u8>) -> &'a [u8] ⓘ
pub fn push_owned_bytes<'a>(&'a self, bytes: Vec<u8>) -> &'a [u8] ⓘ
Moves bytes into the arena and returns a reference valid for its lifetime.
Prefer this to RowArena::push_bytes whenever the bytes are already owned: a value large
enough that it would get a region to itself has its allocation adopted as that region, rather
than a fresh region being allocated and copied into, which for a large value halves the peak.
Smaller values are copied, so the arena keeps bump allocating.
Sourcepub fn push_string<'a>(&'a self, string: String) -> &'a str
pub fn push_string<'a>(&'a self, string: String) -> &'a str
Moves string into the arena and returns a reference valid for its lifetime.
Sourcepub fn writer(&self) -> RowArenaBuf<'_> ⓘ
pub fn writer(&self) -> RowArenaBuf<'_> ⓘ
Returns a growable, writeable byte buffer for assembling a value incrementally.
Write into it with RowArenaBuf::push, RowArenaBuf::extend_from_slice, or
std::io::Write, then call RowArenaBuf::finish to copy the result into the arena and
obtain a reference valid for the arena’s lifetime. The backing buffer is a single scratch
allocation reused across writers, so this lets a producer that builds bytes piecewise (e.g.
decoding a row) avoid managing its own scratch.
Nested writers are sound but not free: a writer obtained while another is still live can’t reuse the (in-use) scratch, so it allocates its own buffer. Steady-state, non-nested use stays allocation-free.
Sourcepub fn push_unary_row<'a>(&'a self, row: Row) -> Datum<'a>
pub fn push_unary_row<'a>(&'a self, row: Row) -> Datum<'a>
Take ownership of row for the lifetime of the arena, returning a
reference to the first datum in the row.
If we had an owned datum type, this method would be much clearer, and
would be called push_owned_datum.
Sourcepub fn make_datum<'a, F>(&'a self, f: F) -> Datum<'a>
pub fn make_datum<'a, F>(&'a self, f: F) -> Datum<'a>
Convenience function to make a new Row containing a single datum, and
take ownership of it for the lifetime of the arena
let arena = RowArena::new();
let datum = arena.make_datum(|packer| {
packer.push_list(&[Datum::String("hello"), Datum::String("world")]);
});
assert_eq!(datum.unwrap_list().iter().collect::<Vec<_>>(), vec![Datum::String("hello"), Datum::String("world")]);Sourcepub fn make_datum_list<'a, T: Borrow<Datum<'a>>>(
&'a self,
iter: impl IntoIterator<Item = T>,
) -> DatumList<'a, T>
pub fn make_datum_list<'a, T: Borrow<Datum<'a>>>( &'a self, iter: impl IntoIterator<Item = T>, ) -> DatumList<'a, T>
Convenience function to build a list datum from an iterator of typed
elements and return it as a DatumList<'a, T>.
By accepting an iterator of T: Borrow<Datum> instead of a raw
RowPacker closure, this guarantees that only elements of type T
are pushed.
Sourcepub fn make_datum_nested<'a, F>(&'a self, f: F) -> DatumNested<'a>
pub fn make_datum_nested<'a, F>(&'a self, f: F) -> DatumNested<'a>
Convenience function identical to make_datum but instead returns a
DatumNested.
Sourcepub fn try_make_datum<'a, F, E>(&'a self, f: F) -> Result<Datum<'a>, E>
pub fn try_make_datum<'a, F, E>(&'a self, f: F) -> Result<Datum<'a>, E>
Like RowArena::make_datum, but the provided closure can return an error.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RowArena
impl !RefUnwindSafe for RowArena
impl !Sync for RowArena
impl Send for RowArena
impl Unpin for RowArena
impl UnsafeUnpin for RowArena
impl UnwindSafe for RowArena
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T, U> OverrideFrom<Option<&T>> for Uwhere
U: OverrideFrom<T>,
impl<T, U> OverrideFrom<Option<&T>> for Uwhere
U: OverrideFrom<T>,
Source§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> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
Source§fn into_rust(self) -> Result<R, TryFromProtoError>
fn into_rust(self) -> Result<R, TryFromProtoError>
RustType::from_proto.Source§fn from_rust(rust: &R) -> P
fn from_rust(rust: &R) -> P
RustType::into_proto.Source§impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
Source§fn plus_equals(&mut self, rhs: &&'a S)
fn plus_equals(&mut self, rhs: &&'a S)
std::ops::AddAssign, for types that do not implement AddAssign.