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

vigna / webgraph-rs / 14130263389

28 Mar 2025 01:40PM UTC coverage: 49.654% (-0.1%) from 49.798%
14130263389

push

github

zommiommy
fixed llp wrong combine types

22 of 41 new or added lines in 4 files covered. (53.66%)

1019 existing lines in 41 files now uncovered.

2437 of 4908 relevant lines covered (49.65%)

18919274.03 hits per line

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

8.7
/src/cli/transform/transpose.rs
1
/*
2
 * SPDX-FileCopyrightText: 2023 Inria
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::cli::*;
9
use crate::prelude::*;
10
use anyhow::Result;
11
use clap::{ArgMatches, Args, Command, FromArgMatches};
12
use dsi_bitstream::dispatch::factory::CodesReaderFactoryHelper;
13
use dsi_bitstream::prelude::*;
14
use std::path::PathBuf;
15
use tempfile::Builder;
16

17
pub const COMMAND_NAME: &str = "transpose";
18

19
#[derive(Args, Debug)]
20
#[command(about = "Transposes a BvGraph.", long_about = None)]
21
pub struct CliArgs {
22
    /// The basename of the graph.
23
    pub src: PathBuf,
24
    /// The basename of the transposed graph.
25
    pub dst: PathBuf,
26

27
    #[clap(flatten)]
28
    pub num_threads: NumThreadsArg,
29

30
    #[clap(flatten)]
31
    pub batch_size: BatchSizeArg,
32

33
    #[clap(flatten)]
34
    pub ca: CompressArgs,
35
}
36

37
pub fn cli(command: Command) -> Command {
18✔
38
    command.subcommand(CliArgs::augment_args(Command::new(COMMAND_NAME)).display_order(0))
18✔
39
}
40

41
pub fn main(submatches: &ArgMatches) -> Result<()> {
×
UNCOV
42
    let args = CliArgs::from_arg_matches(submatches)?;
×
43

UNCOV
44
    create_parent_dir(&args.dst)?;
×
45

UNCOV
46
    match get_endianness(&args.src)?.as_str() {
×
47
        #[cfg(any(
48
            feature = "be_bins",
49
            not(any(feature = "be_bins", feature = "le_bins"))
50
        ))]
UNCOV
51
        BE::NAME => transpose::<BE>(args),
×
52
        #[cfg(any(
53
            feature = "le_bins",
54
            not(any(feature = "be_bins", feature = "le_bins"))
55
        ))]
56
        LE::NAME => transpose::<LE>(args),
×
UNCOV
57
        e => panic!("Unknown endianness: {}", e),
×
58
    }
59
}
60

UNCOV
61
pub fn transpose<E: Endianness>(args: CliArgs) -> Result<()>
×
62
where
63
    MmapHelper<u32>: CodesReaderFactoryHelper<E>,
64
{
UNCOV
65
    let thread_pool = crate::cli::get_thread_pool(args.num_threads.num_threads);
×
66

67
    // TODO!: speed it up by using random access graph if possible
UNCOV
68
    let seq_graph = crate::graphs::bvgraph::sequential::BvGraphSeq::with_basename(&args.src)
×
69
        .endianness::<E>()
70
        .load()?;
71

72
    // transpose the graph
UNCOV
73
    let sorted = crate::transform::transpose(&seq_graph, args.batch_size.batch_size).unwrap();
×
74

75
    let target_endianness = args.ca.endianness.clone();
×
UNCOV
76
    let dir = Builder::new().prefix("transform_transpose_").tempdir()?;
×
77
    BvComp::parallel_endianness(
78
        &args.dst,
×
79
        &sorted,
×
80
        sorted.num_nodes(),
×
81
        args.ca.into(),
×
82
        &thread_pool,
×
83
        dir,
×
UNCOV
84
        &target_endianness.unwrap_or_else(|| E::NAME.into()),
×
85
    )?;
86

UNCOV
87
    Ok(())
×
88
}
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