Allow change minTopNThreshold per topN query

This commit is contained in:
binlijin 2016-01-07 14:51:00 +08:00
parent 3048b1f0a5
commit a6bfcc5bfd
1 changed files with 5 additions and 4 deletions

View File

@ -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);
} }