pub struct SstFileWriter { /* private fields */ }Expand description
Writes a standalone SSTable file that a running crate::Db can
bulk-ingest via crate::Db::ingest_external_files.
Keys must be supplied in strictly ascending user-key order -
duplicates and out-of-order keys are rejected with an error. Every
entry is written with a placeholder sequence number of 0; the
real sequence number is assigned by the engine when the file is
ingested.
Implementations§
Source§impl SstFileWriter
impl SstFileWriter
Sourcepub fn create<P: AsRef<Path>>(path: P, opts: &Options) -> Result<Self>
pub fn create<P: AsRef<Path>>(path: P, opts: &Options) -> Result<Self>
Create a new SSTable file at path. The file is overwritten if
it already exists. The writer borrows block_size,
bloom_bits_per_key, and compression from opts after
validating the option invariants.
Sourcepub fn put(&mut self, key: &[u8], value: &[u8]) -> Result<()>
pub fn put(&mut self, key: &[u8], value: &[u8]) -> Result<()>
Append a (key, value) pair to the default column family.
key must be strictly greater than every previously added
key.
Sourcepub fn delete(&mut self, key: &[u8]) -> Result<()>
pub fn delete(&mut self, key: &[u8]) -> Result<()>
Append a deletion tombstone for key in the default column
family.
Sourcepub fn put_cf(
&mut self,
cf: &ColumnFamilyHandle,
key: &[u8],
value: &[u8],
) -> Result<()>
pub fn put_cf( &mut self, cf: &ColumnFamilyHandle, key: &[u8], value: &[u8], ) -> Result<()>
Append a (key, value) pair scoped to column family cf.
Keys across CFs must still arrive in strictly ascending
order (by prefixed bytes).
Sourcepub fn delete_cf(&mut self, cf: &ColumnFamilyHandle, key: &[u8]) -> Result<()>
pub fn delete_cf(&mut self, cf: &ColumnFamilyHandle, key: &[u8]) -> Result<()>
Append a deletion tombstone scoped to column family cf.
Sourcepub fn finish(self) -> Result<SstFileMeta>
pub fn finish(self) -> Result<SstFileMeta>
Finalize the file. Errors if no entries were written - an empty ingest file is almost certainly a bug and would be rejected at ingest time anyway.