use of org.apache.druid.java.util.common.granularity.IntervalsByGranularity in project druid by apache.
the class IntervalsByGranularityTest method testEmptyInput.
@Test
public void testEmptyInput() {
final List<Interval> inputIntervals = Collections.emptyList();
IntervalsByGranularity intervals = new IntervalsByGranularity(inputIntervals, Granularities.MONTH);
Assert.assertFalse(intervals.granularityIntervalsIterator().hasNext());
}
use of org.apache.druid.java.util.common.granularity.IntervalsByGranularity in project druid by apache.
the class IntervalsByGranularityTest method testALittleMoreComplexEliminateRepeated.
@Test
public void testALittleMoreComplexEliminateRepeated() {
final List<Interval> inputIntervals = ImmutableList.of(Intervals.of("2015-01-08T00Z/2015-01-11T00Z"), Intervals.of("2012-01-08T00Z/2012-01-11T00Z"), Intervals.of("2012-01-07T00Z/2012-01-08T00Z"), Intervals.of("2012-01-03T00Z/2012-01-04T00Z"), Intervals.of("2012-01-01T00Z/2012-01-03T00Z"), Intervals.of("2007-03-08T00Z/2007-04-11T00Z"));
IntervalsByGranularity intervals = new IntervalsByGranularity(inputIntervals, Granularities.MONTH);
Assert.assertEquals(ImmutableList.of(Intervals.of("2007-03-01T00Z/2007-04-01T00Z"), Intervals.of("2007-04-01T00Z/2007-05-01T00Z"), Intervals.of("2012-01-01T00Z/2012-02-01T00Z"), Intervals.of("2015-01-01T00Z/2015-02-01T00Z")), ImmutableList.copyOf(intervals.granularityIntervalsIterator()));
}
use of org.apache.druid.java.util.common.granularity.IntervalsByGranularity in project druid by apache.
the class IntervalsByGranularityTest method testIterateHugeIntervalsWithTinyGranularity.
/**
* This test iterates huge intervals (2.5 years) with the SECOND granularity.
* The motivation behind this test is ensuring that IntervalsByGranularity can handle
* these huge intervals with a tiny granularity. However, this test takes a long time
* to populate all intervals based on the SECOND granularity (more than 1 min), so
* is ignored by default. We should make this test not a unit test, but a load test.
*/
@Ignore
@Test
public void testIterateHugeIntervalsWithTinyGranularity() {
Interval first = Intervals.of("2012-01-01T00Z/2012-12-31T00Z");
Interval second = Intervals.of("2002-01-01T00Z/2002-12-31T00Z");
Interval third = Intervals.of("2021-01-01T00Z/2021-06-30T00Z");
IntervalsByGranularity intervals = new IntervalsByGranularity(ImmutableList.of(first, second, third), Granularities.SECOND);
// get count:
Iterator<Interval> granularityIntervals = intervals.granularityIntervalsIterator();
long count = verifyIteratorAndReturnIntervalCount(granularityIntervals);
Assert.assertEquals(78537600, count);
}
use of org.apache.druid.java.util.common.granularity.IntervalsByGranularity in project druid by apache.
the class IntervalsByGranularityTest method testWithGranularity.
@Test
public void testWithGranularity() {
List<Interval> inputIntervals = ImmutableList.of(Intervals.of("2013-01-01T00Z/2013-01-10T00Z"), Intervals.of("2013-01-15T00Z/2013-01-20T00Z"), Intervals.of("2013-02-07T00Z/2013-02-15T00Z"));
IntervalsByGranularity intervals = new IntervalsByGranularity(inputIntervals, Granularities.MONTH);
// get count:
Iterator<Interval> granularityIntervals = intervals.granularityIntervalsIterator();
long count = verifyIteratorAndReturnIntervalCount(granularityIntervals);
Assert.assertEquals(2, count);
}
use of org.apache.druid.java.util.common.granularity.IntervalsByGranularity in project druid by apache.
the class IntervalsByGranularityTest method testDups.
@Test
public void testDups() {
Interval first = Intervals.of("2013-01-01T00Z/2013-02-01T00Z");
Interval second = Intervals.of("2012-04-01T00Z/2012-05-01T00Z");
// dup
Interval third = Intervals.of("2013-01-01T00Z/2013-02-01T00Z");
IntervalsByGranularity intervals = new IntervalsByGranularity(ImmutableList.of(first, second, third), Granularities.DAY);
// get count:
Iterator<Interval> granularityIntervals = intervals.granularityIntervalsIterator();
long count = verifyIteratorAndReturnIntervalCount(granularityIntervals);
Assert.assertEquals(61, count);
}
Aggregations