From 8920afa75a9f9d12d98011fa77507fae74eb061b Mon Sep 17 00:00:00 2001 From: dan jatnieks Date: Thu, 10 Jun 2021 17:27:39 -0700 Subject: [PATCH] STAR-578 avoid copying EMPTY_STATIC_ROW to heap with offheap memtable(#523) (#188) patch by Zhao Yang; reviewed by Robert Stupp for DB-1375 Co-authored-by: Zhao Yang (cherry picked from commit d09bc6624a657b3e0a37ce7f4c1b5e6a0fc82c91) (cherry picked from commit 90d17f0473d67a3d58fb558e0a731a656472770b) (cherry picked from commit ec57374f696c94f921514ef90eb414a0463790c6) (cherry picked from commit 2203b385e72ed2776e122a35eec0ba9fb33c3450) (cherry picked from commit aa9d44dee0d9230214d3fe2515bf0188d8dbd5e0) --- src/java/org/apache/cassandra/utils/memory/EnsureOnHeap.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/cassandra/utils/memory/EnsureOnHeap.java b/src/java/org/apache/cassandra/utils/memory/EnsureOnHeap.java index d66c02c8e263..b37dfbcf37f7 100644 --- a/src/java/org/apache/cassandra/utils/memory/EnsureOnHeap.java +++ b/src/java/org/apache/cassandra/utils/memory/EnsureOnHeap.java @@ -57,8 +57,9 @@ public DecoratedKey applyToPartitionKey(DecoratedKey key) public Row applyToRow(Row row) { - if (row == null) - return null; + // If current "row" is Rows.EMPTY_STATIC_ROW, don't copy it again, as "copied_empty_static_row" != EMPTY_STATIC_ROW + if (row == null || row == Rows.EMPTY_STATIC_ROW) + return row; return row.clone(HeapCloner.instance); }