///
/// Generate partitions without taking rack assignments into consideration
///
Generate partitions without taking rack assignments into consideration
Generate partitions without taking rack assignments into consideration
fn generate_partitions_without_rack(
    spus: &SpuLocalStore,
    param: &TopicReplicaParam,
    start_index: i32,
) -> ReplicaMap {
    let mut partition_map = BTreeMap::new();
    let spu_cnt = spus.spu_used_for_replica();
    let spu_ids = spus.spu_ids_for_replica();
    let s_idx = if start_index >= 0 {
        start_index
    } else {
        thread_rng().gen_range(0, spu_cnt)
    };
    let gap_max = spu_cnt - param.replication_factor + 1;
    for p_idx in 0..param.partitions {
        let mut replicas: Vec<i32> = vec![];
        let gap_cnt = ((s_idx + p_idx) / spu_cnt) % gap_max;
        for r_idx in 0..param.replication_factor {
            let gap = if r_idx != 0 { gap_cnt } else { 0 };
            let spu_idx = ((s_idx + p_idx + r_idx + gap) % spu_cnt) as usize;
            replicas.push(spu_ids[spu_idx]);
        }
        partition_map.insert(p_idx, replicas);
    }
    partition_map
}
fn generate_partitions_without_rack ( spus : & SpuLocalStore , param : & TopicReplicaParam , start_index : i32 , ) -> ReplicaMap { let mut partition_map = BTreeMap :: new ( ) ; let spu_cnt = spus . spu_used_for_replica ( ) ; let spu_ids = spus . spu_ids_for_replica ( ) ; let s_idx = if start_index >= 0 { start_index } else { thread_rng ( ) . gen_range ( 0 , spu_cnt ) } ; let gap_max = spu_cnt - param . replication_factor + 1 ; for p_idx in 0 .. param . partitions { let mut replicas : Vec < i32 > = vec ! [ ] ; let gap_cnt = ( ( s_idx + p_idx ) / spu_cnt ) % gap_max ; for r_idx in 0 .. param . replication_factor { let gap = if r_idx != 0 { gap_cnt } else { 0 } ; let spu_idx = ( ( s_idx + p_idx + r_idx + gap ) % spu_cnt ) as usize ; replicas . push ( spu_ids [ spu_idx ] ) ; } partition_map . insert ( p_idx , replicas ) ; } partition_map }
Generate partitions without taking rack assignments into consideration
Generate partitions without taking rack assignments into consideration
spus
&SpuLocalStore
param
&TopicReplicaParam
start_index
i32