Skip to content

Commit 2e3441e

Browse files
author
Matt Byrd
committed
remove use of java stream api and consequent allocations in mutateAtomically
avoid array copy when xoring MerkleTree hashes
1 parent 04f9119 commit 2e3441e

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/java/org/apache/cassandra/service/StorageProxy.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,8 +1441,11 @@ public static void mutateAtomically(List<Mutation> mutations,
14411441
boolean attributeNonAccordLatency = true;
14421442
long nonAccordEndTime = -1;
14431443

1444-
if (mutations.stream().anyMatch(mutation -> Keyspace.open(mutation.getKeyspaceName()).getReplicationStrategy().hasTransientReplicas()))
1445-
throw new AssertionError("Logged batches are unsupported with transient replication");
1444+
for (IMutation mutation : mutations)
1445+
{
1446+
if (Keyspace.open(mutation.getKeyspaceName()).getReplicationStrategy().hasTransientReplicas())
1447+
throw new AssertionError("Logged batches are unsupported with transient replication");
1448+
}
14461449

14471450
try
14481451
{

src/java/org/apache/cassandra/utils/MerkleTree.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,7 @@ static byte[] xor(byte[] left, byte[] right)
14821482
{
14831483
assert left.length == right.length;
14841484

1485-
byte[] out = Arrays.copyOf(right, right.length);
1485+
byte[] out = new byte[right.length];
14861486
for (int i = 0; i < left.length; i++)
14871487
out[i] = (byte)((left[i] & 0xFF) ^ (right[i] & 0xFF));
14881488
return out;

0 commit comments

Comments
 (0)