Skip to main content

Scratch

Struct Scratch 

Source
pub struct Scratch<T: Packable> { /* private fields */ }
Expand description

The buffer pack_with and unpack_with transpose through, kept so it can be reused.

Going between row order and the transposed layout needs somewhere to put the other order, and that somewhere is VALUES values, which is 8 KB for a u64. Allocating it per call is not the expensive part. Zeroing it is, because the allocator hands back a page it has to clear and the transpose then writes every element of it anyway. On a scan of a packed integer column that is once per 1024 rows, and it showed up as the largest single item in a ClickBench profile, larger than the unpacking it was making room for.

So a caller that unpacks more than one unit should make one of these and pass it in.

It starts empty and grows on the first unit that needs it, because a caller holds one for a whole decode and most chunks are not bit packed at all. Making the buffer in the constructor was tried and was worse than what it replaced, by more than the zeroing it saved.

Implementations§

Source§

impl<T: Packable> Scratch<T>

Source

pub const fn new() -> Self

A scratch buffer that has not made room for anything yet.

Trait Implementations§

Source§

impl<T: Debug + Packable> Debug for Scratch<T>

Source§

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

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

impl<T: Packable> Default for Scratch<T>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<T> Freeze for Scratch<T>
where Vec<T>: Freeze,

§

impl<T> RefUnwindSafe for Scratch<T>
where Vec<T>: RefUnwindSafe,

§

impl<T> Send for Scratch<T>
where Vec<T>: Send,

§

impl<T> Sync for Scratch<T>
where Vec<T>: Sync,

§

impl<T> Unpin for Scratch<T>
where Vec<T>: Unpin,

§

impl<T> UnsafeUnpin for Scratch<T>
where Vec<T>: UnsafeUnpin,

§

impl<T> UnwindSafe for Scratch<T>
where Vec<T>: UnwindSafe,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.