//! The output generated by this example must be used with the `dot` command coming from the `graphviz` package. //! /!\ As the tree is really large, this example only prints the first root node. //! If you want to get general stats about your database see the `stats` example. use std::fs::File; use std::io::BufWriter; use std::path::PathBuf; use arroy::distances::DotProduct; use arroy::{Database, Reader}; use clap::Parser; use heed::EnvOpenOptions; #[derive(Parser)] #[command(author, version, about, long_about = None)] struct Cli { /// Sets a custom database path. #[arg(default_value = "import.ary")] database: PathBuf, /// Sets the output path for the graph. #[arg(long, default_value = "graph.dot")] output_path: PathBuf, } fn main() { let Cli { database, output_path } = Cli::parse(); let output = File::create(&output_path).unwrap(); let writer = BufWriter::new(output); let env = unsafe { EnvOpenOptions::new() .map_size(1024 * 1024 * 1024 * 2) // 2GiB .open(database) } .unwrap(); let rtxn = env.read_txn().unwrap(); let database: Database = env.database_options().types().open(&rtxn).unwrap().unwrap(); let reader = Reader::::open(&rtxn, 0, database).unwrap(); reader.plot_internals_tree_nodes(&rtxn, writer).unwrap(); eprintln!("To convert the graph to a png, run: `dot {output_path:?} -T png > graph.png`"); eprintln!("`dot` comes from the graphiz package"); }