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

vigna / webgraph-rs / 25054814280

28 Apr 2026 01:11PM UTC coverage: 69.158% (-0.04%) from 69.201%
25054814280

push

github

vigna
Further cleanup of method names; sorted symmetrization now uses IntoParLenders, too

24 of 59 new or added lines in 12 files covered. (40.68%)

761 existing lines in 28 files now uncovered.

7505 of 10852 relevant lines covered (69.16%)

50040578.59 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<()> {
×
UNCOV
52
    create_parent_dir(&args.dst)?;
×
53

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

UNCOV
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;
×
UNCOV
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;
×
UNCOV
78
    let bvgraphz = args.ca.bvgraphz;
×
79
    let mut builder = BvCompConf::new(&args.dst)
×
80
        .comp_flags(args.ca.into())
×
UNCOV
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| {
×
NEW
90
            crate::to::bvgraph::compress_seq_with_perm::<E, _>(
×
91
                thread_pool,
×
92
                builder,
×
UNCOV
93
                &src,
×
UNCOV
94
                target_endianness,
×
UNCOV
95
                memory_usage,
×
96
                log_interval,
×
97
                perm,
×
98
            )
99
        })
100
    } else {
101
        dispatch_int_slice!(loaded, |perm| {
×
NEW
102
            crate::to::bvgraph::compress_par_with_perm::<E, _>(
×
103
                thread_pool,
×
104
                builder,
×
UNCOV
105
                &src,
×
UNCOV
106
                target_endianness,
×
UNCOV
107
                memory_usage,
×
UNCOV
108
                use_dcf,
×
UNCOV
109
                log_interval,
×
UNCOV
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