blambov commented on code in PR #4245:
URL: https://github.com/apache/cassandra/pull/4245#discussion_r2212810541


##########
src/java/org/apache/cassandra/db/memtable/TrieMemtable.java:
##########
@@ -369,16 +370,36 @@ public FlushablePartitionSet<MemtablePartition> 
getFlushSet(PartitionPosition fr
         long partitionKeySize;
         long partitionCount;
 
-        if (allPositionsToFlush)
+        int fromShard = Integer.MIN_VALUE;

Review Comment:
   This should work.
   
   However, it could be a bit simpler, and perhaps more efficient, if we use 
`getShardForToken` for both boundaries. If from/to is a `maxKeyBound` and the 
returned shard's start boundary matches its token, then the span fully includes 
(resp. excludes) that shard.
   
   E.g. if `getShardForToken(from) == 2` and `getShardForToken(to) == 4`, and 
the tokens match, add the precollected counts/sizes for shards 2 and 3.
   If `getShardForToken(from) == 2` and `getShardForToken(to) == 4`, and 
neither token matches, walk shard 2 from `from` and shard 4 to `to` and add the 
precollected count and size for shard 3.



##########
src/java/org/apache/cassandra/db/memtable/TrieMemtable.java:
##########
@@ -369,16 +370,36 @@ public FlushablePartitionSet<MemtablePartition> 
getFlushSet(PartitionPosition fr
         long partitionKeySize;
         long partitionCount;
 
-        if (allPositionsToFlush)
+        int fromShard = Integer.MIN_VALUE;
+        int toShard = Integer.MIN_VALUE;
+        if (from == null || from.isMinimum())
+            fromShard = 0;
+
+        if  (to == null || to.isMaxKeyBound())
         {
-            partitionKeySize = this.partitionKeysTotalSize();
-            partitionCount = partitionCount();
+            toShard = boundaries.shardCount() - 1;
         }
-        else
+
+        for (int i = 0; i < boundaries.shardCount() - 1; i++)
         {
-            long keySize = 0;
-            int keyCount = 0;
+            Token shardRightBoundary = boundaries.getShardRightBoundary(i);
+            if (from != null && shardRightBoundary.equals(from.getToken()))

Review Comment:
   Because `from` and `to` are `PartitionPosition`, they could be different 
from this boundary even if this test returns true (e.g. they could be a 
specific `DecoratedKey` instead of a token, or they could be a token min 
bound). Because the boundaries are end-inclusive, we should be converting the 
right boundary via `Token.maxKeyBound` and comparing that against `from`/`to` 
rather than its token.



-- 
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

Reply via email to