#[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
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
impl OrderTarget
Sourcepub const ALL: &[OrderTarget]
pub const ALL: &[OrderTarget]
Every target, for a test or an index layer that enumerates them.
Sourcepub fn domain_with_nulls(self, nulls: NullOrder) -> Option<&'static str>
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);Trait Implementations§
Source§impl Clone for OrderTarget
impl Clone for OrderTarget
impl Copy for OrderTarget
Source§impl Debug for OrderTarget
impl Debug for OrderTarget
impl Eq for OrderTarget
Source§impl Hash for OrderTarget
impl Hash for OrderTarget
Source§impl PartialEq for OrderTarget
impl PartialEq for OrderTarget
impl StructuralPartialEq for OrderTarget
Source§impl Target for OrderTarget
impl Target for OrderTarget
Source§fn runtime(self) -> OrderTarget
fn runtime(self) -> OrderTarget
Source§fn null_order(self) -> Option<NullOrder>
fn null_order(self) -> Option<NullOrder>
None, unless the
target is a Nulls or a RuntimeNulls, which a space’s
nulls method makes.