Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * See the file LICENSE for redistribution information.
   * Copyright (c) 2002, 2013 Oracle and/or its affiliates.  All rights reserved.
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,java.lang.Object,
  2. copy(int,int,int,
  3. compact(
must be careful to save the result value and use it for subsequent operations, since it could represent the new mutated object.
 public abstract class INArrayRep<ARRAY_BASE_TYPE, REP_ENUM_TYPE,
                                  ELEMENT_TYPE> {
     public INArrayRep() {
     /* Returns the type associated with the representation. */
     public abstract REP_ENUM_TYPE getType();

Sets the array element at idx to the node. The underlying representation can change as a result of the set operation.

idx the index to be set
e the array elelement at the idx
either this, or the new representation if there was a mutation.
     public abstract ARRAY_BASE_TYPE set(int idx, ELEMENT_TYPE eIN parent);

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

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.

from the source (inclusive) of the copy
to the target (inclusive) of the copy
n the number of elements to be copied.
either this, or the new representation if there was a mutation.
     public abstract ARRAY_BASE_TYPE copy(int fromint toint nIN 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.

this or a more compact representation.
     public abstract ARRAY_BASE_TYPE compact(IN parent);

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.

the memory size of the representation in bytes
     public abstract long calculateMemorySize();

Update the cache statistics for this representation.

increment true the stat should be incremented, false if it must be decremented
evictor the evictor that shoulds ths stat counters
See also:
    abstract void updateCacheStats(boolean incrementEvictor evictor);

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.

increment true if the stat is to be incremented, false if it is to be decremented
    final void updateCacheStats(boolean incrementIN parent) {
        if (!parent.getInListResident()) {
            /* If the IN is not in the cache don't accumulate stats for it. */
        final DatabaseImpl database = parent.getDatabase();

Performs the bookkeeping associated with a representation change. It accounts for the change in storage and adjusts the cache statistics.

newRep the new representation that is replacing this one.
    public final void noteRepChange
         IN parent) {
        if (parent == null) {
            /* Only true in unit tests. */
        parent.changeMemorySize(newRep.calculateMemorySize() -
New to GrepCode? Check out our FAQ X