Package uk.gov.gchq.gaffer.time
Class RBMBackedTimestampSet
- java.lang.Object
-
- uk.gov.gchq.gaffer.time.RBMBackedTimestampSet
-
- All Implemented Interfaces:
TimestampSet
public class RBMBackedTimestampSet extends Object implements TimestampSet
AnRBMBackedTimestampSetis an implementation ofTimestampSetthat stores timestamps truncated to a certainCommonTimeUtil.TimeBucket, e.g. if aCommonTimeUtil.TimeBucketof 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 theInstantwhich isInteger.MAX_VALUE * 1000Lmilliseconds after the epoch (approximately 3:14 on January 19th 2038). This is due toRoaringBitmaponly accepting integers. As the smallestCommonTimeUtil.TimeBucketis a second then the maximum supportedInstantis the maximum integer multiplied by 1000L milliseconds after the epoch.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRBMBackedTimestampSet.Builder
-
Constructor Summary
Constructors Constructor Description RBMBackedTimestampSet(CommonTimeUtil.TimeBucket timeBucket)RBMBackedTimestampSet(CommonTimeUtil.TimeBucket timeBucket, Instant... instants)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Instant instant)Adds the provided timestamp to the set.voidadd(Collection<Instant> instants)Adds all the provided timestamps to the set.voidaddAll(RBMBackedTimestampSet other)voidapplyTimeRangeMask(Long startMillis, Long endMillis)Applies a time range mask.booleanequals(Object obj)InstantgetEarliest()The earliest timestamp in the set.InstantgetLatest()The latest timestamp in the set.longgetNumberOfTimestamps()Returns the number of distinct timestamps in the set.org.roaringbitmap.RoaringBitmapgetRbm()This exposes the underlyingRoaringBitmapso that serialisers can access it.RBMBackedTimestampSetgetShallowClone()CommonTimeUtil.TimeBucketgetTimeBucket()SortedSet<Instant>getTimestamps()Returns all the timestamps in the set, sorted in their natural order.inthashCode()voidsetRbm(org.roaringbitmap.RoaringBitmap rbm)Allows theRoaringBitmapto be set.StringtoString()
-
-
-
Constructor Detail
-
RBMBackedTimestampSet
public RBMBackedTimestampSet(CommonTimeUtil.TimeBucket timeBucket)
-
RBMBackedTimestampSet
public RBMBackedTimestampSet(CommonTimeUtil.TimeBucket timeBucket, Instant... instants)
-
-
Method Detail
-
add
public void add(Instant instant)
Description copied from interface:TimestampSetAdds the provided timestamp to the set.- Specified by:
addin interfaceTimestampSet- Parameters:
instant- The timestamp to be added.
-
add
public void add(Collection<Instant> instants)
Description copied from interface:TimestampSetAdds all the provided timestamps to the set.- Specified by:
addin interfaceTimestampSet- Parameters:
instants- TheCollectionof timestamps to be added.
-
getTimestamps
public SortedSet<Instant> getTimestamps()
Description copied from interface:TimestampSetReturns all the timestamps in the set, sorted in their natural order.- Specified by:
getTimestampsin interfaceTimestampSet- Returns:
- All the timestamps in the set, sorted in their natural order.
-
getNumberOfTimestamps
public long getNumberOfTimestamps()
Description copied from interface:TimestampSetReturns the number of distinct timestamps in the set.- Specified by:
getNumberOfTimestampsin interfaceTimestampSet- Returns:
- The number of distinct timestamps in the set.
-
getEarliest
public Instant getEarliest()
Description copied from interface:TimestampSetThe earliest timestamp in the set.- Specified by:
getEarliestin interfaceTimestampSet- Returns:
- The earliest timestamp in the set.
-
getLatest
public Instant getLatest()
Description copied from interface:TimestampSetThe latest timestamp in the set.- Specified by:
getLatestin interfaceTimestampSet- 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 millisecondsendMillis- filter end time in milliseconds
-
getTimeBucket
public CommonTimeUtil.TimeBucket getTimeBucket()
-
getRbm
public org.roaringbitmap.RoaringBitmap getRbm()
This exposes the underlyingRoaringBitmapso that serialisers can access it.- Returns:
- the
RoaringBitmapused by this class to store the timestamps.
-
setRbm
public void setRbm(org.roaringbitmap.RoaringBitmap rbm)
Allows theRoaringBitmapto be set.- Parameters:
rbm- theRoaringBitmapto set theRoaringBitmapof this class to.
-
addAll
public void addAll(RBMBackedTimestampSet other)
-
getShallowClone
public RBMBackedTimestampSet getShallowClone()
-
-