Search in sources :

Example 56 with Interval

use of org.joda.time.Interval in project druid by druid-io.

the class QueryGranularityTest method testIterableMonth.

@Test
public void testIterableMonth() throws Exception {
    final DateTimeZone tz = DateTimeZone.forID("America/Los_Angeles");
    final DateTime baseTime = new DateTime("2012-11-03T10:00:00", tz);
    assertSameInterval(Lists.newArrayList(new DateTime("2012-11-01T00:00:00.000-07:00"), new DateTime("2012-12-01T00:00:00.000-08:00"), new DateTime("2013-01-01T00:00:00.000-08:00"), new DateTime("2013-02-01T00:00:00.000-08:00")), new PeriodGranularity(new Period("P1M"), null, tz).getIterable(new Interval(baseTime.getMillis(), baseTime.plus(Months.months(3)).getMillis())));
}
Also used : PeriodGranularity(io.druid.java.util.common.granularity.PeriodGranularity) Period(org.joda.time.Period) DateTimeZone(org.joda.time.DateTimeZone) DateTime(org.joda.time.DateTime) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 57 with Interval

use of org.joda.time.Interval in project druid by druid-io.

the class QueryGranularityTest method testIterableWeek.

@Test
public void testIterableWeek() throws Exception {
    final DateTimeZone tz = DateTimeZone.forID("America/Los_Angeles");
    final DateTime baseTime = new DateTime("2012-11-03T10:00:00", tz);
    assertSameInterval(Lists.newArrayList(new DateTime("2012-10-29T00:00:00.000-07:00"), new DateTime("2012-11-05T00:00:00.000-08:00"), new DateTime("2012-11-12T00:00:00.000-08:00"), new DateTime("2012-11-19T00:00:00.000-08:00")), new PeriodGranularity(new Period("P1W"), null, tz).getIterable(new Interval(baseTime.getMillis(), baseTime.plus(Weeks.weeks(3)).getMillis())));
    assertSameInterval(Lists.newArrayList(new DateTime("2012-11-03T10:00:00.000-07:00"), new DateTime("2012-11-10T10:00:00.000-08:00"), new DateTime("2012-11-17T10:00:00.000-08:00")), new PeriodGranularity(new Period("P1W"), baseTime, tz).getIterable(new Interval(baseTime.getMillis(), baseTime.plus(Weeks.weeks(3)).getMillis())));
}
Also used : PeriodGranularity(io.druid.java.util.common.granularity.PeriodGranularity) Period(org.joda.time.Period) DateTimeZone(org.joda.time.DateTimeZone) DateTime(org.joda.time.DateTime) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 58 with Interval

use of org.joda.time.Interval in project druid by druid-io.

the class QueryGranularityTest method testIterableAllComplex.

@Test
public void testIterableAllComplex() throws Exception {
    final DateTime baseTime = new DateTime("2011-01-01T09:38:02.992Z");
    assertSameInterval(Lists.newArrayList(baseTime), Granularities.ALL.getIterable(new Interval(baseTime.getMillis(), baseTime.plus(Days.days(3)).getMillis())));
}
Also used : DateTime(org.joda.time.DateTime) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 59 with Interval

use of org.joda.time.Interval in project druid by druid-io.

the class QueryGranularityTest method testIterableDayComplex.

@Test
public void testIterableDayComplex() throws Exception {
    final DateTime baseTime = new DateTime("2011-01-01T09:38:02.992Z");
    assertSameInterval(Lists.newArrayList(new DateTime("2011-01-01T00:00:00.000Z"), new DateTime("2011-01-02T00:00:00.000Z"), new DateTime("2011-01-03T00:00:00.000Z"), new DateTime("2011-01-04T00:00:00.000Z")), Granularities.DAY.getIterable(new Interval(baseTime.getMillis(), baseTime.plus(Days.days(3)).getMillis())));
}
Also used : DateTime(org.joda.time.DateTime) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 60 with Interval

use of org.joda.time.Interval in project druid by druid-io.

the class QueryGranularityTest method testIterableMinuteComplex.

@Test
public void testIterableMinuteComplex() throws Exception {
    final DateTime baseTime = new DateTime("2011-01-01T09:38:02.992Z");
    assertSameInterval(Lists.newArrayList(new DateTime("2011-01-01T09:38:00.000Z"), new DateTime("2011-01-01T09:39:00.000Z"), new DateTime("2011-01-01T09:40:00.000Z"), new DateTime("2011-01-01T09:41:00.000Z")), Granularities.MINUTE.getIterable(new Interval(baseTime.getMillis(), baseTime.plus(Minutes.THREE).getMillis())));
}
Also used : DateTime(org.joda.time.DateTime) Interval(org.joda.time.Interval) Test(org.junit.Test)

Aggregations

Interval (org.joda.time.Interval)1052 Test (org.junit.Test)604 DateTime (org.joda.time.DateTime)316 ArrayList (java.util.ArrayList)186 DataSegment (org.apache.druid.timeline.DataSegment)145 DataSegment (io.druid.timeline.DataSegment)138 List (java.util.List)134 Map (java.util.Map)131 HashMap (java.util.HashMap)106 File (java.io.File)91 IOException (java.io.IOException)75 ImmutableList (com.google.common.collect.ImmutableList)71 ImmutableMap (com.google.common.collect.ImmutableMap)56 Period (org.joda.time.Period)56 TreeMap (java.util.TreeMap)55 ISE (org.apache.druid.java.util.common.ISE)53 HashSet (java.util.HashSet)50 LongSumAggregatorFactory (io.druid.query.aggregation.LongSumAggregatorFactory)49 QueryRunner (io.druid.query.QueryRunner)47 AggregatorFactory (io.druid.query.aggregation.AggregatorFactory)45