|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sleepycat.util.keyrange.KeyRange
public class KeyRange
Encapsulates a key range for use with a RangeCursor.
Field Summary | |
---|---|
static byte[] |
ZERO_LENGTH_BYTE_ARRAY
|
Constructor Summary | |
---|---|
KeyRange(java.util.Comparator comparator)
Creates an unconstrained key range. |
Method Summary | |
---|---|
boolean |
check(DatabaseEntry key)
Returns whether a given key is within range. |
boolean |
check(DatabaseEntry key,
boolean inclusive)
Returns whether a given key is within range. |
boolean |
checkBegin(DatabaseEntry key,
boolean inclusive)
Returns whether the given key is within range with respect to the beginning of the range. |
boolean |
checkEnd(DatabaseEntry key,
boolean inclusive)
Returns whether the given key is within range with respect to the end of the range. |
int |
compare(DatabaseEntry key1,
DatabaseEntry key2)
Compares two keys, using the user comparator if there is one. |
static int |
compareBytes(byte[] data1,
int offset1,
int size1,
byte[] data2,
int offset2,
int size2)
Compares two keys as unsigned byte arrays, which is the default comparison used by JE/DB. |
static DatabaseEntry |
copy(DatabaseEntry from)
Returns a copy of an entry. |
static void |
copy(DatabaseEntry from,
DatabaseEntry to)
Copies one entry to another. |
static byte[] |
copyBytes(byte[] bytes)
Copies a byte array. |
static boolean |
equalBytes(byte[] data1,
int offset1,
int size1,
byte[] data2,
int offset2,
int size2)
Compares two byte arrays for equality. |
static boolean |
equalBytes(DatabaseEntry e1,
DatabaseEntry e2)
Returns the two DatabaseEntry objects have the same data value. |
static byte[] |
getByteArray(DatabaseEntry entry)
Returns an entry's byte array, copying it if the entry offset is non-zero. |
static byte[] |
getByteArray(DatabaseEntry entry,
int maxBytes)
|
DatabaseEntry |
getSingleKey()
Returns the key of a single-key range, or null if not a single-key range. |
boolean |
hasBound()
Returns whether this range has a begin or end bound. |
boolean |
isSingleKey()
Returns whether this is a single-key range. |
KeyRange |
subRange(DatabaseEntry key)
Creates a range for a single key. |
KeyRange |
subRange(DatabaseEntry beginKey,
boolean beginInclusive,
DatabaseEntry endKey,
boolean endInclusive)
Creates a range that is the intersection of this range and the given range parameters. |
java.lang.String |
toString()
Formats this range as a string for debugging. |
static java.lang.String |
toString(DatabaseEntry dbt)
Converts the byte array of this thang to space-separated integers, and suffixed by the record number if applicable. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final byte[] ZERO_LENGTH_BYTE_ARRAY
Constructor Detail |
---|
public KeyRange(java.util.Comparator comparator)
Method Detail |
---|
public KeyRange subRange(DatabaseEntry key) throws KeyRangeException
KeyRangeException
public KeyRange subRange(DatabaseEntry beginKey, boolean beginInclusive, DatabaseEntry endKey, boolean endInclusive) throws KeyRangeException
KeyRangeException
public final boolean isSingleKey()
public final DatabaseEntry getSingleKey()
public final boolean hasBound()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean check(DatabaseEntry key)
public boolean check(DatabaseEntry key, boolean inclusive)
public boolean checkBegin(DatabaseEntry key, boolean inclusive)
The inclusive parameter should be true for checking a key read from the database; this will require that the key is within range. When inclusive=false the key is allowed to be equal to the beginKey for the range; this is used for checking a new exclusive bound of a sub-range.
Note that when inclusive=false and beginInclusive=true our check is not exactly correct because in theory we should allow the key to be "one less" than the existing bound; however, checking for "one less" is impossible so we do the best we can and test the bounds conservatively.
public boolean checkEnd(DatabaseEntry key, boolean inclusive)
public int compare(DatabaseEntry key1, DatabaseEntry key2)
public static byte[] copyBytes(byte[] bytes)
public static int compareBytes(byte[] data1, int offset1, int size1, byte[] data2, int offset2, int size2)
public static boolean equalBytes(byte[] data1, int offset1, int size1, byte[] data2, int offset2, int size2)
public static DatabaseEntry copy(DatabaseEntry from)
public static void copy(DatabaseEntry from, DatabaseEntry to)
public static byte[] getByteArray(DatabaseEntry entry)
public static byte[] getByteArray(DatabaseEntry entry, int maxBytes)
public static boolean equalBytes(DatabaseEntry e1, DatabaseEntry e2)
public static java.lang.String toString(DatabaseEntry dbt)
dbt
- the thang to convert.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |