Don't allocate in ThreadLocalReadAheadBuffer#close()

Patch by Jordan West; reviewed by Benedict Elliot Smith for CASSANDRA-20551
This commit is contained in:
Jordan West 2025-04-13 12:26:55 -07:00
parent ec26d53d6c
commit 79c59347be
2 changed files with 12 additions and 8 deletions

View File

@ -1,4 +1,5 @@
5.0.5
* Don't allocate in ThreadLocalReadAheadBuffer#close() (CASSANDRA-20551)
* Ensure RowFilter#isMutableIntersection() properly evaluates numeric ranges on a single column (CASSANDRA-20566)
* Switch memtable-related off-heap objects to Native Endian and Memory to Little Endian (CASSANDRA-20190)
* SAI marks an index as non-empty when a partial partition/row modifications is flushed due to repair (CASSANDRA-20567)

View File

@ -131,18 +131,21 @@ public final class ThreadLocalReadAheadBuffer
public void clear(boolean deallocate)
{
Block block = getBlock();
// avoid calling block() here to reduce unintended allocations
Block block = blockMap.get().get(channel.filePath());
if (block == null)
return;
block.index = -1;
if (block.buffer == null)
return;
ByteBuffer blockBuffer = block.buffer;
if (blockBuffer != null)
blockBuffer.clear();
if (deallocate)
{
blockBuffer.clear();
if (deallocate)
{
FileUtils.clean(blockBuffer);
block.buffer = null;
}
FileUtils.clean(blockBuffer);
block.buffer = null;
}
}