Skip to content

Commit

Permalink
add minimum top contributor candidate queue size (#151)
Browse files Browse the repository at this point in the history
Signed-off-by: lai <57818076+wnbts@users.noreply.github.com>
  • Loading branch information
wnbts authored Feb 24, 2022
1 parent fe30dd7 commit 7fab72c
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public class AnomalyLocalizerImpl implements AnomalyLocalizer, Executable {
// Partitions the whole data to up to this number of buckets by time.
protected static final int MAX_TIME_BUCKETS = 8;

// The minimum number of contributor candidates.
protected static final int MIN_CONTRIBUTOR_CANDIDATE = 100;

private final Client client;
private final Settings settings;

Expand Down Expand Up @@ -187,11 +190,12 @@ private void onBaseEntryResponse(SearchResponse response, AnomalyLocalizationInp
result.getBuckets().stream().filter(e -> e.getCompleted() != null && e.getCompleted().get() == false)
.forEach(e -> {
PriorityQueue<AnomalyLocalizationOutput.Entity> queue;
int queueSize = Math.max(input.getNumOutputs(), MIN_CONTRIBUTOR_CANDIDATE);
if (e.getOverallAggValue() > 0) {
queue = new PriorityQueue<AnomalyLocalizationOutput.Entity>(input.getNumOutputs(),
queue = new PriorityQueue<AnomalyLocalizationOutput.Entity>(queueSize,
(a, b) -> (int) Math.signum(a.getContributionValue() - b.getContributionValue()));
} else {
queue = new PriorityQueue<AnomalyLocalizationOutput.Entity>(input.getNumOutputs(),
queue = new PriorityQueue<AnomalyLocalizationOutput.Entity>(queueSize,
(a, b) -> (int) Math.signum(b.getContributionValue() - a.getContributionValue()));
}
;
Expand Down

0 comments on commit 7fab72c

Please sign in to comment.