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

Method has_true

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

Returns whether there is at least one non-null `true` value in this array. This is more efficient than `true_count() > 0` because it can short-circuit as soon as a `true` value is found, without counting all set bits. Null values are not counted as `true`. Returns `false` for empty arrays.

(&self)

Source from the content-addressed store, hash-verified

185 ///
186 /// Null values are not counted as `true`. Returns `false` for empty arrays.
187 pub fn has_true(&self) -> bool {
188 match self.nulls() {
189 Some(nulls) => {
190 let null_chunks = nulls.inner().bit_chunks().iter_padded();
191 let value_chunks = self.values().bit_chunks().iter_padded();
192 null_chunks.zip(value_chunks).any(|(n, v)| (n & v) != 0)
193 }
194 None => self.values().has_true(),
195 }
196 }
197
198 /// Returns whether there is at least one non-null `false` value in this array.
199 ///

Callers 1

criterion_benchmarkFunction · 0.45

Calls 6

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

Tested by

no test coverage detected