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
AnRBMBackedTimestampSet
is an implementation ofTimestampSet
that stores timestamps truncated to a certainCommonTimeUtil.TimeBucket
, e.g. if aCommonTimeUtil.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
Instant
s that are before the Unix epoch or after theInstant
which isInteger.MAX_VALUE * 1000L
milliseconds after the epoch (approximately 3:14 on January 19th 2038). This is due toRoaringBitmap
only accepting integers. As the smallestCommonTimeUtil.TimeBucket
is a second then the maximum supportedInstant
is the maximum integer multiplied by 1000L milliseconds after the epoch.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RBMBackedTimestampSet.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 void
add(Instant instant)
Adds the provided timestamp to the set.void
add(Collection<Instant> instants)
Adds all the provided timestamps to the set.void
addAll(RBMBackedTimestampSet other)
void
applyTimeRangeMask(Long startMillis, Long endMillis)
Applies a time range mask.boolean
equals(Object obj)
Instant
getEarliest()
The earliest timestamp in the set.Instant
getLatest()
The latest timestamp in the set.long
getNumberOfTimestamps()
Returns the number of distinct timestamps in the set.org.roaringbitmap.RoaringBitmap
getRbm()
This exposes the underlyingRoaringBitmap
so that serialisers can access it.RBMBackedTimestampSet
getShallowClone()
CommonTimeUtil.TimeBucket
getTimeBucket()
SortedSet<Instant>
getTimestamps()
Returns all the timestamps in the set, sorted in their natural order.int
hashCode()
void
setRbm(org.roaringbitmap.RoaringBitmap rbm)
Allows theRoaringBitmap
to be set.String
toString()
-
-
-
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:TimestampSet
Adds the provided timestamp to the set.- Specified by:
add
in interfaceTimestampSet
- Parameters:
instant
- The timestamp to be added.
-
add
public void add(Collection<Instant> instants)
Description copied from interface:TimestampSet
Adds all the provided timestamps to the set.- Specified by:
add
in interfaceTimestampSet
- Parameters:
instants
- TheCollection
of timestamps 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 interfaceTimestampSet
- 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 interfaceTimestampSet
- 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 interfaceTimestampSet
- 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 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 underlyingRoaringBitmap
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 theRoaringBitmap
to be set.- Parameters:
rbm
- theRoaringBitmap
to set theRoaringBitmap
of this class to.
-
addAll
public void addAll(RBMBackedTimestampSet other)
-
getShallowClone
public RBMBackedTimestampSet getShallowClone()
-
-