8000 上一级节点remove_from_index的疑问 · Issue #5 · enpeizhao/duck_db · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

上一级节点remove_from_index的疑问 #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
liyishui2003 opened this issue Feb 22, 2025 · 0 comments
Open

上一级节点remove_from_index的疑问 #5

liyishui2003 opened this issue Feb 22, 2025 · 0 comments

Comments

@liyishui2003
Copy link

作者您好!代码里写到:

if(where == end(parent) - 1){
                    // if leaf is last element then merge : | prev | leaf | -> | prev leaf |
                    assert(leaf.prev != 0);
                    leaf_node_t prev;
                    map(&prev,leaf.prev);

                    index_key = begin(prev)->key; //此处为什么是begin(prev)->key?

                    merge_leafs(&prev,&leaf);//数据结构层面合并
                    node_remove(&prev,&leaf);//物理层面合并(用到了map/unmap)
                    unmap(&prev,leaf.prev);//修改了prev,要回写
                }
                else {
                    assert(leaf.next!=0);
                    leaf_node_t next;
                    map(&next,leaf.next);
                    index_key = begin(leaf)->key; //此处为什么是begin(leaf)->key?
                    merge_leafs(&leaf,&next);
                    node_remove(&leaf,&next);
                    unmap(&leaf,offset);
                }

合并两个节点后,要删除原本分隔两个节点的键,而这个键应该是取右边节点的最小值或者其它合适的值?不太理解为什么反而取第一个节点最前面的键,还望指教。
谢谢

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

No branches or pull requests

1 participant
0