dcapwell commented on code in PR #2220:
URL: https://github.com/apache/cassandra/pull/2220#discussion_r1139010319
##########
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 way to lower memory in the case of no migration is to do 2 passes, first
to find if any need to migrate, and the second to migrate them. This would
lower the memory costs in the cases where `requiresRead` isn't found and only
adds extra cycles to the cases where it is found.... It was hard for me to say
which way to go as I don't really know how common both sides are, so not sure
which to bias towards... so I went with the less-work route and did a tiny
change to existing `migrateReadRequiredOperations` at the cost of extra memory.
--
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]