Nothing can be done at work. Many places are speculation or inaccurate.
1) bdb compilation is performed under the build_windows and build_unix directories. VC directly converts the DSW of vc6 to vc9. Remember to set the compilation option to debug x86.
2) in the past two days, the research mainly involves the B-tree part. The code starting with Bt is the B-tree operation part, including put, open, delete, search, and split parts, where split is the page.
I don't think there are too many bdb documents, especially those with diagrams in Chinese. You can refer to the btree of SQLite. Everyone is doing almost the same thing. After knowing the principles, carefully analyze the code.
Just say a function:
/*
* _ Bam_split --
* Split a page.
*
* Public: int _ bam_split _ p (DBC *, void *, db_pgno_t *));
*/
Int
_ Bam_split (DBC, ARG, root_pgnop)
DBC * dBc;
Void * ARG;
Db_pgno_t * root_pgnop;
{
For (DIR = up, level = leaflevel; Dir = up? ++ Level: -- level ){
/*
* Acquire a page and its parent, locked.
*/
If (ret = (DBC-> dbtype = db_btree?
_ Bam_search (DBC, pgno_invalid,
Arg, sr_wrpair, level, null, & exact ):
_ Bam_rsearch (DBC,
(Db_recno_t *) Arg, sr_wrpair, level, & exact )))! = 0)
Break;
...
Bdb comments are very good. You can see the comments in many places. Below is the translation
When the space of the leaf node is full, the split will be triggered. A new leaf node will be returned.
In this case, you need to search for the leaf node based on the key to be inserted. In this case, you need to lock the leaf node and its parent page.
Then we can split this leaf page. Then we need to check the new Internal Key (the Internal Key is an internal Node ?) Suitable for parent page.
If it is not suitable, discard the current lock and re-do it. This lock is the parent and parent of the leaf page. This will continue iteration until the split is successful.
The general meaning is actually the process of B-tree split. After work, I will understand it carefully tomorrow.