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

Method has_true

arrow-buffer/src/buffer/boolean.rs:645–652  ·  view source on GitHub ↗

Returns whether there is at least one `true` value in this buffer. This is more efficient than `count_set_bits() > 0` because it can short-circuit as soon as a `true` value is found, without counting all set bits. Returns `false` for empty buffer.

(&self)

Source from the content-addressed store, hash-verified

643 ///
644 /// Returns `false` for empty buffer.
645 pub fn has_true(&self) -> bool {
646 let bit_chunks = self.unaligned_bit_chunks();
647 let chunks = bit_chunks.chunks();
648 let mut exact = chunks.chunks_exact(Self::CHUNK_FOLD_BLOCK_SIZE);
649 let found = bit_chunks.prefix().unwrap_or(0) != 0
650 || exact.any(|block| block.iter().fold(0u64, |acc, &c| acc | c) != 0);
651 found || exact.remainder().iter().any(|&c| c != 0) || bit_chunks.suffix().unwrap_or(0) != 0
652 }
653
654 /// Returns whether there is at least one `false` value in this buffer.
655 ///

Callers

nothing calls this directly

Calls 5

unaligned_bit_chunksMethod · 0.80
chunksMethod · 0.80
prefixMethod · 0.80
suffixMethod · 0.80
iterMethod · 0.45

Tested by

no test coverage detected