|
|
|
@ -60,6 +60,7 @@ import org.apache.druid.query.aggregation.FilteredAggregatorFactory;
|
|
|
|
|
import org.apache.druid.query.aggregation.FloatMaxAggregatorFactory;
|
|
|
|
|
import org.apache.druid.query.aggregation.FloatMinAggregatorFactory;
|
|
|
|
|
import org.apache.druid.query.aggregation.LongSumAggregatorFactory;
|
|
|
|
|
import org.apache.druid.query.aggregation.any.StringAnyAggregatorFactory;
|
|
|
|
|
import org.apache.druid.query.aggregation.cardinality.CardinalityAggregatorFactory;
|
|
|
|
|
import org.apache.druid.query.aggregation.firstlast.first.DoubleFirstAggregatorFactory;
|
|
|
|
|
import org.apache.druid.query.aggregation.firstlast.first.FloatFirstAggregatorFactory;
|
|
|
|
@ -6378,6 +6379,928 @@ public class TopNQueryRunnerTest extends InitializedNullHandlingTest
|
|
|
|
|
assertExpectedResults(expectedResults, query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testTopN_time_granularity_empty_buckets()
|
|
|
|
|
{
|
|
|
|
|
assumeTimeOrdered();
|
|
|
|
|
TopNQuery query = new TopNQueryBuilder()
|
|
|
|
|
.dataSource(QueryRunnerTestHelper.DATA_SOURCE)
|
|
|
|
|
.granularity(Granularities.HOUR)
|
|
|
|
|
.dimension(QueryRunnerTestHelper.MARKET_DIMENSION)
|
|
|
|
|
.metric(QueryRunnerTestHelper.INDEX_METRIC)
|
|
|
|
|
.threshold(10_000)
|
|
|
|
|
.intervals(QueryRunnerTestHelper.FIRST_TO_THIRD)
|
|
|
|
|
.aggregators(QueryRunnerTestHelper.INDEX_LONG_SUM)
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
List<Result<TopNResultValue>> expectedResults = Arrays.asList(
|
|
|
|
|
new Result<>(
|
|
|
|
|
DateTimes.of("2011-04-01T00:00:00.000Z"),
|
|
|
|
|
TopNResultValue.create(
|
|
|
|
|
Arrays.<Map<String, Object>>asList(
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "total_market",
|
|
|
|
|
"index", 2836L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "upfront",
|
|
|
|
|
"index", 2681L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "spot",
|
|
|
|
|
"index", 1102L
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T01:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T02:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T03:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T04:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T05:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T06:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T07:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T08:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T09:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T10:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T11:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T12:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T13:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T14:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T15:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T16:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T17:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T18:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T19:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T20:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T21:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T22:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T23:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(
|
|
|
|
|
DateTimes.of("2011-04-02T00:00:00.000Z"),
|
|
|
|
|
TopNResultValue.create(
|
|
|
|
|
Arrays.<Map<String, Object>>asList(
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "total_market",
|
|
|
|
|
"index", 2514L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "upfront",
|
|
|
|
|
"index", 2193L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "spot",
|
|
|
|
|
"index", 1120L
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T01:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T02:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T03:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T04:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T05:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T06:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T07:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T08:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T09:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T10:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T11:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T12:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T13:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T14:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T15:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T16:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T17:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T18:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T19:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T20:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T21:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T22:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T23:00:00.000Z"), TopNResultValue.create(Collections.emptyList()))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
assertExpectedResults(expectedResults, query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testTopN_time_granularity_empty_buckets_expression()
|
|
|
|
|
{
|
|
|
|
|
assumeTimeOrdered();
|
|
|
|
|
TopNQuery query = new TopNQueryBuilder()
|
|
|
|
|
.dataSource(QueryRunnerTestHelper.DATA_SOURCE)
|
|
|
|
|
.granularity(Granularities.HOUR)
|
|
|
|
|
.virtualColumns(
|
|
|
|
|
new ExpressionVirtualColumn(
|
|
|
|
|
"vc",
|
|
|
|
|
"market + ' ' + placement",
|
|
|
|
|
ColumnType.STRING,
|
|
|
|
|
TestExprMacroTable.INSTANCE
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
.dimension("vc")
|
|
|
|
|
.metric(QueryRunnerTestHelper.INDEX_METRIC)
|
|
|
|
|
.threshold(10_000)
|
|
|
|
|
.intervals(QueryRunnerTestHelper.FIRST_TO_THIRD)
|
|
|
|
|
.aggregators(QueryRunnerTestHelper.INDEX_LONG_SUM)
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
List<Result<TopNResultValue>> expectedResults = Arrays.asList(
|
|
|
|
|
new Result<>(
|
|
|
|
|
DateTimes.of("2011-04-01T00:00:00.000Z"),
|
|
|
|
|
TopNResultValue.create(
|
|
|
|
|
Arrays.<Map<String, Object>>asList(
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"vc", "total_market preferred",
|
|
|
|
|
"index", 2836L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"vc", "upfront preferred",
|
|
|
|
|
"index", 2681L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"vc", "spot preferred",
|
|
|
|
|
"index", 1102L
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T01:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T02:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T03:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T04:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T05:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T06:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T07:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T08:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T09:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T10:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T11:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T12:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T13:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T14:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T15:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T16:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T17:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T18:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T19:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T20:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T21:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T22:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T23:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(
|
|
|
|
|
DateTimes.of("2011-04-02T00:00:00.000Z"),
|
|
|
|
|
TopNResultValue.create(
|
|
|
|
|
Arrays.<Map<String, Object>>asList(
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"vc", "total_market preferred",
|
|
|
|
|
"index", 2514L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"vc", "upfront preferred",
|
|
|
|
|
"index", 2193L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"vc", "spot preferred",
|
|
|
|
|
"index", 1120L
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T01:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T02:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T03:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T04:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T05:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T06:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T07:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T08:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T09:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T10:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T11:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T12:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T13:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T14:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T15:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T16:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T17:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T18:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T19:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T20:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T21:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T22:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T23:00:00.000Z"), TopNResultValue.create(Collections.emptyList()))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
assertExpectedResults(expectedResults, query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testTopN_time_granularity_empty_buckets_2pool()
|
|
|
|
|
{
|
|
|
|
|
assumeTimeOrdered();
|
|
|
|
|
TopNQuery query = new TopNQueryBuilder()
|
|
|
|
|
.dataSource(QueryRunnerTestHelper.DATA_SOURCE)
|
|
|
|
|
.granularity(Granularities.HOUR)
|
|
|
|
|
.dimension(QueryRunnerTestHelper.MARKET_DIMENSION)
|
|
|
|
|
.metric(QueryRunnerTestHelper.INDEX_METRIC)
|
|
|
|
|
.threshold(10_000)
|
|
|
|
|
.intervals(QueryRunnerTestHelper.FIRST_TO_THIRD)
|
|
|
|
|
.aggregators(
|
|
|
|
|
QueryRunnerTestHelper.INDEX_LONG_SUM,
|
|
|
|
|
QueryRunnerTestHelper.INDEX_DOUBLE_MAX
|
|
|
|
|
)
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
List<Result<TopNResultValue>> expectedResults = Arrays.asList(
|
|
|
|
|
new Result<>(
|
|
|
|
|
DateTimes.of("2011-04-01T00:00:00.000Z"),
|
|
|
|
|
TopNResultValue.create(
|
|
|
|
|
Arrays.<Map<String, Object>>asList(
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "total_market",
|
|
|
|
|
"index", 2836L,
|
|
|
|
|
"doubleMaxIndex", 1522.043733
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "upfront",
|
|
|
|
|
"index", 2681L,
|
|
|
|
|
"doubleMaxIndex", 1447.34116
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "spot",
|
|
|
|
|
"index", 1102L,
|
|
|
|
|
"doubleMaxIndex", 158.747224
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T01:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T02:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T03:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T04:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T05:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T06:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T07:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T08:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T09:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T10:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T11:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T12:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T13:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T14:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T15:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T16:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T17:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T18:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T19:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T20:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T21:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T22:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T23:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(
|
|
|
|
|
DateTimes.of("2011-04-02T00:00:00.000Z"),
|
|
|
|
|
TopNResultValue.create(
|
|
|
|
|
Arrays.<Map<String, Object>>asList(
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "total_market",
|
|
|
|
|
"index", 2514L,
|
|
|
|
|
"doubleMaxIndex", 1321.375057
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "upfront",
|
|
|
|
|
"index", 2193L,
|
|
|
|
|
"doubleMaxIndex", 1144.342401
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "spot",
|
|
|
|
|
"index", 1120L,
|
|
|
|
|
"doubleMaxIndex", 166.016049
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T01:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T02:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T03:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T04:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T05:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T06:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T07:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T08:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T09:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T10:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T11:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T12:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T13:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T14:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T15:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T16:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T17:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T18:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T19:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T20:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T21:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T22:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T23:00:00.000Z"), TopNResultValue.create(Collections.emptyList()))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
assertExpectedResults(expectedResults, query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testTopN_time_granularity_empty_buckets_timeExtract()
|
|
|
|
|
{
|
|
|
|
|
// this is pretty wierd to have both query granularity and a time extractionFn... but it is not explicitly
|
|
|
|
|
// forbidden so might as well test it
|
|
|
|
|
assumeTimeOrdered();
|
|
|
|
|
TopNQuery query = new TopNQueryBuilder()
|
|
|
|
|
.dataSource(QueryRunnerTestHelper.DATA_SOURCE)
|
|
|
|
|
.granularity(Granularities.HOUR)
|
|
|
|
|
.dimension(
|
|
|
|
|
new ExtractionDimensionSpec(
|
|
|
|
|
ColumnHolder.TIME_COLUMN_NAME,
|
|
|
|
|
"dayOfWeek",
|
|
|
|
|
new TimeFormatExtractionFn("EEEE", null, null, null, false)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
.metric(QueryRunnerTestHelper.INDEX_METRIC)
|
|
|
|
|
.threshold(10_000)
|
|
|
|
|
.intervals(QueryRunnerTestHelper.FIRST_TO_THIRD)
|
|
|
|
|
.aggregators(
|
|
|
|
|
QueryRunnerTestHelper.INDEX_LONG_SUM
|
|
|
|
|
)
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
List<Result<TopNResultValue>> expectedResults = Arrays.asList(
|
|
|
|
|
new Result<>(
|
|
|
|
|
DateTimes.of("2011-04-01T00:00:00.000Z"),
|
|
|
|
|
TopNResultValue.create(
|
|
|
|
|
Collections.singletonList(
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"dayOfWeek", "Friday",
|
|
|
|
|
"index", 6619L
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T01:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T02:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T03:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T04:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T05:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T06:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T07:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T08:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T09:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T10:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T11:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T12:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T13:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T14:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T15:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T16:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T17:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T18:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T19:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T20:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T21:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T22:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T23:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(
|
|
|
|
|
DateTimes.of("2011-04-02T00:00:00.000Z"),
|
|
|
|
|
TopNResultValue.create(
|
|
|
|
|
Collections.singletonList(
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"dayOfWeek", "Saturday",
|
|
|
|
|
"index", 5827L
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T01:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T02:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T03:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T04:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T05:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T06:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T07:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T08:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T09:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T10:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T11:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T12:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T13:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T14:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T15:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T16:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T17:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T18:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T19:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T20:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T21:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T22:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T23:00:00.000Z"), TopNResultValue.create(Collections.emptyList()))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
assertExpectedResults(expectedResults, query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testTopN_time_granularity_empty_buckets_numeric()
|
|
|
|
|
{
|
|
|
|
|
assumeTimeOrdered();
|
|
|
|
|
TopNQuery query = new TopNQueryBuilder()
|
|
|
|
|
.dataSource(QueryRunnerTestHelper.DATA_SOURCE)
|
|
|
|
|
.granularity(Granularities.HOUR)
|
|
|
|
|
.dimension(new DefaultDimensionSpec("qualityLong", "qualityLong", ColumnType.LONG))
|
|
|
|
|
.metric(QueryRunnerTestHelper.INDEX_METRIC)
|
|
|
|
|
.threshold(10_000)
|
|
|
|
|
.intervals(QueryRunnerTestHelper.FIRST_TO_THIRD)
|
|
|
|
|
.aggregators(
|
|
|
|
|
QueryRunnerTestHelper.INDEX_LONG_SUM
|
|
|
|
|
)
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
List<Result<TopNResultValue>> expectedResults = Arrays.asList(
|
|
|
|
|
new Result<>(
|
|
|
|
|
DateTimes.of("2011-04-01T00:00:00.000Z"),
|
|
|
|
|
TopNResultValue.create(
|
|
|
|
|
Arrays.asList(
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"qualityLong", 1600L,
|
|
|
|
|
"index", 2900L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"qualityLong", 1400L,
|
|
|
|
|
"index", 2870L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"qualityLong", 1200L,
|
|
|
|
|
"index", 158L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"qualityLong", 1000L,
|
|
|
|
|
"index", 135L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"qualityLong", 1500L,
|
|
|
|
|
"index", 121L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"qualityLong", 1300L,
|
|
|
|
|
"index", 120L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"qualityLong", 1800L,
|
|
|
|
|
"index", 119L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"qualityLong", 1100L,
|
|
|
|
|
"index", 118L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"qualityLong", 1700L,
|
|
|
|
|
"index", 78L
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T01:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T02:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T03:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T04:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T05:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T06:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T07:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T08:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T09:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T10:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T11:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T12:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T13:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T14:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T15:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T16:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T17:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T18:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T19:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T20:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T21:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T22:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T23:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(
|
|
|
|
|
DateTimes.of("2011-04-02T00:00:00.000Z"),
|
|
|
|
|
TopNResultValue.create(
|
|
|
|
|
Arrays.asList(
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"qualityLong", 1600L,
|
|
|
|
|
"index", 2505L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"qualityLong", 1400L,
|
|
|
|
|
"index", 2447L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"qualityLong", 1200L,
|
|
|
|
|
"index", 166L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"qualityLong", 1000L,
|
|
|
|
|
"index", 147L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"qualityLong", 1800L,
|
|
|
|
|
"index", 126L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"qualityLong", 1500L,
|
|
|
|
|
"index", 114L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"qualityLong", 1300L,
|
|
|
|
|
"index", 113L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"qualityLong", 1100L,
|
|
|
|
|
"index", 112L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
"qualityLong", 1700L,
|
|
|
|
|
"index", 97L
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T01:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T02:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T03:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T04:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T05:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T06:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T07:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T08:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T09:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T10:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T11:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T12:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T13:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T14:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T15:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T16:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T17:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T18:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T19:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T20:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T21:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T22:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T23:00:00.000Z"), TopNResultValue.create(Collections.emptyList()))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
assertExpectedResults(expectedResults, query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testTopN_time_granularity_multipass_no_pool()
|
|
|
|
|
{
|
|
|
|
|
assumeTimeOrdered();
|
|
|
|
|
TopNQuery query = new TopNQueryBuilder()
|
|
|
|
|
.dataSource(QueryRunnerTestHelper.DATA_SOURCE)
|
|
|
|
|
.granularity(Granularities.HOUR)
|
|
|
|
|
.dimension(QueryRunnerTestHelper.MARKET_DIMENSION)
|
|
|
|
|
.metric(QueryRunnerTestHelper.INDEX_METRIC)
|
|
|
|
|
.threshold(10_000)
|
|
|
|
|
.intervals(QueryRunnerTestHelper.FIRST_TO_THIRD)
|
|
|
|
|
.aggregators(
|
|
|
|
|
QueryRunnerTestHelper.INDEX_LONG_SUM,
|
|
|
|
|
new StringAnyAggregatorFactory("big", QueryRunnerTestHelper.PLACEMENT_DIMENSION, 4000000, null)
|
|
|
|
|
)
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
List<Result<TopNResultValue>> expectedResults = Arrays.asList(
|
|
|
|
|
new Result<>(
|
|
|
|
|
DateTimes.of("2011-04-01T00:00:00.000Z"),
|
|
|
|
|
TopNResultValue.create(
|
|
|
|
|
Arrays.<Map<String, Object>>asList(
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "total_market",
|
|
|
|
|
"big", "preferred",
|
|
|
|
|
"index", 2836L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "upfront",
|
|
|
|
|
"big", "preferred",
|
|
|
|
|
"index", 2681L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "spot",
|
|
|
|
|
"big", "preferred",
|
|
|
|
|
"index", 1102L
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T01:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T02:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T03:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T04:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T05:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T06:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T07:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T08:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T09:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T10:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T11:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T12:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T13:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T14:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T15:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T16:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T17:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T18:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T19:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T20:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T21:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T22:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T23:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(
|
|
|
|
|
DateTimes.of("2011-04-02T00:00:00.000Z"),
|
|
|
|
|
TopNResultValue.create(
|
|
|
|
|
Arrays.<Map<String, Object>>asList(
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "total_market",
|
|
|
|
|
"big", "preferred",
|
|
|
|
|
"index", 2514L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "upfront",
|
|
|
|
|
"big", "preferred",
|
|
|
|
|
"index", 2193L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "spot",
|
|
|
|
|
"big", "preferred",
|
|
|
|
|
"index", 1120L
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T01:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T02:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T03:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T04:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T05:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T06:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T07:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T08:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T09:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T10:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T11:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T12:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T13:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T14:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T15:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T16:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T17:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T18:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T19:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T20:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T21:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T22:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T23:00:00.000Z"), TopNResultValue.create(Collections.emptyList()))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
assertExpectedResults(expectedResults, query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testTopN_time_granularity_multipass_with_pooled()
|
|
|
|
|
{
|
|
|
|
|
assumeTimeOrdered();
|
|
|
|
|
TopNQuery query = new TopNQueryBuilder()
|
|
|
|
|
.dataSource(QueryRunnerTestHelper.DATA_SOURCE)
|
|
|
|
|
.granularity(Granularities.HOUR)
|
|
|
|
|
.dimension(QueryRunnerTestHelper.MARKET_DIMENSION)
|
|
|
|
|
.metric(QueryRunnerTestHelper.INDEX_METRIC)
|
|
|
|
|
.threshold(10_000)
|
|
|
|
|
.intervals(QueryRunnerTestHelper.FIRST_TO_THIRD)
|
|
|
|
|
.context(ImmutableMap.of(QueryContexts.TOPN_USE_MULTI_PASS_POOLED_QUERY_GRANULARITY, true))
|
|
|
|
|
.aggregators(
|
|
|
|
|
QueryRunnerTestHelper.INDEX_LONG_SUM,
|
|
|
|
|
new StringAnyAggregatorFactory("big", QueryRunnerTestHelper.PLACEMENT_DIMENSION, 4000000, null)
|
|
|
|
|
)
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
List<Result<TopNResultValue>> expectedResults = Arrays.asList(
|
|
|
|
|
new Result<>(
|
|
|
|
|
DateTimes.of("2011-04-01T00:00:00.000Z"),
|
|
|
|
|
TopNResultValue.create(
|
|
|
|
|
Arrays.<Map<String, Object>>asList(
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "total_market",
|
|
|
|
|
"big", "preferred",
|
|
|
|
|
"index", 2836L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "upfront",
|
|
|
|
|
"big", "preferred",
|
|
|
|
|
"index", 2681L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "spot",
|
|
|
|
|
"big", "preferred",
|
|
|
|
|
"index", 1102L
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T01:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T02:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T03:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T04:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T05:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T06:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T07:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T08:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T09:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T10:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T11:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T12:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T13:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T14:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T15:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T16:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T17:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T18:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T19:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T20:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T21:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T22:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T23:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(
|
|
|
|
|
DateTimes.of("2011-04-02T00:00:00.000Z"),
|
|
|
|
|
TopNResultValue.create(
|
|
|
|
|
Arrays.<Map<String, Object>>asList(
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "total_market",
|
|
|
|
|
"big", "preferred",
|
|
|
|
|
"index", 2514L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "upfront",
|
|
|
|
|
"big", "preferred",
|
|
|
|
|
"index", 2193L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "spot",
|
|
|
|
|
"big", "preferred",
|
|
|
|
|
"index", 1120L
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T01:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T02:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T03:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T04:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T05:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T06:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T07:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T08:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T09:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T10:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T11:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T12:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T13:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T14:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T15:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T16:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T17:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T18:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T19:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T20:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T21:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T22:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T23:00:00.000Z"), TopNResultValue.create(Collections.emptyList()))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
assertExpectedResults(expectedResults, query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testTopN_time_granularity_uses_heap_if_too_big()
|
|
|
|
|
{
|
|
|
|
|
assumeTimeOrdered();
|
|
|
|
|
TopNQuery query = new TopNQueryBuilder()
|
|
|
|
|
.dataSource(QueryRunnerTestHelper.DATA_SOURCE)
|
|
|
|
|
.granularity(Granularities.HOUR)
|
|
|
|
|
.dimension(QueryRunnerTestHelper.MARKET_DIMENSION)
|
|
|
|
|
.metric(QueryRunnerTestHelper.INDEX_METRIC)
|
|
|
|
|
.threshold(10_000)
|
|
|
|
|
.intervals(QueryRunnerTestHelper.FIRST_TO_THIRD)
|
|
|
|
|
.aggregators(
|
|
|
|
|
QueryRunnerTestHelper.INDEX_LONG_SUM,
|
|
|
|
|
new StringAnyAggregatorFactory("big", QueryRunnerTestHelper.PLACEMENT_DIMENSION, 40000000, null)
|
|
|
|
|
)
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
List<Result<TopNResultValue>> expectedResults = Arrays.asList(
|
|
|
|
|
new Result<>(
|
|
|
|
|
DateTimes.of("2011-04-01T00:00:00.000Z"),
|
|
|
|
|
TopNResultValue.create(
|
|
|
|
|
Arrays.<Map<String, Object>>asList(
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "total_market",
|
|
|
|
|
"big", "preferred",
|
|
|
|
|
"index", 2836L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "upfront",
|
|
|
|
|
"big", "preferred",
|
|
|
|
|
"index", 2681L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "spot",
|
|
|
|
|
"big", "preferred",
|
|
|
|
|
"index", 1102L
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T01:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T02:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T03:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T04:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T05:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T06:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T07:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T08:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T09:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T10:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T11:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T12:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T13:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T14:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T15:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T16:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T17:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T18:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T19:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T20:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T21:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T22:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-01T23:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(
|
|
|
|
|
DateTimes.of("2011-04-02T00:00:00.000Z"),
|
|
|
|
|
TopNResultValue.create(
|
|
|
|
|
Arrays.<Map<String, Object>>asList(
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "total_market",
|
|
|
|
|
"big", "preferred",
|
|
|
|
|
"index", 2514L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "upfront",
|
|
|
|
|
"big", "preferred",
|
|
|
|
|
"index", 2193L
|
|
|
|
|
),
|
|
|
|
|
ImmutableMap.of(
|
|
|
|
|
QueryRunnerTestHelper.MARKET_DIMENSION, "spot",
|
|
|
|
|
"big", "preferred",
|
|
|
|
|
"index", 1120L
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T01:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T02:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T03:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T04:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T05:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T06:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T07:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T08:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T09:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T10:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T11:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T12:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T13:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T14:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T15:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T16:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T17:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T18:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T19:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T20:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T21:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T22:00:00.000Z"), TopNResultValue.create(Collections.emptyList())),
|
|
|
|
|
new Result<>(DateTimes.of("2011-04-02T23:00:00.000Z"), TopNResultValue.create(Collections.emptyList()))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
assertExpectedResults(expectedResults, query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void assumeTimeOrdered()
|
|
|
|
|
{
|
|
|
|
|
try (final CursorHolder cursorHolder =
|
|
|
|
|