Organizational structure of the B + tree

Source: Internet
Author: User

1,B + treeOverall Index Structure
① B + tree index is a multi-level index, but its structure is different from that of multi-level ordered index;
② B + tree indexes adopt a balanced tree structure, that is, the path length from each leaf node to the root is the same;
③ Each non-leaf node has n Children, and N is fixed to a specific tree;
④ All node structures of the B + tree are the same. It contains up to n-1 search code values K1, K2 ,... , Kn-1, and N pointers P1, P2 ,... , Pn, the search code values in each node are stored in order, that is, if I <j, Then Ki <KJ, as shown in Figure 8-3-1.

Figure 8-3-1: node structure of B + tree
2. Leaf nodes of B + tree indexes
① Pointer Pi (I = 1, 2 ,..., N-1) points to a file record or a pointer (storage) bucket with a search code value Ki. Each pointer in the bucket points to a file record with a search code value Ki. The pointer bucket is used only when files are physically stored without the order of search codes. The pointer Pn has a special effect;
② Each leaf node can have up to n-1 search code values and at least one search code value. The ranges of search codes in each leaf node do not match each other. To enableB + treeThe index becomes a dense index, and each search code value in the data file must appear in a leaf node and can only appear once;
③ Because each leaf node has a linear order based on the contained search code value, you can use the pointer Pn of each leaf node to link the leaf node in the search code order. This sort can efficiently process files sequentially, while other structures of the B + tree index can efficiently process files randomly, as shown in Figure 8-3-2.
Figure 8-3-2:B + treeIndex leaf node Structure example
3. Non-leaf nodes of B + tree indexes
① Non-leaf nodes of B + tree indexes form a multi-level (sparse) index on the leaf nodes;
② The structure of the non-leaf node is the same as that of the leaf node, that is, the data structure of the storage unit that can store n-1 search code values and N pointers. All pointers in non-leaf nodes point to the nodes in the tree;
③ If a non-leaf node has m pointers, ≤ m ≤ n. If M <n, all idle space after the pointer PM in the non-leaf node is used as the reserved space, the difference between a leaf node and a leaf node is that the position of the last pointer pm and Pn of the node is different from that of a leaf node, as shown in Figure 8-3-3;
Figure 8-3-3:B + treeNon-leaf node Structure of the Index
④ In a non-leaf node containing M pointers, the pointer Pi (I = 2 ,..., M-1 to a subtree, the search code for all nodes of the subtree is greater than or equal to the Ki-1 and less than the ki. Pointer PM points to the part where the search code value in the subtree is greater than or equal to the Km-1, and pointer P1 points to the part where the search code value in the subtree is less than K1, as shown in Figure 8-3-4.
Figure 8-3-4: Point of the pointer PI in the non-leaf node of the B + Tree Index
4. Root Node of B + Tree Index
① The root node structure is the same as that of the leaf node;
② The number of pointers contained in the root node can be smaller. However, unless the entire tree has only one node, the root node must contain at least two pointers. Figure 8-3-5 shows a B + tree structure.
Figure 8-3-5: B + Tree Index Structure of the account relationship

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.