maedhroz commented on code in PR #2220:
URL: https://github.com/apache/cassandra/pull/2220#discussion_r1139218981


##########
src/java/org/apache/cassandra/cql3/Operations.java:
##########
@@ -42,29 +44,46 @@ public final class Operations implements Iterable<Operation>
     /**
      * The operations on regular columns.
      */
-    private final List<Operation> regularOperations = new ArrayList<>();
+    private final List<Operation> regularOperations;
 
     /**
      * The operations on static columns.
      */
-    private final List<Operation> staticOperations = new ArrayList<>();
+    private final List<Operation> staticOperations;
 
-    private final List<ReferenceOperation> regularSubstitutions = new 
ArrayList<>();
-    private final List<ReferenceOperation> staticSubstitutions = new 
ArrayList<>();
+    private final List<ReferenceOperation> regularSubstitutions;
+    private final List<ReferenceOperation> staticSubstitutions;
 
     public Operations(StatementType type)
     {
         this.type = type;
+        regularOperations = new ArrayList<>();
+        staticOperations = new ArrayList<>();
+        regularSubstitutions = new ArrayList<>();
+        staticSubstitutions = new ArrayList<>();
+    }
+
+    private Operations(Operations other)
+    {
+        type = other.type;
+        regularOperations = new ArrayList<>(other.regularOperations);
+        staticOperations = new ArrayList<>(other.staticOperations);
+        regularSubstitutions = new ArrayList<>(other.regularSubstitutions);
+        staticSubstitutions = new ArrayList<>(other.staticSubstitutions);
     }
 
-    public void migrateReadRequiredOperations()
+    @Nullable
+    public Operations migrateReadRequiredOperations()
     {
-        migrateReadRequiredOperations(staticOperations, staticSubstitutions);
-        migrateReadRequiredOperations(regularOperations, regularSubstitutions);
+        Operations other = new Operations(this);

Review Comment:
   One more idea...
   
   We create `Operations` and add items to it in the 
`ModificationStatement.Parsed#prepareInternal()` implementations. Can we just 
add the `Operation` instances requiring reads to the correct list there and 
avoid later migrations altogether?
   
   ex. In `ParsedUpdate#prepareInternal()`, we have `isForTxn` telling us 
whether or not we're processing a transaction. We could add operations that 
need a read via `Operations#add(ColumnMetadata, ReferenceOperation)` there.



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