ifesdjeen commented on code in PR #3976: URL: https://github.com/apache/cassandra/pull/3976#discussion_r1995776443
########## src/java/org/apache/cassandra/service/accord/CommandsForRanges.java: ########## @@ -102,22 +104,34 @@ private Loader newLoader(Unseekables<?> searchKeysOrRanges, RedundantBefore redu return new Loader(this, searchKeysOrRanges, redundantBefore, testKind, minTxnId, maxTxnId, findAsDep); } + private void updateTransitive(UnaryOperator<NavigableMap<TxnId, Ranges>> update) + { + transitive.updateAndGet(update); + } + public void mergeTransitive(TxnId txnId, Ranges ranges, BiFunction<? super Ranges, ? super Ranges, ? extends Ranges> remappingFunction) { - transitive.merge(txnId, ranges, remappingFunction); + updateTransitive(transitive -> { + NavigableMap<TxnId, Ranges> next = new TreeMap<>(transitive); + next.merge(txnId, ranges, remappingFunction); + return next; + }); } public void gcBefore(TxnId gcBefore, Ranges ranges) { - Iterator<Map.Entry<TxnId, Ranges>> iterator = transitive.headMap(gcBefore).entrySet().iterator(); - while (iterator.hasNext()) - { - Map.Entry<TxnId, Ranges> e = iterator.next(); - Ranges newRanges = e.getValue().without(ranges); - if (newRanges.isEmpty()) - iterator.remove(); - e.setValue(newRanges); - } + updateTransitive(transitive -> { + NavigableMap<TxnId, Ranges> next = new TreeMap<>(); Review Comment: pushed update/fix -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For additional commands, e-mail: pr-h...@cassandra.apache.org