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>
impl BvComp<(), Sink>
Sourcepub fn with_basename(basename: impl AsRef<Path>) -> BvCompConfig
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>
impl<E: EncodeAndEstimate, W: Write> BvComp<E, W>
Sourcepub const NO_INTERVALS: usize = Compressor::NO_INTERVALS
pub const NO_INTERVALS: usize = Compressor::NO_INTERVALS
This value for min_interval_length implies that no intervalization will be performed.
Sourcepub fn new(
encoder: E,
offsets_writer: OffsetsWriter<W>,
compression_window: usize,
max_ref_count: usize,
min_interval_length: usize,
start_node: usize,
) -> Self
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.
Sourcepub fn push<I: IntoIterator<Item = usize>>(
&mut self,
succ_iter: I,
) -> Result<()>
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)
Sourcepub fn flush(self) -> Result<CompStats>
pub fn flush(self) -> Result<CompStats>
Consume the compressor and return the statistics about compression.
Sourcepub fn extend<L>(&mut self, iter_nodes: L) -> Result<()>
pub fn extend<L>(&mut self, iter_nodes: L) -> Result<()>
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§
Auto Trait Implementations§
impl<E, W> Freeze for BvComp<E, W>
impl<E, W> RefUnwindSafe for BvComp<E, W>where
E: RefUnwindSafe,
W: RefUnwindSafe,
impl<E, W> Send for BvComp<E, W>
impl<E, W> Sync for BvComp<E, W>
impl<E, W> Unpin for BvComp<E, W>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
Source§impl<T> DowncastableFrom<T> for T
impl<T> DowncastableFrom<T> for T
Source§fn downcast_from(value: T) -> T
fn downcast_from(value: T) -> T
Source§impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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