Skip to content

Commit

Permalink
Removed support to change amount of storable nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Thiel committed Jun 3, 2019
1 parent b255e63 commit 2aad00a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions src/traverse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 4 additions & 8 deletions tests/interactive.rs
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 2aad00a

Please sign in to comment.