Class NodeAllocator

java.lang.Object
org.apache.derby.impl.store.access.sort.NodeAllocator

final class NodeAllocator extends Object
NodeAllocator manages an array of nodes which can be reused.
  • Field Summary

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

    Constructors
    Constructor
    Description
    Construct an empty allocator.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    void
     
    void
    Return a node to the allocator.
    void
    grow(int percent)
    Expand the node allocator's capacity by certain percent.
    boolean
    Initialize the allocator with default values for initial and maximum size.
    boolean
    init(int maxSize)
    Initialize the allocator with default values for initial size and the provided maximum size.
    boolean
    init(int initSize, int maxSize)
    Initialize the allocator with the given initial and maximum sizes.
     
    void
    Clear all nodes that this allocator has allocated.

    Methods inherited from class java.lang.Object

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

    • DEFAULT_INIT_SIZE

      private static final int DEFAULT_INIT_SIZE
      See Also:
    • GROWTH_MULTIPLIER

      private static final int GROWTH_MULTIPLIER
      See Also:
    • DEFAULT_MAX_SIZE

      private static final int DEFAULT_MAX_SIZE
      See Also:
    • array

      private Node[] array
    • maxSize

      private int maxSize
    • nAllocated

      private int nAllocated
    • freeList

      private Node freeList
  • Constructor Details

    • NodeAllocator

      public NodeAllocator()
      Construct an empty allocator. The caller must call init() before using it.
  • Method Details

    • newNode

      public Node newNode()
    • freeNode

      public void freeNode(Node n)
      Return a node to the allocator.
    • init

      public boolean init()
      Initialize the allocator with default values for initial and maximum size. Returns false if sufficient memory could not be allocated.
    • init

      public boolean init(int maxSize)
      Initialize the allocator with default values for initial size and the provided maximum size. Returns false if sufficient memory could not be allocated.
    • init

      public boolean init(int initSize, int maxSize)
      Initialize the allocator with the given initial and maximum sizes. This method does not check, but assumes that the value of initSize is less than the value of maxSize, and that they are both powers of two. Returns false if sufficient memory could not be allocated.
    • grow

      public void grow(int percent)
      Expand the node allocator's capacity by certain percent.
    • reset

      public void reset()
      Clear all nodes that this allocator has allocated. The allocator must already have been initialized.
    • close

      public void close()
    • capacity

      public int capacity()