Class DoubleBufferSet

All Implemented Interfaces:
Serializable, Cloneable

class DoubleBufferSet extends BufferSet
A set of buffers holding double elements; internally used for computing approximate quantiles.
  • Field Details

    • buffers

      protected DoubleBuffer[] buffers
    • nextTriggerCalculationState

      private boolean nextTriggerCalculationState
  • Constructor Details

    • DoubleBufferSet

      public DoubleBufferSet(int b, int k)
      Constructs a buffer set with b buffers, each having k elements
      Parameters:
      b - the number of buffers
      k - the number of elements per buffer
  • Method Details

    • _getFirstEmptyBuffer

      public DoubleBuffer _getFirstEmptyBuffer()
      Returns an empty buffer if at least one exists. Preferably returns a buffer which has already been used, i.e. a buffer which has already been allocated.
    • _getFullOrPartialBuffers

      public DoubleBuffer[] _getFullOrPartialBuffers()
      Returns all full or partial buffers.
    • _getFullOrPartialBuffersWithLevel

      public DoubleBuffer[] _getFullOrPartialBuffersWithLevel(int level)
      Determines all full buffers having the specified level.
      Returns:
      all full buffers having the specified level
    • _getMinLevelOfFullOrPartialBuffers

      public int _getMinLevelOfFullOrPartialBuffers()
      Returns:
      The minimum level of all buffers which are full.
    • _getNumberOfEmptyBuffers

      public int _getNumberOfEmptyBuffers()
      Returns the number of empty buffers.
    • _getPartialBuffer

      public DoubleBuffer _getPartialBuffer()
      Returns all empty buffers.
    • b

      public int b()
      Returns:
      the number of buffers
    • clear

      public void clear()
      Removes all elements from the receiver. The receiver will be empty after this call returns, and its memory requirements will be close to zero.
    • clear

      protected void clear(int k)
      Removes all elements from the receiver. The receiver will be empty after this call returns, and its memory requirements will be close to zero.
    • clone

      public Object clone()
      Returns a deep copy of the receiver.
      Overrides:
      clone in class PersistentObject
      Returns:
      a deep copy of the receiver.
    • collapse

      public DoubleBuffer collapse(DoubleBuffer[] buffers)
      Collapses the specified full buffers (must not include partial buffer).
      Parameters:
      buffers - the buffers to be collapsed (all of them must be full or partially full)
      Returns:
      a full buffer containing the collapsed values. The buffer has accumulated weight.
    • contains

      public boolean contains(double element)
      Returns whether the specified element is contained in the receiver.
    • forEach

      public boolean forEach(DoubleProcedure procedure)
      Applies a procedure to each element of the receiver, if any. Iterates over the receiver in no particular order.
      Parameters:
      procedure - the procedure to be applied. Stops iteration if the procedure returns false, otherwise continues.
    • getValuesAtPositions

      protected double[] getValuesAtPositions(DoubleBuffer[] buffers, long[] triggerPositions)
      Determines all values of the specified buffers positioned at the specified triggerPositions within the sorted sequence and fills them into outputValues.
      Parameters:
      buffers - the buffers to be searched (all must be full or partial)
      triggerPositions - the positions of elements within the sorted sequence to be retrieved
      Returns:
      outputValues a list filled with the values at triggerPositions
    • k

      public int k()
      Returns:
      the number of elements within a buffer.
    • memory

      public long memory()
      Returns the number of elements currently needed to store all contained elements.
    • nextTriggerPosition

      protected long nextTriggerPosition(int j, long W)
      Computes the next triggerPosition for collapse
      Parameters:
      j - specifies that the j-th trigger position is to be computed
      W - the accumulated weights
      Returns:
      the next triggerPosition for collapse
    • phi

      public double phi(double element)
      Returns how many percent of the elements contained in the receiver are <= element. Does linear interpolation if the element is not contained but lies in between two contained elements.
      Parameters:
      the - element to search for.
      Returns:
      the percentage p of elements <= element (0.0 <= p <=1.0).
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      a String representation of the receiver
    • totalSize

      public long totalSize()
      Returns the number of elements in all buffers.