Struct okaywal::Configuration
source · pub struct Configuration<M> {
pub file_manager: M,
pub directory: PathId,
pub preallocate_bytes: u32,
pub checkpoint_after_bytes: u64,
pub buffer_bytes: usize,
pub version_info: Arc<Vec<u8>>,
}
Expand description
A WriteAheadLog
configuration.
Fields§
§file_manager: M
The file manager to use for storing data.
Typically this is [StdFileManager
].
directory: PathId
The directory to store the log files in.
preallocate_bytes: u32
The number of bytes each log file should be preallocated with. Log files may grow to be larger than this size if needed.
checkpoint_after_bytes: u64
After this many bytes have been written to the active log file, begin a
checkpointing process. This number should be less than
preallocate_bytes
to try to ensure the checkpointing process happens
before the preallocated space is fully exhausted. If this amount is too
close to the preallocation amount, an entry being written may need to
extend the file which is a slow operation.
buffer_bytes: usize
The number of bytes to use for the in-memory buffer when reading and writing from the log.
version_info: Arc<Vec<u8>>
An arbitrary chunk of bytes that is stored in the log files. Limited to 255 bytes. This can be used for any purpose, but the design inspiration was to allow detection of what format or version of a format the data was inside of the log without needing to parse the entries.
Implementations§
source§impl Configuration<StdFileManager>
impl Configuration<StdFileManager>
sourcepub fn default_for<P: AsRef<Path>>(path: P) -> Self
pub fn default_for<P: AsRef<Path>>(path: P) -> Self
Returns the default configuration for a given directory.
This currently is:
preallocate_bytes
: 1 megabytecheckpoint_after_bytes
: 768 kilobytesbuffer_bytes
: 16 kilobytes
source§impl<M> Configuration<M>where
M: FileManager,
impl<M> Configuration<M>where M: FileManager,
sourcepub fn default_with_manager<P: AsRef<Path>>(path: P, file_manager: M) -> Self
pub fn default_with_manager<P: AsRef<Path>>(path: P, file_manager: M) -> Self
Returns the default configuration for a given directory and file manager.
This currently is:
preallocate_bytes
: 1 megabytecheckpoint_after_bytes
: 768 kilobytesbuffer_bytes
: 16 kilobytes
sourcepub fn preallocate_bytes(self, bytes: u32) -> Self
pub fn preallocate_bytes(self, bytes: u32) -> Self
Sets the number of bytes to preallocate for each segment file. Returns self
.
Preallocating disk space allows for more consistent performance. This number should be large enough to allow batching multiple entries into one checkpointing operation.
sourcepub fn checkpoint_after_bytes(self, bytes: u64) -> Self
pub fn checkpoint_after_bytes(self, bytes: u64) -> Self
Sets the number of bytes written required to begin a checkpoint
operation. Returns self
.
This value should be smaller than preallocate_bytes
to ensure
checkpoint operations begin before too much data is written in a log
entry. If more data is written before a checkpoint occurs, the segment
will grow to accommodate the extra data, but that write will not be as
fast due to needing to allocate more space from the filesystem to
perform the write.
sourcepub fn buffer_bytes(self, bytes: usize) -> Self
pub fn buffer_bytes(self, bytes: usize) -> Self
Sets the number of bytes to use for internal buffers when reading and
writing data to the log. Returns self
.
sourcepub fn open<Manager: LogManager<M>>(
self,
manager: Manager
) -> Result<WriteAheadLog<M>>
pub fn open<Manager: LogManager<M>>( self, manager: Manager ) -> Result<WriteAheadLog<M>>
Opens the log using the provided log manager with this configuration.
Trait Implementations§
source§impl<M: Clone> Clone for Configuration<M>
impl<M: Clone> Clone for Configuration<M>
source§fn clone(&self) -> Configuration<M>
fn clone(&self) -> Configuration<M>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more