Tree-structured database management method and system, and storage medium

By employing a radial tree structure and appending files and mapping tables in the database system, the problems of low query efficiency and resource consumption in traditional database systems when processing large amounts of categorized data are solved, achieving efficient data management and query optimization.

WO2026011682A1PCT designated stage Publication Date: 2026-01-15HANGZHOU HIGH-TECH ZONE (BINJIANG) INSTITUTE OF BLOCKCHAIN & DATA SECURITY
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/138218
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-07-12
Filing Date
2024-12-10
Publication Date
2026-01-15

AI Technical Summary

Technical Problem

Traditional database systems suffer from low query efficiency and high management resource consumption when processing large amounts of data of different categories. This is especially true when the number of data categories reaches millions or even hundreds of millions, where sharding technology leads to increased computational resource consumption and difficulties in data structure optimization.

Method used

A radial tree structure is adopted to aggregate data through the trunk tree and radial subtrees. By creating append files and mapping tables, the index information of key-value pair data is separated, thus optimizing the data storage and query process.

Benefits of technology

It improved query efficiency, reduced management resource consumption, simplified database management, reduced the number of data structures, and improved system response speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024138218_15012026_PF_FP_ABST
    Figure CN2024138218_15012026_PF_FP_ABST
Patent Text Reader

Abstract

A tree-structured database management method and system, and a storage medium. The database management method is applied to a tree-structured database system, wherein the database system comprises a hub tree, the hub tree comprises a plurality of branch trees, and each branch tree comprises a plurality of spoke trees. The database management method comprises: on the basis of key-value pair data pre-stored in leaf nodes, creating append files and generating index information of the key-value pair data, wherein the index information comprises index information of the append files and index information of spoke trees pointed to by the leaf node pointers; updating mapping tables of the append files on the basis of the index information of the append files; and on the basis of the index information of the key-value pair data and the mapping tables, reading and / or maintaining the key-value pair data corresponding to the leaf nodes. In the method, a large volume of data of different categories are aggregated into a hub tree by means of different spoke trees, thereby reducing the number of data structures; during data search, corresponding data is retrieved on the basis of index information and mapping tables, thereby improving query efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Tree-structure-based database management methods, systems, and storage media

[0001] This application claims priority to Chinese Patent Application No. 202410931910.5, filed on July 12, 2024, entitled "Database Management Method, System and Storage Medium Based on Tree Structure", the entire contents of which are incorporated herein by reference. Technical Field

[0002] This application relates to the field of database management technology, specifically to a database management method, system, and storage medium based on a tree structure. Background Technology

[0003] A database is a computer software system that stores and manages data according to a data structure. Databases store large amounts of data, including different types of data. In traditional database systems, data is usually stored using a B+ tree schema. When processing multiple types of data, each type of data is managed using a separate B+ tree. However, when the number of data types increases dramatically, such as reaching millions or even hundreds of millions of data categories, using a separate B+ tree for each type of data leads to low query efficiency and consumes excessive management resources. Technical issues

[0004] One of the objectives of this application is to provide a database management method, system, and storage medium based on a tree structure. Technical solutions

[0005] The technical solution adopted in the embodiments of this application is:

[0006] Firstly, a tree-structured database management method is provided. This method is applied to a tree-structured database system, which includes a trunk tree, multiple branch trees, and multiple radial subtrees. The root node of each branch tree is a branch node, and the other nodes are leaf nodes. The database management method includes:

[0007] Based on the key-value pair data pre-stored in each of the leaf nodes, an append file is created and index information of the key-value pair data is generated. The index information includes the index information of the append file and the index information of the radial subtree pointed to by the leaf node pointer.

[0008] Update the mapping table of the appended file according to the index information of the appended file;

[0009] Based on the index information of the key-value pair data and the mapping relationship of the mapping table, read and / or maintain the key-value pair data corresponding to each leaf node.

[0010] Secondly, a tree-structured database management system is provided, including:

[0011] An append file creation module is used to create an append file and generate index information of the key-value pair data based on the key-value pair data pre-stored in each of the leaf nodes. The index information includes the index information of the append file and the index information of the radial subtree pointed to by the leaf node pointer.

[0012] The mapping table update module is used to update the mapping table of the appended file according to the index information of the appended file;

[0013] The data retrieval and maintenance module is used to read and / or maintain the key-value pair data corresponding to each leaf node based on the index information of the key-value pair data and the mapping relationship of the mapping table.

[0014] Thirdly, a terminal device is provided, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method described above.

[0015] Fourthly, a computer-readable storage medium is provided, the computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described above.

[0016] Fifthly, a radial tree structure is provided to aggregate a large amount of data of different categories into a trunk tree through different radial subtrees, thereby reducing the number of data structures, simplifying database management, and improving query efficiency and reducing management resource consumption by creating append files for reading and / or maintenance based on index information and mapping tables. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or exemplary technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 is a schematic diagram of a tree-structured database system provided in an embodiment of this application;

[0019] Figure 2 is a schematic diagram of a tree-structure-based database management method provided in an embodiment of this application;

[0020] Figure 3 is a schematic diagram of the leaf nodes in the radial subtree provided in the embodiment of this application;

[0021] Figure 4 is a schematic diagram of radial subtree data compression provided in an embodiment of this application;

[0022] Figure 5 is a schematic diagram of process S300 in Figure 1 provided in an embodiment of this application;

[0023] Figure 6a is a schematic diagram of the process of appending and deleting key-value pairs in a file according to an embodiment of this application;

[0024] Figure 6b is a schematic diagram of the process of updating the mapping table provided in an embodiment of this application;

[0025] Figure 7 is a schematic diagram of a high-frequency node and low-frequency node recombination process provided in an embodiment of this application;

[0026] Figure 8 is a schematic diagram of a tree-structured database management system provided in an embodiment of this application.

[0027] Figure 9 is a schematic diagram of the structure of the terminal device provided in the embodiment of this application. Embodiments of the present invention

[0028] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the scope of this application.

[0029] It should be noted that the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or collections thereof. It should also be understood that the term "and / or" as used in this specification and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes such combinations. The term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrases "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]." The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features. "A plurality" means two or more, unless otherwise expressly defined.

[0030] A database is a computer software system that stores and manages data according to a data structure. Databases store large amounts of data, including different types of data. In traditional database systems, data is usually stored using a B+ tree schema. When processing multiple types of data, each type of data is managed using a separate B+ tree. However, when the number of data types increases dramatically, such as reaching millions or even hundreds of millions of data categories, using a separate B+ tree for each type of data leads to low query efficiency and consumes excessive management resources.

[0031] Existing database systems typically employ sharding, a common database architecture optimization method that distributes data categories across multiple databases or tables to reduce the load on a single database. Each shard can be viewed as an independent B+ tree instance, processing a subset of the data. By distributing data, system scalability and performance are improved. While maintaining and managing a small number of shards is relatively easy, managing millions or even hundreds of millions of data categories requires creating massive shards, leading to increased computational resource consumption and a greater workload for optimizing and adjusting data structures. Furthermore, each tree requires independent management and index space, and a large number of trees can result in wasted storage and memory resources. As the number of data categories and sharded trees increases, querying and maintaining these trees (such as insertion, deletion, and update operations) becomes increasingly slow, especially under high concurrency, significantly increasing system response time.

[0032] This application provides a radial tree structure that aggregates a large amount of data of different categories into a trunk tree through different radial subtrees, thereby reducing the number of data structures, simplifying database management, and improving query efficiency and reducing management resource consumption by creating append files for reading and / or maintenance based on index information and mapping tables.

[0033] To illustrate the technical solutions provided in this application, the following detailed description is provided in conjunction with specific drawings and embodiments.

[0034] Figure 1 is a schematic diagram of a tree-structured database system provided in an embodiment of this application. The tree-structured database system includes a trunk tree, which includes multiple branch trees. In this embodiment, two branch trees are taken as an example. Each branch tree includes multiple radial subtrees. The root node of each branch tree is a branch node, and the other nodes are leaf nodes.

[0035] This application proposes a radial tree structure (Hub-Spoke Tree, Hub: hub, Spoke: hub outwards). This tree is based on a trunk tree (Hub tree) and generates radial subtrees (Spoke trees) outwards through leaf nodes. The radial tree structure can dynamically process different types of data into multiple buckets, and at the same time, through real-time data analysis, the tree structure can be dynamically adjusted according to the access frequency and relevance of the data.

[0036] As shown in Figure 1, a tree-structured database system includes a trunk tree, which comprises two branches: a high-frequency branch tree and a low-frequency branch tree. Both the high-frequency and low-frequency branch trees are multi-way trees. The high-frequency branches are smaller, with data sizes in the hundreds or thousands, while the low-frequency branches are larger, ranging from tens of thousands to hundreds of millions. It's important to note that when accessing data, the system prioritizes searching for the target data in the high-frequency branches. If the data is not found there, it then searches in the low-frequency branches, improving efficiency in finding the target data. The tree structure highlighted by the dashed box is called a radial subtree. A radial tree structure can be broadly divided into a trunk tree and multiple radial subtrees. The structure of each radial subtree (Spoke Tree) is consistent with the structure of the trunk tree (Hub Tree).

[0037] The root node pointer of the trunk tree points to the high-frequency branch node of the high-frequency branch tree and the low-frequency branch node of the low-frequency branch tree (Branch node) (represented by solid circles in Figure 1). All other nodes are leaf nodes (represented by hollow circles in Figure 1). The branch nodes store the path information of the data, guiding the search operation (such as search, insertion, and deletion) on how to navigate to the correct lower-level node in the tree. The leaf nodes store the target data information. A leaf node stores a limited amount of data information in a sorted manner. This data information includes ordinary key-value pair data (KV data), index information, compressed bytecode of the radial subtree, and pointer information to the next radial subtree.

[0038] Figure 2 is a schematic diagram of a tree-structure-based database management method provided in an embodiment of this application. The database management method is applied to a tree-structure database system. As shown in Figure 2, the database management method includes:

[0039] Step 100: Based on the key-value pair data pre-stored in each of the leaf nodes, create an append file and generate index information for the key-value pair data. The index information includes the index information of the append file and the index information of the radial subtree pointed to by the leaf node pointer.

[0040] Step 200: Update the mapping table of the appended file according to the index information of the appended file.

[0041] Step 300: Read and / or maintain the key-value pair data corresponding to each leaf node according to the index information of the key-value pair data and the mapping relationship of the mapping table.

[0042] In this embodiment, a radial tree-structured database is used to store key-value pair data. Key-value pair data, also known as KV data, refers to the mapping of mathematical concepts in a programming language. The key is used as an index for an element, and the value represents the stored and retrieved data. In the tree structure of this application, any leaf node can store ordinary key-value pair data. When the value data is small, it is directly stored in the leaf node along with the key. However, when the value data is too large, storing it in the leaf node will reduce the number of data items that a leaf node can store, resulting in a taller tree and affecting read / write performance. Furthermore, when retrieving data from a leaf node, reading the data character by character due to its length will consume a significant amount of query time, reducing data retrieval efficiency.

[0043] Therefore, for key-value pairs with excessively large values, this application employs a key-value separation approach in its radial tree-structured database. Key-value separation involves writing the value data of each key-value pair to an append file and generating an index and mapping table for the value data. The append file and the mapping table have a one-to-one correspondence. The actual value data is stored in the append file, while only the index information is stored in the leaf nodes. When data is searched, the value data can be retrieved again based on the index information in the mapping table. When the value data is no longer needed, it is marked as "IsDeleted" in the mapping table, awaiting subsequent compaction operations.

[0044] Specifically, step 100 involves creating an append file and generating index information for the key-value pair data based on the key-value pair data pre-stored in each of the leaf nodes. The key-value pair data includes a key and a value, and the index information is the index information of the append file, including:

[0045] A1: If the storage space required for the key-value pair data is greater than a preset threshold, then an append file is created and the index information of the append file is generated based on the key-value pair data stored in each leaf node.

[0046] A2: Store the values ​​of the key-value pairs in the append file, and store the index information of the append file in the leaf node.

[0047] A3: If the storage space required for the value of the key-value pair is less than or equal to the preset threshold, then the key-value pair is directly stored in the leaf node.

[0048] In this embodiment of the application, as shown in Figure 3, the leaf node may include four types of data: key-value pair data (KV data), append file index information, radial subtree compressed bytecode, and radial subtree index information. In steps A1-A3, the append file index information in the index information is introduced first. If the value data of the key-value pair is small, that is, the storage space required for the value of the key-value pair is less than or equal to a preset threshold, the value data is directly stored in the leaf node. If the value data of the key-value pair is large, that is, the storage space required for the value of the key-value pair is greater than the preset threshold, an append file is created and the index information of the append file is generated.

[0049] Specifically, the step of creating the append file and generating the index information of the append file includes:

[0050] A11: Create an append file and generate append file information, which includes the append file name and append index number, where the append index number is the number of times the append file has been written.

[0051] A12: Generate the index information of the appended file based on the appended file name and the appended index number;

[0052] A13: Store the index information of the appended file and the key of the key-value pair data in the leaf node.

[0053] In this embodiment, an append file is created and append file information is generated. This append file information includes the append file name, append index number, and append position information. The append file name is the name of the append file, and the append index number is the number of times data is written to the append file. Based on the append file name and the append index number, index information for the append file is generated; that is, the index information for the Value data is [append file name + append index number]. The index information of the append file and the key of the key-value pair data are stored in leaf nodes so that the key-value pair data in the corresponding append file can be queried based on the index information of the append file and the mapping relationship in the mapping table.

[0054] By using a key-value separation method, an append file is created, and index information is generated based on the information in the append file. The actual key-value pair data values ​​are stored in the append file, while the leaf nodes in the radial tree structure only store the index information of the key-value pair data. When searching for data, it is only necessary to retrieve the data from the corresponding leaf node based on the index information and the mapping table, without having to traverse the data stored in each leaf node character by character. This improves query efficiency and reduces resource consumption.

[0055] In this embodiment of the application, the index information stored in the leaf nodes also includes radial subtree index information. Specifically, step 100 involves creating an append file and generating index information for the key-value pair data based on the key-value pair data pre-stored in each leaf node. The index information is the index information of the radial subtree pointed to by the leaf node pointer. The method further includes:

[0056] B1: Determine the radial subtree pointed to by the leaf node pointer. The trunk tree includes multiple levels of leaf nodes. The number of lower-level leaf nodes pointed to by the branch node pointer is the degree of the branch tree. The amount of key-value pairs stored in the lower-level leaf node pointed to by the pointer is a multiple of the degree of the amount of key-value pairs stored in the upper-level leaf node.

[0057] In this embodiment, the radial tree structure shown in Figure 1 consists of three leaf nodes forming radial subtrees. Multiple radial subtrees converge into the trunk tree for data storage. Since the number of radial subtrees in low-frequency branch trees is in the billions, the low-frequency leaf nodes contain billions of data points, requiring several gigabytes to tens of gigabytes of storage space. Directly using memory for caching is impractical. To further improve data access speed, this embodiment adopts a memory-based strategy, keeping branch nodes resident in memory. As shown in Figure 1, the trunk tree includes multiple levels of leaf nodes. The subtrees outlined by dashed lines are radial subtrees. A branch node branches into k leaf nodes, and the degree of the branch tree is k. The amount of data stored in the leaf node pointed to by the pointer at the next level is k times the amount of data stored in the node at the previous level. The amount of data stored at each level is magnified by a factor of k. If the total data space required by the bottom-level leaf nodes is 20 gigabytes, then the total data space required by the previous level only needs to occupy (20 / K) gigabytes. Specifically, the data volume in the leaf nodes of each level of the radial tree structure database has the following relationship:

[0058]

[0059]

[0060]

[0061] Calculations show that the data size of the last layer is approximately (k-1) times the total data size of all preceding layers. For example, if K=101, the data size of the leaf nodes in the last layer is 20GB, and the total data size of all branch nodes is 20 / (101-1) = 200MB. Compared to leaf nodes, branch nodes have smaller data sizes. Therefore, in this embodiment, different values ​​of K can be set to keep all branch nodes resident in memory, thus accelerating the access capability of the entire tree.

[0062] B2: If the storage space of key-value pairs in the radial subtree is greater than the preset storage space threshold, then the key-value pairs in the radial subtree are used to generate the index information of the radial subtree, and the index information of the radial subtree is stored in the leaf node.

[0063] B3: If the storage space of key-value pair data in the radial subtree is less than or equal to the preset storage space threshold, then the key-value pair data in the radial subtree is compressed into compressed bytecode and directly stored in the leaf node.

[0064] As shown in Figure 4, which illustrates the data compression of the radial subtree, in this embodiment, if the data of the radial subtree is small, all the data in the radial subtree is compressed to generate radial subtree compressed bytecode, which is then directly stored in the leaf node. If the data of the radial subtree is large, the radial subtree index information is generated based on the radial subtree, and the radial subtree index information is stored in the leaf node. The radial subtree index information is also pointer information, pointing to the correct lower-level node.

[0065] It is important to note that in this embodiment, the index information for appending files and the radial subtree index information are essentially used to prevent the data from being stored directly in the leaf nodes when the key-value pairs and radial subtree data are too large, thus avoiding inefficient queries and wasted query resources. Conversely, storing complete key-value pairs and compressed bytecode directly is done because the key-value pairs and radial subtree data are relatively small and can be stored directly in the leaf nodes. Therefore, if the leaf node contains complete key-value pairs, there is no index information for appending files; similarly, if the leaf node contains compressed bytecode from the radial subtree, there is no index information for the radial subtree.

[0066] Step 200, updating the mapping table of the appended file according to the index information of the appended file, wherein the appended file information includes append position information and the append index number, including:

[0067] S201: Generate the mapping relationship of the appended file based on the appended location information and the appended index number.

[0068] S202: Write the mapping relationship of the appended file into the mapping table to update the mapping table.

[0069] In this embodiment of the application, step 100 creates an append file and generates append file information, which includes append position information. Based on the append position information and the append index number, a mapping relationship for the append file is generated. The append index number + append position is the mapping relationship. The mapping relationship is written into a mapping table, where the information in the mapping table includes the append index number, the append position, and the data status of whether the data has been deleted.

[0070] As shown in Figure 5, a radial subtree is presented, in which key-value pairs are stored in append files, and the index information of the append files is stored in the leaf nodes. A mapping relationship is generated based on the append index number and append position information and written into the mapping table. The mapping table and the append files have a one-to-one correspondence. Therefore, the target data in the append files can be found by using the mapping relationship in the mapping table.

[0071] Step 300: Read and / or maintain the key-value pair data corresponding to each leaf node according to the index information of the key-value pair data and the mapping relationship of the mapping table.

[0072] In this embodiment of the application, according to step 100, the index information of the append file generated by the append file and the index information of the radial subtree are created. In step 200, the mapping table is obtained through the above index information, and the key-value pair data corresponding to each leaf node is retrieved according to the mapping relationship. As shown in Figure 5, the corresponding node is first queried according to the append index number 4, and then the data stored in the append file 2123 is queried according to the append position information 2123.

[0073] In this embodiment of the application, in addition to the process of writing key-value pair data into the radial subtree, there is also a process of deleting the key-value pair data from the radial subtree. The value of the key-value pair data is deleted from the corresponding append file to release the storage space of the append file. The database management method further includes: deleting the value of the key-value pair data to be deleted from the append file, rewriting the values ​​of other key-value pair data into the append file, and updating the mapping table corresponding to the rewritten append file.

[0074] In this embodiment, when the Value data in the append file is no longer used, the radial subtree needs to release the corresponding Value data in the append file. Since a complete computer file cannot have its local space reclaimed by the file system until the entire file is completely released, this application uses a method of rewriting the append file. The data that needs to be deleted is deleted, and the data that needs to be retained is rewritten into the append file. Because the append file and the mapping table have a one-to-one correspondence, the mapping table should be updated accordingly once the append file is modified.

[0075] As shown in Figure 6a, when the Value data in file location 420-1184 is no longer wanted, this storage space cannot be directly returned to the computer file system. Instead, a rewrite method is used to compress and simplify the append file. By rewriting the append file, unwanted file segments are deleted, and the necessary file segments 0-235, 235-420, and 420-1359 are rewritten into the append file, as shown in Figure 6b. Based on the rewritten append file, the position of each Value data in the mapping table is readjusted. By updating the mapping table, it is ensured that the Value data can be found according to the new position information during the query.

[0076] Figure 7 is a schematic diagram of a high-frequency node and low-frequency node reorganization process provided in an embodiment of this application. As shown in Figure 7, the branch tree includes a high-frequency tree and a low-frequency tree. The leaf nodes in the high-frequency tree are high-frequency access nodes, and the leaf nodes in the low-frequency tree are low-frequency access nodes. The high-frequency access nodes are leaf nodes whose access frequency exceeds a preset frequency, and the low-frequency access nodes are leaf nodes whose access frequency is lower than the preset frequency. The database management method further includes:

[0077] By monitoring data access patterns, all leaf nodes in the branch tree are identified. If a high-frequency access node is identified in the low-frequency tree, the high-frequency access node is reassembled into the high-frequency tree. If a low-frequency access node is identified in the high-frequency tree, the low-frequency access node is reassembled into the high-frequency tree.

[0078] As shown in Figure 7, in this embodiment, the access frequency of each node in the high-frequency branch tree and the low-frequency branch tree is different. The radial subtrees in the high-frequency branch tree are smaller, with data sizes in the hundreds or thousands. Accessing data requires accessing shallower node levels and takes less time. Conversely, the radial subtrees in the low-frequency branch tree are tens of thousands or even hundreds of millions in size. Accessing data requires accessing shallower node levels and takes longer. Therefore, by monitoring the data access mode of the system, leaf nodes in the low-frequency tree are prioritized for identification. If a leaf node in the low-frequency tree is found to have an access frequency exceeding a preset frequency threshold, it indicates that the node is a high-frequency leaf node. The high-frequency access node located deep within the low-frequency branch tree should be reorganized and moved to a shallower level in the high-frequency branch tree. By monitoring and identifying the access frequency of each leaf node and adjusting the reorganized leaf node levels, unnecessary access time is avoided, which helps improve the efficiency of the system in querying data.

[0079] Referring to Figure 8, a schematic diagram of a tree-structured database management system provided in an embodiment of this application is shown. For ease of explanation, only the parts related to the embodiment of this application are shown.

[0080] The tree-structured database management system 400 may specifically include the following modules:

[0081] The append file creation module 410 is used to create an append file and generate index information of the key-value pair data based on the key-value pair data pre-stored in each of the leaf nodes. The index information includes the index information of the append file and the index information of the radial subtree pointed to by the leaf node pointer.

[0082] The mapping table update module 420 is used to update the mapping table of the appended file according to the index information of the appended file;

[0083] The data retrieval and maintenance module 430 is used to read and / or maintain the key-value pair data corresponding to each leaf node based on the index information of the key-value pair data and the mapping relationship of the mapping table.

[0084] The append file creation module 410 mainly includes an append file index information generation unit 411 and a radial subtree index information generation unit 412.

[0085] The index information generation unit 411 for appending files is used for:

[0086] If the storage space required for the key-value pair data is greater than the preset threshold, then an append file is created and the index information of the append file is generated based on the key-value pair data stored in each leaf node.

[0087] The values ​​of the key-value pairs are stored in an append file, and the index information of the append file is stored in the leaf node;

[0088] If the storage space required for the key-value pair data is less than or equal to the preset threshold, then the key-value pair data is directly stored in the leaf node.

[0089] The appended file index information generation unit 411 is specifically used for:

[0090] Create an append file and generate append file information, the append file information including the append file name and append index number, the append index number being the number of times the append file has been written;

[0091] Generate the index information of the appended file based on the appended file name and the appended index number;

[0092] The index information of the appended file and the key of the key-value pair data are stored in the leaf node.

[0093] The index information generation unit 412 for the radial subtree is specifically used for:

[0094] The radial subtree pointed to by the leaf node pointer is determined. The trunk tree includes multiple levels of leaf nodes. The number of lower-level leaf nodes pointed to by the branch node pointer is the degree of the branch tree. The amount of key-value pairs stored in the lower-level leaf node pointed to by the pointer is a multiple of the degree of the amount of key-value pairs stored in the upper-level leaf node.

[0095] If the storage space of key-value pair data in the radial subtree is greater than the preset storage space threshold, then the key-value pair data in the radial subtree will be used to generate the index information of the radial subtree, and the index information of the radial subtree will be stored in the leaf node.

[0096] If the storage space for key-value pairs in the radial subtree is less than or equal to the preset storage space threshold, then the key-value pairs in the radial subtree are compressed into compressed bytecode and directly stored in the leaf node.

[0097] The mapping table update module 420 is used for:

[0098] Based on the append location information and the append index number, a mapping relationship for the appended file is generated;

[0099] The mapping relationship of the appended files is written into the mapping table to update the mapping table.

[0100] The database management system also includes a compression and simplification module, used for:

[0101] The values ​​of the key-value pairs that need to be deleted are removed from the append file, the values ​​of other key-value pairs are rewritten into the append file, and the mapping table corresponding to the rewritten append file is updated.

[0102] The database management system also includes a node reorganization module, used for:

[0103] By monitoring data access patterns, all leaf nodes in the branch tree are identified. If a high-frequency access node is identified in the low-frequency tree, the high-frequency access node is reassembled into the high-frequency tree. If a low-frequency access node is identified in the high-frequency tree, the low-frequency access node is reassembled into the high-frequency tree.

[0104] The tree-structure-based database management system provided in this application can be applied to the foregoing method embodiments. For details, please refer to the description of the above method embodiments, which will not be repeated here.

[0105] Figure 9 is a schematic diagram of the structure of a terminal device provided in an embodiment of this application. As shown in Figure 9, the terminal device 700 of this embodiment includes: at least one processor 710 (only one is shown in Figure 9), a memory 720, and a computer program 721 stored in the memory 720 and executable on the at least one processor 710. When the processor 710 executes the computer program 721, it implements the steps in the above method embodiment.

[0106] The terminal device 700 can be a desktop computer, laptop, handheld computer, cloud server, or other computing device. This terminal device may include, but is not limited to, a processor 710 and a memory 720. Those skilled in the art will understand that Figure 9 is merely an example of the terminal device 700 and does not constitute a limitation on the terminal device 700. It may include more or fewer components than illustrated, or combine certain components, or different components, such as input / output devices, network access devices, etc.

[0107] The processor 710 may be a Central Processing Unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.

[0108] In some embodiments, the memory 720 may be an internal storage unit of the terminal device 700, such as a hard disk or memory of the terminal device 700. In other embodiments, the memory 720 may be an external storage device of the terminal device 700, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the terminal device 700. Furthermore, the memory 720 may include both internal and external storage units of the terminal device 700. The memory 720 is used to store the operating system, applications, boot loader, data, and other programs, such as the program code of the computer program. The memory 720 can also be used to temporarily store data that has been output or will be output.

[0109] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0110] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0111] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0112] In the embodiments provided in this application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling or direct coupling or communication connection may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0113] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0114] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0115] If the integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.

[0116] The implementation of all or part of the processes in the methods of the above embodiments can also be accomplished by a computer program product. When the computer program product is run on a terminal device, the terminal device can implement the steps in the various method embodiments described above.

[0117] The above are merely optional embodiments of this application and are not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A database management method based on a tree structure, characterized in that, The database management method is applied to a tree-structured database system, which includes a trunk tree, multiple branch trees, and multiple radial subtrees. The root node of each branch tree is a branch node, and the other nodes are leaf nodes. The database management method includes: Based on the key-value pair data pre-stored in each of the leaf nodes, an append file is created and index information of the key-value pair data is generated. The index information includes the index information of the append file and the index information of the radial subtree pointed to by the leaf node pointer. Update the mapping table of the appended file according to the index information of the appended file; Based on the index information of the key-value pair data and the mapping relationship of the mapping table, read and / or maintain the key-value pair data corresponding to each leaf node.

2. The database management method according to claim 1, characterized in that, The step involves creating an append file and generating index information for the key-value pair data based on the key-value pair data pre-stored in each of the leaf nodes. The key-value pair data includes a key and a value, and the index information is the index information of the append file, including: If the storage space required for the key-value pair data is greater than a preset threshold, then an append file is created and the index information of the append file is generated based on the key-value pair data stored in each leaf node. The values ​​of the key-value pairs are stored in an append file, and the index information of the append file is stored in the leaf node; If the storage space required for the key-value pair data is less than or equal to the preset threshold, then the key-value pair data is directly stored in the leaf node.

3. The database management method according to claim 1, characterized in that, The step of creating an append file and generating index information for the key-value pair data based on the key-value pair data pre-stored in each of the leaf nodes, wherein the index information is the index information of the radial subtree pointed to by the leaf node pointer, further includes: The radial subtree pointed to by the leaf node pointer is determined. The trunk tree includes multiple levels of leaf nodes. The number of lower-level leaf nodes pointed to by the branch node pointer is the degree of the branch tree. The amount of key-value pairs stored in the lower-level leaf node pointed to by the pointer is a multiple of the degree of the amount of key-value pairs stored in the upper-level leaf node. If the storage space of key-value pair data in the radial subtree is greater than a preset storage space threshold, then the key-value pair data in the radial subtree will generate index information of the radial subtree, and the index information of the radial subtree will be stored in the leaf node. If the storage space for key-value pairs in the radial subtree is less than or equal to the preset storage space threshold, then the key-value pairs in the radial subtree are compressed into compressed bytecode and directly stored in the leaf node.

4. The database management method according to claim 2, characterized in that, The process of creating an append file and generating its index information includes: Create an append file and generate append file information, the append file information including the append file name and append index number, the append index number being the number of times the append file has been written; Generate the index information of the appended file based on the appended file name and the appended index number; The index information of the appended file and the key of the key-value pair data are stored in the leaf node.

5. The database management method according to claim 1, characterized in that, The step of updating the mapping table of the appended file based on the index information of the appended file, wherein the appended file information includes append position information and the append index number, includes: Based on the append location information and the append index number, a mapping relationship for the appended file is generated; The mapping relationship of the appended files is written into the mapping table to update the mapping table.

6. The database management method according to claim 1, characterized in that, The value of the key-value pair data is deleted from the corresponding append file to free up the storage space of the append file. The database management method further includes: The values ​​of the key-value pairs that need to be deleted are removed from the append file, the values ​​of other key-value pairs are rewritten into the append file, and the mapping table corresponding to the rewritten append file is updated.

7. The database management method according to claim 1, characterized in that, The branch tree includes a high-frequency tree and a low-frequency tree. Leaf nodes in the high-frequency tree are high-frequency access nodes, and leaf nodes in the low-frequency tree are low-frequency access nodes. High-frequency access nodes are leaf nodes whose access frequency exceeds a preset frequency, and low-frequency access nodes are leaf nodes whose access frequency is lower than the preset frequency. The database management method further includes: By monitoring data access patterns, all leaf nodes in the branch tree are identified. If a high-frequency access node is identified in the low-frequency tree, the high-frequency access node is reassembled into the high-frequency tree. If a low-frequency access node is identified in the high-frequency tree, the low-frequency access node is reassembled into the high-frequency tree.

8. A database management system based on a tree structure, characterized in that, The database management system includes: An append file creation module is used to create an append file based on the key-value pair data pre-stored in each leaf node and generate index information of the key-value pair data. The index information includes the index information of the append file and the index information of the radial subtree pointed to by the leaf node pointer. The mapping table update module is used to update the mapping table of the appended file according to the index information of the appended file; The data retrieval and maintenance module is used to read and / or maintain the key-value pair data corresponding to each leaf node based on the index information of the key-value pair data and the mapping relationship of the mapping table.

9. The database management system according to claim 8, characterized in that, The append file creation module includes an append file index information generation unit; the append file index information generation unit is used for: If the storage space required for the key-value pair data is greater than a preset threshold, then an append file is created and the index information of the append file is generated based on the key-value pair data stored in each leaf node. The values ​​of the key-value pairs are stored in an append file, and the index information of the append file is stored in the leaf node; If the storage space required for the key-value pair data is less than or equal to the preset threshold, then the key-value pair data is directly stored in the leaf node.

10. The database management system according to claim 8, characterized in that, The append file creation module includes a radial subtree index information generation unit, which is used for: The radial subtree pointed to by the leaf node pointer is determined. The trunk tree includes multiple levels of leaf nodes. The number of lower-level leaf nodes pointed to by the branch node pointer is the degree of the branch tree. The amount of key-value pairs stored in the lower-level leaf node pointed to by the pointer is a multiple of the degree of the amount of key-value pairs stored in the upper-level leaf node. If the storage space of key-value pair data in the radial subtree is greater than a preset storage space threshold, then the key-value pair data in the radial subtree will generate index information of the radial subtree, and the index information of the radial subtree will be stored in the leaf node. If the storage space for key-value pairs in the radial subtree is less than or equal to the preset storage space threshold, then the key-value pairs in the radial subtree are compressed into compressed bytecode and directly stored in the leaf node.

11. The database management system according to claim 9, characterized in that, The append file index information generation unit is specifically used for: Create an append file and generate append file information, the append file information including the append file name and append index number, the append index number being the number of times the append file has been written; Generate the index information of the appended file based on the appended file name and the appended index number; The index information of the appended file and the key of the key-value pair data are stored in the leaf node.

12. The database management system according to claim 8, characterized in that, The mapping table update module is used for: Based on the append location information and the append index number, a mapping relationship for the appended file is generated; The mapping relationship of the appended files is written into the mapping table to update the mapping table.

13. The database management system according to claim 8, characterized in that, The database management system also includes a compression and simplification module, used for: The values ​​of the key-value pairs that need to be deleted are removed from the append file, the values ​​of other key-value pairs are rewritten into the append file, and the mapping table corresponding to the rewritten append file is updated.

14. The database management system according to claim 8, characterized in that, The database management system also includes a node reorganization module, used for: By monitoring data access patterns, all leaf nodes in the branch tree are identified. If a high-frequency access node is identified in the low-frequency tree, the high-frequency access node is reassembled into the high-frequency tree. If a low-frequency access node is identified in the high-frequency tree, the low-frequency access node is reassembled into the high-frequency tree.

15. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method as described in any one of claims 1 to 7.

16. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Data storage method, access method, device and equipment based on tree structure

    CN111475511A

  • Hierarchical B + tree algorithm and device based on dynamic prefix and computer storage medium

    CN117632946A

  • Database management method and system based on tree structure and storage medium

    CN118467548A

  • Method and apparatus for providing efficient indexing and computer program included in computer readable medium therefor

    US20190362000A1