• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

vigna / webgraph-rs / 28829100046

06 Jul 2026 11:00PM UTC coverage: 72.759% (+3.5%) from 69.212%
28829100046

Pull #171

github

zommiommy
test: guard mmap-dependent new tests from Miri

The default and explicit LoadMmap load paths mprotect anonymous maps,
which Miri does not support; the zero-node roundtrip now runs only its
LoadMem loads under Miri. The new CLI integration tests are excluded
wholesale like the preexisting ones, as the CLI loads graphs and
Elias-Fano structures through mmap.
Pull Request #171: Fixes from a full-workspace code review: correctness, error handling, robustness

356 of 482 new or added lines in 60 files covered. (73.86%)

9 existing lines in 6 files now uncovered.

8157 of 11211 relevant lines covered (72.76%)

49198900.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/cli/src/transform/perm.rs
1
/*
2
 * SPDX-FileCopyrightText: 2026 Sebastiano Vigna
3
 *
4
 * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
5
 */
6

7
use crate::*;
8
use anyhow::Result;
9
use dsi_bitstream::{dispatch::factory::CodesReaderFactoryHelper, prelude::*};
10
use std::path::PathBuf;
11
use tempfile::Builder;
12
use webgraph::prelude::*;
13

14
#[derive(Parser, Debug)]
15
#[command(name = "perm", about = "Permutes a graph in the BV format according to a given permutation.", long_about = None, next_line_help = true)]
16
pub struct CliArgs {
17
    /// The basename of the graph.​
18
    pub src: PathBuf,
19
    /// The basename of the permuted graph.​
20
    pub dst: PathBuf,
21

22
    /// The path to the permutation to apply to the graph.​
23
    pub permutation: PathBuf,
24

25
    #[arg(long, value_enum, default_value_t)]
26
    /// The format of the permutation file.​
27
    pub fmt: IntSliceFormat,
28

29
    #[arg(short, long)]
30
    /// Uses the sequential algorithm (does not need offsets).​
31
    pub sequential: bool,
32

33
    #[clap(flatten)]
34
    pub num_threads: NumThreadsArg,
35

36
    #[clap(flatten)]
37
    pub memory_usage: MemoryUsageArg,
38

39
    #[clap(flatten)]
40
    pub ca: CompressArgs,
41

42
    #[arg(long, conflicts_with = "sequential")]
43
    /// Uses the degree cumulative function to balance work by arcs rather than
44
    /// by nodes; the DCF must have been pre-built with `webgraph build dcf`.​
45
    pub dcf: bool,
46

47
    #[clap(flatten)]
48
    pub log_interval: LogIntervalArg,
49
}
50

51
pub fn main(args: CliArgs) -> Result<()> {
×
52
    create_parent_dir(&args.dst)?;
×
53

54
    match get_endianness(&args.src)?.as_str() {
×
55
        #[cfg(feature = "be_bins")]
56
        BE::NAME => perm::<BE>(args),
×
57
        #[cfg(feature = "le_bins")]
58
        LE::NAME => perm::<LE>(args),
×
NEW
59
        e => anyhow::bail!("Unknown endianness: {}", e),
×
60
    }
61
}
62

63
pub fn perm<E: Endianness>(args: CliArgs) -> Result<()>
×
64
where
65
    MmapHelper<u32>: CodesReaderFactoryHelper<E>,
66
    for<'a> LoadModeCodesReader<'a, E, Mmap>: BitSeek + Clone + Send + Sync,
67
{
68
    let thread_pool = crate::get_thread_pool(args.num_threads.num_threads);
×
69
    let sequential = args.sequential;
×
70
    let use_dcf = args.dcf;
×
71
    let src = args.src.clone();
×
72
    let target_endianness = args.ca.endianness.clone();
×
73
    let memory_usage = args.memory_usage.memory_usage;
×
74
    let log_interval = args.log_interval.log_interval;
×
75

76
    let dir = Builder::new().prefix("transform_perm_").tempdir()?;
×
77
    let chunk_size = args.ca.chunk_size;
×
78
    let bvgraphz = args.ca.bvgraphz;
×
79
    let mut builder = BvCompConf::new(&args.dst)
×
80
        .comp_flags(args.ca.into())
×
81
        .tmp_dir(&dir);
×
82

83
    if bvgraphz {
×
84
        builder = builder.chunk_size(chunk_size);
×
85
    }
86

87
    let loaded = args.fmt.load(&args.permutation)?;
×
88
    if sequential {
×
89
        dispatch_int_slice!(loaded, |perm| {
×
90
            crate::to::bvgraph::compress_seq_with_perm::<E, _>(
×
91
                thread_pool,
×
92
                builder,
×
93
                &src,
×
94
                target_endianness,
×
95
                memory_usage,
×
96
                log_interval,
×
97
                perm,
×
98
            )
99
        })
100
    } else {
101
        dispatch_int_slice!(loaded, |perm| {
×
102
            crate::to::bvgraph::compress_par_with_perm::<E, _>(
×
103
                thread_pool,
×
104
                builder,
×
105
                &src,
×
106
                target_endianness,
×
107
                memory_usage,
×
108
                use_dcf,
×
109
                log_interval,
×
110
                perm,
×
111
            )
112
        })
113
    }
114
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc