Search in sources :

Example 1 with TimestampSet

use of uk.gov.gchq.gaffer.time.TimestampSet in project gaffer-doc by gchq.

the class BoundedTimestampSetElementGenerator method _apply.

@Override
public Iterable<Element> _apply(final String line) {
    final List<Element> elements = new ArrayList<>();
    for (int i = 0; i < 3; i++) {
        final TimestampSet timestampSet = new BoundedTimestampSet(CommonTimeUtil.TimeBucket.MINUTE, 25);
        timestampSet.add(START_OF_2017.plusSeconds(RANDOM.nextInt(SECONDS_IN_YEAR)));
        final Edge edge = new Edge.Builder().group("red").source("A").dest("B").property("boundedTimestampSet", timestampSet).build();
        elements.add(edge);
    }
    for (int i = 0; i < 1000; i++) {
        final TimestampSet timestampSet = new BoundedTimestampSet(CommonTimeUtil.TimeBucket.MINUTE, 25);
        timestampSet.add(START_OF_2017.plusSeconds(RANDOM.nextInt(SECONDS_IN_YEAR)));
        final Edge edge = new Edge.Builder().group("red").source("A").dest("C").property("boundedTimestampSet", timestampSet).build();
        elements.add(edge);
    }
    return elements;
}
Also used : Element(uk.gov.gchq.gaffer.data.element.Element) ArrayList(java.util.ArrayList) BoundedTimestampSet(uk.gov.gchq.gaffer.time.BoundedTimestampSet) TimestampSet(uk.gov.gchq.gaffer.time.TimestampSet) BoundedTimestampSet(uk.gov.gchq.gaffer.time.BoundedTimestampSet) Edge(uk.gov.gchq.gaffer.data.element.Edge)

Example 2 with TimestampSet

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

the class ToTimestampSetTest method shouldCreateNonBoundedSet.

@Test
public void shouldCreateNonBoundedSet() {
    // Given
    final ToTimestampSet toTimestampSet = new ToTimestampSet(TimeBucket.DAY, false);
    // When
    TimestampSet result = toTimestampSet.apply(TEST_TIMESTAMP);
    // Then
    TimestampSet expected = new RBMBackedTimestampSet.Builder().timeBucket(TimeBucket.DAY).build();
    expected.add(Instant.ofEpochMilli(TEST_TIMESTAMP));
    assertEquals(expected, result);
}
Also used : TimestampSet(uk.gov.gchq.gaffer.time.TimestampSet) BoundedTimestampSet(uk.gov.gchq.gaffer.time.BoundedTimestampSet) RBMBackedTimestampSet(uk.gov.gchq.gaffer.time.RBMBackedTimestampSet) Test(org.junit.jupiter.api.Test) FunctionTest(uk.gov.gchq.koryphe.function.FunctionTest)

Example 3 with TimestampSet

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

the class ToTimestampSetTest method shouldCreateEmptySetWhenNull.

@Test
public void shouldCreateEmptySetWhenNull() {
    // Given
    final ToTimestampSet toTimestampSet = new ToTimestampSet(TimeBucket.DAY, false);
    // When
    TimestampSet result = toTimestampSet.apply(null);
    // Then
    TimestampSet expected = new RBMBackedTimestampSet.Builder().timeBucket(TimeBucket.DAY).build();
    assertEquals(expected, result);
}
Also used : TimestampSet(uk.gov.gchq.gaffer.time.TimestampSet) BoundedTimestampSet(uk.gov.gchq.gaffer.time.BoundedTimestampSet) RBMBackedTimestampSet(uk.gov.gchq.gaffer.time.RBMBackedTimestampSet) Test(org.junit.jupiter.api.Test) FunctionTest(uk.gov.gchq.koryphe.function.FunctionTest)

Example 4 with TimestampSet

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

the class ToTimestampSetTest method shouldCreateBoundedSet.

@Test
public void shouldCreateBoundedSet() {
    // Given
    final ToTimestampSet toTimestampSet = new ToTimestampSet(TimeBucket.DAY, 10);
    // When
    TimestampSet result = toTimestampSet.apply(TEST_TIMESTAMP);
    // Then
    TimestampSet expected = new BoundedTimestampSet.Builder().timeBucket(TimeBucket.DAY).maxSize(10).build();
    expected.add(Instant.ofEpochMilli(TEST_TIMESTAMP));
    assertEquals(expected, result);
}
Also used : BoundedTimestampSet(uk.gov.gchq.gaffer.time.BoundedTimestampSet) TimestampSet(uk.gov.gchq.gaffer.time.TimestampSet) BoundedTimestampSet(uk.gov.gchq.gaffer.time.BoundedTimestampSet) RBMBackedTimestampSet(uk.gov.gchq.gaffer.time.RBMBackedTimestampSet) Test(org.junit.jupiter.api.Test) FunctionTest(uk.gov.gchq.koryphe.function.FunctionTest)

Example 5 with TimestampSet

use of uk.gov.gchq.gaffer.time.TimestampSet in project gaffer-doc by gchq.

the class TimestampSetElementGenerator method _apply.

@Override
public Iterable<Element> _apply(final String line) {
    final Set<Element> elements = new HashSet<>();
    for (int i = 0; i < 25; i++) {
        final TimestampSet timestampSet = new RBMBackedTimestampSet(CommonTimeUtil.TimeBucket.MINUTE);
        timestampSet.add(START_OF_2017.plusSeconds(RANDOM.nextInt(SECONDS_IN_YEAR)));
        final Edge edge = new Edge.Builder().group("red").source("A").dest("B").property("timestampSet", timestampSet).build();
        elements.add(edge);
    }
    return elements;
}
Also used : RBMBackedTimestampSet(uk.gov.gchq.gaffer.time.RBMBackedTimestampSet) Element(uk.gov.gchq.gaffer.data.element.Element) TimestampSet(uk.gov.gchq.gaffer.time.TimestampSet) RBMBackedTimestampSet(uk.gov.gchq.gaffer.time.RBMBackedTimestampSet) Edge(uk.gov.gchq.gaffer.data.element.Edge) HashSet(java.util.HashSet)

Aggregations

TimestampSet (uk.gov.gchq.gaffer.time.TimestampSet)5 BoundedTimestampSet (uk.gov.gchq.gaffer.time.BoundedTimestampSet)4 RBMBackedTimestampSet (uk.gov.gchq.gaffer.time.RBMBackedTimestampSet)4 Test (org.junit.jupiter.api.Test)3 FunctionTest (uk.gov.gchq.koryphe.function.FunctionTest)3 Edge (uk.gov.gchq.gaffer.data.element.Edge)2 Element (uk.gov.gchq.gaffer.data.element.Element)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1