Search in sources :

Example 21 with IntervalsByGranularity

use of org.apache.druid.java.util.common.granularity.IntervalsByGranularity in project druid by apache.

the class IntervalsByGranularityTest method testTrivialIntervalExplosion.

@Test
public void testTrivialIntervalExplosion() {
    Interval first = Intervals.of("2013-01-01T00Z/2013-02-01T00Z");
    Interval second = Intervals.of("2012-01-01T00Z/2012-02-01T00Z");
    Interval third = Intervals.of("2002-01-01T00Z/2003-01-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(62 + 365, count);
    granularityIntervals = intervals.granularityIntervalsIterator();
    count = getCountWithNoHasNext(granularityIntervals);
    Assert.assertEquals(62 + 365, count);
}
Also used : IntervalsByGranularity(org.apache.druid.java.util.common.granularity.IntervalsByGranularity) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 22 with IntervalsByGranularity

use of org.apache.druid.java.util.common.granularity.IntervalsByGranularity in project druid by apache.

the class IntervalsByGranularityTest method testRemoveThrowsException.

@Test(expected = UnsupportedOperationException.class)
public void testRemoveThrowsException() {
    final List<Interval> inputIntervals = ImmutableList.of(Intervals.of("2015-01-08T00Z/2015-01-11T00Z"));
    IntervalsByGranularity intervals = new IntervalsByGranularity(inputIntervals, Granularities.MONTH);
    intervals.granularityIntervalsIterator().remove();
}
Also used : IntervalsByGranularity(org.apache.druid.java.util.common.granularity.IntervalsByGranularity) Interval(org.joda.time.Interval) Test(org.junit.Test)

Aggregations

IntervalsByGranularity (org.apache.druid.java.util.common.granularity.IntervalsByGranularity)22 Interval (org.joda.time.Interval)22 Test (org.junit.Test)20 LockGranularity (org.apache.druid.indexing.common.LockGranularity)2 TaskLock (org.apache.druid.indexing.common.TaskLock)2 TimeChunkLockTryAcquireAction (org.apache.druid.indexing.common.actions.TimeChunkLockTryAcquireAction)2 MaxAllowedLocksExceededException (org.apache.druid.indexing.common.task.batch.MaxAllowedLocksExceededException)2 ISE (org.apache.druid.java.util.common.ISE)2 Granularity (org.apache.druid.java.util.common.granularity.Granularity)2 Ignore (org.junit.Ignore)2