Skip to content

Commit

Permalink
[FLINK-8561] [cep] Fix SharedBuffer.removeEdges to use .equals().
Browse files Browse the repository at this point in the history
This closes apache#5414.
  • Loading branch information
kl0u committed Feb 5, 2018
1 parent 47638d0 commit 3d323ba
Showing 1 changed file with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public boolean isEmpty() {
* @return {@code true} if pruning happened
*/
public boolean prune(long pruningTimestamp) {
final List<SharedBufferEntry<K, V>> prunedEntries = new ArrayList<>();
final Set<SharedBufferEntry<K, V>> prunedEntries = new HashSet<>();

final Iterator<Map.Entry<K, SharedBufferPage<K, V>>> it = pages.entrySet().iterator();
while (it.hasNext()) {
Expand Down Expand Up @@ -428,7 +428,7 @@ public SharedBufferEntry<K, V> get(final ValueTimeWrapper<V> valueTime) {
* @param pruningTimestamp Timestamp for the pruning
* @param prunedEntries a {@link Set} to put the removed {@link SharedBufferEntry SharedBufferEntries}.
*/
private void prune(final long pruningTimestamp, final List<SharedBufferEntry<K, V>> prunedEntries) {
private void prune(final long pruningTimestamp, final Set<SharedBufferEntry<K, V>> prunedEntries) {
Iterator<Map.Entry<ValueTimeWrapper<V>, SharedBufferEntry<K, V>>> it = entries.entrySet().iterator();
while (it.hasNext()) {
SharedBufferEntry<K, V> entry = it.next().getValue();
Expand All @@ -442,7 +442,7 @@ private void prune(final long pruningTimestamp, final List<SharedBufferEntry<K,
/**
* Remove edges with the specified targets for the entries.
*/
private void removeEdges(final List<SharedBufferEntry<K, V>> prunedEntries) {
private void removeEdges(final Set<SharedBufferEntry<K, V>> prunedEntries) {
for (SharedBufferEntry<K, V> entry : entries.values()) {
entry.removeEdges(prunedEntries);
}
Expand Down Expand Up @@ -542,15 +542,12 @@ public void addEdge(SharedBufferEdge<K, V> edge) {
/**
* Remove edges with the specified targets.
*/
private void removeEdges(final List<SharedBufferEntry<K, V>> prunedEntries) {
Iterator<SharedBufferEdge<K, V>> itor = edges.iterator();
while (itor.hasNext()) {
SharedBufferEdge<K, V> edge = itor.next();
for (SharedBufferEntry<K, V> prunedEntry : prunedEntries) {
if (prunedEntry == edge.getTarget()) {
itor.remove();
break;
}
private void removeEdges(final Set<SharedBufferEntry<K, V>> prunedEntries) {
Iterator<SharedBufferEdge<K, V>> it = edges.iterator();
while (it.hasNext()) {
SharedBufferEdge<K, V> edge = it.next();
if (prunedEntries.contains(edge.getTarget())) {
it.remove();
}
}
}
Expand Down

0 comments on commit 3d323ba

Please sign in to comment.