vortex_array/array/validity.rs
1use vortex_error::VortexResult;
2use vortex_mask::Mask;
3
4/// Implementation trait for validity functions.
5///
6/// These functions should not be called directly, rather their equivalents on the base
7/// [`crate::Array`] trait should be used.
8pub trait ArrayValidityImpl {
9 /// Returns whether the `index` item is valid.
10 ///
11 /// ## Pre-conditions
12 /// - `index` is less than the length of the array.
13 fn _is_valid(&self, index: usize) -> VortexResult<bool>;
14
15 /// Returns whether the array is all valid.
16 fn _all_valid(&self) -> VortexResult<bool>;
17
18 /// Returns whether the array is all invalid.
19 fn _all_invalid(&self) -> VortexResult<bool>;
20
21 /// Returns the number of valid elements in the array.
22 ///
23 /// ## Post-conditions
24 /// - The count is less than or equal to the length of the array.
25 fn _valid_count(&self) -> VortexResult<usize> {
26 Ok(self._validity_mask()?.true_count())
27 }
28
29 /// Returns the number of invalid elements in the array.
30 ///
31 /// ## Post-conditions
32 /// - The count is less than or equal to the length of the array.
33 fn _invalid_count(&self) -> VortexResult<usize> {
34 Ok(self._validity_mask()?.false_count())
35 }
36
37 /// Returns the canonical validity mask for the array.
38 ///
39 /// ## Post-conditions
40 /// - The count is less than or equal to the length of the array.
41 fn _validity_mask(&self) -> VortexResult<Mask>;
42}