com.sleepycat.je.tree
Class Key

java.lang.Object
  extended by com.sleepycat.je.tree.Key
All Implemented Interfaces:
Comparable<Key>

public final class Key
extends Object
implements Comparable<Key>

Key represents a JE B-Tree Key. Keys are immutable. Within JE, keys are usually represented as byte arrays rather than as Key instances in order to reduce the in-memory footprint. The static methods of this class are used to operate on the byte arrays. One exception is when keys are held within a collection. In that case, Key objects are instantiated so that keys are hashed and compared by value.


Nested Class Summary
static class Key.DumpType
           
 
Field Summary
static Key.DumpType DUMP_TYPE
           
static byte[] EMPTY_KEY
           
 
Constructor Summary
Key(byte[] key)
          Construct a new key from a byte array.
 
Method Summary
static int compareKeys(byte[] key1, byte[] key2, Comparator<byte[]> comparator)
          Compare keys with an optional comparator.
static int compareKeys(byte[] key1, int off1, int len1, byte[] key2, int off2, int len2, Comparator<byte[]> comparator)
          Compare keys with an optional comparator.
 int compareTo(Key argKey)
          Compare two keys.
static int compareUnsignedBytes(byte[] key1, int off1, int len1, byte[] key2, int off2, int len2)
          Compare using a default unsigned byte comparison.
static byte[] createKeyPrefix(byte[] key1, byte[] key2)
           
static String dumpString(byte[] key, int nspaces)
           
 boolean equals(Object o)
          Support Set of Key in BINReference.
 byte[] getKey()
          Get the byte array for the key.
static int getKeyPrefixLength(byte[] key1, int a1Len, byte[] key2)
           
static String getNoFormatString(byte[] key)
          Print the string w/out XML format.
 int hashCode()
          Support HashSet of Key in BINReference.
static byte[] makeKey(DatabaseEntry dbt)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DUMP_TYPE

public static Key.DumpType DUMP_TYPE

EMPTY_KEY

public static final byte[] EMPTY_KEY
Constructor Detail

Key

public Key(byte[] key)
Construct a new key from a byte array.

Method Detail

makeKey

public static byte[] makeKey(DatabaseEntry dbt)

getKey

public byte[] getKey()
Get the byte array for the key.


compareTo

public int compareTo(Key argKey)
Compare two keys. Standard compareTo function and returns. Note that any configured user comparison function is not used, and therefore this method should not be used for comparison of keys during Btree operations.

Specified by:
compareTo in interface Comparable<Key>

equals

public boolean equals(Object o)
Support Set of Key in BINReference.

Overrides:
equals in class Object

hashCode

public int hashCode()
Support HashSet of Key in BINReference.

Overrides:
hashCode in class Object

compareKeys

public static int compareKeys(byte[] key1,
                              int off1,
                              int len1,
                              byte[] key2,
                              int off2,
                              int len2,
                              Comparator<byte[]> comparator)
Compare keys with an optional comparator.


compareKeys

public static int compareKeys(byte[] key1,
                              byte[] key2,
                              Comparator<byte[]> comparator)
Compare keys with an optional comparator.


compareUnsignedBytes

public static int compareUnsignedBytes(byte[] key1,
                                       int off1,
                                       int len1,
                                       byte[] key2,
                                       int off2,
                                       int len2)
Compare using a default unsigned byte comparison.


getKeyPrefixLength

public static int getKeyPrefixLength(byte[] key1,
                                     int a1Len,
                                     byte[] key2)

createKeyPrefix

public static byte[] createKeyPrefix(byte[] key1,
                                     byte[] key2)

dumpString

public static String dumpString(byte[] key,
                                int nspaces)

getNoFormatString

public static String getNoFormatString(byte[] key)
Print the string w/out XML format.



Copyright (c) 2004-2012 Oracle. All rights reserved.