pub struct AppendVec { /* private fields */ }
Expand description
A thread-safe, file-backed block of memory used to store Account
instances. Append operations
are serialized such that only one thread updates the internal append_lock
at a time. No
restrictions are placed on reading. That is, one may read items from one thread while another
is appending new items.
Implementations§
Source§impl AppendVec
impl AppendVec
pub fn new(file: &Path, create: bool, size: usize) -> Self
pub fn set_no_remove_on_drop(&mut self)
pub fn flush(&self) -> Result<()>
pub fn reset(&self)
Sourcepub fn remaining_bytes(&self) -> u64
pub fn remaining_bytes(&self) -> u64
how many more bytes can be stored in this append vec
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn capacity(&self) -> u64
pub fn file_name(slot: Slot, id: impl Display) -> String
pub fn new_from_file<P: AsRef<Path>>( path: P, current_len: usize, ) -> Result<(Self, usize)>
Sourcepub fn new_from_file_unchecked<P: AsRef<Path>>(
path: P,
current_len: usize,
) -> Result<Self>
pub fn new_from_file_unchecked<P: AsRef<Path>>( path: P, current_len: usize, ) -> Result<Self>
Creates an appendvec from file without performing sanitize checks or counting the number of accounts
Sourcepub fn get_account<'a>(
&'a self,
offset: usize,
) -> Option<(StoredAccountMeta<'a>, usize)>
pub fn get_account<'a>( &'a self, offset: usize, ) -> Option<(StoredAccountMeta<'a>, usize)>
Return account metadata for the account at offset
if its data doesn’t overrun
the internal buffer. Otherwise return None. Also return the offset of the first byte
after the requested data that falls on a 64-byte boundary.
pub fn get_path(&self) -> PathBuf
Sourcepub fn account_iter(&self) -> AppendVecAccountsIter<'_> ⓘ
pub fn account_iter(&self) -> AppendVecAccountsIter<'_> ⓘ
Return iterator for account metadata
Sourcepub fn accounts(&self, offset: usize) -> Vec<StoredAccountMeta<'_>>
pub fn accounts(&self, offset: usize) -> Vec<StoredAccountMeta<'_>>
Return a vector of account metadata for each account, starting from offset
.
Sourcepub fn append_accounts(
&self,
accounts: &[(StoredMeta, Option<&impl ReadableAccount>)],
hashes: &[impl Borrow<Hash>],
) -> Vec<usize>
pub fn append_accounts( &self, accounts: &[(StoredMeta, Option<&impl ReadableAccount>)], hashes: &[impl Borrow<Hash>], ) -> Vec<usize>
Copy each account metadata, account and hash to the internal buffer.
Return the starting offset of each account metadata.
After each account is appended, the internal current_len
is updated
and will be available to other threads.
Sourcepub fn append_account(
&self,
storage_meta: StoredMeta,
account: &AccountSharedData,
hash: Hash,
) -> Option<usize>
pub fn append_account( &self, storage_meta: StoredMeta, account: &AccountSharedData, hash: Hash, ) -> Option<usize>
Copy the account metadata, account and hash to the internal buffer.
Return the starting offset of the account metadata.
After the account is appended, the internal current_len
is updated.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for AppendVec
impl RefUnwindSafe for AppendVec
impl Send for AppendVec
impl Sync for AppendVec
impl Unpin for AppendVec
impl UnwindSafe for AppendVec
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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