Search in sources :

Example 11 with ListColumnIncluderator

use of io.druid.query.metadata.metadata.ListColumnIncluderator in project druid by druid-io.

the class SegmentMetadataUnionQueryTest method testSegmentMetadataUnionQuery.

@Test
public void testSegmentMetadataUnionQuery() {
    SegmentAnalysis expected = new SegmentAnalysis(QueryRunnerTestHelper.segmentId, Lists.newArrayList(new Interval("2011-01-12T00:00:00.000Z/2011-04-15T00:00:00.001Z")), ImmutableMap.of("placement", new ColumnAnalysis(ValueType.STRING.toString(), false, mmap ? 43524 : 43056, 1, "preferred", "preferred", null)), mmap ? 495876 : 498656, 4836, null, null, null, null);
    SegmentMetadataQuery query = new Druids.SegmentMetadataQueryBuilder().dataSource(QueryRunnerTestHelper.unionDataSource).intervals(QueryRunnerTestHelper.fullOnInterval).toInclude(new ListColumnIncluderator(Lists.newArrayList("placement"))).analysisTypes(SegmentMetadataQuery.AnalysisType.CARDINALITY, SegmentMetadataQuery.AnalysisType.SIZE, SegmentMetadataQuery.AnalysisType.INTERVAL, SegmentMetadataQuery.AnalysisType.MINMAX).build();
    List result = Sequences.toList(runner.run(query, Maps.newHashMap()), Lists.<SegmentAnalysis>newArrayList());
    TestHelper.assertExpectedObjects(ImmutableList.of(expected), result, "failed SegmentMetadata union query");
}
Also used : SegmentMetadataQuery(io.druid.query.metadata.metadata.SegmentMetadataQuery) ListColumnIncluderator(io.druid.query.metadata.metadata.ListColumnIncluderator) Druids(io.druid.query.Druids) ColumnAnalysis(io.druid.query.metadata.metadata.ColumnAnalysis) SegmentAnalysis(io.druid.query.metadata.metadata.SegmentAnalysis) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 12 with ListColumnIncluderator

use of io.druid.query.metadata.metadata.ListColumnIncluderator in project druid by druid-io.

the class DumpSegment method runMetadata.

private void runMetadata(final Injector injector, final QueryableIndex index) throws IOException {
    final ObjectMapper objectMapper = injector.getInstance(Key.get(ObjectMapper.class, Json.class)).copy().configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false);
    final SegmentMetadataQuery query = new SegmentMetadataQuery(new TableDataSource("dataSource"), new SpecificSegmentSpec(new SegmentDescriptor(index.getDataInterval(), "0", 0)), new ListColumnIncluderator(getColumnsToInclude(index)), false, null, EnumSet.allOf(SegmentMetadataQuery.AnalysisType.class), false, false);
    withOutputStream(new Function<OutputStream, Object>() {

        @Override
        public Object apply(final OutputStream out) {
            evaluateSequenceForSideEffects(Sequences.map(executeQuery(injector, index, query), new Function<SegmentAnalysis, Object>() {

                @Override
                public Object apply(SegmentAnalysis analysis) {
                    try {
                        objectMapper.writeValue(out, analysis);
                    } catch (IOException e) {
                        throw Throwables.propagate(e);
                    }
                    return null;
                }
            }));
            return null;
        }
    });
}
Also used : ListColumnIncluderator(io.druid.query.metadata.metadata.ListColumnIncluderator) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) Json(io.druid.guice.annotations.Json) IOException(java.io.IOException) TableDataSource(io.druid.query.TableDataSource) SpecificSegmentSpec(io.druid.query.spec.SpecificSegmentSpec) SegmentMetadataQuery(io.druid.query.metadata.metadata.SegmentMetadataQuery) SegmentDescriptor(io.druid.query.SegmentDescriptor) SegmentAnalysis(io.druid.query.metadata.metadata.SegmentAnalysis) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

ListColumnIncluderator (io.druid.query.metadata.metadata.ListColumnIncluderator)12 SegmentAnalysis (io.druid.query.metadata.metadata.SegmentAnalysis)10 Test (org.junit.Test)10 ColumnAnalysis (io.druid.query.metadata.metadata.ColumnAnalysis)9 FinalizeResultsQueryRunner (io.druid.query.FinalizeResultsQueryRunner)8 QueryRunner (io.druid.query.QueryRunner)8 QueryToolChest (io.druid.query.QueryToolChest)8 ExecutorService (java.util.concurrent.ExecutorService)8 SegmentMetadataQuery (io.druid.query.metadata.metadata.SegmentMetadataQuery)5 Interval (org.joda.time.Interval)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ImmutableList (com.google.common.collect.ImmutableList)1 TimestampSpec (io.druid.data.input.impl.TimestampSpec)1 Json (io.druid.guice.annotations.Json)1 Druids (io.druid.query.Druids)1 Query (io.druid.query.Query)1 SegmentDescriptor (io.druid.query.SegmentDescriptor)1 TableDataSource (io.druid.query.TableDataSource)1 AggregatorFactory (io.druid.query.aggregation.AggregatorFactory)1 SpecificSegmentSpec (io.druid.query.spec.SpecificSegmentSpec)1