com.sleepycat.je.tree
Class INArrayRep<ARRAY_BASE_TYPE,REP_ENUM_TYPE,ELEMENT_TYPE>

java.lang.Object
  extended by com.sleepycat.je.tree.INArrayRep<ARRAY_BASE_TYPE,REP_ENUM_TYPE,ELEMENT_TYPE>
Direct Known Subclasses:
INKeyRep, INTargetRep

public abstract class INArrayRep<ARRAY_BASE_TYPE,REP_ENUM_TYPE,ELEMENT_TYPE>
extends Object

The base class for the various array representations used by fields associated with an IN node. Storage efficiency, especially when JE is operating in a "cache full" environment is the prime motivation for the various representations.

Each representation assumes that all read operations are done under a shared latch and all updates (set, copy and compact) are done under an exclusive latch. As a result, the representations themselves do not make any provisions for synchronization.

The callers of all the potentially representation mutating methods:

  1. set(int, Object, IN)
  2. copy(int, int, int, IN)
  3. compact(IN)
must be careful to save the result value and use it for subsequent operations, since it could represent the new mutated object.


Constructor Summary
INArrayRep()
           
 
Method Summary
abstract  long calculateMemorySize()
          Returns the current memory size of the underlying representation in bytes.
abstract  ARRAY_BASE_TYPE compact(IN parent)
          Chooses a more compact representation, if that's possible, otherwise does nothing.
abstract  ARRAY_BASE_TYPE copy(int from, int to, int n, IN parent)
          Copies n elements at index denoted by "from" to the index denoted by "to".
abstract  ELEMENT_TYPE get(int idx)
          Returns the element at idx.
abstract  REP_ENUM_TYPE getType()
           
 void noteRepChange(INArrayRep<ARRAY_BASE_TYPE,REP_ENUM_TYPE,ELEMENT_TYPE> newRep, IN parent)
          Performs the bookkeeping associated with a representation change.
abstract  ARRAY_BASE_TYPE set(int idx, ELEMENT_TYPE e, IN parent)
          Sets the array element at idx to the node.
(package private) abstract  void updateCacheStats(boolean increment, Evictor evictor)
          Update the cache statistics for this representation.
(package private)  void updateCacheStats(boolean increment, IN parent)
          Updates the cache statistics associated with this representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

INArrayRep

public INArrayRep()
Method Detail

getType

public abstract REP_ENUM_TYPE getType()

set

public abstract ARRAY_BASE_TYPE set(int idx,
                                    ELEMENT_TYPE e,
                                    IN parent)
Sets the array element at idx to the node. The underlying representation can change as a result of the set operation.

Parameters:
idx - the index to be set
e - the array elelement at the idx
Returns:
either this, or the new representation if there was a mutation.

get

public abstract ELEMENT_TYPE get(int idx)
Returns the element at idx.


copy

public abstract ARRAY_BASE_TYPE copy(int from,
                                     int to,
                                     int n,
                                     IN parent)
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.

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.

compact

public abstract ARRAY_BASE_TYPE compact(IN parent)
Chooses a more compact representation, if that's possible, otherwise does nothing.

WARNING: This method must not change the memory size of the current representation and return 'this', without explicitly adjusting memory usage (via noteRepChange) before returning. Returning a new instance is the trigger for adjusting memory usage in the parent.

Returns:
this or a more compact representation.

calculateMemorySize

public abstract long calculateMemorySize()
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.

Returns:
the memory size of the representation in bytes

updateCacheStats

abstract void updateCacheStats(boolean increment,
                               Evictor evictor)
Update the cache statistics for this representation.

Parameters:
increment - true the stat should be incremented, false if it must be decremented
evictor - the evictor that shoulds ths stat counters
See Also:
#updateCacheStats(boolean)

updateCacheStats

final void updateCacheStats(boolean increment,
                            IN parent)
Updates the cache statistics associated with this representation. It should be invoked upon every creation, every rep change and finally when the IN node is decached.

Parameters:
increment - true if the stat is to be incremented, false if it is to be decremented

noteRepChange

public final void noteRepChange(INArrayRep<ARRAY_BASE_TYPE,REP_ENUM_TYPE,ELEMENT_TYPE> newRep,
                                IN parent)
Performs the bookkeeping associated with a representation change. It accounts for the change in storage and adjusts the cache statistics.

Parameters:
newRep - the new representation that is replacing this one.


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