Skip to main content

OrderTarget

Enum OrderTarget 

Source
#[non_exhaustive]
pub enum OrderTarget {
Show 15 variants I16, U16, I32, U32, I64, U64, I128, U128, F64, Date, Timestamp, Decimal, Text, Bytes, Uuid,
}
Expand description

The type an order index declares, which every value it holds is encoded as. A layer above maps its own column types onto these: an EQL int column is OrderTarget::I32, whatever language the value comes from.

An integer of any width is accepted by an integer target it fits, and refused with NormalizeError::OutOfRange otherwise. An f32 is widened exactly to OrderTarget::F64. Every other target takes only its own kind; anything else is NormalizeError::Mismatch. An integer is not a float, a date or a decimal, so none of those take one.

§What has no target

An order term reveals the order of the values it encrypts. That is the point of the scheme, and it is safe only when the set of possible values is large enough that knowing the order of the rows does not give the values away. A boolean has two values, so an order term over a boolean column says which rows are true: order refuses one with NormalizeError::NoDomain. An 8-bit integer has 256, so an order index over such a column is a frequency table of the column with the order on top, and anyone who knows a handful of rows’ values, or the rough distribution of the data (ages, quantities, ratings), reads the rest off. So the narrowest integer target is sixteen bits. An i8 or u8 value still goes into any wider target it fits; what there is not is a one-byte space.

The floor removes only the case where the type guarantees few values. An I16 or I32 column that holds ages or ratings leaks the same frequency table, since the leak is a property of how many distinct values the column holds, not of the width. Whether a column should have an order index at all is a question about its data; a column of few distinct values wants an equality index.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

I16

An i16. The narrowest integer target; see above for why.

§

U16

A u16.

§

I32

An i32.

§

U32

A u32.

§

I64

An i64.

§

U64

A u64.

§

I128

An i128.

§

U128

A u128.

§

F64

An f64; an f32 widens to it exactly.

§

Date

§

Timestamp

A Logical::Timestamp in any unit, truncated to microseconds.

§

Decimal

A Logical::Decimal at any scale.

§

Text

Text.

§

Bytes

Bytes.

§

Uuid

Implementations§

Source§

impl OrderTarget

Source

pub const ALL: &[OrderTarget]

Every target, for a test or an index layer that enumerates them.

Source

pub fn domain(self) -> &'static str

The frozen domain label of every term of this target.

Source

pub fn domain_with_nulls(self, nulls: NullOrder) -> Option<&'static str>

The frozen domain label of every term of this target in a space that places nulls as nulls says, or None for text and bytes, which take no null policy.

use vitaminc_ore::{domain, NullOrder, OrderTarget};

assert_eq!(
    OrderTarget::I32.domain_with_nulls(NullOrder::Last),
    Some(domain::INT32_NULLS_LAST)
);
assert_eq!(OrderTarget::Text.domain_with_nulls(NullOrder::Last), None);
Source

pub fn width(self) -> Option<usize>

The width of every term of this target, or None for text and bytes, whose terms vary in length. Never one byte: see the type’s docs.

Trait Implementations§

Source§

impl Clone for OrderTarget

Source§

fn clone(&self) -> Self

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 Copy for OrderTarget

Source§

impl Debug for OrderTarget

Source§

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

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

impl Eq for OrderTarget

Source§

impl Hash for OrderTarget

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for OrderTarget

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
Source§

impl StructuralPartialEq for OrderTarget

Source§

impl Target for OrderTarget

Source§

fn runtime(self) -> OrderTarget

The target as the value every encoding is keyed by.
Source§

fn null_order(self) -> Option<NullOrder>

Where a space of this target places nulls: None, unless the target is a Nulls or a RuntimeNulls, which a space’s nulls method makes.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<S, T, P> Supports<Nulls<T, P>> for S
where S: Supports<T> + ?Sized, T: FixedWidth, P: NullPolicy,

Source§

fn supports(target: Nulls<T, P>) -> bool

Whether the scheme takes terms of target. For a marker, true (the impl exists); for an OrderTarget, the scheme’s list.
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 = !

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.