Class KeyRange
- All Implemented Interfaces:
oracle.kv.impl.util.FastExternalizable
The KeyRange defines a range of String values for the key components immediately following the last component of a parent key that is used in a multiple-key operation. In terms of a tree structure, the range defines the parent key's immediate children that are selected by the multiple-key operation.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
static KeyRange
fromByteArray
(byte[] keyBytes) Deserializes the given bytes that were returned earlier bytoByteArray()
and returns the resulting KeyRange.static KeyRange
fromString
(String keyRangeStringArg) Converts an encoded KeyRange back to a KeyRange.getEnd()
Returns the String component that defines upper bound of the key range, or null if no upper bound is enforced.boolean
Returns whether end is included in the range, i.e., end is greater than or equal to the last String component in the key range.getStart()
Returns the String component that defines lower bound of the key range, or null if no lower bound is enforced.boolean
Returns whether start is included in the range, i.e., start is less than or equal to the first String component in the key range.int
hashCode()
boolean
Returns true if a Key is within the bounds of this range with respect to a parent Key.boolean
isPrefix()
Returns whether this is a prefix range, i.e., whether start and end are equal and both inclusive.byte[]
Returns this KeyRange as a serialized byte array, such thatfromByteArray(byte[])
may be used to reconstitute the KeyRange.toString()
Encodes the KeyRange object and returns the resulting String which can later be decoded usingfromString(java.lang.String)
.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface oracle.kv.impl.util.FastExternalizable
deserializedForm
-
Constructor Details
-
KeyRange
Creates a start/end KeyRange.- Parameters:
start
- is the String component that defines lower bound of the key range. If null, no lower bound is enforced.startInclusive
- is true if start is included in the range, i.e., start is less than or equal to the first String component in the key range.end
- is the String component that defines upper bound of the key range. If null, no upper bound is enforced.endInclusive
- is true if end is included in the range, i.e., end is greater than or equal to the last String component in the key range.- Throws:
IllegalArgumentException
- if either start and end are null or start is not less than end.
-
KeyRange
Creates a prefix KeyRange.For a KeyRange created using this constructor,
isPrefix()
will return true.Additionally, both
getStart()
andgetEnd()
will return the prefix, and bothgetStartInclusive()
andgetEndInclusive()
will return true. However, theKeyRange
will be treated as a prefix, not an inclusive range.- Parameters:
prefix
- is the value that is a prefix of all matching key components. The KeyRange matches a key component if the component starts with (as inString.startsWith
) the prefix value.
-
-
Method Details
-
toByteArray
public byte[] toByteArray()Returns this KeyRange as a serialized byte array, such thatfromByteArray(byte[])
may be used to reconstitute the KeyRange. Values returned by calls to this method can be used with current and newer releases, but are not guaranteed to be compatible with earlier releases. -
fromByteArray
Deserializes the given bytes that were returned earlier bytoByteArray()
and returns the resulting KeyRange. Values created with either the current or earlier releases can be used with this method, but values created by later releases are not guaranteed to be compatible. -
getStart
Returns the String component that defines lower bound of the key range, or null if no lower bound is enforced. For a prefix range, this method returns the prefix. -
getStartInclusive
public boolean getStartInclusive()Returns whether start is included in the range, i.e., start is less than or equal to the first String component in the key range. For a prefix range, this method returns true. -
getEnd
Returns the String component that defines upper bound of the key range, or null if no upper bound is enforced. For a prefix range, this method returns the prefix. -
getEndInclusive
public boolean getEndInclusive()Returns whether end is included in the range, i.e., end is greater than or equal to the last String component in the key range. For a prefix range, this method returns true. -
isPrefix
public boolean isPrefix()Returns whether this is a prefix range, i.e., whether start and end are equal and both inclusive. -
inRange
Returns true if a Key is within the bounds of this range with respect to a parent Key.- Parameters:
parentKey
- the parent of the key range, or null to check the first key component.checkKey
- the full key being checked.- Returns:
- true if it's in range, false otherwise.
-
equals
-
hashCode
public int hashCode() -
toString
Encodes the KeyRange object and returns the resulting String which can later be decoded usingfromString(java.lang.String)
. The format is:<startType>/<start>/<end>/<endType>
where the
startType/endType
is either"I"
or"E"
for Inclusive or Exclusive andstart
andend
are the start/end key strings. The leadingstartType/start
specification is omitted from the String representation if the range does not have a lower bound. Similarly, the trailingend/endType
specification is omitted if the range does not have an upper bound. Since aKeyRange
requires at least one bound, at least one of the specifications is always present in the String representation. Here are some examples:I/alpha/beta/E
- fromalpha
inclusive tobeta
exclusiveE//0123/I
- from "" exclusive to0123
inclusiveI/chi/
- fromchi
inclusive to infinityE//
- from "" exclusive to infinity/chi/E
- from negative infinity tochi
exclusive//I
- from negative infinity to "" inclusive
-
fromString
Converts an encoded KeyRange back to a KeyRange. The argument String should normally be created usingtoString()
. SeetoString()
for more information about the KeyRange String format.- Parameters:
keyRangeStringArg
- a non null KeyRange encoding string, which should normally be created usingtoString()
.- Returns:
- the resulting KeyRange object.
- Throws:
IllegalArgumentException
- if keyRangeStringArg does not contain a valid KeyRange encoding.- Since:
- 2.0
-