Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion webgraph/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "webgraph"
version = "0.4.0"
edition = "2021"
edition = "2024"
description = "A Rust port of the WebGraph framework (http://webgraph.di.unimi.it/)."
repository = "https://github.com/vigna/webgraph-rs/"
license = "Apache-2.0 OR LGPL-2.1-or-later"
Expand Down
4 changes: 2 additions & 2 deletions webgraph/examples/bench_sort_pairs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ use anyhow::Result;
use clap::Parser;
use dsi_bitstream::traits::BitRead;
use dsi_bitstream::traits::BitWrite;
use dsi_bitstream::traits::{Endianness, BE};
use dsi_bitstream::traits::{BE, Endianness};
use dsi_progress_logger::prelude::{ProgressLog, ProgressLogger};
use rand::rngs::SmallRng;
use rand::RngCore;
use rand::SeedableRng;
use rand::rngs::SmallRng;
use tempfile::Builder;
use webgraph::prelude::*;
use webgraph::utils::gaps::GapsCodec;
Expand Down
2 changes: 1 addition & 1 deletion webgraph/examples/bench_swh_labels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bitstream::Supply;
use clap::Parser;
use dsi_bitstream::codes::GammaRead;
use dsi_bitstream::impls::{BufBitReader, MemWordReader};
use dsi_bitstream::traits::{BitRead, BitSeek, Endianness, BE};
use dsi_bitstream::traits::{BE, BitRead, BitSeek, Endianness};
use dsi_progress_logger::prelude::*;
use epserde::deser::{Deserialize, Flags};
use lender::*;
Expand Down
9 changes: 6 additions & 3 deletions webgraph/src/graphs/arc_list_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

use crate::{labels::Left, traits::*};
use anyhow::{ensure, Result};
use anyhow::{Result, ensure};
use lender::*;

/// An adapter exhibiting a list of labeled arcs sorted by source as a [labeled
Expand Down Expand Up @@ -108,7 +108,10 @@ impl<L: Clone + 'static, I: Iterator<Item = ((usize, usize), L)>> Iter<L, I> {
pub fn try_new_from(num_nodes: usize, iter: I, from: usize) -> Result<Self> {
let mut iter = iter.peekable();
if let Some(((first_src, _), _)) = iter.peek() {
ensure!(*first_src >= from, "Tried to create arc_list_graph::Iter starting from {from} using an iterator starting from {first_src}");
ensure!(
*first_src >= from,
"Tried to create arc_list_graph::Iter starting from {from} using an iterator starting from {first_src}"
);
}
Ok(Iter {
num_nodes: num_nodes + from,
Expand Down Expand Up @@ -222,7 +225,7 @@ impl<L, I: IntoIterator<Item = ((usize, usize), L)>> Iterator for Succ<'_, L, I>
type Item = (usize, L);
fn next(&mut self) -> Option<Self::Item> {
// If the next pair is not there, or it has a different source, we are done
if self.node_iter.iter.peek()?.0 .0 >= self.node_iter.next_node {
if self.node_iter.iter.peek()?.0.0 >= self.node_iter.next_node {
return None;
}
// get the next labeled pair
Expand Down
122 changes: 61 additions & 61 deletions webgraph/src/graphs/bvgraph/codecs/dec_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
use std::marker::PhantomData;

use super::super::*;
use anyhow::bail;
use anyhow::Result;
use anyhow::bail;
use dsi_bitstream::dispatch::code_consts;
use dsi_bitstream::dispatch::factory::CodesReaderFactoryHelper;
use dsi_bitstream::prelude::*;
Expand Down Expand Up @@ -38,14 +38,14 @@ pub struct ConstCodesDecoder<
}

impl<
E: Endianness,
CR: CodesRead<E> + BitSeek,
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> BitSeek for ConstCodesDecoder<E, CR, OUTDEGREES, REFERENCES, BLOCKS, INTERVALS, RESIDUALS>
E: Endianness,
CR: CodesRead<E> + BitSeek,
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> BitSeek for ConstCodesDecoder<E, CR, OUTDEGREES, REFERENCES, BLOCKS, INTERVALS, RESIDUALS>
{
type Error = <CR as BitSeek>::Error;

Expand All @@ -59,14 +59,14 @@ impl<
}

impl<
E: Endianness,
CR: CodesRead<E>,
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> ConstCodesDecoder<E, CR, OUTDEGREES, REFERENCES, BLOCKS, INTERVALS, RESIDUALS>
E: Endianness,
CR: CodesRead<E>,
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> ConstCodesDecoder<E, CR, OUTDEGREES, REFERENCES, BLOCKS, INTERVALS, RESIDUALS>
{
/// Creates a new [`ConstCodesEncoder`] from a [`CodesRead`] implementation.
/// and a [`CompFlags`] struct
Expand Down Expand Up @@ -96,14 +96,14 @@ impl<
}

impl<
E: Endianness,
CR: CodesRead<E>,
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> Decode for ConstCodesDecoder<E, CR, OUTDEGREES, REFERENCES, BLOCKS, INTERVALS, RESIDUALS>
E: Endianness,
CR: CodesRead<E>,
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> Decode for ConstCodesDecoder<E, CR, OUTDEGREES, REFERENCES, BLOCKS, INTERVALS, RESIDUALS>
{
#[inline(always)]
fn read_outdegree(&mut self) -> u64 {
Expand Down Expand Up @@ -167,15 +167,15 @@ pub struct ConstCodesDecoderFactory<
}

impl<
E: Endianness,
F: CodesReaderFactoryHelper<E>,
OFF: Offsets,
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> ConstCodesDecoderFactory<E, F, OFF, OUTDEGREES, REFERENCES, BLOCKS, INTERVALS, RESIDUALS>
E: Endianness,
F: CodesReaderFactoryHelper<E>,
OFF: Offsets,
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> ConstCodesDecoderFactory<E, F, OFF, OUTDEGREES, REFERENCES, BLOCKS, INTERVALS, RESIDUALS>
{
/// Remaps the offsets in a slice of `usize`.
///
Expand Down Expand Up @@ -210,15 +210,15 @@ impl<
}

impl<
E: Endianness,
F: CodesReaderFactoryHelper<E>,
OFF: Offsets,
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> ConstCodesDecoderFactory<E, F, OFF, OUTDEGREES, REFERENCES, BLOCKS, INTERVALS, RESIDUALS>
E: Endianness,
F: CodesReaderFactoryHelper<E>,
OFF: Offsets,
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> ConstCodesDecoderFactory<E, F, OFF, OUTDEGREES, REFERENCES, BLOCKS, INTERVALS, RESIDUALS>
{
/// Creates a new builder from the given data and compression flags.
pub fn new(factory: F, offsets: MemCase<OFF>, comp_flags: CompFlags) -> anyhow::Result<Self> {
Expand Down Expand Up @@ -246,15 +246,15 @@ impl<
}

impl<
E: Endianness,
F: CodesReaderFactoryHelper<E>,
OFF: Offsets,
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> RandomAccessDecoderFactory
E: Endianness,
F: CodesReaderFactoryHelper<E>,
OFF: Offsets,
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> RandomAccessDecoderFactory
for ConstCodesDecoderFactory<E, F, OFF, OUTDEGREES, REFERENCES, BLOCKS, INTERVALS, RESIDUALS>
where
for<'a> <F as CodesReaderFactory<E>>::CodesReader<'a>: BitSeek,
Expand All @@ -276,15 +276,15 @@ where
}

impl<
E: Endianness,
F: CodesReaderFactoryHelper<E>,
OFF: Offsets,
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> SequentialDecoderFactory
E: Endianness,
F: CodesReaderFactoryHelper<E>,
OFF: Offsets,
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> SequentialDecoderFactory
for ConstCodesDecoderFactory<E, F, OFF, OUTDEGREES, REFERENCES, BLOCKS, INTERVALS, RESIDUALS>
{
type Decoder<'a>
Expand Down
2 changes: 1 addition & 1 deletion webgraph/src/graphs/bvgraph/codecs/dec_dyn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
use std::marker::PhantomData;

use super::super::*;
use dsi_bitstream::dispatch::factory::CodesReaderFactoryHelper;
use dsi_bitstream::dispatch::CodesReaderFactory;
use dsi_bitstream::dispatch::factory::CodesReaderFactoryHelper;
use dsi_bitstream::prelude::*;

use epserde::deser::{MemCase, Owned};
Expand Down
88 changes: 44 additions & 44 deletions webgraph/src/graphs/bvgraph/codecs/enc_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ pub struct ConstCodesEncoder<
}

impl<
E: Endianness,
CW: CodesWrite<E> + BitSeek,
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> BitSeek for ConstCodesEncoder<E, CW, OUTDEGREES, REFERENCES, BLOCKS, INTERVALS, RESIDUALS>
E: Endianness,
CW: CodesWrite<E> + BitSeek,
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> BitSeek for ConstCodesEncoder<E, CW, OUTDEGREES, REFERENCES, BLOCKS, INTERVALS, RESIDUALS>
{
type Error = <CW as BitSeek>::Error;

Expand All @@ -49,14 +49,14 @@ impl<
}

impl<
E: Endianness,
CW: CodesWrite<E>,
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> ConstCodesEncoder<E, CW, OUTDEGREES, REFERENCES, BLOCKS, INTERVALS, RESIDUALS>
E: Endianness,
CW: CodesWrite<E>,
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> ConstCodesEncoder<E, CW, OUTDEGREES, REFERENCES, BLOCKS, INTERVALS, RESIDUALS>
{
/// Creates a new [`ConstCodesEncoder`] with the given [`CodesWrite`] implementation.
pub fn new(code_writer: CW) -> Self {
Expand All @@ -68,14 +68,14 @@ impl<
}

impl<
E: Endianness,
CW: CodesWrite<E>,
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> Encode for ConstCodesEncoder<E, CW, OUTDEGREES, REFERENCES, BLOCKS, INTERVALS, RESIDUALS>
E: Endianness,
CW: CodesWrite<E>,
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> Encode for ConstCodesEncoder<E, CW, OUTDEGREES, REFERENCES, BLOCKS, INTERVALS, RESIDUALS>
{
type Error = <CW as BitWrite<E>>::Error;

Expand Down Expand Up @@ -136,14 +136,14 @@ impl<
}

impl<
E: Endianness,
CW: CodesWrite<E>,
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> EncodeAndEstimate
E: Endianness,
CW: CodesWrite<E>,
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> EncodeAndEstimate
for ConstCodesEncoder<E, CW, OUTDEGREES, REFERENCES, BLOCKS, INTERVALS, RESIDUALS>
{
type Estimator<'a>
Expand All @@ -166,25 +166,25 @@ pub struct ConstCodesEstimator<
>;

impl<
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> ConstCodesEstimator<OUTDEGREES, REFERENCES, BLOCKS, INTERVALS, RESIDUALS>
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> ConstCodesEstimator<OUTDEGREES, REFERENCES, BLOCKS, INTERVALS, RESIDUALS>
{
pub fn new() -> Self {
Self
}
}

impl<
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> Encode for ConstCodesEstimator<OUTDEGREES, REFERENCES, BLOCKS, INTERVALS, RESIDUALS>
const OUTDEGREES: usize,
const REFERENCES: usize,
const BLOCKS: usize,
const INTERVALS: usize,
const RESIDUALS: usize,
> Encode for ConstCodesEstimator<OUTDEGREES, REFERENCES, BLOCKS, INTERVALS, RESIDUALS>
{
type Error = Infallible;

Expand Down
2 changes: 1 addition & 1 deletion webgraph/src/graphs/bvgraph/codecs/factories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::{
prelude::{FileBufReader, MemBufReader},
utils::MmapHelper,
};
use anyhow::{ensure, Context};
use anyhow::{Context, ensure};
use bitflags::bitflags;
use common_traits::UnsignedInt;
use dsi_bitstream::{
Expand Down
2 changes: 1 addition & 1 deletion webgraph/src/graphs/bvgraph/comp/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
*/

use anyhow::{bail, ensure, Result};
use anyhow::{Result, bail, ensure};
use dsi_bitstream::dispatch::Codes;
use dsi_bitstream::traits::{BigEndian, Endianness, LittleEndian};
use std::collections::HashMap;
Expand Down
Loading