use of org.apache.druid.java.util.common.granularity.IntervalsByGranularity in project druid by druid-io.
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);
}
use of org.apache.druid.java.util.common.granularity.IntervalsByGranularity in project druid by druid-io.
the class IntervalsByGranularityTest method testCondenseForManyIntervals.
@Test
public void testCondenseForManyIntervals() {
// This method attempts to test that there are no issues when condensed is called
// with an iterator pointing to millions of intervals (since the version of condensed
// used here takes an interval iterator and does not materialize intervals)
Interval first = Intervals.of("2012-01-01T00Z/P1Y");
IntervalsByGranularity intervals = new IntervalsByGranularity(ImmutableList.of(first), Granularities.SECOND);
Assert.assertEquals(ImmutableList.of(Intervals.of("2012-01-01T00Z/2013-01-01T00Z")), ImmutableList.copyOf(JodaUtils.condensedIntervalsIterator(intervals.granularityIntervalsIterator())));
}
use of org.apache.druid.java.util.common.granularity.IntervalsByGranularity in project druid by druid-io.
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 druid-io.
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 druid-io.
the class IntervalsByGranularityTest method testOverlappingShouldThrow.
@Test
public void testOverlappingShouldThrow() {
List<Interval> inputIntervals = ImmutableList.of(Intervals.of("2013-01-01T00Z/2013-01-11T00Z"), Intervals.of("2013-01-05T00Z/2013-01-08T00Z"), Intervals.of("2013-01-07T00Z/2013-01-15T00Z"));
IntervalsByGranularity intervals = new IntervalsByGranularity(inputIntervals, Granularities.DAY);
Iterator<Interval> granularityIntervals = intervals.granularityIntervalsIterator();
long count = verifyIteratorAndReturnIntervalCount(granularityIntervals);
Assert.assertEquals(14, count);
}
Aggregations