pub enum Partitioning {
Hash {
columns: Vec<ColumnId>,
buckets: u32,
},
Range {
columns: Vec<ColumnId>,
splits: Vec<Key>,
},
Tenant {
tenant_column: ColumnId,
buckets_per_tenant: u32,
},
TimeRange {
timestamp_column: ColumnId,
interval: TimeInterval,
},
}Expand description
How one table’s rows map onto tablets (spec section 12.2). Declaration order is frozen; variants are never reused (spec section 4.10).
Variants§
Hash
Hash of the declared columns into a fixed bucket space. Tablets own
contiguous runs of buckets (see Partitioning::routed_key).
Fields
Range
Lexicographic ranges over the declared columns, split at splits.
splits.len() + 1 partitions cover the key space: partition i owns
[splits[i - 1], splits[i]), unbounded at the edges.
Fields
Tenant
One bucket space per tenant: the tenant column hashes into
buckets_per_tenant buckets, so every tenant’s rows spread evenly and
tenants can be isolated onto dedicated tablets (spec section 12.5).
Fields
TimeRange
Time-bucketed ranges: partition i owns
[i * interval, (i + 1) * interval) of the timestamp column.
Fields
interval: TimeIntervalFixed interval width.
Implementations§
Source§impl Partitioning
impl Partitioning
Sourcepub fn validate(&self) -> Result<(), PartitionError>
pub fn validate(&self) -> Result<(), PartitionError>
Validates the declaration: non-empty column lists, positive bucket counts, strictly increasing splits, positive interval.
Sourcepub fn partition_columns(&self) -> Vec<ColumnId>
pub fn partition_columns(&self) -> Vec<ColumnId>
The declared partition-key columns, in key order (spec section 12.2: every table has a declared partition key).
Sourcepub fn partition_key(
&self,
values: &BTreeMap<ColumnId, KeyValue>,
) -> Result<Key, PartitionError>
pub fn partition_key( &self, values: &BTreeMap<ColumnId, KeyValue>, ) -> Result<Key, PartitionError>
Extracts the partition key from a row’s column values: the declared
partition-key columns, in declared order, encoded by
RowKeyEncoder. A missing declared column fails closed.
The fast path of spec section 12.2 — the primary key includes the partition key — means the caller can usually supply the primary-key components directly; this function does not care where the values came from.
Sourcepub fn route(&self, partition_key: &Key) -> Result<u64, PartitionError>
pub fn route(&self, partition_key: &Key) -> Result<u64, PartitionError>
Maps an extracted partition key onto its partition slot (spec section 12.2):
Hash:fnv1a64(key) % buckets.Range: index of the first split above the key,0..=splits.len().Tenant:fnv1a64(tenant key) % buckets_per_tenant; the slot is per tenant, so the full partition address is(tenant, slot)— seeSelf::routed_key.TimeRange:timestamp / interval(epoch-floored); pre-epoch timestamps fail closed withPartitionError::NegativeSlot.
Sourcepub fn routed_key(&self, partition_key: &Key) -> Result<Key, PartitionError>
pub fn routed_key(&self, partition_key: &Key) -> Result<Key, PartitionError>
The canonical routing address of a partition key — the byte string
whose ranges the tablet PartitionBounds of this table are
allocated over:
RangeandTimeRange: the partition key itself; bounds range directly over encoded key bytes.Hash: the 8 big-endian bytes of the bucket; the meta plane allocates tablet bounds as contiguous bucket runs, e.g. buckets[lo, hi)viahash_slot_bounds.Tenant: the tenant key encoding followed by the 8 big-endian bytes of the bucket, so bounds range per tenant over the composite.
Sourcepub fn range_bounds(&self, index: u64) -> Option<PartitionBounds>
pub fn range_bounds(&self, index: u64) -> Option<PartitionBounds>
The bounds of range partition index (0..=splits.len()); None
for out-of-range indexes and non-range partitioning.
Trait Implementations§
Source§impl Clone for Partitioning
impl Clone for Partitioning
Source§fn clone(&self) -> Partitioning
fn clone(&self) -> Partitioning
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Partitioning
impl Debug for Partitioning
Source§impl<'de> Deserialize<'de> for Partitioning
impl<'de> Deserialize<'de> for Partitioning
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Partitioning
Source§impl PartialEq for Partitioning
impl PartialEq for Partitioning
Source§impl Serialize for Partitioning
impl Serialize for Partitioning
impl StructuralPartialEq for Partitioning
Auto Trait Implementations§
impl Freeze for Partitioning
impl RefUnwindSafe for Partitioning
impl Send for Partitioning
impl Sync for Partitioning
impl Unpin for Partitioning
impl UnsafeUnpin for Partitioning
impl UnwindSafe for Partitioning
Blanket Implementations§
impl<T> AppData for Twhere
T: OptionalSend + OptionalSync + 'static + OptionalSerde,
impl<T> AppDataResponse for Twhere
T: OptionalSend + OptionalSync + 'static + OptionalSerde,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> 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::Request