Package uk.gov.gchq.gaffer.time
Class LongTimeSeries
- java.lang.Object
-
- uk.gov.gchq.gaffer.time.LongTimeSeries
-
- All Implemented Interfaces:
TimeSeries<Long>
public class LongTimeSeries extends Object implements TimeSeries<Long>
This is a time series where the values areLongs. When the time series is created, aCommonTimeUtil.TimeBucketis specified. When timestamps are added, they are rounded to the nearest bucket, e.g. if aCommonTimeUtil.TimeBucketofMINUTEis specified, and a timestamp of January 1st 2017, 12:34:56 is added then the seconds are removed so that the value is associated to 12:34.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLongTimeSeries.Builder
-
Constructor Summary
Constructors Constructor Description LongTimeSeries(CommonTimeUtil.TimeBucket timeBucket)LongTimeSeries(CommonTimeUtil.TimeBucket timeBucket, Map<Instant,Long> timeSeries)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)Longget(Instant instant)Returns the value associated to the givenInstant.SortedSet<Instant>getInstants()intgetNumberOfInstants()Returns the number of instants in the time series.CommonTimeUtil.TimeBucketgetTimeBucket()SortedMap<Instant,Long>getTimeSeries()inthashCode()voidput(Instant instant, Long value)voidsetTimeSeries(Map<Instant,Long> timeSeries)Sets the time series to be the given time series.StringtoString()voidupsert(Instant instant, long count)Adds the givencountto the current value associated to the givenInstant.
-
-
-
Constructor Detail
-
LongTimeSeries
public LongTimeSeries(CommonTimeUtil.TimeBucket timeBucket)
-
LongTimeSeries
public LongTimeSeries(CommonTimeUtil.TimeBucket timeBucket, Map<Instant,Long> timeSeries)
-
-
Method Detail
-
put
public void put(Instant instant, Long value)
Puts the providedvalueinto the time series associated to theInstantinstant. Note that this overwrites any previous value in that bucket.- Specified by:
putin interfaceTimeSeries<Long>- Parameters:
instant- The instant at which the value was observed.value- The value observed at the instant.
-
get
public Long get(Instant instant)
Returns the value associated to the givenInstant. Note that this instant is rounded to the nearest time bucket.- Specified by:
getin interfaceTimeSeries<Long>- Parameters:
instant- The instant that the value is required for.- Returns:
- The value associated to the instant.
-
upsert
public void upsert(Instant instant, long count)
Adds the givencountto the current value associated to the givenInstant. If there is no value currently associated to theInstantthen thecountis simply inserted. Note that the caller of this method is responsible for dealing with the case where addingcountwould cause an overflow.- Parameters:
instant- The instant at which the value was observed.count- The value observed at the instant.
-
getNumberOfInstants
public int getNumberOfInstants()
Returns the number of instants in the time series.- Returns:
- The number of instants in the time series.
-
getTimeSeries
public SortedMap<Instant,Long> getTimeSeries()
Returns the time series as aSortedMapwhere the key is anInstantrounded to the nearest bucket and the value is the associated count.- Returns:
- The time series.
-
setTimeSeries
public void setTimeSeries(Map<Instant,Long> timeSeries)
Sets the time series to be the given time series.- Parameters:
timeSeries- The time series to copy entries from.
-
getTimeBucket
public CommonTimeUtil.TimeBucket getTimeBucket()
-
-