pub struct ClayCode {
pub k: usize,
pub m: usize,
pub n: usize,
pub d: usize,
pub q: usize,
pub t: usize,
pub nu: usize,
pub sub_chunk_no: usize,
pub beta: usize,
/* private fields */
}Expand description
Clay (Coupled-Layer) erasure code
Fields§
§k: usizeNumber of data chunks
m: usizeNumber of parity chunks
n: usizeTotal nodes (k + m)
d: usizeNumber of helper nodes for repair (k <= d <= n-1)
q: usizeCoupling factor: q = d - k + 1
t: usizeNumber of y-sections: t = (n + nu) / q
nu: usizeShortening parameter: makes (k + m + nu) divisible by q
sub_chunk_no: usizeSub-packetization level: α = q^t (sub-chunks per chunk)
beta: usizeSub-chunks needed from each helper during repair: β = α / q
Implementations§
Source§impl ClayCode
impl ClayCode
Sourcepub fn new_default(k: usize, m: usize) -> Result<Self, ClayError>
pub fn new_default(k: usize, m: usize) -> Result<Self, ClayError>
Create with default d = k + m - 1 (maximum helpers)
Sourcepub fn decode(
&self,
available: &HashMap<usize, Vec<u8>>,
erasures: &[usize],
) -> Result<Vec<u8>, ClayError>
pub fn decode( &self, available: &HashMap<usize, Vec<u8>>, erasures: &[usize], ) -> Result<Vec<u8>, ClayError>
Sourcepub fn minimum_to_repair(
&self,
lost_node: usize,
available: &[usize],
) -> Result<Vec<(usize, Vec<usize>)>, ClayError>
pub fn minimum_to_repair( &self, lost_node: usize, available: &[usize], ) -> Result<Vec<(usize, Vec<usize>)>, ClayError>
Determine minimum sub-chunks needed to repair a lost node
§Parameters
lost_node: Index of the lost node (0 to n-1)available: Available node indices
§Returns
Vector of (helper_node_idx, sub_chunk_indices) where sub_chunk_indices is a vector of the specific sub-chunk indices needed from that helper. The repair() function expects helper data to contain these sub-chunks concatenated in the ORDER they appear in sub_chunk_indices.
Sourcepub fn repair(
&self,
lost_node: usize,
helper_data: &HashMap<usize, Vec<u8>>,
chunk_size: usize,
) -> Result<Vec<u8>, ClayError>
pub fn repair( &self, lost_node: usize, helper_data: &HashMap<usize, Vec<u8>>, chunk_size: usize, ) -> Result<Vec<u8>, ClayError>
Repair a lost chunk using partial data from helper nodes
§Parameters
lost_node: Index of the lost node (0 to n-1)helper_data: Map from helper node index to partial chunk data. Each helper’s data must be the concatenation of sub-chunks at the indices returned by minimum_to_repair(), in that exact order.chunk_size: Full chunk size
§Returns
The recovered full chunk, or error if repair fails
Sourcepub fn normalized_repair_bandwidth(&self) -> f64
pub fn normalized_repair_bandwidth(&self) -> f64
Calculate normalized repair bandwidth
This is the ratio of data downloaded for repair to the size of the repaired chunk. For Clay codes, this is d / (k * q).