dcapwell commented on code in PR #3694:
URL: https://github.com/apache/cassandra/pull/3694#discussion_r1852722807


##########
src/java/org/apache/cassandra/cql3/statements/TransactionStatement.java:
##########
@@ -346,10 +340,7 @@ public Txn createTxn(ClientState state, QueryOptions 
options)
             List<TxnNamedRead> reads = createNamedReads(options, state, null, 
keySet::add);
             Keys txnKeys = toKeys(keySet);
             TxnKeyRead read = createTxnRead(reads, null);
-            Txn.Kind kind = txnKeys.size() == 1
-                    && transactionalModeForSingleKey(txnKeys) == 
TransactionalMode.full
-                    && 
DatabaseDescriptor.getAccordEphemeralReadEnabledEnabled()
-                    ? EphemeralRead : Read;
+            Txn.Kind kind = shouldReadEphemerally(txnKeys, 
Schema.instance.getTableMetadata(((AccordRoutableKey) 
txnKeys.get(0)).table()).params, Read);

Review Comment:
   API nit... rather than providing the table params maybe we should let this 
method fetch them?  when there are multiple reads or we are doing a write why 
load the table?



##########
src/java/org/apache/cassandra/service/accord/txn/TxnRangeRead.java:
##########
@@ -87,44 +88,50 @@ public class TxnRangeRead extends 
AbstractSerialized<ReadCommand> implements Txn
 {
     private static final Logger logger = 
LoggerFactory.getLogger(TxnRangeRead.class);
 
-    public static final TxnRangeRead EMPTY = new TxnRangeRead(null, null, 
null);
+    public static final TxnRangeRead EMPTY = new TxnRangeRead(null, null, 
(Ranges)null);
     private static final long EMPTY_SIZE = ObjectSizes.measure(EMPTY);
 
     @Nonnull
     private final ConsistencyLevel cassandraConsistencyLevel;
     @Nonnull
     private final Ranges covering;
 
-    public TxnRangeRead(@Nonnull PartitionRangeReadCommand command, @Nonnull 
ConsistencyLevel cassandraConsistencyLevel)
+    public TxnRangeRead(@Nonnull PartitionRangeReadCommand command, @Nonnull 
List<AbstractBounds<PartitionPosition>> ranges, @Nonnull ConsistencyLevel 
cassandraConsistencyLevel)
     {
         super(command);
         checkArgument(cassandraConsistencyLevel == null || 
SUPPORTED_READ_CONSISTENCY_LEVELS.contains(cassandraConsistencyLevel), 
"Unsupported consistency level for read");
         this.cassandraConsistencyLevel = cassandraConsistencyLevel;
         TableId tableId = command.metadata().id;
 
-        AbstractBounds<PartitionPosition> range = 
command.dataRange().keyRange();
-
-        // Read commands can contain a mix of different kinds of bounds to 
facilitate paging
-        // and we need to communicate that to Accord as its own ranges. We 
will use
-        // TokenKey and Sentinel key and stick exclusively with left 
exclusive/right inclusive
-        // ranges rather add more types of ranges to the mix
-        boolean inclusiveLeft = range.inclusiveLeft();
-        Token startToken = range.left.getToken();
-        AccordRoutingKey startAccordRoutingKey;
-        if (startToken.isMinimum() && inclusiveLeft)
-            startAccordRoutingKey = SentinelKey.min(tableId);
-        else
-            startAccordRoutingKey = new TokenKey(tableId, startToken);
-
-        boolean inclusiveRight = range.inclusiveRight();
-        Token stopToken = range.right.getToken();
-        AccordRoutingKey stopAccordRoutingKey;
-        if (inclusiveRight)
-            stopAccordRoutingKey = new TokenKey(tableId, stopToken);
-        else
-            stopAccordRoutingKey = new TokenKey(tableId, 
stopToken.decreaseSlightly());
-
-        covering = Ranges.of(new TokenRange(startAccordRoutingKey, 
stopAccordRoutingKey));
+        TokenRange[] accordRanges = new TokenRange[ranges.size()];
+        for (int i = 0; i < ranges.size(); i++)
+        {
+            AbstractBounds<PartitionPosition> range = ranges.get(i);
+            // Read commands can contain a mix of different kinds of bounds to 
facilitate paging
+            // and we need to communicate that to Accord as its own ranges. 
This uses
+            // TokenKey, SentinelKey, and MinTokenKey and sticks exclusively 
with left exclusive/right inclusive
+            // ranges rather add more types of ranges to the mix
+            // MinTokenKey allows emulating inclusive left and exclusive right 
with Range
+            boolean inclusiveLeft = range.inclusiveLeft();
+            Token startToken = range.left.getToken();
+            AccordRoutingKey startAccordRoutingKey;
+            if (startToken.isMinimum() && inclusiveLeft)

Review Comment:
   for me: is this correct?  I can't ever rememember if min token is allowed... 
we are not consistent... (`(min, min]` means something different for repair 
than normal storage.... thanks Abe for finding that... 😢 )



##########
src/java/org/apache/cassandra/service/accord/txn/TxnRangeRead.java:
##########
@@ -161,44 +174,54 @@ public AsyncChain<Data> read(Seekable range, 
SafeCommandStore commandStore, Time
         return AsyncChains.reduce(results, Data::merge);
     }
 
-    private AsyncChain<Data> performLocalRead(PartitionRangeReadCommand 
command, Range r, int nowInSeconds)
+    public PartitionRangeReadCommand commandForSubrange(Range r, long 
nowInSeconds)
+    {
+        return commandForSubrange((PartitionRangeReadCommand) get(), r, 
nowInSeconds);
+    }
+
+    public PartitionRangeReadCommand 
commandForSubrange(PartitionRangeReadCommand command, Range r, long 
nowInSeconds)
+    {
+        AbstractBounds<PartitionPosition> bounds = 
command.dataRange().keyRange();
+        PartitionPosition startPP = bounds.left;
+        PartitionPosition endPP = bounds.right;
+        TokenKey startTokenKey = new TokenKey(command.metadata().id, 
startPP.getToken());
+        Token subRangeStartToken = 
((AccordRoutingKey)r.start()).asTokenKey().token();
+        Token subRangeEndToken = 
((AccordRoutingKey)r.end()).asTokenKey().token();

Review Comment:
   is it possible this is a `SentinelKey`? 



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

Reply via email to