Struct block_array_cow::BArrayStore
[−]
[src]
pub struct BArrayStore { /* fields omitted */ }Main storage for all states
Methods
impl BArrayStore[src]
Main Array Storage API
Create a new array store, which can store any number of arrays as long as their stride matches.
stridethesizeof()each element,
Note while a stride of 1 will always work,
its less efficient since duplicate chunks of memory will be searched
at positions unaligned with the array data.
chunk_countNumber of elements to split each chunk into.- A small value increases the ability to de-duplicate chunks,
but adds overhead by increasing the number of chunks
to look-up when searching for duplicates,
as well as some overhead constructing the original
array again, with more calls to
memcpy. - Larger values reduce the book keeping overhead, but increase the chance a small, isolated change will cause a larger amount of data to be duplicated.
- A small value increases the ability to de-duplicate chunks,
but adds overhead by increasing the number of chunks
to look-up when searching for duplicates,
as well as some overhead constructing the original
array again, with more calls to
Return a new array store.
fn new(stride: usize, chunk_count: usize) -> BArrayStore
fn clear(&mut self)
Clear all contents, allowing reuse of self.
fn calc_size_expanded_get(&self) -> usize
BArrayStore Statistics
return the total amount of memory that would be used by getting the arrays for all states.
fn calc_size_compacted_get(&self) -> usize
return the amount of memory used by all BChunk.data
(duplicate chunks are only counted once).
fn state_add(&mut self,
data: &[u8],
state_reference: Option<*const BArrayState>)
-> *mut BArrayState
data: &[u8],
state_reference: Option<*const BArrayState>)
-> *mut BArrayState
BArrayState Access
dataData used to create.state_referenceThe state to use as a reference when adding the new state, typically this is the previous state, however it can be any previously created state from thisself.
Returns the new state,
which is used by the caller as a handle to get back the contents of data.
This may be removed using BArrayStore.state_remove,
otherwise it will be removed with BArrayStore.destroy.
fn state_remove(&mut self, state: *mut BArrayState)
Remove a state and free any unused BChunk data.
The states can be freed in any order.
fn state_size_get(state: *const BArrayState) -> usize
return the expanded size of the array,
use this to know how much memory to allocate BArrayStore.state_data_get 's argument.
fn state_data_get(state: *const BArrayState, data: &mut [u8])
Fill in existing allocated memory with the contents of state.
fn state_data_get_alloc(state: *const BArrayState) -> Vec<u8>
Allocate an array for state and return it.