Skip to main content

BvComp

Struct BvComp 

Source
pub struct BvComp<E, W: Write> {
    pub offsets_writer: OffsetsWriter<W>,
    /* private fields */
}
Expand description

Compresses a graph into the BV graph format.

This is the standard compressor: for each node, it considers the preceding nodes in a window of configurable size and greedily selects the reference that minimizes the bitstream length, subject to a maximum reference-chain depth (max_ref_count). It then splits the “extra” nodes (those that cannot be copied from the reference list) into intervals and residuals, as documented in the module-level documentation.

The compressor writes two bitstreams:

  • the graph bitstream, through the encoder E;
  • the offsets bitstream, through the OffsetsWriter.

Nodes must be pushed in order via push (or extend) and the compressor must be finalized with flush, which returns the CompStats.

In most cases you do not need to instantiate this struct directly: use BvComp::with_basename to obtain a BvCompConfig with suitable defaults, then call comp_graph or par_comp_graph on it.

For a compressor that uses an alternative reference-selection strategy based on dynamic programming, see BvCompZ.

Fields§

§offsets_writer: OffsetsWriter<W>

The offset writer, we should push the number of bits used by each node.

Implementations§

Source§

impl BvComp<(), Sink>

Source

pub fn with_basename(basename: impl AsRef<Path>) -> BvCompConfig

Convenience method returning a BvCompConfig with settings suitable for the standard Boldi–Vigna compressor.

Source§

impl<E: EncodeAndEstimate, W: Write> BvComp<E, W>

Source

pub const NO_INTERVALS: usize = Compressor::NO_INTERVALS

This value for min_interval_length implies that no intervalization will be performed.

Source

pub fn new( encoder: E, offsets_writer: OffsetsWriter<W>, compression_window: usize, max_ref_count: usize, min_interval_length: usize, start_node: usize, ) -> Self

Creates a new BvGraph compressor.

Source

pub fn push<I: IntoIterator<Item = usize>>( &mut self, succ_iter: I, ) -> Result<()>

Push a new node to the compressor. The iterator must yield the successors of the node and the nodes HAVE TO BE CONTIGUOUS (i.e. if a node has no neighbors you have to pass an empty iterator)

Source

pub fn flush(self) -> Result<CompStats>

Consume the compressor and return the statistics about compression.

Source

pub fn extend<L>(&mut self, iter_nodes: L) -> Result<()>
where L: IntoLender, L::Lender: for<'next> NodeLabelsLender<'next, Label = usize>,

Given an iterator over the nodes successors iterators, push them all. The iterator must yield the successors of the node and the nodes HAVE TO BE CONTIGUOUS (i.e. if a node has no neighbors you have to pass an empty iterator).

This most commonly is called with a reference to a graph.

Trait Implementations§

Source§

impl<E: Debug, W: Debug + Write> Debug for BvComp<E, W>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<E, W> Freeze for BvComp<E, W>
where E: Freeze, W: Freeze,

§

impl<E, W> RefUnwindSafe for BvComp<E, W>

§

impl<E, W> Send for BvComp<E, W>
where E: Send, W: Send,

§

impl<E, W> Sync for BvComp<E, W>
where E: Sync, W: Sync,

§

impl<E, W> Unpin for BvComp<E, W>
where E: Unpin, W: Unpin,

§

impl<E, W> UnsafeUnpin for BvComp<E, W>
where E: UnsafeUnpin, W: UnsafeUnpin,

§

impl<E, W> UnwindSafe for BvComp<E, W>
where E: UnwindSafe, W: UnwindSafe,

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