diff options
author | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-06-03 22:27:18 +0530 |
---|---|---|
committer | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-06-03 22:27:18 +0530 |
commit | 2aad00a568b31120144a16e80965be0495cf036f (patch) | |
tree | c9c3d62058ea8ffb355834870947a90083ec4b0d | |
parent | b255e63193cbb5e8e09c169334df2b2c35e2a5e7 (diff) |
Removed support to change amount of storable nodes
-rw-r--r-- | README.md | 12 | ||||
-rw-r--r-- | src/traverse.rs | 5 | ||||
-rw-r--r-- | tests/interactive.rs | 12 |
3 files changed, 15 insertions, 14 deletions
@@ -54,12 +54,18 @@ make Thanks to [jwalk][jwalk], all there was left to do is to write a command-line interface. As `jwalk` matures, **dua** should benefit instantly. -### Tradeoffs - +### Limitations + +* In interactive mode, you will need about 60MB of memory for 1 million entries in the graph. +* In interactive mode, the maximum amount of files is limited to 2^32 - 1 (`u32::max_value() - 1`) entries. + * One node is used as to 'virtual' root + * The actual amount of nodes stored might be lower, as there might be more edges than nodes, which are also limited by a `u32` (I guess) + * The limitation is imposed by the underlying [`petgraph`][petgraph] crate, which declares it as `unsafe` to use u64 for instance. + * It's possibly *UB* when that limit is reached, however, it was never observed either. * Dedication to `termion` * we use [`termion`][termion] exlusively, and even though [`tui`][tui] supports multiple backends, we only support its termion backend. _Reason_: `tui` is only used for parts of the program, and in all other parts `termion` is used for coloring the output. Thus we wouldn't support changing to a different backend anyway unless everything is done with TUI, which is really not what it is made for. - +[petgraph]: https://crates.io/crates/petgraph [rustup]: https://rustup.rs/ [jwalk]: https://crates.io/crates/jwalk [termion]: https://crates.io/crates/termion diff --git a/src/traverse.rs b/src/traverse.rs index 9c2501c..3690c1e 100644 --- a/src/traverse.rs +++ b/src/traverse.rs @@ -4,9 +4,8 @@ use petgraph::graph::NodeIndex; use petgraph::{Directed, Direction, Graph}; use std::{ffi::OsString, path::PathBuf, time::Duration, time::Instant}; -pub type TreeIndexType = u32; -pub type TreeIndex = NodeIndex<TreeIndexType>; -pub type Tree = Graph<EntryData, (), Directed, TreeIndexType>; +pub type TreeIndex = NodeIndex; +pub type Tree = Graph<EntryData, (), Directed>; #[derive(Eq, PartialEq, Debug, Default)] pub struct EntryData { diff --git a/tests/interactive.rs b/tests/interactive.rs index 6ade220..6ad4213 100644 --- a/tests/interactive.rs +++ b/tests/interactive.rs @@ -1,18 +1,15 @@ mod app { use dua::{ interactive::{widgets::SortMode, TerminalApp}, - traverse::{EntryData, Tree, TreeIndex, TreeIndexType}, + traverse::{EntryData, Tree, TreeIndex}, ByteFormat, Color, TraversalSorting, WalkOptions, }; use failure::Error; use petgraph::prelude::NodeIndex; use pretty_assertions::assert_eq; - use std::ffi::OsStr; - use std::path::PathBuf; - use std::{ffi::OsString, fmt, path::Path}; + use std::{ffi::OsStr, ffi::OsString, fmt, path::Path, path::PathBuf}; use termion::input::TermRead; - use tui::backend::TestBackend; - use tui::Terminal; + use tui::{backend::TestBackend, Terminal}; const FIXTURE_PATH: &'static str = "tests/fixtures"; @@ -315,8 +312,7 @@ mod app { fn make_add_node<'a>( t: &'a mut Tree, - ) -> impl FnMut(&str, u64, Option<NodeIndex<TreeIndexType>>) -> NodeIndex<TreeIndexType> + 'a - { + ) -> impl FnMut(&str, u64, Option<NodeIndex>) -> NodeIndex + 'a { move |name, size, maybe_from_idx| { let n = t.add_node(EntryData { name: OsString::from(name), |