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
with_comp_flags: setsCompFlags(compression window, maximum reference count, minimum interval length, and the instantaneous codes used for each component);with_bvgraphz: switches to the Zuckerli-based reference-selection algorithm;with_chunk_size: sets the chunk size forBvCompZ(implieswith_bvgraphz);with_tmp_dir: sets the temporary directory for parallel compression.
§Compression Methods
comp_graph: compresses aSequentialGraphsequentially;comp_lender: compresses aNodeLabelsLendersequentially;par_comp_graph: compresses a splittable graph in parallel;par_comp_lenders: compresses multiple lenders in parallel.
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
impl BvCompConfig
Sourcepub fn new(basename: impl AsRef<Path>) -> Self
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
impl BvCompConfig
Sourcepub fn with_comp_flags(self, compression_flags: CompFlags) -> Self
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).
Sourcepub fn with_tmp_dir(self, tmp_dir: impl AsRef<Path>) -> Self
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.
Sourcepub fn with_bvgraphz(self) -> Self
pub fn with_bvgraphz(self) -> Self
Switches to the BvCompZ (Zuckerli-based) reference-selection
algorithm.
Sourcepub fn with_chunk_size(self, chunk_size: usize) -> Self
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.
Sourcepub fn comp_graph<E: Endianness>(
&mut self,
graph: impl SequentialGraph,
) -> Result<u64>
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.
Sourcepub 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>,
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.
Sourcepub fn par_comp_lenders_endianness<G: SplitLabeling + SequentialGraph>(
&mut self,
graph: &G,
num_nodes: usize,
endianness: &str,
) -> Result<u64>
pub fn par_comp_lenders_endianness<G: SplitLabeling + SequentialGraph>( &mut self, graph: &G, num_nodes: usize, endianness: &str, ) -> Result<u64>
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.
Sourcepub fn par_comp_graph<E: Endianness>(
&mut self,
graph: &(impl SequentialGraph + for<'a> SplitLabeling<SplitLender<'a>: ExactSizeLender>),
) -> Result<u64>where
BufBitWriter<E, WordAdapter<usize, BufWriter<File>>>: CodesWrite<E>,
BufBitReader<E, WordAdapter<u32, BufReader<File>>>: BitRead<E>,
pub fn par_comp_graph<E: Endianness>(
&mut self,
graph: &(impl SequentialGraph + for<'a> SplitLabeling<SplitLender<'a>: ExactSizeLender>),
) -> Result<u64>where
BufBitWriter<E, WordAdapter<usize, BufWriter<File>>>: CodesWrite<E>,
BufBitReader<E, WordAdapter<u32, BufReader<File>>>: BitRead<E>,
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.
Sourcepub 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>where
BufBitWriter<E, WordAdapter<usize, BufWriter<File>>>: CodesWrite<E>,
BufBitReader<E, WordAdapter<u32, BufReader<File>>>: BitRead<E>,
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>where
BufBitWriter<E, WordAdapter<usize, BufWriter<File>>>: CodesWrite<E>,
BufBitReader<E, WordAdapter<u32, BufReader<File>>>: BitRead<E>,
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§
Auto Trait Implementations§
impl Freeze for BvCompConfig
impl RefUnwindSafe for BvCompConfig
impl Send for BvCompConfig
impl Sync for BvCompConfig
impl Unpin for BvCompConfig
impl UnsafeUnpin for BvCompConfig
impl UnwindSafe for BvCompConfig
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