com.sleepycat.je.tree
Class INKeyRep.MaxKeySize

java.lang.Object
  extended by com.sleepycat.je.tree.INArrayRep<INKeyRep,INKeyRep.Type,byte[]>
      extended by com.sleepycat.je.tree.INKeyRep
          extended by com.sleepycat.je.tree.INKeyRep.MaxKeySize
Enclosing class:
INKeyRep

public static class INKeyRep.MaxKeySize
extends INKeyRep

The compact representation that can be used to represent keys <= 16 bytes in length. The keys are all represented inside a single byte array instead of having one byte array per key. Within the array, all keys are assigned a storage size equal to that taken up by the largest key, plus one byte to hold the actual key length. This makes key retreival fast. However, insertion and deletion for larger keys move bytes proportional to the storage length of the keys. This is why the representation is restricted to keys <= 16 bytes in size. On a 32 bit VM the per key overhead for the Default representation is 4 bytes for the pointer + 16 bytes for each byte array key object, for a total of 20 bytes/key. On a 64 bit machine the overheads are much larger: 8 bytes for the pointer plus 24 bytes per key. The more fully populated the IN the more the savings with this representation since the single byte array is sized to hold all the keys regardless of the actual number of keys that are present. It's worth noting that the storage savings here are realized in addition to the storage benefits of key prefixing, since the keys stored in the key array are the smaller key values after the prefix has been stripped, reducing the length of the key and making it more likely that it's small enough for this specialized representation.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.sleepycat.je.tree.INKeyRep
INKeyRep.Default, INKeyRep.MaxKeySize, INKeyRep.Type
 
Field Summary
static byte MAX_KEY_LENGTH
           
static int MAX_KEYS
           
 
Fields inherited from class com.sleepycat.je.tree.INArrayRep
parent
 
Constructor Summary
INKeyRep.MaxKeySize(IN parent, int nodeMaxEntries, short maxKeySize)
           
INKeyRep.MaxKeySize(SizeofMarker marker)
           
 
Method Summary
 long calculateMemorySize()
          Returns the current memory size of the underlying representation in bytes.
 INKeyRep compact()
          Chooses a more compact representation, if that's possible, otherwise does nothing.
 INKeyRep copy(int from, int to, int n)
          Copies n elements at index denoted by "from" to the index denoted by "to".
 byte[] get(int idx)
          Returns the element at idx.
 INKeyRep.Type getType()
           
 int length()
          Returns the length, that is, the range within which get and set operations can be performed.
 INKeyRep set(int idx, byte[] key)
          Sets the array element at idx to the node.
(package private)  void updateCacheStats(boolean increment, Evictor evictor)
          Update the cache statistics for this representation.
 
Methods inherited from class com.sleepycat.je.tree.INArrayRep
noteRepChange, noteRepChange, updateCacheStats
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_KEY_LENGTH

public static final byte MAX_KEY_LENGTH
See Also:
Constant Field Values

MAX_KEYS

public static final int MAX_KEYS
See Also:
Constant Field Values
Constructor Detail

INKeyRep.MaxKeySize

public INKeyRep.MaxKeySize(IN parent,
                           int nodeMaxEntries,
                           short maxKeySize)

INKeyRep.MaxKeySize

public INKeyRep.MaxKeySize(SizeofMarker marker)
Method Detail

getType

public INKeyRep.Type getType()
Specified by:
getType in class INArrayRep<INKeyRep,INKeyRep.Type,byte[]>

copy

public INKeyRep copy(int from,
                     int to,
                     int n)
Description copied from class: INArrayRep
Copies n elements at index denoted by "from" to the index denoted by "to". Overlapping copies are supported. It's possible that the representation may mutate as a result of the copy.

Specified by:
copy in class INArrayRep<INKeyRep,INKeyRep.Type,byte[]>
Parameters:
from - the source (inclusive) of the copy
to - the target (inclusive) of the copy
n - the number of elements to be copied.
Returns:
either this, or the new representation if there was a mutation.

get

public byte[] get(int idx)
Description copied from class: INArrayRep
Returns the element at idx.

Specified by:
get in class INArrayRep<INKeyRep,INKeyRep.Type,byte[]>

set

public INKeyRep set(int idx,
                    byte[] key)
Description copied from class: INArrayRep
Sets the array element at idx to the node. The underlying representation can change as a result of the set operation.

Specified by:
set in class INArrayRep<INKeyRep,INKeyRep.Type,byte[]>
Parameters:
idx - the index to be set
key - the array elelement at the idx
Returns:
either this, or the new representation if there was a mutation.

calculateMemorySize

public long calculateMemorySize()
Description copied from class: INArrayRep
Returns the current memory size of the underlying representation in bytes. It returns the size of the representation, excluding the size of the elements contained in it.

Specified by:
calculateMemorySize in class INArrayRep<INKeyRep,INKeyRep.Type,byte[]>
Returns:
the memory size of the representation in bytes

compact

public INKeyRep compact()
Description copied from class: INArrayRep
Chooses a more compact representation, if that's possible, otherwise does nothing.

Specified by:
compact in class INArrayRep<INKeyRep,INKeyRep.Type,byte[]>
Returns:
this or a more compact representation.

length

public int length()
Description copied from class: INArrayRep
Returns the length, that is, the range within which get and set operations can be performed.

Specified by:
length in class INArrayRep<INKeyRep,INKeyRep.Type,byte[]>

updateCacheStats

void updateCacheStats(boolean increment,
                      Evictor evictor)
Description copied from class: INArrayRep
Update the cache statistics for this representation.

Specified by:
updateCacheStats in class INArrayRep<INKeyRep,INKeyRep.Type,byte[]>
Parameters:
increment - true the stat should be incremented, false if it must be decremented
evictor - the evictor that shoulds ths stat counters
See Also:
INArrayRep.updateCacheStats(boolean)


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