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

vigna / webgraph-rs / 14196927616

01 Apr 2025 01:28PM UTC coverage: 56.787% (+7.4%) from 49.345%
14196927616

Pull #122

github

web-flow
Merge 706583c76 into 5b5393a19
Pull Request #122: Refactored argmin and argmax into an extension trait for Iterator and moved argmin_filtered and argmax_filtered into compute.rs

1279 of 1630 new or added lines in 34 files covered. (78.47%)

3736 of 6579 relevant lines covered (56.79%)

13936227.79 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(any(
39
            feature = "be_bins",
40
            not(any(feature = "be_bins", feature = "le_bins"))
41
        ))]
42
        BE::NAME => transpose::<BE>(global_args, args),
×
43
        #[cfg(any(
44
            feature = "le_bins",
45
            not(any(feature = "be_bins", feature = "le_bins"))
46
        ))]
47
        LE::NAME => transpose::<LE>(global_args, args),
×
48
        e => panic!("Unknown endianness: {}", e),
×
49
    }
50
}
51

52
pub fn transpose<E: Endianness>(_global_args: GlobalArgs, args: CliArgs) -> Result<()>
×
53
where
54
    MmapHelper<u32>: CodesReaderFactoryHelper<E>,
55
{
NEW
56
    let thread_pool = crate::get_thread_pool(args.num_threads.num_threads);
×
57

58
    // TODO!: speed it up by using random access graph if possible
NEW
59
    let seq_graph = webgraph::graphs::bvgraph::sequential::BvGraphSeq::with_basename(&args.src)
×
60
        .endianness::<E>()
61
        .load()?;
62

63
    // transpose the graph
NEW
64
    let sorted = webgraph::transform::transpose(&seq_graph, args.batch_size.batch_size).unwrap();
×
65

66
    let target_endianness = args.ca.endianness.clone();
×
67
    let dir = Builder::new().prefix("transform_transpose_").tempdir()?;
×
68
    BvComp::parallel_endianness(
69
        &args.dst,
×
70
        &sorted,
×
71
        sorted.num_nodes(),
×
72
        args.ca.into(),
×
73
        &thread_pool,
×
74
        dir,
×
75
        &target_endianness.unwrap_or_else(|| E::NAME.into()),
×
76
    )?;
77

78
    Ok(())
×
79
}
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