Skip to content

Conversation

@netudima
Copy link
Contributor

Avoid BTree iterators allocation in ColumnsCollector.update
reduce amount of virtual calls for Cell.dataSize
avoid capturing lambda allocation in BTreeRow.clone
do not recalculate minLocalDeletionTime when BTreeRow is cloned

Patch by Dmitry Konstantinov; reviewed by TBD for CASSANDRA-21088

return result;
}

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method & transformLeaf is duplicating a lot of code. Do we have any metrics on performance improvements? otherwise the duplication could cause cause inconsistencies in code, maintenance issues and could create bugs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I've attached test results to the ticket. Unfortunately the method reference trick which I mentioned in another comment does not work for logic in org.apache.cassandra.db.rows.BTreeRow#clone.
BTree functionality is stable and does not change frequently to introduce too much maintenance cost here. Also, the same pattern has been already used previously in this class for transformAndFilter logic.

Copy link
Contributor

@jyothsnakonisa jyothsnakonisa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good to me. However It would be nice if you can get it reviewed by someone who is more familiar with this code path.

* If no modifications are made, the original is returned.
* NOTE: codewise *identical* to {@link #transform(Object[], Function)}
*/
public static <I, I2, O> Object[] transform(Object[] tree, BiFunction<? super I, ? super I2, ? extends O> function, I2 param)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does Cloner parameter need to be a generic ?

Suggested change
public static <I, I2, O> Object[] transform(Object[] tree, BiFunction<? super I, ? super I2, ? extends O> function, I2 param)
public static <I, O> Object[] transform(Object[] tree, BiFunction<? super I, Cloner, ? extends O> function, Cloner cloner)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to keep the original generic style, reasons:

  1. (coupling) BTree is a generic utility logic, it is better to not create an unnecessary coupling to specific logic related to memory allocation
  2. (generality/abstraction) the method logic is generic and does not depend on the argument type (it is correct for any type), it can be used in other use cases later if needed
  3. (consistency) the same style with generics is ready used in BTree, for example: transformAndFilter uses exactly the same style.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wfm

Avoid BTree iterators allocation in ColumnsCollector.update
reduce amout of virtual calls for Cell.dataSize
avoid capturing lambda allocation in BTreeRow.clone
do not recalculate minLocalDeletionTime when BTreeRow is cloned
avoid CAS write if EncodingStats is not changed after merge

Patch by Dmitry Konstantinov; reviewed by Jyothsna Konisa, Michael Semb Wever for CASSANDRA-21088
@netudima netudima force-pushed the CASSANDRA-21088-trunk branch from 9b24d7d to 2ca9d8f Compare January 10, 2026 10:00
@netudima netudima closed this Jan 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants