use of org.apache.druid.query.GenericQueryMetricsFactory in project druid by druid-io.
the class DataSourceMetadataQueryTest method testFilterSegments.
@Test
public void testFilterSegments() {
GenericQueryMetricsFactory queryMetricsFactory = DefaultGenericQueryMetricsFactory.instance();
DataSourceQueryQueryToolChest toolChest = new DataSourceQueryQueryToolChest(queryMetricsFactory);
List<LogicalSegment> segments = toolChest.filterSegments(null, Arrays.asList(new LogicalSegment() {
@Override
public Interval getInterval() {
return Intervals.of("2012-01-01/P1D");
}
@Override
public Interval getTrueInterval() {
return getInterval();
}
}, new LogicalSegment() {
@Override
public Interval getInterval() {
return Intervals.of("2012-01-01T01/PT1H");
}
@Override
public Interval getTrueInterval() {
return getInterval();
}
}, new LogicalSegment() {
@Override
public Interval getInterval() {
return Intervals.of("2013-01-01/P1D");
}
@Override
public Interval getTrueInterval() {
return getInterval();
}
}, new LogicalSegment() {
@Override
public Interval getInterval() {
return Intervals.of("2013-01-01T01/PT1H");
}
@Override
public Interval getTrueInterval() {
return getInterval();
}
}, new LogicalSegment() {
@Override
public Interval getInterval() {
return Intervals.of("2013-01-01T02/PT1H");
}
@Override
public Interval getTrueInterval() {
return getInterval();
}
}));
Assert.assertEquals(segments.size(), 2);
// should only have the latest segments.
List<LogicalSegment> expected = Arrays.asList(new LogicalSegment() {
@Override
public Interval getInterval() {
return Intervals.of("2013-01-01/P1D");
}
@Override
public Interval getTrueInterval() {
return getInterval();
}
}, new LogicalSegment() {
@Override
public Interval getInterval() {
return Intervals.of("2013-01-01T02/PT1H");
}
@Override
public Interval getTrueInterval() {
return getInterval();
}
});
for (int i = 0; i < segments.size(); i++) {
Assert.assertEquals(expected.get(i).getInterval(), segments.get(i).getInterval());
}
}
use of org.apache.druid.query.GenericQueryMetricsFactory in project druid by druid-io.
the class DataSourceMetadataQueryTest method testFilterOverlappingSegments.
@Test
public void testFilterOverlappingSegments() {
final GenericQueryMetricsFactory queryMetricsFactory = DefaultGenericQueryMetricsFactory.instance();
final DataSourceQueryQueryToolChest toolChest = new DataSourceQueryQueryToolChest(queryMetricsFactory);
final List<LogicalSegment> segments = toolChest.filterSegments(null, ImmutableList.of(new LogicalSegment() {
@Override
public Interval getInterval() {
return Intervals.of("2015/2016-08-01");
}
@Override
public Interval getTrueInterval() {
return Intervals.of("2015/2016-08-01");
}
}, new LogicalSegment() {
@Override
public Interval getInterval() {
return Intervals.of("2016-08-01/2017");
}
@Override
public Interval getTrueInterval() {
return Intervals.of("2016-08-01/2017");
}
}, new LogicalSegment() {
@Override
public Interval getInterval() {
return Intervals.of("2017/2017-08-01");
}
@Override
public Interval getTrueInterval() {
return Intervals.of("2017/2018");
}
}, new LogicalSegment() {
@Override
public Interval getInterval() {
return Intervals.of("2017-08-01/2017-08-02");
}
@Override
public Interval getTrueInterval() {
return Intervals.of("2017-08-01/2017-08-02");
}
}, new LogicalSegment() {
@Override
public Interval getInterval() {
return Intervals.of("2017-08-02/2018");
}
@Override
public Interval getTrueInterval() {
return Intervals.of("2017/2018");
}
}));
final List<LogicalSegment> expected = ImmutableList.of(new LogicalSegment() {
@Override
public Interval getInterval() {
return Intervals.of("2017/2017-08-01");
}
@Override
public Interval getTrueInterval() {
return Intervals.of("2017/2018");
}
}, new LogicalSegment() {
@Override
public Interval getInterval() {
return Intervals.of("2017-08-01/2017-08-02");
}
@Override
public Interval getTrueInterval() {
return Intervals.of("2017-08-01/2017-08-02");
}
}, new LogicalSegment() {
@Override
public Interval getInterval() {
return Intervals.of("2017-08-02/2018");
}
@Override
public Interval getTrueInterval() {
return Intervals.of("2017/2018");
}
});
Assert.assertEquals(expected.size(), segments.size());
for (int i = 0; i < expected.size(); i++) {
Assert.assertEquals(expected.get(i).getInterval(), segments.get(i).getInterval());
Assert.assertEquals(expected.get(i).getTrueInterval(), segments.get(i).getTrueInterval());
}
}
use of org.apache.druid.query.GenericQueryMetricsFactory in project druid by druid-io.
the class SqlModuleTest method makeInjectorWithProperties.
private Injector makeInjectorWithProperties(final Properties props) {
return Guice.createInjector(ImmutableList.of(new DruidGuiceExtensions(), new LifecycleModule(), new ServerModule(), new JacksonModule(), (Module) binder -> {
binder.bind(Validator.class).toInstance(Validation.buildDefaultValidatorFactory().getValidator());
binder.bind(JsonConfigurator.class).in(LazySingleton.class);
binder.bind(Properties.class).toInstance(props);
binder.bind(ExprMacroTable.class).toInstance(ExprMacroTable.nil());
binder.bind(AuthorizerMapper.class).toInstance(CalciteTests.TEST_AUTHORIZER_MAPPER);
binder.bind(Escalator.class).toInstance(new NoopEscalator());
binder.bind(ServiceEmitter.class).toInstance(serviceEmitter);
binder.bind(RequestLogger.class).toInstance(new NoopRequestLogger());
binder.bind(new TypeLiteral<Supplier<DefaultQueryConfig>>() {
}).toInstance(Suppliers.ofInstance(new DefaultQueryConfig(null)));
binder.bind(FilteredServerInventoryView.class).toInstance(inventoryView);
binder.bind(TimelineServerView.class).toInstance(timelineServerView);
binder.bind(DruidLeaderClient.class).annotatedWith(Coordinator.class).toInstance(druidLeaderClient);
binder.bind(DruidLeaderClient.class).annotatedWith(IndexingService.class).toInstance(druidLeaderClient);
binder.bind(DruidNodeDiscoveryProvider.class).toInstance(druidNodeDiscoveryProvider);
binder.bind(GenericQueryMetricsFactory.class).toInstance(genericQueryMetricsFactory);
binder.bind(QuerySegmentWalker.class).toInstance(querySegmentWalker);
binder.bind(QueryToolChestWarehouse.class).toInstance(queryToolChestWarehouse);
binder.bind(LookupExtractorFactoryContainerProvider.class).toInstance(lookupExtractorFactoryContainerProvider);
binder.bind(JoinableFactory.class).toInstance(joinableFactory);
binder.bind(SegmentLoader.class).toInstance(segmentLoader);
binder.bind(QuerySchedulerProvider.class).in(LazySingleton.class);
binder.bind(QueryScheduler.class).toProvider(QuerySchedulerProvider.class).in(LazySingleton.class);
}, new SqlModule(props), new TestViewManagerModule()));
}
Aggregations