Mercurial > hg
annotate rust/hg-core/examples/nodemap/main.rs @ 50979:4c5f6e95df84
rust: make `Revision` a newtype
This change is the one we've been building towards during this series.
The aim is to make `Revision` mean more than a simple integer, holding
the information that it is valid for a given revlog index.
While this still allows for programmer error, since creating a revision
directly and querying a different index with a "checked" revision are
still possible, the friction created by the newtype will hopefully make
us think twice about which type to use.
Enough of the Rust ecosystem relies on the newtype pattern to be
efficiently optimized away (even compiler in codegen testsĀ¹), so I'm not
worried about this being a fundamental problem.
[1] https://github.com/rust-lang/rust/blob/7a70647f195f6b0a0f1ebd72b1542ba91a32f43a/tests/codegen/vec-in-place.rs#L47
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Fri, 18 Aug 2023 14:34:29 +0200 |
parents | 0d301f4180f5 |
children |
rev | line source |
---|---|
44386
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
1 // Copyright 2019-2020 Georges Racinet <georges.racinet@octobus.net> |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
2 // |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
3 // This software may be used and distributed according to the terms of the |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
4 // GNU General Public License version 2 or any later version. |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
5 |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
6 use hg::revlog::node::*; |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
7 use hg::revlog::nodemap::*; |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
8 use hg::revlog::*; |
47955
e834b79def74
rust: Switch to the memmap2-rs crate
Simon Sapin <simon.sapin@octobus.net>
parents:
46432
diff
changeset
|
9 use memmap2::MmapOptions; |
44386
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
10 use rand::Rng; |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
11 use std::fs::File; |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
12 use std::io; |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
13 use std::io::Write; |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
14 use std::path::{Path, PathBuf}; |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
15 use std::time::Instant; |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
16 |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
17 mod index; |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
18 use index::Index; |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
19 |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
20 fn mmap_index(repo_path: &Path) -> Index { |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
21 let mut path = PathBuf::from(repo_path); |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
22 path.extend([".hg", "store", "00changelog.i"].iter()); |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
23 Index::load_mmap(path) |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
24 } |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
25 |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
26 fn mmap_nodemap(path: &Path) -> NodeTree { |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
27 let file = File::open(path).unwrap(); |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
28 let mmap = unsafe { MmapOptions::new().map(&file).unwrap() }; |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
29 let len = mmap.len(); |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
30 NodeTree::load_bytes(Box::new(mmap), len) |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
31 } |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
32 |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
33 /// Scan the whole index and create the corresponding nodemap file at `path` |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
34 fn create(index: &Index, path: &Path) -> io::Result<()> { |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
35 let mut file = File::create(path)?; |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
36 let start = Instant::now(); |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
37 let mut nm = NodeTree::default(); |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
38 for rev in 0..index.len() { |
50979
4c5f6e95df84
rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents:
49920
diff
changeset
|
39 let rev = Revision(rev as BaseRevision); |
44386
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
40 nm.insert(index, index.node(rev).unwrap(), rev).unwrap(); |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
41 } |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
42 eprintln!("Nodemap constructed in RAM in {:?}", start.elapsed()); |
49920
0d301f4180f5
rust-clippy: use `write_all` since we're not expecting a partial write
Raphaël Gomès <rgomes@octobus.net>
parents:
49914
diff
changeset
|
43 file.write_all(&nm.into_readonly_and_added_bytes().1)?; |
44386
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
44 eprintln!("Nodemap written to disk"); |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
45 Ok(()) |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
46 } |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
47 |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
48 fn query(index: &Index, nm: &NodeTree, prefix: &str) { |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
49 let start = Instant::now(); |
46432
18a261b11b20
rust: Remove hex parsing from the nodemap
Simon Sapin <simon.sapin@octobus.net>
parents:
46427
diff
changeset
|
50 let res = NodePrefix::from_hex(prefix).map(|p| nm.find_bin(index, p)); |
44386
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
51 println!("Result found in {:?}: {:?}", start.elapsed(), res); |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
52 } |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
53 |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
54 fn bench(index: &Index, nm: &NodeTree, queries: usize) { |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
55 let len = index.len() as u32; |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
56 let mut rng = rand::thread_rng(); |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
57 let nodes: Vec<Node> = (0..queries) |
50979
4c5f6e95df84
rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents:
49920
diff
changeset
|
58 .map(|_| { |
4c5f6e95df84
rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents:
49920
diff
changeset
|
59 *index |
4c5f6e95df84
rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents:
49920
diff
changeset
|
60 .node(Revision((rng.gen::<u32>() % len) as BaseRevision)) |
4c5f6e95df84
rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents:
49920
diff
changeset
|
61 .unwrap() |
4c5f6e95df84
rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents:
49920
diff
changeset
|
62 }) |
44386
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
63 .collect(); |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
64 if queries < 10 { |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
65 let nodes_hex: Vec<String> = |
46427
6380efb82191
rust: replace Node::encode_hex with std::fmt::LowerHex
Simon Sapin <simon.sapin@octobus.net>
parents:
44386
diff
changeset
|
66 nodes.iter().map(|n| format!("{:x}", n)).collect(); |
44386
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
67 println!("Nodes: {:?}", nodes_hex); |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
68 } |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
69 let mut last: Option<Revision> = None; |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
70 let start = Instant::now(); |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
71 for node in nodes.iter() { |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
72 last = nm.find_bin(index, node.into()).unwrap(); |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
73 } |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
74 let elapsed = start.elapsed(); |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
75 println!( |
46427
6380efb82191
rust: replace Node::encode_hex with std::fmt::LowerHex
Simon Sapin <simon.sapin@octobus.net>
parents:
44386
diff
changeset
|
76 "Did {} queries in {:?} (mean {:?}), last was {:x} with result {:?}", |
44386
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
77 queries, |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
78 elapsed, |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
79 elapsed / (queries as u32), |
46427
6380efb82191
rust: replace Node::encode_hex with std::fmt::LowerHex
Simon Sapin <simon.sapin@octobus.net>
parents:
44386
diff
changeset
|
80 nodes.last().unwrap(), |
44386
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
81 last |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
82 ); |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
83 } |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
84 |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
85 fn main() { |
49637
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
86 use clap::{Parser, Subcommand}; |
44386
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
87 |
49637
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
88 #[derive(Parser)] |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
89 #[command()] |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
90 /// Nodemap pure Rust example |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
91 struct App { |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
92 // Path to the repository, always necessary for its index |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
93 #[arg(short, long)] |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
94 repository: PathBuf, |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
95 // Path to the nodemap file, independent of REPOSITORY |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
96 #[arg(short, long)] |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
97 nodemap_file: PathBuf, |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
98 #[command(subcommand)] |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
99 command: Command, |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
100 } |
44386
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
101 |
49637
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
102 #[derive(Subcommand)] |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
103 enum Command { |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
104 /// Create `NODEMAP_FILE` by scanning repository index |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
105 Create, |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
106 /// Query `NODEMAP_FILE` for `prefix` |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
107 Query { prefix: String }, |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
108 /// Perform #`QUERIES` random successful queries on `NODEMAP_FILE` |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
109 Bench { queries: usize }, |
44386
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
110 } |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
111 |
49637
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
112 let app = App::parse(); |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
113 |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
114 let repo = &app.repository; |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
115 let nm_path = &app.nodemap_file; |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
116 |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
117 let index = mmap_index(repo); |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
118 let nm = mmap_nodemap(nm_path); |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
119 |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
120 match &app.command { |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
121 Command::Create => { |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
122 println!( |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
123 "Creating nodemap file {} for repository {}", |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
124 nm_path.display(), |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
125 repo.display() |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
126 ); |
49914
58074252db3c
rust: run `cargo clippy`
Raphaël Gomès <rgomes@octobus.net>
parents:
49637
diff
changeset
|
127 create(&index, Path::new(nm_path)).unwrap(); |
49637
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
128 } |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
129 Command::Bench { queries } => { |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
130 println!( |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
131 "Doing {} random queries in nodemap file {} of repository {}", |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
132 queries, |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
133 nm_path.display(), |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
134 repo.display() |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
135 ); |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
136 bench(&index, &nm, *queries); |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
137 } |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
138 Command::Query { prefix } => { |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
139 println!( |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
140 "Querying {} in nodemap file {} of repository {}", |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
141 prefix, |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
142 nm_path.display(), |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
143 repo.display() |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
144 ); |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
145 query(&index, &nm, prefix); |
14bfd22a57a9
hg-core: upgrade `clap` dependency
Raphaël Gomès <rgomes@octobus.net>
parents:
47955
diff
changeset
|
146 } |
44386
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
147 } |
8f7c6656ac79
rust-nodemap: pure Rust example
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
148 } |