Skip to content

Commit a7a85c6

Browse files
committed
Calculate once and cache the result of ModificationStatement#requiresRead as a perf optimization
Patch by Dmitry Konstantinov; reviewed by Stefan Miklosovic for CASSANDRA-21040
1 parent 241f478 commit a7a85c6

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
5.1
2+
* Calculate once and cache the result of ModificationStatement#requiresRead as a perf optimization (CASSANDRA-21040)
23
* Update system schema tables with new distributed keyspace on upgrade (CASSANDRA-20872)
34
* Fix issue when running cms reconfiguration with paxos repair disabled (CASSANDRA-20869)
45
* Added additional parameter to JVM shutdown to allow for logs to be properly shutdown (CASSANDRA-20978)

src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ public abstract class ModificationStatement implements CQLStatement.SingleKeyspa
158158

159159
private final Operations operations;
160160

161+
private final boolean isReadRequired;
162+
161163
private final RegularAndStaticColumns updatedColumns;
162164

163165
protected final Conditions conditions;
@@ -262,6 +264,7 @@ else if (this.type.isDelete())
262264
this.conditionColumns = conditionColumnsBuilder.build();
263265
this.requiresRead = requiresReadBuilder.build();
264266
this.functions = findAllFunctions();
267+
this.isReadRequired = operations.requiresRead();
265268
}
266269

267270
@Override
@@ -536,7 +539,7 @@ public boolean requiresRead()
536539
// * Deleting list element by value
537540
// * Performing addition on a StringType (i.e. concatenation, only supported for CAS operations)
538541
// * Performing addition on a NumberType, again only supported for CAS operations.
539-
return operations.requiresRead();
542+
return isReadRequired;
540543
}
541544

542545
private Map<DecoratedKey, Partition> readRequiredLists(Collection<ByteBuffer> partitionKeys,

0 commit comments

Comments
 (0)