MCPcopy Create free account
hub / github.com/apache/arrow-rs / true_count

Method true_count

arrow-array/src/array/boolean_array.rs:161–173  ·  view source on GitHub ↗

Returns the number of non null, true values within this array. If you only need to check if there is at least one true value, consider using `has_true()` which can short-circuit and be more efficient.

(&self)

Source from the content-addressed store, hash-verified

159 /// Returns the number of non null, true values within this array.
160 /// If you only need to check if there is at least one true value, consider using `has_true()` which can short-circuit and be more efficient.
161 pub fn true_count(&self) -> usize {
162 match self.nulls() {
163 Some(nulls) => {
164 let null_chunks = nulls.inner().bit_chunks().iter_padded();
165 let value_chunks = self.values().bit_chunks().iter_padded();
166 null_chunks
167 .zip(value_chunks)
168 .map(|(a, b)| (a & b).count_ones() as usize)
169 .sum()
170 }
171 None => self.values().count_set_bits(),
172 }
173 }
174
175 /// Returns the number of non null, false values within this array.
176 /// If you only need to check if there is at least one false value, consider using `has_false()` which can short-circuit and be more efficient.

Callers 5

boolean_rankFunction · 0.80
criterion_benchmarkFunction · 0.80
false_countMethod · 0.80

Calls 8

iter_paddedMethod · 0.80
zipMethod · 0.80
count_set_bitsMethod · 0.80
nullsMethod · 0.45
bit_chunksMethod · 0.45
innerMethod · 0.45
valuesMethod · 0.45
count_onesMethod · 0.45

Tested by

no test coverage detected