Class RBMBackedTimestampSet

  • All Implemented Interfaces:
    TimestampSet

    public class RBMBackedTimestampSet
    extends Object
    implements TimestampSet
    An RBMBackedTimestampSet is an implementation of TimestampSet that stores timestamps truncated to a certain CommonTimeUtil.TimeBucket, e.g. if a CommonTimeUtil.TimeBucket of a minute is specified then a timestamp of 12:34:56 on January 1st 2015 would be truncated to the previous minute, namely 12:34:00 on January 1st 2015. Timebuckets of second, minute, hour, day, week, month and year are supported.

    Internally this class stores the timestamps in a RoaringBitmap.

    NB: This class does not accept Instants that are before the Unix epoch or after the Instant which is Integer.MAX_VALUE * 1000L milliseconds after the epoch (approximately 3:14 on January 19th 2038). This is due to RoaringBitmap only accepting integers. As the smallest CommonTimeUtil.TimeBucket is a second then the maximum supported Instant is the maximum integer multiplied by 1000L milliseconds after the epoch.

    • Method Detail

      • add

        public void add​(Instant instant)
        Description copied from interface: TimestampSet
        Adds the provided timestamp to the set.
        Specified by:
        add in interface TimestampSet
        Parameters:
        instant - The timestamp to be added.
      • getTimestamps

        public SortedSet<Instant> getTimestamps()
        Description copied from interface: TimestampSet
        Returns all the timestamps in the set, sorted in their natural order.
        Specified by:
        getTimestamps in interface TimestampSet
        Returns:
        All the timestamps in the set, sorted in their natural order.
      • getNumberOfTimestamps

        public long getNumberOfTimestamps()
        Description copied from interface: TimestampSet
        Returns the number of distinct timestamps in the set.
        Specified by:
        getNumberOfTimestamps in interface TimestampSet
        Returns:
        The number of distinct timestamps in the set.
      • getEarliest

        public Instant getEarliest()
        Description copied from interface: TimestampSet
        The earliest timestamp in the set.
        Specified by:
        getEarliest in interface TimestampSet
        Returns:
        The earliest timestamp in the set.
      • getLatest

        public Instant getLatest()
        Description copied from interface: TimestampSet
        The latest timestamp in the set.
        Specified by:
        getLatest in interface TimestampSet
        Returns:
        The latest timestamp in the set.
      • applyTimeRangeMask

        public void applyTimeRangeMask​(Long startMillis,
                                       Long endMillis)
        Applies a time range mask. Timestamps which fall outside the range are filtered.
        Parameters:
        startMillis - filter start time in milliseconds
        endMillis - filter end time in milliseconds
      • getRbm

        public org.roaringbitmap.RoaringBitmap getRbm()
        This exposes the underlying RoaringBitmap so that serialisers can access it.
        Returns:
        the RoaringBitmap used by this class to store the timestamps.
      • setRbm

        public void setRbm​(org.roaringbitmap.RoaringBitmap rbm)
        Allows the RoaringBitmap to be set.
        Parameters:
        rbm - the RoaringBitmap to set the RoaringBitmap of this class to.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object