Class AbstractObjDynamicHistogram<T>

  • Type Parameters:
    T - Data type
    All Implemented Interfaces:
    Histogram

    public abstract class AbstractObjDynamicHistogram<T>
    extends ObjHistogram<T>
    A dynamic histogram can dynamically adapt the number of bins to the data fed into the histogram.
    Since:
    0.5.5
    Author:
    Erich Schubert
    • Field Detail

      • cacheposs

        private double[] cacheposs
        Cache for positions to be inserted.
      • cachevals

        private java.lang.Object[] cachevals
        Cache for data to be inserted.
      • cachefill

        private int cachefill
        Cache fill size
      • destsize

        private int destsize
        Destination (minimum) size of the structure. At most 2*destsize bins are allowed.
    • Constructor Detail

      • AbstractObjDynamicHistogram

        public AbstractObjDynamicHistogram​(int bins)
        Constructor.
        Parameters:
        bins - Design number of bins - may become twice as large!
    • Method Detail

      • materialize

        void materialize()
        Materialize the histogram from the cache.
      • get

        public T get​(double coord)
        Description copied from class: ObjHistogram
        Access the value of a bin with new data.
        Overrides:
        get in class ObjHistogram<T>
        Parameters:
        coord - Coordinate
        Returns:
        bin contents
      • putData

        public void putData​(double coord,
                            T value)
        Put fresh data into the histogram (or into the cache).
        Parameters:
        coord - Coordinate
        value - Value
      • aggregateSpecial

        protected void aggregateSpecial​(T value,
                                        int bin)
        Aggregate for a special value.
        Parameters:
        value - Parameter value
        bin - Special bin index.
      • testResample

        private void testResample​(double coord)
        Test (and perform) downsampling when needed.
        Parameters:
        coord - coordinate to accommodate.
      • downsample

        protected abstract T downsample​(java.lang.Object[] data,
                                        int start,
                                        int end,
                                        int size)
        Perform downsampling on a number of bins.
        Parameters:
        data - Data array (needs cast!)
        start - Interval start
        end - Interval end (exclusive)
        size - Intended size - extra bins are assumed to be empty, should be a power of two
        Returns:
        New bin value
      • aggregate

        protected abstract T aggregate​(T first,
                                       T second)
        Rule to combine two bins or entries into one.

        Note: first and second MAY be modified and returned, they will not be used afterwards.

        Parameters:
        first - First bin value
        second - Second bin value
        Returns:
        combined bin value
      • cloneForCache

        protected abstract T cloneForCache​(T data)
        Clone a data passed to the algorithm for computing the initial size.
        Parameters:
        data - Data to be cloned
        Returns:
        cloned data
      • makeObject

        protected abstract T makeObject()
        Make a new empty bucket for the data store.
        Returns:
        New instance.