belliottsmith commented on code in PR #4257: URL: https://github.com/apache/cassandra/pull/4257#discussion_r2221936344
########## src/java/org/apache/cassandra/service/accord/RouteInMemoryIndex.java: ########## @@ -151,46 +174,79 @@ private void add(TxnId id, Unseekable keyOrRange) tableIndex.computeIfAbsent(tableId, i -> new TableIndex()).add(id, ts); } - public void search(TableId tableId, byte[] start, byte[] end, Consumer<Map.Entry<IndexRange, TxnId>> fn) + public void search(TableId tableId, + byte[] start, byte[] end, + TxnId minTxnId, Timestamp maxTxnId, @Nullable TxnId minDecidedId, + Consumer<Map.Entry<IndexRange, TxnId>> fn) { TableIndex index = tableIndex.get(tableId); if (index == null) return; - index.search(start, end, fn); + index.search(start, end, minTxnId, maxTxnId, minDecidedId, fn); } - public void search(TableId tableId, byte[] key, Consumer<Map.Entry<IndexRange, TxnId>> fn) + public void search(TableId tableId, + byte[] key, + TxnId minTxnId, Timestamp maxTxnId, @Nullable TxnId minDecidedId, + Consumer<Map.Entry<IndexRange, TxnId>> fn) { TableIndex index = tableIndex.get(tableId); if (index == null) return; - index.search(key, fn); + index.search(key, minTxnId, maxTxnId, minDecidedId, fn); } } private static class TableIndex { private final RangeTree<byte[], IndexRange, TxnId> index = createRangeTree(); + private TxnId min = TxnId.MAX; + private TxnId max = TxnId.NONE; + private TxnId maxRX = TxnId.NONE; private TableIndex() { } - public void add(TxnId id, TokenRange ts) + private void add(TxnId id, TokenRange ts) { byte[] start = OrderedRouteSerializer.serializeTokenOnly(ts.start()); byte[] end = OrderedRouteSerializer.serializeTokenOnly(ts.end()); IndexRange range = new IndexRange(start, end); index.add(range, id); + if (min.compareTo(id) > 0) + min = id; + if (max.compareTo(id) < 0) + max = id; + if (id.is(Txn.Kind.ExclusiveSyncPoint) && id.compareTo(maxRX) > 0) + maxRX = id; Review Comment: We probably need to null this out if we witness a non-RX, so we know we cannot filter on it (until we have time to embellish the indexing behaviour) -- 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