Search in sources :

Example 1 with LogicalSegment

use of io.druid.timeline.LogicalSegment in project druid by druid-io.

the class TimeBoundaryQueryQueryToolChestTest method testFilteredFilterSegments.

@Test
public void testFilteredFilterSegments() throws Exception {
    List<LogicalSegment> segments = new TimeBoundaryQueryQueryToolChest().filterSegments(FILTERED_BOUNDARY_QUERY, Arrays.asList(createLogicalSegment(new Interval("2013-01-01/P1D")), createLogicalSegment(new Interval("2013-01-01T01/PT1H")), createLogicalSegment(new Interval("2013-01-01T02/PT1H")), createLogicalSegment(new Interval("2013-01-02/P1D")), createLogicalSegment(new Interval("2013-01-03T01/PT1H")), createLogicalSegment(new Interval("2013-01-03T02/PT1H")), createLogicalSegment(new Interval("2013-01-03/P1D"))));
    Assert.assertEquals(7, segments.size());
}
Also used : LogicalSegment(io.druid.timeline.LogicalSegment) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 2 with LogicalSegment

use of io.druid.timeline.LogicalSegment in project druid by druid-io.

the class TimeBoundaryQueryQueryToolChestTest method testMinTimeFilterSegments.

@Test
public void testMinTimeFilterSegments() throws Exception {
    List<LogicalSegment> segments = new TimeBoundaryQueryQueryToolChest().filterSegments(MINTIME_BOUNDARY_QUERY, Arrays.asList(createLogicalSegment(new Interval("2013-01-01/P1D")), createLogicalSegment(new Interval("2013-01-01T01/PT1H")), createLogicalSegment(new Interval("2013-01-01T02/PT1H")), createLogicalSegment(new Interval("2013-01-02/P1D")), createLogicalSegment(new Interval("2013-01-03T01/PT1H")), createLogicalSegment(new Interval("2013-01-03T02/PT1H")), createLogicalSegment(new Interval("2013-01-03/P1D"))));
    Assert.assertEquals(3, segments.size());
    List<LogicalSegment> expected = Arrays.asList(createLogicalSegment(new Interval("2013-01-01/P1D")), createLogicalSegment(new Interval("2013-01-01T01/PT1H")), createLogicalSegment(new Interval("2013-01-01T02/PT1H")));
    for (int i = 0; i < segments.size(); i++) {
        Assert.assertEquals(segments.get(i).getInterval(), expected.get(i).getInterval());
    }
}
Also used : LogicalSegment(io.druid.timeline.LogicalSegment) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 3 with LogicalSegment

use of io.druid.timeline.LogicalSegment in project druid by druid-io.

the class SegmentMetadataQueryTest method testDefaultIntervalAndFiltering.

@Test
public void testDefaultIntervalAndFiltering() throws Exception {
    SegmentMetadataQuery testQuery = Druids.newSegmentMetadataQueryBuilder().dataSource("testing").toInclude(new ListColumnIncluderator(Arrays.asList("placement"))).merge(true).build();
    Interval expectedInterval = new Interval(JodaUtils.MIN_INSTANT, JodaUtils.MAX_INSTANT);
    /* No interval specified, should use default interval */
    Assert.assertTrue(testQuery.isUsingDefaultInterval());
    Assert.assertEquals(testQuery.getIntervals().get(0), expectedInterval);
    Assert.assertEquals(testQuery.getIntervals().size(), 1);
    List<LogicalSegment> testSegments = Arrays.asList(new LogicalSegment() {

        @Override
        public Interval getInterval() {
            return new Interval("2012-01-01/P1D");
        }
    }, new LogicalSegment() {

        @Override
        public Interval getInterval() {
            return new Interval("2012-01-01T01/PT1H");
        }
    }, new LogicalSegment() {

        @Override
        public Interval getInterval() {
            return new Interval("2013-01-05/P1D");
        }
    }, new LogicalSegment() {

        @Override
        public Interval getInterval() {
            return new Interval("2013-05-20/P1D");
        }
    }, new LogicalSegment() {

        @Override
        public Interval getInterval() {
            return new Interval("2014-01-05/P1D");
        }
    }, new LogicalSegment() {

        @Override
        public Interval getInterval() {
            return new Interval("2014-02-05/P1D");
        }
    }, new LogicalSegment() {

        @Override
        public Interval getInterval() {
            return new Interval("2015-01-19T01/PT1H");
        }
    }, new LogicalSegment() {

        @Override
        public Interval getInterval() {
            return new Interval("2015-01-20T02/PT1H");
        }
    });
    /* Test default period filter */
    List<LogicalSegment> filteredSegments = new SegmentMetadataQueryQueryToolChest(new SegmentMetadataQueryConfig()).filterSegments(testQuery, testSegments);
    List<LogicalSegment> expectedSegments = Arrays.asList(new LogicalSegment() {

        @Override
        public Interval getInterval() {
            return new Interval("2015-01-19T01/PT1H");
        }
    }, new LogicalSegment() {

        @Override
        public Interval getInterval() {
            return new Interval("2015-01-20T02/PT1H");
        }
    });
    Assert.assertEquals(filteredSegments.size(), 2);
    for (int i = 0; i < filteredSegments.size(); i++) {
        Assert.assertEquals(expectedSegments.get(i).getInterval(), filteredSegments.get(i).getInterval());
    }
    /* Test 2 year period filtering */
    SegmentMetadataQueryConfig twoYearPeriodCfg = new SegmentMetadataQueryConfig("P2Y");
    List<LogicalSegment> filteredSegments2 = new SegmentMetadataQueryQueryToolChest(twoYearPeriodCfg).filterSegments(testQuery, testSegments);
    List<LogicalSegment> expectedSegments2 = Arrays.asList(new LogicalSegment() {

        @Override
        public Interval getInterval() {
            return new Interval("2013-05-20/P1D");
        }
    }, new LogicalSegment() {

        @Override
        public Interval getInterval() {
            return new Interval("2014-01-05/P1D");
        }
    }, new LogicalSegment() {

        @Override
        public Interval getInterval() {
            return new Interval("2014-02-05/P1D");
        }
    }, new LogicalSegment() {

        @Override
        public Interval getInterval() {
            return new Interval("2015-01-19T01/PT1H");
        }
    }, new LogicalSegment() {

        @Override
        public Interval getInterval() {
            return new Interval("2015-01-20T02/PT1H");
        }
    });
    Assert.assertEquals(filteredSegments2.size(), 5);
    for (int i = 0; i < filteredSegments2.size(); i++) {
        Assert.assertEquals(expectedSegments2.get(i).getInterval(), filteredSegments2.get(i).getInterval());
    }
}
Also used : LogicalSegment(io.druid.timeline.LogicalSegment) SegmentMetadataQuery(io.druid.query.metadata.metadata.SegmentMetadataQuery) ListColumnIncluderator(io.druid.query.metadata.metadata.ListColumnIncluderator) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 4 with LogicalSegment

use of io.druid.timeline.LogicalSegment in project druid by druid-io.

the class DataSourceMetadataQueryTest method testFilterSegments.

@Test
public void testFilterSegments() {
    List<LogicalSegment> segments = new DataSourceQueryQueryToolChest().filterSegments(null, Arrays.asList(new LogicalSegment() {

        @Override
        public Interval getInterval() {
            return new Interval("2012-01-01/P1D");
        }
    }, new LogicalSegment() {

        @Override
        public Interval getInterval() {
            return new Interval("2012-01-01T01/PT1H");
        }
    }, new LogicalSegment() {

        @Override
        public Interval getInterval() {
            return new Interval("2013-01-01/P1D");
        }
    }, new LogicalSegment() {

        @Override
        public Interval getInterval() {
            return new Interval("2013-01-01T01/PT1H");
        }
    }, new LogicalSegment() {

        @Override
        public Interval getInterval() {
            return new Interval("2013-01-01T02/PT1H");
        }
    }));
    Assert.assertEquals(segments.size(), 2);
    // should only have the latest segments. 
    List<LogicalSegment> expected = Arrays.asList(new LogicalSegment() {

        @Override
        public Interval getInterval() {
            return new Interval("2013-01-01/P1D");
        }
    }, new LogicalSegment() {

        @Override
        public Interval getInterval() {
            return new Interval("2013-01-01T02/PT1H");
        }
    });
    for (int i = 0; i < segments.size(); i++) {
        Assert.assertEquals(expected.get(i).getInterval(), segments.get(i).getInterval());
    }
}
Also used : LogicalSegment(io.druid.timeline.LogicalSegment) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 5 with LogicalSegment

use of io.druid.timeline.LogicalSegment in project druid by druid-io.

the class TimeBoundaryQueryQueryToolChestTest method testFilterSegments.

@Test
public void testFilterSegments() throws Exception {
    List<LogicalSegment> segments = new TimeBoundaryQueryQueryToolChest().filterSegments(TIME_BOUNDARY_QUERY, Arrays.asList(createLogicalSegment(new Interval("2013-01-01/P1D")), createLogicalSegment(new Interval("2013-01-01T01/PT1H")), createLogicalSegment(new Interval("2013-01-01T02/PT1H")), createLogicalSegment(new Interval("2013-01-02/P1D")), createLogicalSegment(new Interval("2013-01-03T01/PT1H")), createLogicalSegment(new Interval("2013-01-03T02/PT1H")), createLogicalSegment(new Interval("2013-01-03/P1D"))));
    Assert.assertEquals(6, segments.size());
    List<LogicalSegment> expected = Arrays.asList(createLogicalSegment(new Interval("2013-01-01/P1D")), createLogicalSegment(new Interval("2013-01-01T01/PT1H")), createLogicalSegment(new Interval("2013-01-01T02/PT1H")), createLogicalSegment(new Interval("2013-01-03T01/PT1H")), createLogicalSegment(new Interval("2013-01-03T02/PT1H")), createLogicalSegment(new Interval("2013-01-03/P1D")));
    for (int i = 0; i < segments.size(); i++) {
        Assert.assertEquals(segments.get(i).getInterval(), expected.get(i).getInterval());
    }
}
Also used : LogicalSegment(io.druid.timeline.LogicalSegment) Interval(org.joda.time.Interval) Test(org.junit.Test)

Aggregations

LogicalSegment (io.druid.timeline.LogicalSegment)6 Interval (org.joda.time.Interval)6 Test (org.junit.Test)6 ListColumnIncluderator (io.druid.query.metadata.metadata.ListColumnIncluderator)1 SegmentMetadataQuery (io.druid.query.metadata.metadata.SegmentMetadataQuery)1