Skip to main content

BvCompConfig

Struct BvCompConfig 

Source
pub struct BvCompConfig { /* private fields */ }
Expand description

Configures and runs BvGraph compression.

A BvCompConfig is normally obtained via the convenience methods BvComp::with_basename (for the standard compressor) or BvCompZ::with_basename (for the Zuckerli-based compressor). It can then be customized using the builder methods below and finally used to compress a graph.

§Configuration

§Compression Methods

All methods produce the .graph, .offsets, and .properties files and return the total number of bits written to the graph bitstream.

§Examples

// Standard compression with default settings
BvComp::with_basename("output").comp_graph::<BE>(&graph)?;

// Standard compression with custom flags
BvComp::with_basename("output")
    .with_comp_flags(CompFlags {
        compression_window: 10,
        min_interval_length: 2,
        ..Default::default()
    })
    .comp_graph::<BE>(&graph)?;

// Parallel compression
BvComp::with_basename("output").par_comp_graph::<BE>(&graph)?;

// Zuckerli-based compression
BvCompZ::with_basename("output").comp_graph::<BE>(&graph)?;

Implementations§

Source§

impl BvCompConfig

Source

pub fn new(basename: impl AsRef<Path>) -> Self

Creates a new compression configuration with the given basename and default options.

Note that the convenience methods BvComp::with_basename and BvCompZ::with_basename can be used to create a configuration with default options.

Source§

impl BvCompConfig

Source

pub fn with_comp_flags(self, compression_flags: CompFlags) -> Self

Sets the CompFlags controlling the compression parameters (compression window, maximum reference count, minimum interval length, and the instantaneous codes used for each component of the successor list).

Source

pub fn with_tmp_dir(self, tmp_dir: impl AsRef<Path>) -> Self

Sets the temporary directory used by par_comp_lenders to store partial bitstreams. If not set, a system temporary directory is created automatically.

Source

pub fn with_bvgraphz(self) -> Self

Switches to the BvCompZ (Zuckerli-based) reference-selection algorithm.

Source

pub fn with_chunk_size(self, chunk_size: usize) -> Self

Sets the chunk size for BvCompZ and enables the Zuckerli-based compressor. The chunk size controls how many consecutive nodes are buffered before running the dynamic-programming reference-selection algorithm; larger chunks can yield better compression at the cost of more memory. Implies with_bvgraphz.

Source

pub fn comp_graph<E: Endianness>( &mut self, graph: impl SequentialGraph, ) -> Result<u64>

Compresses sequentially a SequentialGraph and returns the number of bits written to the graph bitstream.

Source

pub fn comp_lender<E, L>( &mut self, iter: L, expected_num_nodes: Option<usize>, ) -> Result<u64>
where E: Endianness, L: IntoLender, L::Lender: for<'next> NodeLabelsLender<'next, Label = usize>, BufBitWriter<E, WordAdapter<usize, BufWriter<File>>>: CodesWrite<E>,

Compresses sequentially a NodeLabelsLender and returns the number of bits written to the graph bitstream.

The optional expected_num_nodes parameter will be used to provide forecasts on the progress logger.

Source

pub fn par_comp_lenders_endianness<G: SplitLabeling + SequentialGraph>( &mut self, graph: &G, num_nodes: usize, endianness: &str, ) -> Result<u64>
where for<'a> <G as SplitLabeling>::SplitLender<'a>: ExactSizeLender + Send + Sync,

A wrapper over par_comp_lenders that takes the endianness as a string.

Endianness can only be BE::NAME or LE::NAME.

A given endianness is enabled only if the corresponding feature is enabled, be_bins for big endian and le_bins for little endian, or if neither features are enabled.

Source

pub fn par_comp_graph<E: Endianness>( &mut self, graph: &(impl SequentialGraph + for<'a> SplitLabeling<SplitLender<'a>: ExactSizeLender>), ) -> Result<u64>

Compresses a splittable sequential graph in parallel and returns the length in bits of the graph bitstream.

Note that the number of parallel compression threads will be current_num_threads. The graph will be split into as many lenders as there are threads.

Source

pub fn par_comp_lenders<E: Endianness, L: Lender + for<'next> NodeLabelsLender<'next, Label = usize> + ExactSizeLender + Send>( &mut self, iter: impl IntoIterator<Item = L>, num_nodes: usize, ) -> Result<u64>

Compresses multiple NodeLabelsLender in parallel and returns the length in bits of the graph bitstream.

The first lender must start from node 0, and each lender must continue from where the previous lender stopped. All in all, they must return a total of num_nodes nodes.

Note that the number of parallel compression threads will be current_num_threads. It is your responsibility to ensure that the number of threads is appropriate for the number of lenders you pass, possibly using install.

This method is useful to compress graphs that can be iterated upon using multiple lenders, but such lenders do not derive from splitting. For example, this happens when using ParSortIters.

Trait Implementations§

Source§

impl Debug for BvCompConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CastableFrom<T> for T

Source§

fn cast_from(value: T) -> T

Call Self as W
Source§

impl<T, U> CastableInto<U> for T
where U: CastableFrom<T>,

Source§

fn cast(self) -> U

Call W::cast_from(self)
Source§

impl<T> DowncastableFrom<T> for T

Source§

fn downcast_from(value: T) -> T

Truncate the current UnsignedInt to a possibly smaller size
Source§

impl<T, U> DowncastableInto<U> for T
where U: DowncastableFrom<T>,

Source§

fn downcast(self) -> U

Call W::downcast_from(self)
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Splat<T> for T

Source§

fn splat(value: T) -> T

Source§

impl<T> To<T> for T

Source§

fn to(self) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UpcastableFrom<T> for T

Source§

fn upcast_from(value: T) -> T

Extend the current UnsignedInt to a possibly bigger size.
Source§

impl<T, U> UpcastableInto<U> for T
where U: UpcastableFrom<T>,

Source§

fn upcast(self) -> U

Call W::upcast_from(self)
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V