mirror of https://github.com/apache/druid.git
Allow change minTopNThreshold per topN query
This commit is contained in:
parent
3048b1f0a5
commit
a6bfcc5bfd
|
@ -470,7 +470,7 @@ public class TopNQueryQueryToolChest extends QueryToolChest<Result<TopNResultVal
|
||||||
{
|
{
|
||||||
final ThresholdAdjustingQueryRunner thresholdRunner = new ThresholdAdjustingQueryRunner(
|
final ThresholdAdjustingQueryRunner thresholdRunner = new ThresholdAdjustingQueryRunner(
|
||||||
runner,
|
runner,
|
||||||
config.getMinTopNThreshold()
|
config
|
||||||
);
|
);
|
||||||
return new QueryRunner<Result<TopNResultValue>>()
|
return new QueryRunner<Result<TopNResultValue>>()
|
||||||
{
|
{
|
||||||
|
@ -535,15 +535,15 @@ public class TopNQueryQueryToolChest extends QueryToolChest<Result<TopNResultVal
|
||||||
private static class ThresholdAdjustingQueryRunner implements QueryRunner<Result<TopNResultValue>>
|
private static class ThresholdAdjustingQueryRunner implements QueryRunner<Result<TopNResultValue>>
|
||||||
{
|
{
|
||||||
private final QueryRunner<Result<TopNResultValue>> runner;
|
private final QueryRunner<Result<TopNResultValue>> runner;
|
||||||
private final int minTopNThreshold;
|
private final TopNQueryConfig config;
|
||||||
|
|
||||||
public ThresholdAdjustingQueryRunner(
|
public ThresholdAdjustingQueryRunner(
|
||||||
QueryRunner<Result<TopNResultValue>> runner,
|
QueryRunner<Result<TopNResultValue>> runner,
|
||||||
int minTopNThreshold
|
TopNQueryConfig config
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.runner = runner;
|
this.runner = runner;
|
||||||
this.minTopNThreshold = minTopNThreshold;
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -557,6 +557,7 @@ public class TopNQueryQueryToolChest extends QueryToolChest<Result<TopNResultVal
|
||||||
}
|
}
|
||||||
|
|
||||||
final TopNQuery query = (TopNQuery) input;
|
final TopNQuery query = (TopNQuery) input;
|
||||||
|
final int minTopNThreshold = query.getContextValue("minTopNThreshold", config.getMinTopNThreshold());
|
||||||
if (query.getThreshold() > minTopNThreshold) {
|
if (query.getThreshold() > minTopNThreshold) {
|
||||||
return runner.run(query, responseContext);
|
return runner.run(query, responseContext);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue