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

vigna / webgraph-rs / 14398898444

11 Apr 2025 08:24AM UTC coverage: 56.011% (-0.4%) from 56.361%
14398898444

push

github

vigna
Fixed test

8 of 8 new or added lines in 1 file covered. (100.0%)

477 existing lines in 19 files now uncovered.

3993 of 7129 relevant lines covered (56.01%)

20186811.3 hits per line

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

0.0
/cli/src/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::*;
9
use anyhow::Result;
10
use dsi_bitstream::dispatch::factory::CodesReaderFactoryHelper;
11
use dsi_bitstream::prelude::*;
12
use std::path::PathBuf;
13
use tempfile::Builder;
14
use webgraph::prelude::*;
15

16
#[derive(Parser, Debug)]
17
#[command(name = "transpose", about = "Transposes a BvGraph.", long_about = None)]
18
pub struct CliArgs {
19
    /// The basename of the graph.
20
    pub src: PathBuf,
21
    /// The basename of the transposed graph.
22
    pub dst: PathBuf,
23

24
    #[clap(flatten)]
25
    pub num_threads: NumThreadsArg,
26

27
    #[clap(flatten)]
28
    pub batch_size: BatchSizeArg,
29

30
    #[clap(flatten)]
31
    pub ca: CompressArgs,
32
}
33

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

37
    match get_endianness(&args.src)?.as_str() {
×
38
        #[cfg(feature = "be_bins")]
UNCOV
39
        BE::NAME => transpose::<BE>(global_args, args),
×
40
        #[cfg(feature = "le_bins")]
UNCOV
41
        LE::NAME => transpose::<LE>(global_args, args),
×
42
        e => panic!("Unknown endianness: {}", e),
×
43
    }
44
}
45

UNCOV
46
pub fn transpose<E: Endianness>(_global_args: GlobalArgs, args: CliArgs) -> Result<()>
×
47
where
48
    MmapHelper<u32>: CodesReaderFactoryHelper<E>,
49
{
UNCOV
50
    let thread_pool = crate::get_thread_pool(args.num_threads.num_threads);
×
51

52
    // TODO!: speed it up by using random access graph if possible
UNCOV
53
    let seq_graph = webgraph::graphs::bvgraph::sequential::BvGraphSeq::with_basename(&args.src)
×
54
        .endianness::<E>()
55
        .load()?;
56

57
    // transpose the graph
UNCOV
58
    let sorted = webgraph::transform::transpose(&seq_graph, args.batch_size.batch_size).unwrap();
×
59

UNCOV
60
    let target_endianness = args.ca.endianness.clone();
×
UNCOV
61
    let dir = Builder::new().prefix("transform_transpose_").tempdir()?;
×
62
    BvComp::parallel_endianness(
UNCOV
63
        &args.dst,
×
64
        &sorted,
×
UNCOV
65
        sorted.num_nodes(),
×
66
        args.ca.into(),
×
67
        &thread_pool,
×
UNCOV
68
        dir,
×
69
        &target_endianness.unwrap_or_else(|| E::NAME.into()),
×
70
    )?;
71

72
    Ok(())
×
73
}
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