• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

vortex-data / vortex / 16646733609

31 Jul 2025 10:38AM UTC coverage: 83.045% (-0.02%) from 83.063%
16646733609

push

github

web-flow
chore(deps): update rust crate divan to v3.0.5 (#4073)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [divan](https://codspeed.io)
([source](https://redirect.github.com/CodSpeedHQ/codspeed-rust)) |
workspace.dependencies | patch | `3.0.4` -> `3.0.5` |

---

### Release Notes

<details>
<summary>CodSpeedHQ/codspeed-rust (divan)</summary>

###
[`v3.0.5`](https://redirect.github.com/CodSpeedHQ/codspeed-rust/compare/v3.0.4...v3.0.5)

[Compare
Source](https://redirect.github.com/CodSpeedHQ/codspeed-rust/compare/v3.0.4...v3.0.5)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

â™» **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/vortex-data/vortex).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS40Ni4zIiwidXBkYXRlZEluVmVyIjoiNDEuNDYuMyIsInRhcmdldEJyYW5jaCI6ImRldmVsb3AiLCJsYWJlbHMiOlsiY2hvcmUiXX0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

46016 of 55411 relevant lines covered (83.04%)

452882.11 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
/vortex-array/src/compute/invert.rs
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3

4
use std::sync::LazyLock;
5

6
use arcref::ArcRef;
7
use vortex_dtype::DType;
8
use vortex_error::{VortexError, VortexResult, vortex_bail, vortex_err, vortex_panic};
9

10
use crate::compute::{ComputeFn, ComputeFnVTable, InvocationArgs, Kernel, Output, UnaryArgs};
11
use crate::vtable::VTable;
12
use crate::{Array, ArrayRef, IntoArray, ToCanonical};
13

14
static INVERT_FN: LazyLock<ComputeFn> = LazyLock::new(|| {
115✔
15
    let compute = ComputeFn::new("invert".into(), ArcRef::new_ref(&Invert));
115✔
16
    for kernel in inventory::iter::<InvertKernelRef> {
536✔
17
        compute.register_kernel(kernel.0.clone());
421✔
18
    }
421✔
19
    compute
115✔
20
});
115✔
21

22
/// Logically invert a boolean array, preserving its validity.
23
pub fn invert(array: &dyn Array) -> VortexResult<ArrayRef> {
116✔
24
    INVERT_FN
116✔
25
        .invoke(&InvocationArgs {
116✔
26
            inputs: &[array.into()],
116✔
27
            options: &(),
116✔
28
        })?
116✔
29
        .unwrap_array()
116✔
30
}
116✔
31

32
struct Invert;
33

34
impl ComputeFnVTable for Invert {
35
    fn invoke(
116✔
36
        &self,
116✔
37
        args: &InvocationArgs,
116✔
38
        kernels: &[ArcRef<dyn Kernel>],
116✔
39
    ) -> VortexResult<Output> {
116✔
40
        let UnaryArgs { array, .. } = UnaryArgs::<()>::try_from(args)?;
116✔
41

42
        for kernel in kernels {
116✔
43
            if let Some(output) = kernel.invoke(args)? {
116✔
44
                return Ok(output);
116✔
45
            }
×
46
        }
47
        if let Some(output) = array.invoke(&INVERT_FN, args)? {
×
48
            return Ok(output);
×
49
        }
×
50

51
        // Otherwise, we canonicalize into a boolean array and invert.
52
        log::debug!(
×
53
            "No invert implementation found for encoding {}",
×
54
            array.encoding_id(),
×
55
        );
56
        if array.is_canonical() {
×
57
            vortex_panic!("Canonical bool array does not implement invert");
×
58
        }
×
59
        Ok(invert(&array.to_bool()?.into_array())?.into())
×
60
    }
116✔
61

62
    fn return_dtype(&self, args: &InvocationArgs) -> VortexResult<DType> {
116✔
63
        let UnaryArgs { array, .. } = UnaryArgs::<()>::try_from(args)?;
116✔
64

65
        if !matches!(array.dtype(), DType::Bool(..)) {
116✔
66
            vortex_bail!("Expected boolean array, got {}", array.dtype());
×
67
        }
116✔
68
        Ok(array.dtype().clone())
116✔
69
    }
116✔
70

71
    fn return_len(&self, args: &InvocationArgs) -> VortexResult<usize> {
116✔
72
        let UnaryArgs { array, .. } = UnaryArgs::<()>::try_from(args)?;
116✔
73
        Ok(array.len())
116✔
74
    }
116✔
75

76
    fn is_elementwise(&self) -> bool {
116✔
77
        true
116✔
78
    }
116✔
79
}
80

81
struct InvertArgs<'a> {
82
    array: &'a dyn Array,
83
}
84

85
impl<'a> TryFrom<&InvocationArgs<'a>> for InvertArgs<'a> {
86
    type Error = VortexError;
87

88
    fn try_from(value: &InvocationArgs<'a>) -> Result<Self, Self::Error> {
116✔
89
        if value.inputs.len() != 1 {
116✔
90
            vortex_bail!("Invert expects exactly one argument",);
×
91
        }
116✔
92
        let array = value.inputs[0]
116✔
93
            .array()
116✔
94
            .ok_or_else(|| vortex_err!("Invert expects an array argument"))?;
116✔
95
        Ok(InvertArgs { array })
116✔
96
    }
116✔
97
}
98

99
pub struct InvertKernelRef(ArcRef<dyn Kernel>);
100
inventory::collect!(InvertKernelRef);
101

102
pub trait InvertKernel: VTable {
103
    /// Logically invert a boolean array. Converts true -> false, false -> true, null -> null.
104
    fn invert(&self, array: &Self::Array) -> VortexResult<ArrayRef>;
105
}
106

107
#[derive(Debug)]
108
pub struct InvertKernelAdapter<V: VTable>(pub V);
109

110
impl<V: VTable + InvertKernel> InvertKernelAdapter<V> {
111
    pub const fn lift(&'static self) -> InvertKernelRef {
×
112
        InvertKernelRef(ArcRef::new_ref(self))
×
113
    }
×
114
}
115

116
impl<V: VTable + InvertKernel> Kernel for InvertKernelAdapter<V> {
117
    fn invoke(&self, args: &InvocationArgs) -> VortexResult<Option<Output>> {
116✔
118
        let args = InvertArgs::try_from(args)?;
116✔
119
        let Some(array) = args.array.as_opt::<V>() else {
116✔
120
            return Ok(None);
×
121
        };
122
        Ok(Some(V::invert(&self.0, array)?.into()))
116✔
123
    }
116✔
124
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc