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

vortex-data / vortex / 16331938722

16 Jul 2025 10:49PM UTC coverage: 80.702% (-0.9%) from 81.557%
16331938722

push

github

web-flow
feat: build with stable rust (#3881)

120 of 173 new or added lines in 28 files covered. (69.36%)

174 existing lines in 102 files now uncovered.

41861 of 51871 relevant lines covered (80.7%)

157487.71 hits per line

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

95.08
/vortex-array/src/array/display/tree.rs
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3

4
use std::fmt::{self};
5

6
use humansize::{DECIMAL, format_size};
7

8
use crate::arrays::ChunkedEncoding;
9
use crate::display::DisplayOptions;
10
use crate::{Array, ArrayRef, ArrayVisitor};
11

12
pub(super) struct TreeDisplayWrapper(pub(super) ArrayRef);
13

14
impl fmt::Display for TreeDisplayWrapper {
15
    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
361✔
16
        let mut array_fmt = TreeFormatter {
361✔
17
            fmt,
361✔
18
            indent: "".to_string(),
361✔
19
            total_size: None,
361✔
20
        };
361✔
21
        array_fmt.format("root", self.0.clone())
361✔
22
    }
361✔
23
}
24

25
pub struct TreeFormatter<'a, 'b: 'a> {
26
    fmt: &'a mut fmt::Formatter<'b>,
27
    indent: String,
28
    total_size: Option<usize>,
29
}
30

31
impl<'a, 'b: 'a> TreeFormatter<'a, 'b> {
32
    fn format(&mut self, name: &str, array: ArrayRef) -> fmt::Result {
830✔
33
        let nbytes = array.nbytes();
830✔
34
        let total_size = self.total_size.unwrap_or(nbytes);
830✔
35
        writeln!(
830✔
36
            self,
830✔
37
            "{}: {} nbytes={} ({:.2}%)",
830✔
38
            name,
39
            array.display_as(DisplayOptions::MetadataOnly),
830✔
40
            format_size(nbytes, DECIMAL),
830✔
41
            100_f64 * nbytes as f64 / total_size as f64
830✔
UNCOV
42
        )?;
×
43

44
        self.indent(|i| {
830✔
45
            write!(i, "metadata: ")?;
830✔
46
            array.metadata_fmt(i.fmt)?;
830✔
47
            writeln!(i.fmt)?;
830✔
48

49
            for buffer in array.buffers() {
830✔
50
                writeln!(
722✔
51
                    i,
722✔
52
                    "buffer (align={}): {} ({:.2}%)",
722✔
53
                    buffer.alignment(),
722✔
54
                    format_size(buffer.len(), DECIMAL),
722✔
55
                    100_f64 * buffer.len() as f64 / nbytes as f64
722✔
UNCOV
56
                )?;
×
57
            }
58

59
            Ok(())
830✔
60
        })?;
830✔
61

62
        let old_total_size = self.total_size;
830✔
63
        if array.is_encoding(ChunkedEncoding.id()) {
830✔
64
            // Clear the total size so each chunk is treated as a new root.
65
            self.total_size = None
×
66
        } else {
830✔
67
            self.total_size = Some(nbytes);
830✔
68
        }
830✔
69

70
        self.indent(|i| {
830✔
71
            for (name, child) in array
830✔
72
                .children_names()
830✔
73
                .into_iter()
830✔
74
                .zip(array.children().into_iter())
830✔
75
            {
76
                i.format(&name, child)?;
469✔
77
            }
78
            Ok(())
830✔
79
        })?;
830✔
80

81
        self.total_size = old_total_size;
830✔
82
        Ok(())
830✔
83
    }
830✔
84

85
    fn indent<F>(&mut self, indented: F) -> fmt::Result
1,660✔
86
    where
1,660✔
87
        F: FnOnce(&mut TreeFormatter) -> fmt::Result,
1,660✔
88
    {
89
        let original_ident = self.indent.clone();
1,660✔
90
        self.indent += "  ";
1,660✔
91
        let res = indented(self);
1,660✔
92
        self.indent = original_ident;
1,660✔
93
        res
1,660✔
94
    }
1,660✔
95

96
    fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> fmt::Result {
2,382✔
97
        write!(self.fmt, "{}{}", self.indent, fmt)
2,382✔
98
    }
2,382✔
99
}
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

© 2025 Coveralls, Inc