| 144 | } |
| 145 | |
| 146 | fn gen_combinations(vs: &Vec<Vec<u16>>) -> Vec<Vec<u16>> { |
| 147 | if vs.is_empty() { |
| 148 | return vec![]; |
| 149 | } |
| 150 | // Start with a single empty combination |
| 151 | let mut combinations = vec![Vec::new()]; |
| 152 | // For each vector in the input |
| 153 | for v in vs { |
| 154 | // Create new combinations by extending each existing combination |
| 155 | // with each element from the current vector |
| 156 | let mut new_combinations = Vec::new(); |
| 157 | for combination in combinations { |
| 158 | for item in v { |
| 159 | // Create a new combination by cloning the existing |
| 160 | // one and adding the new item |
| 161 | let mut new_combination = combination.clone(); |
| 162 | new_combination.push(*item); |
| 163 | new_combinations.push(new_combination); |
| 164 | } |
| 165 | } |
| 166 | // Replace the old combinations with the new ones |
| 167 | combinations = new_combinations; |
| 168 | } |
| 169 | combinations |
| 170 | } |
| 171 | |
| 172 | /// Calculates level probs for pseudo replica nodes that are added at |
| 173 | /// the time of index creation for collections that have metadata |