pub struct BArrayStore { /* private fields */ }Expand description
Main storage for all states
Implementations§
Source§impl BArrayStore
impl BArrayStore
§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.
pub fn new(stride: usize, chunk_count: usize) -> BArrayStore
Sourcepub fn calc_size_expanded_get(&self) -> usize
pub 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.
Sourcepub fn calc_size_compacted_get(&self) -> usize
pub fn calc_size_compacted_get(&self) -> usize
return the amount of memory used by all BChunk.data
(duplicate chunks are only counted once).
Sourcepub fn state_add(
&mut self,
data: &[u8],
state_reference: Option<*const BArrayState>,
) -> *mut BArrayState
pub fn state_add( &mut self, 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.
Sourcepub fn state_remove(&mut self, state: *mut BArrayState)
pub 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.
Sourcepub fn state_size_get(state: *const BArrayState) -> usize
pub 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.
Sourcepub fn state_data_get(state: *const BArrayState, data: &mut [u8])
pub fn state_data_get(state: *const BArrayState, data: &mut [u8])
Fill in existing allocated memory with the contents of state.
Sourcepub fn state_data_get_alloc(state: *const BArrayState) -> Vec<u8> ⓘ
pub fn state_data_get_alloc(state: *const BArrayState) -> Vec<u8> ⓘ
Allocate an array for state and return it.