Is there any algorithm for bulk loading in B-Tree?

I know there is bulk loading in the b + tree. I just wanted to know if there is any algorithm for bulk loading in B-Tree. For example, a given dataset is the best way to create a B-Tree?

+7
source share
1 answer

Actually the answer is yes.

The main difference between B + -trees and equal B-trees is that the values ​​are actually stored in the sheets for the first, and later on you will find the values ​​in each node. Therefore, B + -trees allow you to store data in an almost continuous way, each sheet contains an adjacent slice of all sorted data. This may not be true for B-trees: the inner node will contain several elements, but they will not be adjacent to. The entire sorted dataset.

This property is important for bulk loading: this process runs on an already sorted dataset, cutting it into arrays that form B + -tree leaves. Thus, for a B-tree, it seems that it cannot work.

If we can sort the data in such a way as to group the internal elements of the nodes, then the problem is solved. To do this, you need to know in advance how the elements will be grouped. It is possible.

Call o (arrange) the minimum number of children in the node (which is consistent with the original definition of the order of the B-tree). We believe that the root of the node is at the highest stage of the tree, and the leaves are at the lowest level (stage 0). For a well-balanced tree, all the leaves will really be on the same level.

Stage k elements of groups of trees located at a distance of at least o elements at stage k-1. After the initial sort, we need to extract the elements from the sorted array, which is stage 0, and group them in another array to build stage 1, and then do it again with this array in a new array for stage 2 and repeat the process until there are fewer elements o in the newest array, which will be the root stage. From now on, you can build a tree directly from a set of scenes:

  • separates each stage in arrays of elements o ,
  • build index arrays for binding nodes to subnodes
  • create each node as a pair of corresponding arrays of index array values

The resulting tree will not necessarily be well balanced. It depends on the number of records in the dataset and o . It should be possible to customize the interval used in the construction of steps to have a more distributed tree.

In general, the work required for bulk loading of the B-tree is more tedious than for B + -tree, but it is possible.

+4
source

All Articles