pub struct PartitionKey { /* private fields */ }Expand description
Partition key for distributing events across fixed partitions
SierraDB uses 32 fixed partitions for single-node, 1024+ for clusters. We start with 32 for single-node deployment, ready for clustering.
§Invariants
- Partition count is fixed at construction (default: 32)
- Partition ID is always in range [0, partition_count)
- Same entity always maps to same partition (consistent hashing)
Implementations§
Source§impl PartitionKey
impl PartitionKey
Sourcepub const DEFAULT_PARTITION_COUNT: u32 = 32u32
pub const DEFAULT_PARTITION_COUNT: u32 = 32u32
Default partition count (SierraDB uses 32 for single-node)
Sourcepub fn from_entity_id(entity_id: &str) -> Self
pub fn from_entity_id(entity_id: &str) -> Self
Create a partition key from an entity ID
Uses consistent hashing to ensure same entity always maps to same partition. This is critical for ordering guarantees within a partition.
Sourcepub fn from_entity_id_with_count(entity_id: &str, partition_count: u32) -> Self
pub fn from_entity_id_with_count(entity_id: &str, partition_count: u32) -> Self
Create a partition key with custom partition count
Sourcepub fn from_partition_id(
partition_id: u32,
partition_count: u32,
) -> Result<Self>
pub fn from_partition_id( partition_id: u32, partition_count: u32, ) -> Result<Self>
Create from explicit partition ID (for reconstruction)
Sourcepub fn partition_id(&self) -> u32
pub fn partition_id(&self) -> u32
Get partition ID
Sourcepub fn partition_count(&self) -> u32
pub fn partition_count(&self) -> u32
Get partition count
Sourcepub fn belongs_to_node(&self, node_id: u32, total_nodes: u32) -> bool
pub fn belongs_to_node(&self, node_id: u32, total_nodes: u32) -> bool
Check if this partition belongs to a specific node (for clustering)
Trait Implementations§
Source§impl Clone for PartitionKey
impl Clone for PartitionKey
Source§fn clone(&self) -> PartitionKey
fn clone(&self) -> PartitionKey
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PartitionKey
impl Debug for PartitionKey
Source§impl<'de> Deserialize<'de> for PartitionKey
impl<'de> Deserialize<'de> for PartitionKey
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for PartitionKey
impl Display for PartitionKey
Source§impl PartialEq for PartitionKey
impl PartialEq for PartitionKey
Source§impl Serialize for PartitionKey
impl Serialize for PartitionKey
impl Copy for PartitionKey
impl Eq for PartitionKey
impl StructuralPartialEq for PartitionKey
Auto Trait Implementations§
impl Freeze for PartitionKey
impl RefUnwindSafe for PartitionKey
impl Send for PartitionKey
impl Sync for PartitionKey
impl Unpin for PartitionKey
impl UnwindSafe for PartitionKey
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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§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
Compare self to
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> 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>
Converts
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>
Converts
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> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.