Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vortex-tui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ futures-executor = { workspace = true }
futures-util = { workspace = true }
humansize = { workspace = true }
indicatif = { workspace = true, features = ["futures"] }
itertools = { workspace = true }
parquet = { workspace = true, features = ["arrow", "async"] }
ratatui = { workspace = true }
taffy = { workspace = true }
Expand Down
20 changes: 13 additions & 7 deletions vortex-tui/src/segments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
// SPDX-FileCopyrightText: Copyright the Vortex contributors

use std::collections::VecDeque;
use std::fmt::Display;
use std::path::Path;
use std::sync::Arc;

use itertools::Itertools as _;
use vortex::error::{VortexExpect, VortexResult};
use vortex::file::VortexOpenOptions;
use vortex::layout::LayoutRef;
Expand All @@ -14,31 +16,35 @@ pub async fn segments(file: impl AsRef<Path>) -> VortexResult<()> {

let segment_map = vxf.footer().segment_map();

let mut segment_names: Vec<Option<Arc<str>>> = vec![None; segment_map.len()];
let mut segment_paths: Vec<Option<Vec<Arc<str>>>> = vec![None; segment_map.len()];

let root_layout = vxf.footer().layout().clone();

let mut queue = VecDeque::<(Arc<str>, LayoutRef)>::from_iter([("".into(), root_layout)]);
let mut queue = VecDeque::<(Vec<Arc<str>>, LayoutRef)>::from_iter([(Vec::new(), root_layout)]);
while !queue.is_empty() {
let (name, layout) = queue.pop_front().vortex_expect("queue is not empty");
let (path, layout) = queue.pop_front().vortex_expect("queue is not empty");
for segment in layout.segment_ids() {
segment_names[*segment as usize] = Some(name.clone());
segment_paths[*segment as usize] = Some(path.clone());
}

for (child_layout, child_name) in layout.children()?.into_iter().zip(layout.child_names()) {
queue.push_back((child_name, child_layout));
let child_path = path.iter().cloned().chain([child_name]).collect();
queue.push_back((child_path, child_layout));
}
}

for (i, name) in segment_names.iter().enumerate() {
for (i, name) in segment_paths.iter().enumerate() {
println!(
"{}: {}..{} (len={}, alignment={}) - {}",
i,
segment_map[i].offset,
segment_map[i].offset + segment_map[i].length as u64,
segment_map[i].length,
segment_map[i].alignment,
name.clone().unwrap_or_else(|| "<missing>".into())
match name.as_ref() {
Some(path) => &path.iter().format(".") as &dyn Display,
None => &"<missing>",
}
);
}

Expand Down
Loading