Seq

Enum Seq 

Source
pub enum Seq {
    Boxed(Vec<Value>),
    Ints(Vec<i64>),
    Floats(Vec<f64>),
}
Expand description

A list’s elements. See the module docs for what a caller may not be able to tell.

Variants§

§

Boxed(Vec<Value>)

Any elements at all.

§

Ints(Vec<i64>)

Int elements, dense.

§

Floats(Vec<f64>)

Float elements, dense and as f64.

Implementations§

Source§

impl Seq

Source

pub fn pack(values: Vec<Value>) -> Seq

The elements a primitive produced, in whatever layout they fit.

One pass over a list that has just been built by a pass over something else, so this is a constant on a cost the caller was already paying — and it stops at the first element that does not fit, so a list of records pays a single comparison.

Source

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

The elements, unpacked — what a caller that wants a Vec<Value> gets.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn get(&self, i: usize) -> Option<Value>

One element, as a Value. By value rather than by reference, because a column has no Value to lend — and an Int or a Float is two words, so there is nothing to save.

Source

pub fn iter(&self) -> Iter<'_> ⓘ

Every element, in order.

Source

pub fn ints(&self) -> Option<&[i64]>

The elements as a dense i64 run, if that is what this list is.

Source

pub fn floats(&self) -> Option<&[f64]>

The elements as a dense f64 run, if that is what this list is — the pointer a kernel and an Arrow Float64Array both take, and the reason this module exists (105 §105.8).

None for a boxed list rather than a copy of one: a caller that gets a slice knows it cost nothing, and a caller that gets None can decide whether a copy is worth it. Handing back a materialised buffer here would make the cheap case and the expensive one look alike, which is the shape of every “why is this slow” question a zero-copy interface exists to prevent.

Source

pub fn for_each(&self, f: impl FnMut(&Value))

Every element, borrowed where the layout has one to lend.

Seq::iter yields by value, which is right for a caller that wanted an owned Value and wrong for one that only wanted to look: cloning a Value::Data is an atomic increment and a later decrement, and the digest, the wire format and to_json each walk every element of every list without keeping any of them. Those walk through here, so the boxed layout — which is every list that is not a column — pays exactly what it paid before this module existed.

A column has no Value to lend, so one is built on the stack and lent; it is two words and no allocation.

Source

pub fn try_for_each<E>( &self, f: impl FnMut(&Value) -> Result<(), E>, ) -> Result<(), E>

Seq::for_each for a walk that can fail, which is what a wire encoder is.

Source

pub fn as_values(&self) -> Cow<'_, [Value]>

The elements as a slice, borrowed when the layout allows and materialised when it does not.

Source

pub fn min(&self) -> Option<Value>

The smallest element, and the largest — over the dense buffer where there is one.

This is the half of 105 §105.10’s aggregate row that costs nothing to take: min over an Ints column is a pass over i64s with no Value built at all, where the boxed form builds one per element to compare it.

Source

pub fn max(&self) -> Option<Value>

Source

pub fn is_column(&self) -> bool

Whether this list is stored as a column — for a gate and for a report, never for a decision about what a program means.

Source

pub fn heap_bytes(&self) -> usize

What this list occupies on the heap, in bytes, not counting anything its elements point at.

The number the second layout exists to move, so it is readable rather than inferred.

Source

pub fn push(&mut self, value: Value)

Add one element to the end.

An empty list promotes to the layout its first element fits, which is what gives the accumulator idiom a column; a list that already has elements keeps its layout, or falls back to Seq::Boxed once for an element that does not fit. Both are O(1) amortised. What is deliberately not here is a re-examination of a boxed list on every push: that would be the quadratic 70 removed from this idiom, put straight back.

Source

pub fn extend(&mut self, other: &Seq)

Add every element of another list to the end.

Source

pub fn slice(&self, from: usize, to: usize) -> Seq

A range of the elements, as a list of its own.

Source

pub fn set(&mut self, i: usize, value: Value)

Replace one element, keeping the layout where the new element fits it.

Trait Implementations§

Source§

impl Clone for Seq

Source§

fn clone(&self) -> Seq

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Seq

Source§

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

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

impl Default for Seq

Source§

fn default() -> Seq

Returns the “default value” for a type. Read more
Source§

impl From<Vec<Value>> for Seq

Source§

fn from(v: Vec<Value>) -> Seq

Converts to this type from the input type.
Source§

impl FromIterator<Value> for Seq

Source§

fn from_iter<I: IntoIterator<Item = Value>>(iter: I) -> Seq

Creates a value from an iterator. Read more
Source§

impl<'a> IntoIterator for &'a Seq

Source§

type Item = Value

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Iter<'a> ⓘ

Creates an iterator from a value. Read more
Source§

impl Ord for Seq

Source§

fn cmp(&self, other: &Seq) -> Ordering

Lexicographic over the elements, which is what Vec<Value>’s derived order was.

A Floats column is compared through Value::float, not as raw f64. The two agree on every ordinary number because the order key is monotone, and disagree on exactly the two IEEE values Value::float exists to canonicalise — NaN, which has no partial_cmp, and -0.0, which compares equal to 0.0 and hashes differently. Going through the constructor is how those two stay the one value the language says they are.

1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Seq

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Seq

Source§

fn partial_cmp(&self, other: &Seq) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Eq for Seq

Auto Trait Implementations§

§

impl Freeze for Seq

§

impl RefUnwindSafe for Seq

§

impl Send for Seq

§

impl Sync for Seq

§

impl Unpin for Seq

§

impl UnwindSafe for Seq

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.