[ 
https://issues.apache.org/jira/browse/CASSANDRA-9989?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16591169#comment-16591169
 ] 

Jay Zhuang commented on CASSANDRA-9989:
---------------------------------------

Sorry, I missed {{point 1.}} (I thought it's something else), but you already 
get it:
{noformat}
     int childrenNum = (size + childSize + 1) / (childSize +1)
==>  int childrenNum = size / (childSize + 1) + (childSize + 1) / (childSize + 
1)
==>  int childrenNum = size / (childSize + 1) + 1
{noformat}
We can make it more clear with: {{(size / (childSize + 1)) + 1}}.

 
{quote}I think it might be nicer in this case to make the TREE_SIZE logically 
more obvious, so that its accessors (which are rather more complicated) are 
simplified, rather than its calculation? I don't think this is very tricky 
anyway - just set TREE_SIZE[0] = FAN_FACTOR, and leave the loop as it is, I 
think?
{quote}
It's also used here: 
[{{TREE_SIZE[level-2]}}|https://github.com/cooldoger/cassandra/commit/8369dc8b7be3ccf8d1972e9c8cff95adb3493005#diff-4b911b7d0959c6219175e2349968f3cdR196].
 Which needs to be changed to: {{int grandchildSize = level == 1 ? 0 : 
TREE_SIZE[level - 2];}}. I prefer avoiding this check while building every node 
(will add a comment that leaf node is level 1). But I'm fine with either way.

 
{quote}I think this is also more easily done by an incrementing counter, rather 
than decrementing?
{quote}
Sure, I'll update the patch for that.

> Optimise BTree.Buider
> ---------------------
>
>                 Key: CASSANDRA-9989
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-9989
>             Project: Cassandra
>          Issue Type: Sub-task
>            Reporter: Benedict
>            Assignee: Jay Zhuang
>            Priority: Minor
>             Fix For: 4.x
>
>         Attachments: 9989-trunk.txt
>
>
> BTree.Builder could reduce its copying, and exploit toArray more efficiently, 
> with some work. It's not very important right now because we don't make as 
> much use of its bulk-add methods as we otherwise might, however over time 
> this work will become more useful.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to