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

vigna / webgraph-rs / 18008720487

25 Sep 2025 01:16PM UTC coverage: 49.589% (-0.4%) from 49.949%
18008720487

push

github

vigna
Fixed fuzzing code for new epserde

0 of 2 new or added lines in 1 file covered. (0.0%)

650 existing lines in 25 files now uncovered.

3862 of 7788 relevant lines covered (49.59%)

25127316.85 hits per line

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

37.21
/cli/src/perm/comp.rs
1
/*
2
 * SPDX-FileCopyrightText: 2023 Sebastiano Vigna
3
 * SPDX-FileCopyrightText: 2023 Tommaso Fontana
4
 *
5
 * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
6
 */
7

8
use crate::{create_parent_dir, GlobalArgs};
9
use anyhow::{ensure, Result};
10
use clap::Parser;
11
use dsi_progress_logger::prelude::*;
12
use epserde::prelude::*;
13
use mmap_rs::MmapFlags;
14
use std::io::{BufWriter, Write};
15
use std::path::PathBuf;
16
use sux::traits::BitFieldSlice;
17
use webgraph::prelude::*;
18

19
#[derive(Parser, Debug)]
20
#[command(name="comp", about = "Compose multiple permutations into a single one", long_about = None)]
21
pub struct CliArgs {
22
    /// The filename of the resulting permutation in binary big-endian format.
23
    pub dst: PathBuf,
24

25
    /// Filenames of the permutations in binary big-endian format to compose (in order of application).
26
    pub perms: Vec<PathBuf>,
27

28
    #[arg(short, long)]
29
    /// Load and store permutations in ε-serde format.
30
    pub epserde: bool,
31
}
32

33
pub fn main(global_args: GlobalArgs, args: CliArgs) -> Result<()> {
4✔
34
    create_parent_dir(&args.dst)?;
8✔
35

36
    let mut pl = ProgressLogger::default();
4✔
37
    pl.display_memory(true).item_name("indices");
×
38

39
    if let Some(duration) = global_args.log_interval {
×
40
        pl.log_interval(duration);
×
41
    }
42

43
    if args.epserde {
×
44
        let mut perm = Vec::new();
×
45
        for path in args.perms {
×
46
            let p = unsafe { <Vec<usize>>::mmap(&path, Flags::RANDOM_ACCESS) }?;
×
47
            perm.push(p);
×
48
        }
49
        let mut merged = Vec::new();
×
50
        // TODO: reduce the number of uncase
51
        ensure!(
×
52
            perm.iter()
×
53
                .all(|p| p.uncase().len() == perm[0].uncase().len()),
×
UNCOV
54
            "All permutations must have the same length"
×
55
        );
56

57
        pl.start("Combining permutations...");
×
58
        for i in 0..perm[0].uncase().len() {
×
59
            let mut v = i;
×
60
            for p in &perm {
×
UNCOV
61
                v = p.uncase()[v];
×
62
            }
63
            merged.push(v);
×
UNCOV
64
            pl.light_update();
×
65
        }
66
        pl.done();
×
UNCOV
67
        unsafe { merged.store(&args.dst) }?;
×
68
    } else {
69
        let mut writer = BufWriter::new(std::fs::File::create(&args.dst)?);
8✔
UNCOV
70
        let mut perm = Vec::new();
×
71
        for path in args.perms {
20✔
72
            let p = JavaPermutation::mmap(&path, MmapFlags::RANDOM_ACCESS)?;
24✔
UNCOV
73
            perm.push(p);
×
74
        }
75

76
        ensure!(
4✔
UNCOV
77
            perm.iter()
×
78
                .all(|p| p.as_ref().len() == perm[0].as_ref().len()),
32✔
UNCOV
79
            "All permutations must have the same length"
×
80
        );
81

82
        pl.start("Combining permutations...");
4✔
83
        for i in 0..perm[0].as_ref().len() {
1,302,228✔
84
            let mut v = i;
2,604,456✔
85
            for p in &perm {
6,511,140✔
UNCOV
86
                v = p.get(v);
×
87
            }
88
            writer.write_all(&(v as u64).to_be_bytes())?;
3,906,684✔
89
            pl.light_update();
1,302,228✔
90
        }
91
        pl.done();
4✔
92
    }
93
    Ok(())
4✔
94
}
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