Skip to content
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

请问value可以自定义类型吗? #25

Open
windflowerly opened this issue Mar 19, 2024 · 6 comments
Open

请问value可以自定义类型吗? #25

windflowerly opened this issue Mar 19, 2024 · 6 comments

Comments

@windflowerly
Copy link

请问value可以自定义类型吗?

@windflowerly
Copy link
Author

另外,key可以自定义类型吗?

@begeekmyfriend
Copy link
Owner

可以,不过你需要计算一下每个结点的空间大小

@windflowerly
Copy link
Author

我先看下代码,如有不懂的地方,还要叨扰。

@windflowerly
Copy link
Author

请问下,节点空间计算在哪里,没找到对应的代码。

@windflowerly
Copy link
Author

代码中的node是不是对应一个block。
然后计算一个block中,存放多少个key-value

@begeekmyfriend
Copy link
Owner

参见bplustree.h定义空间大小由BPLUS_MAX_ENTRIES以及BPLUS_MAX_ORDER决定,而节点内部寻址在bplustree.c里面定义。

#define data(node) ((long *)(offset_ptr(node) + _max_entries * sizeof(key_t)))
#define sub(node) ((off_t *)(offset_ptr(node) + (_max_order - 1) * sizeof(key_t)))

其中_max_entries_max_order都是由bplus_tree_init函数计算的

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

2 participants