Interface KeyFilter
byte[]
keys that is also capable of efficiently jumping over
contiguous regions of uncontained keys.
Instances assume byte[]
keys are ordered in unsigned lexicographical order.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(byte[] key) Determine whether this instance contains the given key.byte[]
seekHigher
(byte[] key) Skip over the largest possible uncontained region in an upward direction.byte[]
seekLower
(byte[] key) Skip over the largest possible uncontained region in a downward direction.
-
Method Details
-
contains
boolean contains(byte[] key) Determine whether this instance contains the given key.- Parameters:
key
- key to test- Returns:
- true if
key
is contained by this instance, otherwise false - Throws:
IllegalArgumentException
- ifkey
is null
-
seekHigher
byte[] seekHigher(byte[] key) Skip over the largest possible uncontained region in an upward direction.This method should return an inclusive lower bound on all keys greater than or equal to
key
that are contained by this instance. The bound does not have to be tight, but the tighter the better.A value of null may be returned to indicate that no key greater than or equal to
key
is contained by this instance.If
key
is contained by this instance, this method must returnkey
; ifkey
is not contained by this instance, this method must return a key strictly higher thankey
or null.- Parameters:
key
- starting key- Returns:
- a lower bound (inclusive) for contained keys greater than or equal to
key
, or null if no key greater than or equal tokey
is contained by this instance - Throws:
IllegalArgumentException
- ifkey
is null
-
seekLower
byte[] seekLower(byte[] key) Skip over the largest possible uncontained region in a downward direction.This method should return an exclusive upper bound on all keys strictly less than
key
that are contained by this instance. The bound does not have to be tight, but the tighter the better.A value of null may be returned to indicate that no key strictly less than
key
is contained by this instance.For the purposes of this method, an empty
byte[]
array represents an upper bound greater than allbyte[]
keys. This interpretation applies both to thekey
parameter and returned value. Note that this implies an empty array cannot be returned to indicate that no keys exist (instead, return null).This method must either return null or a value less than or equal to
key
(using the above interpretation for empty arrays).- Parameters:
key
- starting key, or an empty array to indicate a maximal upper bound- Returns:
- an upper bound (exclusive) for contained keys strictly less that
key
, null if no key strictly less thankey
is contained by this instance, or an emptybyte[]
array to indicate an upper bound greater than allbyte[]
keys (which implieskey
was also empty) - Throws:
IllegalArgumentException
- ifkey
is null
-