pub struct PhysicalNode {
pub id: String,
pub num_vnodes: usize,
pub vnodes: BTreeMap<String, VirtualNode>,
pub data: BTreeMap<u64, Item>,
}Expand description
Represents a physical node in the consistent hashing ring.
Fields§
§id: StringA unique identifier for the physical node.
num_vnodes: usizeThe number of virtual nodes associated with this physical node.
vnodes: BTreeMap<String, VirtualNode>A map of virtual node IDs to their corresponding VirtualNode structs.
data: BTreeMap<u64, Item>A map of hash values to Item structs, representing the data stored on this node.
Implementations§
Source§impl PhysicalNode
impl PhysicalNode
Sourcepub fn builder() -> PhysicalNodeBuilder
pub fn builder() -> PhysicalNodeBuilder
Create an instance of PhysicalNode using the builder syntax
Source§impl PhysicalNode
impl PhysicalNode
Sourcepub fn init_vnodes<T: RingHasherTrait>(&mut self, hasher: &T) -> Result<()>
pub fn init_vnodes<T: RingHasherTrait>(&mut self, hasher: &T) -> Result<()>
Initializes the virtual nodes for this physical node.
This method generates virtual node IDs based on the physical node’s ID and the number
of virtual nodes (num_vnodes). It computes a hash for each virtual node ID using
the provided hasher and creates a VirtualNode instance for each ID. The virtual
nodes are then added to the vnodes map of the physical node.
§Arguments
hasher: A reference to an object implementing theRingHasherTraitto compute hashes.
§Returns
Result<()>: ReturnsOk(())if the virtual nodes are successfully initialized, or an error if hashing fails.
Trait Implementations§
Source§impl Clone for PhysicalNode
impl Clone for PhysicalNode
Source§fn clone(&self) -> PhysicalNode
fn clone(&self) -> PhysicalNode
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 PhysicalNode
impl Debug for PhysicalNode
Source§impl Hash for PhysicalNode
impl Hash for PhysicalNode
Source§impl PartialEq for PhysicalNode
impl PartialEq for PhysicalNode
impl Eq for PhysicalNode
impl StructuralPartialEq for PhysicalNode
Auto Trait Implementations§
impl Freeze for PhysicalNode
impl RefUnwindSafe for PhysicalNode
impl Send for PhysicalNode
impl Sync for PhysicalNode
impl Unpin for PhysicalNode
impl UnwindSafe for PhysicalNode
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.