pub struct TableBuilder { /* private fields */ }
Expand description
| TableBuilder provides the interface used to | build a Table (an immutable and sorted map from | keys to values). | | Multiple threads can invoke const methods on | a TableBuilder without external | synchronization, but if any of the threads may | call a non-const method, all threads accessing | the same TableBuilder must use external | synchronization.
Implementations§
Source§impl TableBuilder
impl TableBuilder
Sourcepub fn new(options: &Options, file: *mut dyn WritableFile) -> Self
pub fn new(options: &Options, file: *mut dyn WritableFile) -> Self
| Create a builder that will store the contents | of the table it is building in *file. Does | not close the file. It is up to the caller | to close the file after calling Finish().
Sourcepub fn change_options(&mut self, options: &Options) -> Status
pub fn change_options(&mut self, options: &Options) -> Status
| Change the options used by this builder. | Note: only some of the option fields can be | changed after construction. If a field is | not allowed to change dynamically and its | value in the structure passed to the | constructor is different from its value in | the structure passed to this method, this | method will return an error without changing | any fields.
Sourcepub fn add(&mut self, key_: &Slice, value: &Slice)
pub fn add(&mut self, key_: &Slice, value: &Slice)
| Add key,value to the table being constructed. | | REQUIRES: key is after any previously added | key according to comparator. | | REQUIRES: Finish(), Abandon() have not been | called
Sourcepub fn flush(&mut self)
pub fn flush(&mut self)
| Advanced operation: flush any buffered | key/value pairs to file. | | Can be used to ensure that two adjacent | entries never live in the same data block. | Most clients should not need to use this | method. | | REQUIRES: Finish(), Abandon() have not been | called
pub fn write_block( &mut self, block: *mut BlockBuilder, handle: *mut BlockHandle, )
pub fn write_raw_block( &mut self, block_contents: &Slice, ty: CompressionType, handle: *mut BlockHandle, )
Sourcepub fn finish(&mut self) -> Status
pub fn finish(&mut self) -> Status
| Finish building the table. Stops using the | file passed to the constructor after this | function returns. | | REQUIRES: Finish(), Abandon() have not been | called
Sourcepub fn abandon(&mut self)
pub fn abandon(&mut self)
| Indicate that the contents of this builder | should be abandoned. Stops using the file | passed to the constructor after this function | returns. | | If the caller is not going to call Finish(), | it must call Abandon() before destroying this | builder. | | REQUIRES: Finish(), Abandon() have not been | called
Sourcepub fn num_entries(&self) -> u64
pub fn num_entries(&self) -> u64
| Number of calls to Add() so far. |
Sourcepub fn file_size(&self) -> u64
pub fn file_size(&self) -> u64
| Size of the file generated so far. If | invoked after a successful Finish() | call, returns the size of the final generated | file. |