Skip to content

Commit

Permalink
[FLINK-18332][state] Add error message to precondition in KeyGroupPar…
Browse files Browse the repository at this point in the history
…titionedPriorityQueue

This closes apache#12508.
  • Loading branch information
Tartarus0zm authored and carp84 committed Jun 17, 2020
1 parent 07772bd commit 204aa6d
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import java.util.HashSet;
import java.util.Set;

import static org.apache.flink.util.Preconditions.checkArgument;

/**
* This implementation of {@link InternalPriorityQueue} is internally partitioned into sub-queues per key-group and
* essentially works as a heap-of-heaps. Instances will have set semantics for elements if the sub-queues have set
Expand Down Expand Up @@ -181,7 +183,11 @@ private int computeKeyGroupIndex(T element) {
}

private int globalKeyGroupToLocalIndex(int keyGroupId) {
return keyGroupId - firstKeyGroup;
int keyGroupIndex = keyGroupId - firstKeyGroup;
checkArgument((keyGroupIndex >= 0 && keyGroupIndex < keyGroupedHeaps.length),
"key group from %s to %s does not contain %s", firstKeyGroup,
(firstKeyGroup + keyGroupedHeaps.length), keyGroupId);
return keyGroupIndex;
}

@Nonnull
Expand Down

0 comments on commit 204aa6d

Please sign in to comment.