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

vortex-data / vortex / 16728097825

04 Aug 2025 04:00PM UTC coverage: 48.355% (-35.1%) from 83.429%
16728097825

Pull #4108

github

web-flow
Merge 1b2d27fd8 into 649ba9576
Pull Request #4108: perf[vortex-array]: use all_valid instead of `invalid_count() == 0`

1 of 1 new or added line in 1 file covered. (100.0%)

11596 existing lines in 378 files now uncovered.

18635 of 38538 relevant lines covered (48.35%)

151786.4 hits per line

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

77.5
/vortex-array/src/arrays/struct_/serde.rs
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3

4
use itertools::Itertools;
5
use vortex_buffer::ByteBuffer;
6
use vortex_dtype::DType;
7
use vortex_error::{VortexExpect, VortexResult, vortex_bail};
8

9
use super::StructEncoding;
10
use crate::arrays::{StructArray, StructVTable};
11
use crate::serde::ArrayChildren;
12
use crate::validity::Validity;
13
use crate::vtable::{SerdeVTable, ValidityHelper, VisitorVTable};
14
use crate::{ArrayBufferVisitor, ArrayChildVisitor, EmptyMetadata};
15

16
impl SerdeVTable<StructVTable> for StructVTable {
17
    type Metadata = EmptyMetadata;
18

19
    fn metadata(_array: &StructArray) -> VortexResult<Option<Self::Metadata>> {
244✔
20
        Ok(Some(EmptyMetadata))
244✔
21
    }
244✔
22

23
    fn build(
250✔
24
        _encoding: &StructEncoding,
250✔
25
        dtype: &DType,
250✔
26
        len: usize,
250✔
27
        _metadata: &Self::Metadata,
250✔
28
        _buffers: &[ByteBuffer],
250✔
29
        children: &dyn ArrayChildren,
250✔
30
    ) -> VortexResult<StructArray> {
250✔
31
        let DType::Struct(struct_dtype, nullability) = dtype else {
250✔
32
            vortex_bail!("Expected struct dtype, found {:?}", dtype)
×
33
        };
34

35
        let (validity, non_data_children) = if children.len() == struct_dtype.nfields() {
250✔
36
            (Validity::from(*nullability), 0_usize)
250✔
UNCOV
37
        } else if children.len() == struct_dtype.nfields() + 1 {
×
38
            // Validity is the first child if it exists.
UNCOV
39
            let validity = children.get(0, &Validity::DTYPE, len)?;
×
UNCOV
40
            (Validity::Array(validity), 1_usize)
×
41
        } else {
42
            vortex_bail!(
×
43
                "Expected {} or {} children, found {}",
×
44
                struct_dtype.nfields(),
×
45
                struct_dtype.nfields() + 1,
×
46
                children.len()
×
47
            );
48
        };
49

50
        let children = (0..struct_dtype.nfields())
250✔
51
            .map(|i| {
1,412✔
52
                let child_dtype = struct_dtype
1,412✔
53
                    .field_by_index(i)
1,412✔
54
                    .vortex_expect("no out of bounds");
1,412✔
55
                children.get(non_data_children + i, &child_dtype, len)
1,412✔
56
            })
1,412✔
57
            .try_collect()?;
250✔
58

59
        StructArray::try_new_with_dtype(children, struct_dtype.clone(), len, validity)
250✔
60
    }
250✔
61
}
62

63
impl VisitorVTable<StructVTable> for StructVTable {
64
    fn visit_buffers(_array: &StructArray, _visitor: &mut dyn ArrayBufferVisitor) {}
366✔
65

66
    fn visit_children(array: &StructArray, visitor: &mut dyn ArrayChildVisitor) {
582✔
67
        visitor.visit_validity(array.validity(), array.len());
582✔
68
        for (idx, name) in array.names().iter().enumerate() {
3,130✔
69
            visitor.visit_child(name.as_ref(), &array.fields()[idx]);
3,130✔
70
        }
3,130✔
71
    }
582✔
72
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc