risingwave_common::hash

Trait VnodeCountCompat

source
pub trait VnodeCountCompat {
    // Required method
    fn vnode_count_inner(&self) -> VnodeCount;

    // Provided method
    fn vnode_count(&self) -> usize { ... }
}
Expand description

A trait for accessing the vnode count field with backward compatibility.

§maybe_?

The reason why there’s a maybe_ prefix on the protobuf field is that, a getter method with the same name as the field will be generated for prost structs. Directly naming it vnode_count will lead to the method vnode_count() returning 0 when the field is unset, which can be misleading sometimes.

Instead, we name the field as maybe_vnode_count and provide the method vnode_count through this trait, ensuring that backward compatibility is handled properly.

Required Methods§

source

fn vnode_count_inner(&self) -> VnodeCount

Get the maybe_vnode_count field.

Provided Methods§

source

fn vnode_count(&self) -> usize

Returns the vnode count if it’s set. Otherwise, returns VirtualNode::COUNT_FOR_COMPAT for distributed tables/fragments, and 1 for singleton tables/fragments, for backward compatibility. Panics if the field is a placeholder.

See the documentation on the field of the implementing type for more details.

Implementations on Foreign Types§

source§

impl VnodeCountCompat for Table

source§

impl VnodeCountCompat for Fragment

source§

impl VnodeCountCompat for StorageTableDesc

Implementors§