Search in sources :

Example 6 with LongTimeSeries

use of uk.gov.gchq.gaffer.time.LongTimeSeries in project Gaffer by gchq.

the class DeltaLongTimeSeriesSerialiserTest method testConsistent.

@Test
public void testConsistent() throws SerialisationException {
    // Given
    final LongTimeSeries timeSeries1 = new LongTimeSeries(TimeBucket.SECOND);
    timeSeries1.upsert(Instant.ofEpochMilli(1000L), 10L);
    final LongTimeSeries timeSeries2 = new LongTimeSeries(TimeBucket.SECOND);
    timeSeries2.upsert(Instant.ofEpochMilli(1000L), 5L);
    timeSeries2.upsert(Instant.ofEpochMilli(1000L), 5L);
    // When
    final byte[] serialised1 = SERIALISER.serialise(timeSeries1);
    final byte[] serialised2 = SERIALISER.serialise(timeSeries2);
    // Then
    assertArrayEquals(serialised1, serialised2);
}
Also used : LongTimeSeries(uk.gov.gchq.gaffer.time.LongTimeSeries) Test(org.junit.jupiter.api.Test) ToBytesSerialisationTest(uk.gov.gchq.gaffer.serialisation.ToBytesSerialisationTest)

Example 7 with LongTimeSeries

use of uk.gov.gchq.gaffer.time.LongTimeSeries in project Gaffer by gchq.

the class DeltaLongTimeSeriesSerialiserTest method getExampleValueWeek.

private LongTimeSeries getExampleValueWeek() {
    final LongTimeSeries timeSeries = new LongTimeSeries(TimeBucket.WEEK);
    timeSeries.upsert(Instant.ofEpochMilli(CommonTimeUtil.MILLISECONDS_IN_DAY * 7), 7L);
    timeSeries.upsert(Instant.ofEpochMilli(CommonTimeUtil.MILLISECONDS_IN_DAY * 70), 70L);
    timeSeries.upsert(Instant.ofEpochMilli(CommonTimeUtil.MILLISECONDS_IN_DAY * 700), 700L);
    return timeSeries;
}
Also used : LongTimeSeries(uk.gov.gchq.gaffer.time.LongTimeSeries)

Example 8 with LongTimeSeries

use of uk.gov.gchq.gaffer.time.LongTimeSeries in project Gaffer by gchq.

the class LongTimeSeriesAggregatorTest method testCantMergeIfDifferentTimeBucket.

@Test
public void testCantMergeIfDifferentTimeBucket() {
    try {
        final LongTimeSeries timeSeries1 = new LongTimeSeries(TimeBucket.SECOND);
        final LongTimeSeries timeSeries2 = new LongTimeSeries(TimeBucket.MINUTE);
        LONG_TIME_SERIES_AGGREGATOR._apply(timeSeries1, timeSeries2);
    } catch (final RuntimeException e) {
    // Expected
    }
}
Also used : LongTimeSeries(uk.gov.gchq.gaffer.time.LongTimeSeries) Test(org.junit.jupiter.api.Test)

Example 9 with LongTimeSeries

use of uk.gov.gchq.gaffer.time.LongTimeSeries in project Gaffer by gchq.

the class DeltaLongTimeSeriesSerialiserTest method getExampleValueMinute.

private LongTimeSeries getExampleValueMinute() {
    final LongTimeSeries timeSeries = new LongTimeSeries(TimeBucket.MINUTE);
    timeSeries.upsert(Instant.ofEpochMilli(CommonTimeUtil.MILLISECONDS_IN_MINUTE * 100), 100L);
    timeSeries.upsert(Instant.ofEpochMilli(CommonTimeUtil.MILLISECONDS_IN_MINUTE * 10_000), 10_000L);
    timeSeries.upsert(Instant.ofEpochMilli(CommonTimeUtil.MILLISECONDS_IN_MINUTE * 1_000_000), 1_000_000L);
    return timeSeries;
}
Also used : LongTimeSeries(uk.gov.gchq.gaffer.time.LongTimeSeries)

Example 10 with LongTimeSeries

use of uk.gov.gchq.gaffer.time.LongTimeSeries in project Gaffer by gchq.

the class DeltaLongTimeSeriesSerialiserTest method getExampleValueHour.

private LongTimeSeries getExampleValueHour() {
    final LongTimeSeries timeSeries = new LongTimeSeries(TimeBucket.HOUR);
    timeSeries.upsert(Instant.ofEpochMilli(CommonTimeUtil.MILLISECONDS_IN_HOUR * 100), 100L);
    timeSeries.upsert(Instant.ofEpochMilli(CommonTimeUtil.MILLISECONDS_IN_HOUR * 1_000), 1_000L);
    timeSeries.upsert(Instant.ofEpochMilli(CommonTimeUtil.MILLISECONDS_IN_HOUR * 1_000_000), 1_000_000L);
    return timeSeries;
}
Also used : LongTimeSeries(uk.gov.gchq.gaffer.time.LongTimeSeries)

Aggregations

LongTimeSeries (uk.gov.gchq.gaffer.time.LongTimeSeries)15 Test (org.junit.jupiter.api.Test)5 ToBytesSerialisationTest (uk.gov.gchq.gaffer.serialisation.ToBytesSerialisationTest)3 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 IOException (java.io.IOException)1 SerialisationException (uk.gov.gchq.gaffer.exception.SerialisationException)1 TimeBucket (uk.gov.gchq.gaffer.time.CommonTimeUtil.TimeBucket)1