[][src]Trait rocks::comparator::Comparator

pub trait Comparator {
    pub fn compare(&self, a: &[u8], b: &[u8]) -> Ordering;

    pub fn equal(&self, a: &[u8], b: &[u8]) -> bool { ... }
pub fn name(&self) -> &str { ... }
pub fn find_shortest_separator(
        &self,
        _start: &[u8],
        _limit: &[u8]
    ) -> Option<&[u8]> { ... }
pub fn find_short_successor(&self, _key: &[u8]) -> Option<&[u8]> { ... } }

A Comparator object provides a total order across slices that are used as keys in an sstable or a database. A Comparator implementation must be thread-safe since rocksdb may invoke its methods concurrently from multiple threads.

Required methods

pub fn compare(&self, a: &[u8], b: &[u8]) -> Ordering[src]

Three-way comparison. Returns value:

  • < 0 iff "a" < "b",
  • == 0 iff "a" == "b",
  • > 0 iff "a" > "b"
Loading content...

Provided methods

pub fn equal(&self, a: &[u8], b: &[u8]) -> bool[src]

Compares two slices for equality. The following invariant should always hold (and is the default implementation):

Equal(a, b) iff Compare(a, b) == 0

Overwrite only if equality comparisons can be done more efficiently than three-way comparisons.

pub fn name(&self) -> &str[src]

The name of the comparator. Used to check for comparator mismatches (i.e., a DB created with one comparator is accessed using a different comparator.

The client of this package should switch to a new name whenever the comparator implementation changes in a way that will cause the relative ordering of any two keys to change.

Names starting with "rocksdb." are reserved and should not be used by any clients of this package.

pub fn find_shortest_separator(
    &self,
    _start: &[u8],
    _limit: &[u8]
) -> Option<&[u8]>
[src]

If *start < limit, changes *start to a short string in [start,limit). Simple comparator implementations may return with *start unchanged, i.e., an implementation of this method that does nothing is correct.

pub fn find_short_successor(&self, _key: &[u8]) -> Option<&[u8]>[src]

Changes *key to a short string >= *key.

Simple comparator implementations may return with *key unchanged, i.e., an implementation of this method that does nothing is correct.

Loading content...

Implementors

Loading content...