Search in sources :

Example 1 with ClientAppendQuery

use of io.druid.client.indexing.ClientAppendQuery in project druid by druid-io.

the class TaskSerdeTest method testAppendTaskSerde.

@Test
public void testAppendTaskSerde() throws Exception {
    final List<DataSegment> segments = ImmutableList.of(DataSegment.builder().dataSource("foo").interval(new Interval("2010-01-01/P1D")).version("1234").build(), DataSegment.builder().dataSource("foo").interval(new Interval("2010-01-02/P1D")).version("5678").build());
    final AppendTask task = new AppendTask(null, "foo", segments, ImmutableList.<AggregatorFactory>of(new CountAggregatorFactory("cnt")), indexSpec, true, null);
    final String json = jsonMapper.writeValueAsString(task);
    // Just want to run the clock a bit to make sure the task id doesn't change
    Thread.sleep(100);
    final AppendTask task2 = (AppendTask) jsonMapper.readValue(json, Task.class);
    Assert.assertEquals("foo", task.getDataSource());
    Assert.assertEquals(new Interval("2010-01-01/P2D"), task.getInterval());
    Assert.assertEquals(task.getId(), task2.getId());
    Assert.assertEquals(task.getGroupId(), task2.getGroupId());
    Assert.assertEquals(task.getDataSource(), task2.getDataSource());
    Assert.assertEquals(task.getInterval(), task2.getInterval());
    Assert.assertEquals(task.getSegments(), task2.getSegments());
    final AppendTask task3 = (AppendTask) jsonMapper.readValue(jsonMapper.writeValueAsString(new ClientAppendQuery("foo", segments)), Task.class);
    Assert.assertEquals("foo", task3.getDataSource());
    Assert.assertEquals(new Interval("2010-01-01/P2D"), task3.getInterval());
    Assert.assertEquals(task3.getSegments(), segments);
    Assert.assertEquals(task.getAggregators(), task2.getAggregators());
}
Also used : ClientAppendQuery(io.druid.client.indexing.ClientAppendQuery) CountAggregatorFactory(io.druid.query.aggregation.CountAggregatorFactory) DataSegment(io.druid.timeline.DataSegment) Interval(org.joda.time.Interval) Test(org.junit.Test)

Aggregations

ClientAppendQuery (io.druid.client.indexing.ClientAppendQuery)1 CountAggregatorFactory (io.druid.query.aggregation.CountAggregatorFactory)1 DataSegment (io.druid.timeline.DataSegment)1 Interval (org.joda.time.Interval)1 Test (org.junit.Test)1