risingwave_hummock_sdk::key

Function next_key

source
pub fn next_key(key: &[u8]) -> Vec<u8> 
Expand description

Computes the next key of the given key.

If the key has no successor key (e.g. the input is “\xff\xff”), the result would be an empty vector.

§Examples

use risingwave_hummock_sdk::key::next_key;
assert_eq!(next_key(b"123"), b"124");
assert_eq!(next_key(b"12\xff"), b"13");
assert_eq!(next_key(b"\xff\xff"), b"");
assert_eq!(next_key(b"\xff\xfe"), b"\xff\xff");
assert_eq!(next_key(b"T"), b"U");
assert_eq!(next_key(b""), b"");