use of io.druid.segment.incremental.IncrementalIndex.TimeAndDims in project druid by druid-io.
the class TimeAndDimsCompTest method testBasic.
@Test
public void testBasic() throws IndexSizeExceededException {
IncrementalIndex index = new OnheapIncrementalIndex(0, Granularities.NONE, new AggregatorFactory[] { new CountAggregatorFactory("cnt") }, 1000);
long time = System.currentTimeMillis();
TimeAndDims td1 = index.toTimeAndDims(toMapRow(time, "billy", "A", "joe", "B"));
TimeAndDims td2 = index.toTimeAndDims(toMapRow(time, "billy", "A", "joe", "A"));
TimeAndDims td3 = index.toTimeAndDims(toMapRow(time, "billy", "A"));
TimeAndDims td4 = index.toTimeAndDims(toMapRow(time + 1, "billy", "A", "joe", "B"));
TimeAndDims td5 = index.toTimeAndDims(toMapRow(time + 1, "billy", "A", "joe", Arrays.asList("A", "B")));
TimeAndDims td6 = index.toTimeAndDims(toMapRow(time + 1));
Comparator<IncrementalIndex.TimeAndDims> comparator = index.dimsComparator();
Assert.assertEquals(0, comparator.compare(td1, td1));
Assert.assertEquals(0, comparator.compare(td2, td2));
Assert.assertEquals(0, comparator.compare(td3, td3));
Assert.assertTrue(comparator.compare(td1, td2) > 0);
Assert.assertTrue(comparator.compare(td2, td1) < 0);
Assert.assertTrue(comparator.compare(td2, td3) > 0);
Assert.assertTrue(comparator.compare(td3, td2) < 0);
Assert.assertTrue(comparator.compare(td1, td3) > 0);
Assert.assertTrue(comparator.compare(td3, td1) < 0);
Assert.assertTrue(comparator.compare(td6, td1) > 0);
Assert.assertTrue(comparator.compare(td6, td2) > 0);
Assert.assertTrue(comparator.compare(td6, td3) > 0);
Assert.assertTrue(comparator.compare(td4, td6) > 0);
Assert.assertTrue(comparator.compare(td5, td6) > 0);
Assert.assertTrue(comparator.compare(td4, td5) < 0);
Assert.assertTrue(comparator.compare(td5, td4) > 0);
}
Aggregations