public class KeySelector extends Object
KeySelector identifies a particular key in the database. FoundationDB's
lexicographically ordered data model permits finding keys based on their order (for
example, finding the first key in the database greater than a given key). Key selectors
represent a description of a key in the database that could be resolved to an actual
key by Transaction's getKey()
or used directly as the beginning or end of a range in Transaction's
getRange().KeySelector:
add(int) call does not
modify internal state, but returns a new instance.
| Constructor and Description |
|---|
KeySelector(byte[] key,
boolean orEqual,
int offset)
Constructs a new
KeySelector from the given parameters. |
| Modifier and Type | Method and Description |
|---|---|
KeySelector |
add(int offset)
Returns a new
KeySelector offset by a given
number of keys from this one. |
static KeySelector |
firstGreaterOrEqual(byte[] key)
Creates a
KeySelector that picks the first key greater than or equal to the parameter |
static KeySelector |
firstGreaterThan(byte[] key)
Creates a
KeySelector that picks the first key greater than the parameter |
byte[] |
getKey()
Returns a copy of the key that serves as the anchor for this
KeySelector. |
int |
getOffset()
Returns the key offset for this
KeySelector. |
static KeySelector |
lastLessOrEqual(byte[] key)
Creates a
KeySelector that picks the last key less than or equal to the parameter |
static KeySelector |
lastLessThan(byte[] key)
Creates a
KeySelector that picks the last key less than the parameter |
String |
toString() |
public KeySelector(byte[] key,
boolean orEqual,
int offset)
KeySelector from the given parameters. Client code
will not generally call this constructor.key - the base key to referenceorEqual - true if the key should be considered for equalityoffset - the number of keys to offset from once the key is foundpublic static KeySelector lastLessThan(byte[] key)
KeySelector that picks the last key less than the parameterkey - the key to use as the edge of the edge of selection criteriaKeySelectorpublic static KeySelector lastLessOrEqual(byte[] key)
KeySelector that picks the last key less than or equal to the parameterkey - the key to use as the edge of the edge of selection criteriaKeySelectorpublic static KeySelector firstGreaterThan(byte[] key)
KeySelector that picks the first key greater than the parameterkey - the key to use as the edge of the edge of selection criteriaKeySelectorpublic static KeySelector firstGreaterOrEqual(byte[] key)
KeySelector that picks the first key greater than or equal to the parameterkey - the key to use as the edge of the edge of selection criteriaKeySelectorpublic KeySelector add(int offset)
KeySelector offset by a given
number of keys from this one. For example, an offset of 1 means
that the new KeySelector specifies the key in the database
after the key selected by this KeySelector. The offset can be negative;
these will move the selector to previous keys in the database.KeySelector.) For more information see
the KeySelector documentation.offset - the number of keys to offset the KeySelector. This number can be
negative.KeySelector that is offset by a number of keys.public byte[] getKey()
KeySelector. This is
not the key to which this KeySelector would resolve to. For this
function see ReadTransaction.getKey(KeySelector).KeySelector.public int getOffset()
KeySelector. For internal use.