dcapwell commented on code in PR #4257:
URL: https://github.com/apache/cassandra/pull/4257#discussion_r2211265971
##########
src/java/org/apache/cassandra/index/accord/RangeMemoryIndex.java:
##########
@@ -58,13 +63,51 @@ public class RangeMemoryIndex
{
@GuardedBy("this")
- private final Map<Group, RangeTree<byte[], Range, DecoratedKey>> map = new
HashMap<>();
- @GuardedBy("this")
- private final Map<Group, Metadata> groupMetadata = new HashMap<>();
+ private final Map<Key, Group> map = new HashMap<>();
- private static class Metadata
+ private static class Group
{
+ private RangeTree<byte[], Range, DecoratedKey> tree =
createRangeTree();
public byte[] minTerm, maxTerm;
+ public TxnId minTimestamp = TxnId.MAX;
+ public TxnId maxTimestamp = TxnId.NONE;
+
+ void add(Range range, DecoratedKey key, TxnId txnId, byte[] start,
byte[] end)
+ {
+ tree.add(range, key);
+ minTerm = minTerm == null ? start :
ByteArrayUtil.compareUnsigned(minTerm, 0, start, 0, minTerm.length) > 0 ? start
: minTerm;
+ maxTerm = maxTerm == null ? end :
ByteArrayUtil.compareUnsigned(maxTerm, 0, end, 0, maxTerm.length) < 0 ? end :
maxTerm;
+ if (minTimestamp.compareTo(txnId) > 0)
+ minTimestamp = txnId;
+ if (maxTimestamp.compareTo(txnId) < 0)
+ maxTimestamp = txnId;
+ }
+
+ void search(byte[] start, byte[] end,
+ Timestamp minTimestamp, Timestamp maxTimestamp,
+ Consumer<Map.Entry<RangeMemoryIndex.Range, DecoratedKey>>
fn)
+ {
+ if (this.minTimestamp.compareTo(maxTimestamp) > 0 ||
this.maxTimestamp.compareTo(minTimestamp) < 0)
+ return;
+ tree.search(new Range(start, end), e -> {
+ TxnId id =
AccordKeyspace.JournalColumns.getJournalKey(e.getValue()).id;
Review Comment:
Ok so think i can just remove this logic...
`org.apache.cassandra.service.accord.RangeSearcher.DefaultResult#consume(java.util.function.Consumer<accord.primitives.TxnId>)`
We filter at this layer so won't return the result to the caller without
applying the filter... but this means we have to deserialize the key to do the
filter, so this logic just does that twice!
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]