Class Heap

java.lang.Object
org.apache.uima.cas.impl.Heap

public final class Heap extends Object
A heap for CAS.

This class is agnostic about what you store on the heap. It only copies values from integer arrays.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final int
     
    private static final int
     
    private static final boolean
     
    static final int
    Default size of the heap.
    (package private) int[]
     
    private int
     
    private int
     
    static final int
    Minimum size of the heap.
    private static final int
     
    private static final int
     
    private int
     
    private final int[]
     
    private static final int
     
    private static final int
     
    private static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor.
    Heap(int initialSize)
    Constructor lets you set initial heap size.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    add(int[] fs)
    Add a structure to the heap.
    int
    add(int len, int val)
    Reserve space for len items on the heap and set the first item to val.
    (package private) int
    Return the number of cells used.
    (package private) int
     
    int
     
    (package private) int[]
     
    int
     
    private void
     
    void
    grow(int len)
     
    private final void
     
    private final void
    initHeap(int size)
     
    (package private) void
    reinit(int[] md, int[] shortHeap)
     
    private void
    reinitNoMetaData(int[] shortHeap)
    Re-init the heap without metadata.
    (package private) void
    reinitSizeOnly(int newSize)
    Re-create the heap for the given size.
    void
    Reset the temporary heap.
    (package private) void
    reset(boolean doFullReset)
    Reset the temporary heap.

    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:
    • MIN_SIZE

      public static final int MIN_SIZE
      Minimum size of the heap. Currently set to 1000.
      See Also:
    • DEFAULT_SIZE

      public static final int DEFAULT_SIZE
      Default size of the heap. Currently set to 500000(2 MB).
      See Also:
    • MULTIPLICATION_LIMIT

      private static final int MULTIPLICATION_LIMIT
      See Also:
    • initialSize

      private int initialSize
    • heap

      int[] heap
    • pos

      private int pos
    • max

      private int max
    • shrinkableCount

      private final int[] shrinkableCount
    • SIZE_POS

      private static final int SIZE_POS
      See Also:
    • TMPP_POS

      private static final int TMPP_POS
      See Also:
    • TMPM_POS

      private static final int TMPM_POS
      See Also:
    • PGSZ_POS

      private static final int PGSZ_POS
      See Also:
    • AVSZ_POS

      private static final int AVSZ_POS
      See Also:
    • AVST_POS

      private static final int AVST_POS
      See Also:
  • Constructor Details

    • Heap

      public Heap()
      Default constructor.
    • Heap

      public Heap(int initialSize)
      Constructor lets you set initial heap size. Use only if you know what you're doing.
      Parameters:
      initialSize - The initial heap size. If this is smaller than the MIN_SIZE, the default will be used instead.
  • Method Details

    • initHeap

      private final void initHeap()
    • initHeap

      private final void initHeap(int size)
    • reinit

      void reinit(int[] md, int[] shortHeap)
    • reinitNoMetaData

      private void reinitNoMetaData(int[] shortHeap)
      Re-init the heap without metadata. Use default values for metadata.
      Parameters:
      shortHeap -
    • reinitSizeOnly

      void reinitSizeOnly(int newSize)
      Re-create the heap for the given size. Just use the size of the incoming heap, unless it's smaller than our minimum. It is expected that the caller will then fill in the new heap up to newSize.
      Parameters:
      newSize -
    • getCellsUsed

      int getCellsUsed()
      Return the number of cells used.
    • getHeapSize

      int getHeapSize()
      Returns:
      The overall size of the heap (in words) (including unused space).
    • getMetaData

      int[] getMetaData()
    • grow

      private void grow()
    • reset

      public void reset()
      Reset the temporary heap.
    • reset

      void reset(boolean doFullReset)
      Reset the temporary heap. Logic for shrinking: Based on a short history of the sizes 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 1/2 the distance to the size needed to hold the large of the prev 2 sizes
    • add

      public int add(int[] fs)
      Add a structure to the heap.
      Parameters:
      fs - The input structure.
      Returns:
      The position where the structure was added, i.e., a pointer to the first element of the structure.
    • add

      public int add(int len, int val)
      Reserve space for len items on the heap and set the first item to val. The other items are set to 0.
      Parameters:
      len - The length of the new structure.
      val - The value of the first cell in the new structure.
      Returns:
      The position where the structure was added, i.e., a pointer to the first element of the structure.
    • getNextId

      public int getNextId()
    • grow

      public void grow(int len)
    • getInitialSize

      public int getInitialSize()