netudima commented on code in PR #3761:
URL: https://github.com/apache/cassandra/pull/3761#discussion_r1901159994
##########
src/java/org/apache/cassandra/io/sstable/format/SortedTableWriter.java:
##########
@@ -270,22 +271,29 @@ protected void onStaticRow(Row row)
protected void onRow(Row row)
{
- notifyObservers(o -> o.nextUnfilteredCluster(row));
+ if (hasObservers())
+ notifyObservers(o -> o.nextUnfilteredCluster(row));
}
protected void onRangeTombstoneMarker(RangeTombstoneMarker marker)
{
- notifyObservers(o -> o.nextUnfilteredCluster(marker));
+ if (hasObservers())
+ notifyObservers(o -> o.nextUnfilteredCluster(marker));
}
protected abstract AbstractRowIndexEntry createRowIndexEntry(DecoratedKey
key, DeletionTime partitionLevelDeletion, long finishResult) throws IOException;
protected final void notifyObservers(Consumer<SSTableFlushObserver> action)
{
- if (observers != null && !observers.isEmpty())
+ if (hasObservers())
observers.forEach(action);
}
+ private boolean hasObservers()
Review Comment:
Yes, as I see currently the only non-test implementations for observers are
related to indexes, and indexes are a rare thing. In the methods we have
capturing lamdas (with an externally captured variable value) which are
allocated on each invocation, so I am trying to avoid them.
<img width="1294" alt="image"
src="https://github.com/user-attachments/assets/9e87750b-7b1f-410f-8051-7f6178df440c"
/>
--
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]