Search in sources :

Example 6 with TimeseriesQuery

use of org.apache.druid.query.timeseries.TimeseriesQuery in project druid by druid-io.

the class HiLoQueryLaningStrategyTest method testLaningNoPriority.

@Test
public void testLaningNoPriority() {
    TimeseriesQuery query = queryBuilder.build();
    Assert.assertFalse(strategy.computeLane(QueryPlus.wrap(query), ImmutableSet.of()).isPresent());
}
Also used : TimeseriesQuery(org.apache.druid.query.timeseries.TimeseriesQuery) Test(org.junit.Test)

Example 7 with TimeseriesQuery

use of org.apache.druid.query.timeseries.TimeseriesQuery in project druid by druid-io.

the class NoQueryLaningStrategyTest method testPreservesManualLaneFromContext.

@Test
public void testPreservesManualLaneFromContext() {
    final String someLane = "some-lane";
    TimeseriesQuery query = queryBuilder.context(ImmutableMap.of(QueryContexts.PRIORITY_KEY, 100, QueryContexts.LANE_KEY, someLane)).build();
    Assert.assertEquals(someLane, strategy.computeLane(QueryPlus.wrap(query), ImmutableSet.of()).get());
}
Also used : TimeseriesQuery(org.apache.druid.query.timeseries.TimeseriesQuery) Test(org.junit.Test)

Example 8 with TimeseriesQuery

use of org.apache.druid.query.timeseries.TimeseriesQuery in project druid by druid-io.

the class ThresholdBasedQueryPrioritizationStrategyTest method testPrioritizationSegmentCountWithinThreshold.

@Test
public void testPrioritizationSegmentCountWithinThreshold() {
    QueryPrioritizationStrategy strategy = new ThresholdBasedQueryPrioritizationStrategy(null, null, 2, adjustment);
    DateTime startDate = DateTimes.nowUtc().minusDays(1);
    DateTime endDate = DateTimes.nowUtc();
    TimeseriesQuery query = queryBuilder.intervals(ImmutableList.of(new Interval(startDate, endDate))).granularity(Granularities.MINUTE).context(ImmutableMap.of()).build();
    Assert.assertFalse(strategy.computePriority(QueryPlus.wrap(query), ImmutableSet.of(EasyMock.createMock(SegmentServerSelector.class))).isPresent());
}
Also used : QueryPrioritizationStrategy(org.apache.druid.server.QueryPrioritizationStrategy) TimeseriesQuery(org.apache.druid.query.timeseries.TimeseriesQuery) DateTime(org.joda.time.DateTime) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 9 with TimeseriesQuery

use of org.apache.druid.query.timeseries.TimeseriesQuery in project druid by druid-io.

the class ThresholdBasedQueryPrioritizationStrategyTest method testPrioritizationSegmentCountOverThreshold.

@Test
public void testPrioritizationSegmentCountOverThreshold() {
    QueryPrioritizationStrategy strategy = new ThresholdBasedQueryPrioritizationStrategy(null, null, 2, adjustment);
    DateTime startDate = DateTimes.nowUtc().minusDays(20);
    DateTime endDate = DateTimes.nowUtc();
    TimeseriesQuery query = queryBuilder.intervals(ImmutableList.of(new Interval(startDate, endDate))).granularity(Granularities.HOUR).context(ImmutableMap.of()).build();
    Assert.assertEquals(-adjustment, (int) strategy.computePriority(QueryPlus.wrap(query), ImmutableSet.of(EasyMock.createMock(SegmentServerSelector.class), EasyMock.createMock(SegmentServerSelector.class), EasyMock.createMock(SegmentServerSelector.class))).get());
}
Also used : QueryPrioritizationStrategy(org.apache.druid.server.QueryPrioritizationStrategy) TimeseriesQuery(org.apache.druid.query.timeseries.TimeseriesQuery) SegmentServerSelector(org.apache.druid.client.SegmentServerSelector) DateTime(org.joda.time.DateTime) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 10 with TimeseriesQuery

use of org.apache.druid.query.timeseries.TimeseriesQuery in project druid by druid-io.

the class ThresholdBasedQueryPrioritizationStrategyTest method testPrioritizationPeriodThresholdOutsidePeriod.

@Test
public void testPrioritizationPeriodThresholdOutsidePeriod() {
    QueryPrioritizationStrategy strategy = new ThresholdBasedQueryPrioritizationStrategy("P90D", null, null, adjustment);
    DateTime startDate = DateTimes.nowUtc().minusDays(100);
    DateTime endDate = DateTimes.nowUtc().minusDays(80);
    TimeseriesQuery query = queryBuilder.intervals(ImmutableList.of(new Interval(startDate, endDate))).granularity(Granularities.HOUR).context(ImmutableMap.of()).build();
    Assert.assertEquals(-adjustment, (int) strategy.computePriority(QueryPlus.wrap(query), ImmutableSet.of()).get());
}
Also used : QueryPrioritizationStrategy(org.apache.druid.server.QueryPrioritizationStrategy) TimeseriesQuery(org.apache.druid.query.timeseries.TimeseriesQuery) DateTime(org.joda.time.DateTime) Interval(org.joda.time.Interval) Test(org.junit.Test)

Aggregations

TimeseriesQuery (org.apache.druid.query.timeseries.TimeseriesQuery)130 Test (org.junit.Test)109 TimeseriesQueryQueryToolChest (org.apache.druid.query.timeseries.TimeseriesQueryQueryToolChest)58 CountAggregatorFactory (org.apache.druid.query.aggregation.CountAggregatorFactory)50 Result (org.apache.druid.query.Result)39 TimeseriesResultValue (org.apache.druid.query.timeseries.TimeseriesResultValue)35 LongSumAggregatorFactory (org.apache.druid.query.aggregation.LongSumAggregatorFactory)29 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)25 QueryRunner (org.apache.druid.query.QueryRunner)22 FinalizeResultsQueryRunner (org.apache.druid.query.FinalizeResultsQueryRunner)21 FieldAccessPostAggregator (org.apache.druid.query.aggregation.post.FieldAccessPostAggregator)17 Interval (org.joda.time.Interval)17 TimeseriesQueryEngine (org.apache.druid.query.timeseries.TimeseriesQueryEngine)15 TimeseriesQueryRunnerFactory (org.apache.druid.query.timeseries.TimeseriesQueryRunnerFactory)15 ArrayList (java.util.ArrayList)13 FinalizingFieldAccessPostAggregator (org.apache.druid.query.aggregation.post.FinalizingFieldAccessPostAggregator)13 DateTime (org.joda.time.DateTime)12 Sequence (org.apache.druid.java.util.common.guava.Sequence)11 IOException (java.io.IOException)10 SpatialDimFilter (org.apache.druid.query.filter.SpatialDimFilter)9