Class CommonAuxHeap

java.lang.Object
org.apache.uima.cas.impl.CommonAuxHeap
Direct Known Subclasses:
ByteHeap, LongHeap, ShortHeap

abstract class CommonAuxHeap extends Object
Encapsulate 8, 16, and 64 bit storage for the CAS.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final boolean
     
    protected static final int
     
    protected static final int
     
    protected static final int
     
    protected static final int
     
    protected final int
     
    protected final int
     
    protected int
     
    protected static final int
     
    protected static final int
     
    private final int[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    CommonAuxHeap(int heapBaseSize, int heapMultLimit)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) int
    computeNewArraySize(int size, int needed_size, int growth_factor, int multiplication_limit)
     
    (package private) static int
    computeShrunkArraySize(int capacity, int size_used, int growth_factor, int multiplication_limit, int min_size, int[] shrinkableCount)
    This routine is used to compute the capacity an internal expandable array should be reallocated to, upon reset.
    (package private) abstract int
     
    (package private) int
     
    (package private) abstract void
     
    (package private) abstract void
     
    (package private) abstract void
    initMemory(int size)
     
    (package private) int
    reserve(int numCells)
     
    (package private) void
     
    (package private) void
    reset(boolean doFullReset)
    Logic for shrinking: Based on a short history of the capacity needed to hold the larger of the previous 2 sizes (Note: can be overridden by calling reset() multiple times in a row) Never shrink below initialSize Shrink in exact reverse sequence of growth - using the subtraction method and then (for small enough sizes) the dividing method Shrink by one jump if that is large enough to hold the larger of the prev 2 sizes
    (package private) abstract void
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • debugLogShrink

      private static final boolean debugLogShrink
      See Also:
    • DEFAULT_HEAP_BASE_SIZE

      protected static final int DEFAULT_HEAP_BASE_SIZE
      See Also:
    • DEFAULT_HEAP_MULT_LIMIT

      protected static final int DEFAULT_HEAP_MULT_LIMIT
      See Also:
    • MIN_HEAP_BASE_SIZE

      protected static final int MIN_HEAP_BASE_SIZE
      See Also:
    • GROWTH_FACTOR

      protected static final int GROWTH_FACTOR
      See Also:
    • NULL

      protected static final int NULL
      See Also:
    • FIRST_CELL_REF

      protected static final int FIRST_CELL_REF
      See Also:
    • heapBaseSize

      protected final int heapBaseSize
    • heapMultLimit

      protected final int heapMultLimit
    • heapPos

      protected int heapPos
    • shrinkableCount

      private final int[] shrinkableCount
  • Constructor Details

    • CommonAuxHeap

      CommonAuxHeap()
    • CommonAuxHeap

      CommonAuxHeap(int heapBaseSize, int heapMultLimit)
  • Method Details

    • initMemory

      abstract void initMemory()
    • initMemory

      abstract void initMemory(int size)
    • resetToZeros

      abstract void resetToZeros()
    • growHeapIfNeeded

      abstract void growHeapIfNeeded()
    • reset

      void reset()
    • reset

      void reset(boolean doFullReset)
      Logic for shrinking: Based on a short history of the capacity needed to hold the larger of the previous 2 sizes (Note: can be overridden by calling reset() multiple times in a row) Never shrink below initialSize Shrink in exact reverse sequence of growth - using the subtraction method and then (for small enough sizes) the dividing method Shrink by one jump if that is large enough to hold the larger of the prev 2 sizes
      Parameters:
      doFullReset - true means reallocate from scratch
    • reserve

      int reserve(int numCells)
    • computeNewArraySize

      int computeNewArraySize(int size, int needed_size, int growth_factor, int multiplication_limit)
    • computeShrunkArraySize

      static int computeShrunkArraySize(int capacity, int size_used, int growth_factor, int multiplication_limit, int min_size, int[] shrinkableCount)
      This routine is used to compute the capacity an internal expandable array should be reallocated to, upon reset. It returns at most a 1 increment shrink, based on the doubling up to multiplication limit, then addition thereafter. It maintains a shrinkableCount - the number of consecutive times this could be shrunk. This is reset to 0 if current size requires current capacity, that is, no shrinkage is possible for current size. Otherwise, the count is incremented. If the shrinkableCount is incremented to exceed 20, the capacity is allowed to drop by 1 allocation unit. This guarantees the shrinkages are delayed until 20 shrinkable sizes are found (with no intervening non-shrinkable ones). When a shrinkage happens, the count is reset to 16; this delays subsequent shrinkages to happen only every (20 - 16) 4 resets.
      Parameters:
      capacity - the current capacity
      size_used - the maximum number of used entries, <= current capacity
      growth_factor - is 2
      multiplication_limit - the point where we start adding this limit, vs using the growth factor
      shrinkableCount - a pass-by-reference int reflecting the number of times it was shrinkable
      Returns:
      the capacity shrink down by one step, if that will still hold the size_used number of entries, minimum limited to min_size.
    • getSize

      int getSize()
    • getCapacity

      abstract int getCapacity()