MCPcopy Create free account
hub / github.com/cosdata/cosdata / gen_combinations

Function gen_combinations

src/metadata/mod.rs:146–170  ·  view source on GitHub ↗
(vs: &Vec<Vec<u16>>)

Source from the content-addressed store, hash-verified

144}
145
146fn 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

Callers 2

test_gen_combinationsFunction · 0.85

Calls 3

cloneMethod · 0.80
is_emptyMethod · 0.45
pushMethod · 0.45

Tested by 1

test_gen_combinationsFunction · 0.68