pub use vortex_utils::tree::IndentedFormatter;
use vortex_utils::tree::TreeDisplayContext;
pub use vortex_utils::tree::TreeDisplayExtractor as TreeExtractor;
use crate::ArrayRef;
use crate::arrays::Chunked;
pub struct TreeContext {
pub(crate) ancestor_sizes: Vec<Option<u64>>,
}
impl TreeContext {
pub(crate) fn new() -> Self {
Self {
ancestor_sizes: Vec::new(),
}
}
pub fn parent_total_size(&self) -> Option<u64> {
self.ancestor_sizes.last().cloned().flatten()
}
}
impl TreeDisplayContext<ArrayRef> for TreeContext {
fn push_parent(&mut self, parent: &ArrayRef) {
self.ancestor_sizes.push(if parent.is::<Chunked>() {
None
} else {
Some(parent.nbytes())
});
}
fn pop_parent(&mut self, _parent: &ArrayRef) {
self.ancestor_sizes.pop();
}
}