Search in sources :

Example 6 with IntervalsByGranularity

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

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());
}
Also used : IntervalsByGranularity(org.apache.druid.java.util.common.granularity.IntervalsByGranularity) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 7 with IntervalsByGranularity

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

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)

Example 8 with IntervalsByGranularity

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

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())));
}
Also used : IntervalsByGranularity(org.apache.druid.java.util.common.granularity.IntervalsByGranularity) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 9 with IntervalsByGranularity

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

the class IntervalsByGranularityTest method testSimpleEliminateRepeated.

@Test
public void testSimpleEliminateRepeated() {
    final List<Interval> inputIntervals = ImmutableList.of(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"));
    IntervalsByGranularity intervals = new IntervalsByGranularity(inputIntervals, Granularities.MONTH);
    Assert.assertEquals(ImmutableList.of(Intervals.of("2012-01-01T00Z/2012-02-01T00Z")), ImmutableList.copyOf(intervals.granularityIntervalsIterator()));
}
Also used : IntervalsByGranularity(org.apache.druid.java.util.common.granularity.IntervalsByGranularity) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 10 with IntervalsByGranularity

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

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);
}
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