Efficient data retrieval method and related equipment based on artificial intelligence
By building a balanced lookup tree and automatically balancing it when data is updated, the problem of retrieval efficiency reduction caused by the increase in data orders in the data lake is solved, and efficient data retrieval and real-time update are achieved.
Patent Information
- Application Number
- CN202210696597.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-20
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2042-06-20
AI Technical Summary
In the data lake, as the data order increases, the performance degradation caused by the segment tree index structure leads to a decrease in data retrieval efficiency.
Using an efficient data retrieval method based on artificial intelligence, we use data files in the database to extract index values as index labels, build a balanced search tree, and automatically balanced search tree when data is updated to ensure retrieval efficiency.
It effectively avoids performance degradation, realizes efficient data retrieval and real-time updates, and improves the accuracy and speed of data retrieval.
Smart Images

Figure CN114968927B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to an efficient data retrieval method, device, electronic device and storage medium based on artificial intelligence. Background Art
[0002] Data lake is an extension of traditional data warehouse, which can solve the collection and storage of data of any scale, any source and any type, and support the insertion, update and incremental query of massive data. In the process of building data lake, Apache Hudi is often used as a storage component to support users to perform insertion, update and incremental query operations on data.
[0003] Currently, segment trees are often used as index structures in data lakes to query target data in large amounts of data. However, as the amount of data continues to increase, segment trees will continue to deepen, resulting in performance degradation, which reduces the efficiency of data retrieval. Summary of the invention
[0004] In view of the above content, it is necessary to propose an efficient data retrieval method and related equipment based on artificial intelligence to solve the technical problem of how to ensure efficient data retrieval, wherein the related equipment includes an efficient data retrieval device based on artificial intelligence, electronic equipment and storage medium.
[0005] The present application provides an efficient data retrieval method based on artificial intelligence, the method comprising:
[0006] Read all data files in the target database, extract the maximum index value and the minimum index value in the same data file as the index label of each data file, the data file contains multiple data information, and the data information includes index values and data content;
[0007] Using the index label as node information to construct a balanced search tree;
[0008] When the target database has new data, searching the balanced search tree based on the index value of the new data to obtain the target data file;
[0009] Retrieving the target data file based on the index value of the newly added data to obtain a retrieval result, and updating the target data file based on the retrieval result to obtain an updated target data file;
[0010] The balanced search tree is updated based on the updated target data file for the next retrieval.
[0011] In some embodiments, using the index label as node information to construct a balanced search tree includes:
[0012] A1, randomly select an index label from all index labels as the node information of the root node to build the initial search tree;
[0013] A2, randomly select an index label from the unselected index labels as the node information as the newly added node;
[0014] A3, comparing the node information of the newly added node with the node information in the initial search tree to obtain a comparison result, and inserting the newly added node into the initial search tree based on the comparison result to obtain a first search tree;
[0015] A4, calculating the balance coefficient of the nodes in the first search tree to screen out abnormal nodes;
[0016] A5, if no abnormal node is found, the first search tree is used as a new initial search tree; if an abnormal node is found, the abnormal node is rotated according to a preset rule to obtain a second search tree, and the second search tree is used as a new initial search tree;
[0017] A6, repeating steps A2-A5 to continuously obtain new nodes from the remaining index tags to update the initial search tree, and stopping the updating when all index tags are traversed to obtain a balanced search tree.
[0018] In some embodiments, comparing the node information of the newly added node with the node information of the node in the initial search tree to obtain a comparison result, and inserting the newly added node into the initial search tree to obtain a first search tree based on the comparison result, includes:
[0019] a. Select the root node in the initial search tree as the target node;
[0020] b. The maximum index value and the minimum index value in the target node are used as the target maximum value and the target minimum value, respectively, and the maximum index value and the minimum index value in the newly added node are used as the newly added maximum value and the newly added minimum value, respectively;
[0021] c. Compare the node information of the newly added node and the target node to obtain a comparison result, wherein the comparison result includes two cases: the newly added maximum value is less than the target minimum value, and the newly added minimum value is greater than the target maximum value;
[0022] d. If the comparison result is that the newly added maximum value is less than the target minimum value, the newly added node is an alternative left child node of the target node, and it is determined whether the target node already has a left child node. If not, the newly added node is used as the left child node of the target node to be inserted into the initial search tree; if it already exists, the left child node of the target node is used as the new target node;
[0023] e. If the newly added minimum value is greater than the target maximum value, the newly added node is an alternative right child node of the target node, and it is determined whether the target node already has a right child node. If not, the newly added node is inserted into the initial search tree as the right child node of the target node; if it already exists, the right child node of the target node is used as the new target node;
[0024] f. Repeat steps b to e until the newly added node is inserted into the initial search tree to obtain a first search tree.
[0025] In some embodiments, calculating the balance coefficient of the nodes in the first search tree to screen abnormal nodes includes:
[0026] a. Use the newly added node as a computing node;
[0027] b. Calculate the balance coefficient of the computing node, the balance coefficient satisfies the relationship:
[0028] p=|h left -h right |
[0029] Among them, h left is the height of the left subtree of the computing node, and the left subtree of the computing node is the left branch in the tree structure with the computing node as the root node; right is the height of the right subtree of the computing node, where the right subtree of the computing node is the right branch of the tree structure with the computing node as the root node;
[0030] c. If the balance coefficient of the computing node is greater than a preset threshold, the computing node is regarded as an abnormal node; if the balance coefficient of the computing node is not greater than the preset threshold, it means that the computing node is a normal node, and the parent node of the computing node is regarded as a new computing node;
[0031] d. Repeat steps b to c to filter abnormal nodes. When an abnormal node or a computing node is found to be the root node of the first search tree, stop filtering.
[0032] In some embodiments, rotating the abnormal node according to a preset rule to obtain a second search tree includes:
[0033] Acquire an abnormal tree structure with the abnormal node as a root node, wherein the abnormal tree structure includes the newly added node;
[0034] In the abnormal tree structure, if the newly added node is in the left subtree of the left child node of the abnormal node, it is necessary to perform an LL-type rotation on the abnormal tree structure to obtain a second search tree;
[0035] If the newly added node is in the right subtree of the right child node of the abnormal node, it is necessary to perform RR type rotation on the abnormal tree structure to obtain a second search tree;
[0036] If the newly added node is in the right subtree of the left child node of the abnormal node, it is necessary to perform an LR rotation on the abnormal tree structure to obtain a second search tree;
[0037] If the newly added node is in the left subtree of the right child node of the abnormal node, it is necessary to perform an RL type rotation on the abnormal tree structure to obtain a second search tree.
[0038] In some embodiments, when the target database has new data, searching the balanced search tree based on the index value of the new data to obtain the target data file includes:
[0039] When there is new data in the target database, the index value of the new data is used as the new index value, and the root node of the balanced search tree is used as the search node;
[0040] Comparing the newly added index value with the node information of the search node to search for the target data file, wherein the node information of the search node includes a maximum index value and a minimum index value;
[0041] If the newly added index value is not greater than the maximum index value in the search node and not less than the minimum index value in the search node, the data file corresponding to the index tag in the search node is used as the target data file and the search is stopped;
[0042] If the newly added index value is greater than the maximum index value in the search node, the right child node of the search node is used as a new search node to continue searching for the target data file until the target data file is obtained or all nodes of the balanced search tree are traversed;
[0043] If the newly added index value is less than the minimum index value in the search node, the left child node of the search node is used as a new search node to continue searching for the target data file until the target data file is obtained or all nodes of the balanced search tree are traversed;
[0044] When the search is stopped, if the target data file is not obtained, a new data file with a preset reserve is generated as the target data file, and the preset reserve reflects the amount of quantity information stored in the new data file.
[0045] In some embodiments, the updating of the balanced search tree based on the updated target data file for the next retrieval includes:
[0046] Acquire a matching node in the balanced search tree based on the index tag of the target data file;
[0047] If there is a matching node, obtaining the maximum index value and the minimum index value in the updated target data file as an updated index label, and using the updated index label as the node information of the matching node to update the balanced search tree;
[0048] If there is no matching node, the index label of the target data file is used as the node information to obtain a newly added node, the node information of the newly added node is compared with the node information of all nodes in the balanced search tree to obtain a comparison result, and based on the comparison result, the newly added node is inserted into the balanced search tree to obtain an updated balanced search tree.
[0049] The embodiment of the present application also provides an efficient data retrieval device based on artificial intelligence, the device comprising:
[0050] An extraction unit is used to read all data files in the target database, extract the maximum index value and the minimum index value in the same data file as the index label of each data file, wherein the data file contains multiple data information, and the data information includes the index value and the data content;
[0051] A construction unit, used to use the index label as node information to construct a balanced search tree;
[0052] A search unit, configured to search the balanced search tree based on the index value of the newly added data to obtain the target data file when the target database has newly added data;
[0053] A retrieval unit, configured to retrieve the target data file based on the index value of the newly added data to obtain a retrieval result, and update the target data file based on the retrieval result to obtain an updated target data file;
[0054] An updating unit is used to update the balanced search tree based on the updated target data file for the next retrieval.
[0055] The present application also provides an electronic device, the electronic device comprising:
[0056] A memory storing at least one instruction;
[0057] A processor executes instructions stored in the memory to implement the efficient data retrieval method based on artificial intelligence.
[0058] An embodiment of the present application also provides a computer-readable storage medium, in which at least one instruction is stored. The at least one instruction is executed by a processor in an electronic device to implement the efficient data retrieval method based on artificial intelligence.
[0059] In summary, the present application uses the maximum index value and the minimum index value of each data file in the database as the index label of the data file, and uses the index label as the node information to construct a balanced search tree. The balanced search tree can be automatically updated according to the database, and automatic balancing can be achieved during the update process, avoiding the risk of performance degradation and ensuring efficient data retrieval. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 It is a flow chart of a preferred embodiment of the efficient data retrieval method based on artificial intelligence involved in this application.
[0061] Figure 2 It is a schematic diagram of the LL type rotation involved in this application.
[0062] Figure 3 It is a schematic diagram of the RR type rotation involved in this application.
[0063] Figure 4 It is a schematic diagram of the LR type rotation involved in this application.
[0064] Figure 5 It is a schematic diagram of the RL type rotation involved in this application.
[0065] Figure 6 It is a functional module diagram of a preferred embodiment of the artificial intelligence-based data efficient retrieval device involved in this application.
[0066] Figure 7 It is a schematic diagram of the structure of an electronic device of a preferred embodiment of the efficient data retrieval method based on artificial intelligence involved in the present application. DETAILED DESCRIPTION
[0067] In order to more clearly understand the purpose, features and advantages of the present application, the present application is described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that, in the absence of conflict, the embodiments of the present application and the features in the embodiments can be combined with each other. In the following description, many specific details are set forth to facilitate a full understanding of the present application, and the embodiments described are only a part of the embodiments of the present application, rather than all of the embodiments.
[0068] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of this application, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0069] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those generally understood by those skilled in the art to which the present application belongs. The terms used herein in the specification of the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.
[0070] The embodiment of the present application provides an efficient data retrieval method based on artificial intelligence, which can be applied to one or more electronic devices. The electronic device is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.
[0071] An electronic device can be any electronic product that can interact with a customer, such as a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), a game console, an interactive network television (IPTV), a smart wearable device, etc.
[0072] The electronic device may also include a network device and / or a client device, wherein the network device includes, but is not limited to, a single network server, a server group consisting of multiple network servers, or a cloud consisting of a large number of hosts or network servers based on cloud computing.
[0073] The network where the electronic device is located includes but is not limited to the Internet, wide area network, metropolitan area network, local area network, virtual private network (VPN), etc.
[0074] like Figure 1, which is a flow chart of a preferred embodiment of the present invention's efficient data retrieval method based on artificial intelligence. According to different requirements, the order of the steps in the flow chart can be changed, and some steps can be omitted.
[0075] S10, reading all data files in the target database, extracting the maximum index value and the minimum index value in the same data file as the index tag of each data file, wherein the data file contains multiple pieces of data information, and the data information includes index values and data content.
[0076] In an optional embodiment, the target database stores multiple data files related to the business, each data file includes multiple data information, and each data information is stored in the target database in the form of a key-value pair, that is, each data information includes an index value and data content, and the index value is a continuous integer data, and the index value and the data information correspond one to one. Among them, the target database can be a data lake or other types of databases with a large amount of data, which is not limited in this application.
[0077] In this optional embodiment, the maximum index value and the minimum index value in the same data file are extracted as the index label of each data file. For example, if the maximum index value in a data file is 15 and the minimum index value is 5, the index label of the data file is 5 and 15; all data files are traversed to obtain the index label of each data file, and the index label can reflect the range of the index value in the data file. It should be noted that different data files correspond to different index labels, and the index label is a unique identifier of the data file, so the index label is used as the ID information of the data file.
[0078] In this way, the index label of each data file can be obtained based on the index value of the data information, providing a data basis for the subsequent construction of a balanced search tree.
[0079] S11, using the index label as node information to construct a balanced search tree.
[0080] In an optional embodiment, using the index label as node information to construct a balanced search tree includes:
[0081] A1, randomly select an index label from all index labels as the node information of the root node to build the initial search tree;
[0082] A2, randomly select an index label from the unselected index labels as the node information as the newly added node;
[0083] A3, comparing the node information of the newly added node with the node information in the initial search tree to obtain a comparison result, and inserting the newly added node into the initial search tree based on the comparison result to obtain a first search tree;
[0084] A4, calculating the balance coefficient of the nodes in the first search tree to screen out abnormal nodes;
[0085] A5, if no abnormal node is found, the first search tree is used as a new initial search tree; if an abnormal node is found, the abnormal node is rotated according to a preset rule to obtain a second search tree, and the second search tree is used as a new initial search tree;
[0086] A6, repeating steps A2-A5 to continuously obtain new nodes from the remaining index tags to update the initial search tree, and stopping the updating when all index tags are traversed to obtain a balanced search tree.
[0087] In this optional embodiment, an index tag is randomly selected from all index tags as the node information of the root node to construct an initial search tree; the initial search tree only includes one root node, and the node information of the root node includes a maximum index value and a minimum index value.
[0088] In this optional embodiment, an index tag is randomly selected from unselected index tags, and the index tag is used as node information as a newly added node. The node information of the newly added node also includes a maximum index value and a minimum index value.
[0089] In this optional embodiment, comparing the node information of the newly added node with the node information of the nodes in the initial search tree to obtain a comparison result, and inserting the newly added node into the initial search tree to obtain a first search tree based on the comparison result, includes:
[0090] a. Select the root node in the initial search tree as the target node;
[0091] b. The maximum index value and the minimum index value in the target node are used as the target maximum value and the target minimum value, respectively, and the maximum index value and the minimum index value in the newly added node are used as the newly added maximum value and the newly added minimum value, respectively;
[0092] c. Compare the node information of the newly added node and the target node to obtain a comparison result, wherein the comparison result includes two cases: the newly added maximum value is less than the target minimum value, and the newly added minimum value is greater than the target maximum value;
[0093] d. If the comparison result is that the newly added maximum value is less than the target minimum value, the newly added node is an alternative left child node of the target node, and it is determined whether the target node already has a left child node. If not, the newly added node is used as the left child node of the target node to be inserted into the initial search tree; if it already exists, the left child node of the target node is used as the new target node;
[0094] e. If the newly added minimum value is greater than the target maximum value, the newly added node is an alternative right child node of the target node, and it is determined whether the target node already has a right child node. If not, the newly added node is inserted into the initial search tree as the right child node of the target node; if it already exists, the right child node of the target node is used as the new target node;
[0095] f. Repeat steps b to e until the newly added node is inserted into the initial search tree to obtain a first search tree.
[0096] In this optional embodiment, calculating the balance coefficient of the nodes in the first search tree to screen abnormal nodes includes:
[0097] a. Use the newly added node as a computing node;
[0098] b. Calculate the balance coefficient of the computing node, the balance coefficient satisfies the relationship:
[0099] p=|h left -h right |
[0100] Among them, h left is the height of the left subtree of the computing node, and the left subtree of the computing node is the left branch in the tree structure with the computing node as the root node; right is the height of the right subtree of the computing node, where the right subtree of the computing node is the right branch of the tree structure with the computing node as the root node;
[0101] c. If the balance coefficient of the computing node is greater than a preset threshold, the computing node is regarded as an abnormal node; if the balance coefficient of the computing node is not greater than the preset threshold, it means that the computing node is a normal node, and the parent node of the computing node is regarded as a new computing node;
[0102] d. Repeat steps b to c to filter abnormal nodes. When an abnormal node or a computing node is found to be the root node of the first search tree, stop filtering.
[0103] Among them, the value of the preset threshold is 2.
[0104] In this optional embodiment, if no abnormal node is screened out, it means that the depth from the root node to all leaf nodes of the first search tree is the same, that is, the first search tree is a balanced tree, and the first search tree is directly used as the new initial search tree; if an abnormal node is screened out, it means that the insertion of the new node causes the first search tree to not be a balanced tree, and the abnormal node needs to be rotated according to preset rules to obtain a second search tree, and the second search tree is used as the new initial search tree, and the second search tree is a balanced tree.
[0105] In this optional embodiment, rotating the abnormal node according to a preset rule to obtain a second search tree includes:
[0106] Acquire an abnormal tree structure with the abnormal node as a root node, wherein the abnormal tree structure includes the newly added node;
[0107] In the abnormal tree structure, if the newly added node is in the left subtree of the left child node of the abnormal node, it is necessary to perform an LL-type rotation on the abnormal tree structure to obtain a second search tree;
[0108] If the newly added node is in the right subtree of the right child node of the abnormal node, it is necessary to perform RR type rotation on the abnormal tree structure to obtain a second search tree;
[0109] If the newly added node is in the right subtree of the left child node of the abnormal node, it is necessary to perform an LR rotation on the abnormal tree structure to obtain a second search tree;
[0110] If the newly added node is in the left subtree of the right child node of the abnormal node, it is necessary to perform an RL type rotation on the abnormal tree structure to obtain a second search tree.
[0111] In this optional embodiment, the schematic diagram of the LL type rotation is as follows Figure 2 As shown, the abnormal tree structure is as follows Figure 2 -(1), in the abnormal tree structure, node A is an abnormal node and node X is a newly added node; in the process of LL type rotation, node B is first promoted to the root node of the new tree structure, node A is demoted to the right child node of node B, and node E is rotated to the left child node of node A; after LL type rotation, the following can be obtained Figure 2 -The new tree structure shown in (2).
[0112] In this optional embodiment, the schematic diagram of the RR type rotation is as follows Figure 3 As shown, the abnormal tree structure is as follows Figure 3-(1), in the abnormal tree structure, node A is an abnormal node and node X is a newly added node; in the process of RR type rotation, node C is first promoted to the root node of the new tree structure, node A is demoted to the left child node of node C, and node D is rotated to the right child node of node A; after RR type rotation, the following can be obtained Figure 3 -The new tree structure shown in (2).
[0113] In this optional embodiment, the schematic diagram of the LR type rotation is as follows Figure 4 As shown, the abnormal tree structure is as follows Figure 4 -(1), in the abnormal tree structure, node A is an abnormal node, and node X is a newly added node; in the process of LR type rotation, the tree structure with the left child node of node A as the root node is first used as the abnormal subtree structure, and the abnormal subtree structure is subjected to RR type rotation to obtain an intermediate tree structure; the intermediate tree structure is further subjected to LL type rotation to complete the LR type rotation; after the LR type rotation, the following can be obtained Figure 4 -The new tree structure shown in (3).
[0114] In this optional embodiment, the schematic diagram of the RL type rotation is as follows Figure 5 As shown, the abnormal tree structure is as follows Figure 5 -(1), in the abnormal tree structure, node A is an abnormal node, and node X is a newly added node; in the process of RL type rotation, the tree structure with the right child node of node A as the root node is first used as the abnormal subtree structure, and the abnormal subtree structure is subjected to LL type rotation to obtain an intermediate tree structure; the intermediate tree structure is further subjected to RR type rotation to complete the RL type rotation; after the RL type rotation, the following can be obtained Figure 5 -The new tree structure shown in (3).
[0115] At this point, the newly added node is successfully inserted into the initial search tree, completing the update process of the initial search tree. The newly added nodes are continuously obtained from the remaining index tags to update the initial search tree until all index tags are traversed to obtain a balanced search tree. The node information of each node in the balanced search tree corresponds one-to-one to the index tag of the data file.
[0116] In this way, the construction of a balanced search tree is completed by using the index label as the node information. One node information corresponds to all the data information in the data file. The retrieval of a large amount of data information is achieved using a tree with a lower depth value. The depth from the root node to all leaf nodes in the balanced search tree is the same, ensuring the retrieval efficiency of each node.
[0117] S12: When there is new data in the target database, searching the balanced search tree based on the index value of the new data to obtain the target data file.
[0118] In an optional embodiment, when the target database has new data, searching the balanced search tree based on the index value of the new data to obtain the target data file includes:
[0119] When there is new data in the target database, the index value of the new data is used as the new index value, and the root node of the balanced search tree is used as the search node;
[0120] Comparing the newly added index value with the node information of the search node to search for the target data file, wherein the node information of the search node includes a maximum index value and a minimum index value;
[0121] If the newly added index value is not greater than the maximum index value in the search node and not less than the minimum index value in the search node, the data file corresponding to the index tag in the search node is used as the target data file and the search is stopped;
[0122] If the newly added index value is greater than the maximum index value in the search node, the right child node of the search node is used as a new search node to continue searching for the target data file until the target data file is obtained or all nodes of the balanced search tree are traversed;
[0123] If the newly added index value is less than the minimum index value in the search node, the left child node of the search node is used as a new search node to continue searching for the target data file until the target data file is obtained or all nodes of the balanced search tree are traversed;
[0124] When the search is stopped, if the target data file is not obtained, a new data file with a preset reserve is generated as the target data file, and the preset reserve reflects the amount of quantity information stored in the new data file.
[0125] In order to ensure the retrieval efficiency of subsequent target data files, the preset reserve value is 5000. At the same time, the index tag of the new data file can be automatically generated based on the preset reserve. The index tag is (MAX, MAX+5000], where MAX is the maximum value of the index value of all data information in the target database.
[0126] In this way, the target data file corresponding to the newly added data can be located without traversing the leaf nodes of the balanced search tree, thereby improving the search speed of the target data file.
[0127] S13, searching the target data file based on the index value of the newly added data to obtain a search result, and updating the target data file based on the search result to obtain an updated target data file.
[0128] In an optional embodiment, after obtaining the target data file, all data information of the target data file is searched based on the index value of the newly added data to obtain the search results. Since the amount of data information contained in the target data file is small, the time for obtaining the search results is shortened and the efficiency of data retrieval is improved. The search method can adopt one-by-one traversal or existing search methods such as binary search, which is not limited in this application.
[0129] In this optional embodiment, updating the target data file based on the retrieval result to obtain an updated target data file includes: if the index value of the newly added data already exists in the target data file, the retrieval result is a successful retrieval, and then according to preset requirements, the original data of the target data file is replaced by the newly added data to achieve data update, or the original data of the target data file is directly deleted to achieve data deletion, and the preset requirements are deletion and update; if the index value of the newly added data does not exist in the target data file, the retrieval result is a failed retrieval, and the newly added data needs to be inserted into the target data file to achieve data insertion.
[0130] In this way, each new data can be updated, inserted and deleted according to the preset requirements, avoiding the process of full table scan and matching, greatly improving the task timeliness of update, insert and delete operations, and reducing the consumption of computing resources.
[0131] S14, updating the balanced search tree based on the updated target data file for the next retrieval.
[0132] In an optional embodiment, in order to ensure high efficiency and speed during the next data retrieval, after the target data file is updated, the balanced search tree needs to be updated based on the updated target data file.
[0133] In this optional embodiment, the updating of the balanced search tree based on the updated target data file for the next retrieval includes:
[0134] Acquire a matching node in the balanced search tree based on the index tag of the target data file;
[0135] If there is a matching node, obtaining the maximum index value and the minimum index value in the updated target data file as an updated index label, and using the updated index label as the node information of the matching node to update the balanced search tree;
[0136] If there is no matching node, the index label of the target data file is used as the node information to obtain a newly added node, the node information of the newly added node is compared with the node information of all nodes in the balanced search tree to obtain a comparison result, and based on the comparison result, the newly added node is inserted into the balanced search tree to obtain an updated balanced search tree.
[0137] In this way, when data is updated, deleted or inserted in the target database, the balanced search tree can be automatically updated for the next search, thereby ensuring the real-time performance of the balanced search tree and the accuracy and efficiency of data retrieval.
[0138] It can be seen from the above technical solution that the present application uses the maximum index value and the minimum index value of each data file in the database as the index label of the data file, and uses the index label as the node information to construct a balanced search tree. The balanced search tree can be automatically updated according to the database, and automatic balancing can be achieved during the update process, avoiding the risk of performance degradation and ensuring efficient data retrieval.
[0139] See also Figure 6 , Figure 6 1 is a functional module diagram of a preferred embodiment of the data efficient retrieval device based on artificial intelligence of the present application. The data efficient retrieval device based on artificial intelligence 11 includes an extraction unit 110, a construction unit 111, a search unit 112, a retrieval unit 113, and an update unit 114. The module / unit referred to in the present application refers to a series of computer-readable instruction segments that can be executed by the processor 13 and can complete fixed functions, which are stored in the memory 12. In this embodiment, the functions of each module / unit will be described in detail in subsequent embodiments.
[0140] In an optional embodiment, the extraction unit 110 is used to read all data files in the target database, extract the maximum index value and the minimum index value in the same data file as the index tag of each data file, and the data file contains multiple data information, and the data information includes index values and data content.
[0141] In an optional embodiment, the target database stores multiple data files related to the business, each data file includes multiple data information, and each data information is stored in the target database in the form of a key-value pair, that is, each data information includes an index value and data content, and the index value is a continuous integer data, and the index value and the data information correspond one to one. Among them, the target database can be a data lake or other types of databases with a large amount of data, which is not limited in this application.
[0142] In this optional embodiment, the maximum index value and the minimum index value in the same data file are extracted as the index label of each data file. For example, if the maximum index value in a data file is 15 and the minimum index value is 5, the index label of the data file is 5 and 15; all data files are traversed to obtain the index label of each data file, and the index label can reflect the range of the index value in the data file. It should be noted that different data files correspond to different index labels, and the index label is a unique identifier of the data file, so the index label is used as the ID information of the data file.
[0143] In an optional embodiment, the construction unit 111 is configured to use the index label as node information to construct a balanced search tree.
[0144] In an optional embodiment, using the index label as node information to construct a balanced search tree includes:
[0145] A1, randomly select an index label from all index labels as the node information of the root node to build the initial search tree;
[0146] A2, randomly select an index label from the unselected index labels as the node information as the newly added node;
[0147] A3, comparing the node information of the newly added node with the node information in the initial search tree to obtain a comparison result, and inserting the newly added node into the initial search tree based on the comparison result to obtain a first search tree;
[0148] A4, calculating the balance coefficient of the nodes in the first search tree to screen out abnormal nodes;
[0149] A5, if no abnormal node is found, the first search tree is used as a new initial search tree; if an abnormal node is found, the abnormal node is rotated according to a preset rule to obtain a second search tree, and the second search tree is used as a new initial search tree;
[0150] A6, repeating steps A2-A5 to continuously obtain new nodes from the remaining index tags to update the initial search tree, and stopping the updating when all index tags are traversed to obtain a balanced search tree.
[0151] In this optional embodiment, an index tag is randomly selected from all index tags as the node information of the root node to construct an initial search tree; the initial search tree only includes one root node, and the node information of the root node includes a maximum index value and a minimum index value.
[0152] In this optional embodiment, an index tag is randomly selected from unselected index tags, and the index tag is used as node information as a newly added node. The node information of the newly added node also includes a maximum index value and a minimum index value.
[0153] In this optional embodiment, comparing the node information of the newly added node with the node information of the nodes in the initial search tree to obtain a comparison result, and inserting the newly added node into the initial search tree to obtain a first search tree based on the comparison result, includes:
[0154] a. Select the root node in the initial search tree as the target node;
[0155] b. The maximum index value and the minimum index value in the target node are used as the target maximum value and the target minimum value, respectively, and the maximum index value and the minimum index value in the newly added node are used as the newly added maximum value and the newly added minimum value, respectively;
[0156] c. Compare the node information of the newly added node and the target node to obtain a comparison result, wherein the comparison result includes two cases: the newly added maximum value is less than the target minimum value, and the newly added minimum value is greater than the target maximum value;
[0157] d. If the comparison result is that the newly added maximum value is less than the target minimum value, the newly added node is an alternative left child node of the target node, and it is determined whether the target node already has a left child node. If not, the newly added node is used as the left child node of the target node to be inserted into the initial search tree; if it already exists, the left child node of the target node is used as the new target node;
[0158] e. If the newly added minimum value is greater than the target maximum value, the newly added node is an alternative right child node of the target node, and it is determined whether the target node already has a right child node. If not, the newly added node is inserted into the initial search tree as the right child node of the target node; if it already exists, the right child node of the target node is used as the new target node;
[0159] f. Repeat steps b to e until the newly added node is inserted into the initial search tree to obtain a first search tree.
[0160] In this optional embodiment, calculating the balance coefficient of the nodes in the first search tree to screen abnormal nodes includes:
[0161] a. Use the newly added node as a computing node;
[0162] b. Calculate the balance coefficient of the computing node, the balance coefficient satisfies the relationship:
[0163] p=|h left -h right |
[0164] Among them, h left is the height of the left subtree of the computing node, and the left subtree of the computing node is the left branch in the tree structure with the computing node as the root node; right is the height of the right subtree of the computing node, where the right subtree of the computing node is the right branch of the tree structure with the computing node as the root node;
[0165] c. If the balance coefficient of the computing node is greater than a preset threshold, the computing node is regarded as an abnormal node; if the balance coefficient of the computing node is not greater than the preset threshold, it means that the computing node is a normal node, and the parent node of the computing node is regarded as a new computing node;
[0166] d. Repeat steps b to c to filter abnormal nodes. When an abnormal node or a computing node is found to be the root node of the first search tree, stop filtering.
[0167] Among them, the value of the preset threshold is 2.
[0168] In this optional embodiment, if no abnormal node is screened out, it means that the depth from the root node to all leaf nodes of the first search tree is the same, that is, the first search tree is a balanced tree, and the first search tree is directly used as the new initial search tree; if an abnormal node is screened out, it means that the insertion of the new node causes the first search tree to not be a balanced tree, and the abnormal node needs to be rotated according to preset rules to obtain a second search tree, and the second search tree is used as the new initial search tree, and the second search tree is a balanced tree.
[0169] In this optional embodiment, rotating the abnormal node according to a preset rule to obtain a second search tree includes:
[0170] Acquire an abnormal tree structure with the abnormal node as a root node, wherein the abnormal tree structure includes the newly added node;
[0171] In the abnormal tree structure, if the newly added node is in the left subtree of the left child node of the abnormal node, it is necessary to perform an LL-type rotation on the abnormal tree structure to obtain a second search tree;
[0172] If the newly added node is in the right subtree of the right child node of the abnormal node, it is necessary to perform RR type rotation on the abnormal tree structure to obtain a second search tree;
[0173] If the newly added node is in the right subtree of the left child node of the abnormal node, it is necessary to perform an LR rotation on the abnormal tree structure to obtain a second search tree;
[0174] If the newly added node is in the left subtree of the right child node of the abnormal node, it is necessary to perform an RL type rotation on the abnormal tree structure to obtain a second search tree.
[0175] In this optional embodiment, the schematic diagram of the LL type rotation is as follows Figure 2 As shown, the abnormal tree structure is as follows Figure 2 -(1), in the abnormal tree structure, node A is an abnormal node and node X is a newly added node; in the process of LL type rotation, node B is first promoted to the root node of the new tree structure, node A is demoted to the right child node of node B, and node E is rotated to the left child node of node A; after LL type rotation, the following can be obtained Figure 2 -The new tree structure shown in (2).
[0176] In this optional embodiment, the schematic diagram of the RR type rotation is as follows Figure 3 As shown, the abnormal tree structure is as follows Figure 3 -(1), in the abnormal tree structure, node A is an abnormal node and node X is a newly added node; in the process of RR type rotation, node C is first promoted to the root node of the new tree structure, node A is demoted to the left child node of node C, and node D is rotated to the right child node of node A; after RR type rotation, the following can be obtained Figure 3 -The new tree structure shown in (2).
[0177] In this optional embodiment, the schematic diagram of the LR type rotation is as follows Figure 4 As shown, the abnormal tree structure is as follows Figure 4 -(1), in the abnormal tree structure, node A is an abnormal node, and node X is a newly added node; in the process of LR type rotation, the tree structure with the left child node of node A as the root node is first used as the abnormal subtree structure, and the abnormal subtree structure is subjected to RR type rotation to obtain an intermediate tree structure; the intermediate tree structure is further subjected to LL type rotation to complete the LR type rotation; after the LR type rotation, the following can be obtained Figure 4 -The new tree structure shown in (3).
[0178] In this optional embodiment, the schematic diagram of the RL type rotation is as follows Figure 5 As shown, the abnormal tree structure is as follows Figure 5-(1), in the abnormal tree structure, node A is an abnormal node, and node X is a newly added node; in the process of RL type rotation, the tree structure with the right child node of node A as the root node is first used as the abnormal subtree structure, and the abnormal subtree structure is subjected to LL type rotation to obtain an intermediate tree structure; the intermediate tree structure is further subjected to RR type rotation to complete the RL type rotation; after the RL type rotation, the following can be obtained Figure 5 -The new tree structure shown in (3).
[0179] At this point, the newly added node is successfully inserted into the initial search tree, completing the update process of the initial search tree. The newly added nodes are continuously obtained from the remaining index tags to update the initial search tree until all index tags are traversed to obtain a balanced search tree. The node information of each node in the balanced search tree corresponds one-to-one to the index tag of the data file.
[0180] In an optional embodiment, the search unit 112 is configured to search the balanced search tree based on the index value of the newly added data to obtain the target data file when the target database has newly added data.
[0181] In an optional embodiment, when the target database has new data, searching the balanced search tree based on the index value of the new data to obtain the target data file includes:
[0182] When there is new data in the target database, the index value of the new data is used as the new index value, and the root node of the balanced search tree is used as the search node;
[0183] Comparing the newly added index value with the node information of the search node to search for the target data file, wherein the node information of the search node includes a maximum index value and a minimum index value;
[0184] If the newly added index value is not greater than the maximum index value in the search node and not less than the minimum index value in the search node, the data file corresponding to the index tag in the search node is used as the target data file and the search is stopped;
[0185] If the newly added index value is greater than the maximum index value in the search node, the right child node of the search node is used as a new search node to continue searching for the target data file until the target data file is obtained or all nodes of the balanced search tree are traversed;
[0186] If the newly added index value is less than the minimum index value in the search node, the left child node of the search node is used as a new search node to continue searching for the target data file until the target data file is obtained or all nodes of the balanced search tree are traversed;
[0187] When the search is stopped, if the target data file is not obtained, a new data file with a preset reserve is generated as the target data file, and the preset reserve reflects the amount of quantity information stored in the new data file.
[0188] In order to ensure the retrieval efficiency of subsequent target data files, the preset reserve value is 5000. At the same time, the index tag of the new data file can be automatically generated based on the preset reserve. The index tag is (MAX, MAX+5000], where MAX is the maximum value of the index value of all data information in the target database.
[0189] In an optional embodiment, the retrieval unit 113 is configured to retrieve the target data file based on the index value of the newly added data to obtain a retrieval result, and update the target data file based on the retrieval result to obtain an updated target data file.
[0190] In an optional embodiment, after obtaining the target data file, all data information of the target data file is searched based on the index value of the newly added data to obtain the search results. Since the amount of data information contained in the target data file is small, the time for obtaining the search results is shortened and the efficiency of data retrieval is improved. The search method can adopt one-by-one traversal or existing search methods such as binary search, which is not limited in this application.
[0191] In this optional embodiment, updating the target data file based on the retrieval result to obtain an updated target data file includes: if the index value of the newly added data already exists in the target data file, the retrieval result is a successful retrieval, and then according to preset requirements, the original data of the target data file is replaced by the newly added data to achieve data update, or the original data of the target data file is directly deleted to achieve data deletion, and the preset requirements are deletion and update; if the index value of the newly added data does not exist in the target data file, the retrieval result is a failed retrieval, and the newly added data needs to be inserted into the target data file to achieve data insertion.
[0192] In an optional embodiment, the updating unit 114 is configured to update the balanced search tree based on the updated target data file for the next retrieval.
[0193] In an optional embodiment, in order to ensure high efficiency and speed during the next data retrieval, after the target data file is updated, the balanced search tree needs to be updated based on the updated target data file.
[0194] In this optional embodiment, the updating of the balanced search tree based on the updated target data file for the next retrieval includes:
[0195] Acquire a matching node in the balanced search tree based on the index tag of the target data file;
[0196] If there is a matching node, obtaining the maximum index value and the minimum index value in the updated target data file as an updated index label, and using the updated index label as the node information of the matching node to update the balanced search tree;
[0197] If there is no matching node, the index label of the target data file is used as the node information to obtain a newly added node, the node information of the newly added node is compared with the node information of all nodes in the balanced search tree to obtain a comparison result, and based on the comparison result, the newly added node is inserted into the balanced search tree to obtain an updated balanced search tree.
[0198] It can be seen from the above technical solution that the present application uses the maximum index value and the minimum index value of each data file in the database as the index label of the data file, and uses the index label as the node information to construct a balanced search tree. The balanced search tree can be automatically updated according to the database, and automatic balancing can be achieved during the update process, avoiding the risk of performance degradation and ensuring efficient data retrieval.
[0199] See also Figure 7 , is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device 1 includes a memory 12 and a processor 13. The memory 12 is used to store computer-readable instructions, and the processor 13 is used to execute the computer-readable instructions stored in the memory to implement the efficient data retrieval method based on artificial intelligence described in any of the above embodiments.
[0200] In an optional embodiment, the electronic device 1 further includes a bus, a computer program stored in the memory 12 and executable on the processor 13, such as an efficient data retrieval program based on artificial intelligence.
[0201] Figure 7 Only the electronic device 1 having the memory 12 and the processor 13 is shown, and those skilled in the art can understand that Figure 7 The structure shown does not constitute a limitation on the electronic device 1 , and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0202] Combination Figure 1The memory 12 in the electronic device 1 stores a plurality of computer-readable instructions to implement an efficient data retrieval method based on artificial intelligence, and the processor 13 can execute the plurality of instructions to implement:
[0203] Read all data files in the target database, extract the maximum index value and the minimum index value in the same data file as the index label of each data file, the data file contains multiple data information, and the data information includes index values and data content;
[0204] Using the index label as node information to construct a balanced search tree;
[0205] When the target database has new data, searching the balanced search tree based on the index value of the new data to obtain the target data file;
[0206] Retrieving the target data file based on the index value of the newly added data to obtain a retrieval result, and updating the target data file based on the retrieval result to obtain an updated target data file;
[0207] The balanced search tree is updated based on the updated target data file for the next retrieval.
[0208] Specifically, the specific implementation method of the processor 13 for the above instructions can refer to Figure 1 The description of the relevant steps in the corresponding embodiments will not be repeated here.
[0209] Those skilled in the art will appreciate that the schematic diagram is merely an example of the electronic device 1 and does not constitute a limitation on the electronic device 1. The electronic device 1 may be a bus structure or a star structure. The electronic device 1 may also include more or less other hardware or software than shown in the diagram, or a different arrangement of components. For example, the electronic device 1 may also include input and output devices, network access devices, etc.
[0210] It should be noted that the electronic device 1 is only an example, and other existing or future electronic products that are suitable for the present application should also be included in the protection scope of the present application and included here by reference.
[0211] Among them, the memory 12 includes at least one type of readable storage medium, and the readable storage medium can be non-volatile or volatile. The readable storage medium includes flash memory, mobile hard disk, multimedia card, card-type memory (for example: SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 12 can be an internal storage unit of the electronic device 1, such as a mobile hard disk of the electronic device 1. In other embodiments, the memory 12 can also be an external storage device of the electronic device 1, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 1. The memory 12 can not only be used to store application software and various types of data installed in the electronic device 1, such as the code of the data efficient retrieval program based on artificial intelligence, but also can be used to temporarily store data that has been output or is to be output.
[0212] In some embodiments, the processor 13 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips. The processor 13 is the control core (Control Unit) of the electronic device 1, and uses various interfaces and lines to connect the various components of the entire electronic device 1, and executes or executes programs or modules stored in the memory 12 (for example, executing an efficient data retrieval program based on artificial intelligence, etc.), and calls the data stored in the memory 12 to execute various functions of the electronic device 1 and process data.
[0213] The processor 13 executes the operating system of the electronic device 1 and various installed applications. The processor 13 executes the applications to implement the steps in the above-mentioned embodiments of the efficient data retrieval method based on artificial intelligence, for example Figure 1 Steps shown.
[0214] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory 12 and executed by the processor 13 to complete the present application. The one or more modules / units may be a series of computer-readable instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program in the electronic device 1. For example, the computer program may be divided into an extraction unit 110, a construction unit 111, a search unit 112, a retrieval unit 113, and an update unit 114.
[0215] The above-mentioned integrated unit implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a computer device, or a network device, etc.) or a processor to execute a part of the efficient data retrieval method based on artificial intelligence described in each embodiment of the present application.
[0216] If the module / unit integrated in the electronic device 1 is implemented in the form of 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, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also instruct the relevant hardware devices to complete through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by the processor, the steps of each of the above-mentioned method embodiments can be implemented.
[0217] The computer program includes computer program code, which may be in source code form, object code form, executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory and other memory, etc.
[0218] Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.
[0219] The blockchain referred to in this application is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0220] The bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. Figure 7 Only one arrow is used in the figure, but it does not mean that there is only one bus or one type of bus. The bus is configured to realize the connection and communication between the memory 12 and at least one processor 13, etc.
[0221] An embodiment of the present application also provides a computer-readable storage medium (not shown), in which computer-readable storage medium is stored computer-readable instructions, and the computer-readable instructions are executed by a processor in an electronic device to implement the efficient data retrieval method based on artificial intelligence described in any of the above embodiments.
[0222] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0223] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0224] In addition, each functional module in each embodiment of the present 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 above integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0225] In addition, it is obvious that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the specification can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any specific order.
[0226] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present application and are not intended to limit it. Although the present application has been described in detail with reference to the preferred embodiments, a person of ordinary skill in the art should understand that the technical solution of the present application may be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present application.
Claims
1. An efficient data retrieval method based on artificial intelligence, characterized in that: The method comprises: Read all data files in the target database, extract the maximum index value and the minimum index value in the same data file as the index label of each data file, the data file contains multiple data information, and the data information includes index values and data content; Using the index tag as node information to construct a balanced search tree, including: A1, randomly selecting an index tag from all index tags as the node information of the root node to construct an initial search tree; A2, randomly selecting an index tag from the unselected index tags as the node information as a newly added node; A3, comparing the node information of the newly added node with the node in the initial search tree to obtain a comparison result, and inserting the newly added node into the initial search tree based on the comparison result to obtain a first search tree; A4, calculating the balance coefficient of the nodes in the first search tree to screen abnormal nodes; A5, if no abnormal node is screened, using the first search tree as a new initial search tree, if an abnormal node is screened, rotating the abnormal node according to a preset rule to obtain a second search tree, and using the second search tree as a new initial search tree; A6, repeating steps A2-A5 to continuously obtain new nodes from the remaining index tags to update the initial search tree, until all index tags are traversed and the update is stopped to obtain a balanced search tree; When the target database has new data, searching the balanced search tree based on the index value of the new data to obtain the target data file; Retrieving the target data file based on the index value of the newly added data to obtain a retrieval result, and updating the target data file based on the retrieval result to obtain an updated target data file; The balanced search tree is updated based on the updated target data file for the next retrieval.
2. The efficient data retrieval method based on artificial intelligence as claimed in claim 1, characterized in that: The step of comparing the node information of the newly added node with the node information in the initial search tree to obtain a comparison result, and inserting the newly added node into the initial search tree to obtain a first search tree based on the comparison result, includes: a. Select the root node in the initial search tree as the target node; b. The maximum index value and the minimum index value in the target node are used as the target maximum value and the target minimum value, respectively, and the maximum index value and the minimum index value in the newly added node are used as the newly added maximum value and the newly added minimum value, respectively; c. Compare the node information of the newly added node and the target node to obtain a comparison result, wherein the comparison result includes two cases: the newly added maximum value is less than the target minimum value, and the newly added minimum value is greater than the target maximum value; d. If the comparison result is that the newly added maximum value is less than the target minimum value, the newly added node is an alternative left child node of the target node, and it is determined whether the target node already has a left child node. If not, the newly added node is used as the left child node of the target node to be inserted into the initial search tree; if it already exists, the left child node of the target node is used as the new target node; e. If the newly added minimum value is greater than the target maximum value, the newly added node is an alternative right child node of the target node, and it is determined whether the target node already has a right child node. If not, the newly added node is inserted into the initial search tree as the right child node of the target node; if it already exists, the right child node of the target node is used as the new target node; f. Repeat steps b to e until the newly added node is inserted into the initial search tree to obtain a first search tree.
3. The efficient data retrieval method based on artificial intelligence according to claim 1, characterized in that: The calculating the balance coefficient of the nodes in the first search tree to screen abnormal nodes includes: a. Use the newly added node as a computing node; b. Calculate the balance coefficient of the computing node, the balance coefficient satisfies the relationship: in, The height of the left subtree of the computing node, the left subtree of the computing node being the branch on the left side of the tree structure with the computing node as the root node; is the height of the right subtree of the computing node, where the right subtree of the computing node is the right branch of the tree structure with the computing node as the root node; c. If the balance coefficient of the computing node is greater than a preset threshold, the computing node is regarded as an abnormal node; if the balance coefficient of the computing node is not greater than the preset threshold, it means that the computing node is a normal node, and the parent node of the computing node is regarded as a new computing node; d. Repeat steps b to c to filter abnormal nodes. When an abnormal node or a computing node is found to be the root node of the first search tree, stop filtering.
4. The efficient data retrieval method based on artificial intelligence according to claim 1, characterized in that: The rotating the abnormal node according to the preset rule to obtain the second search tree comprises: Acquire an abnormal tree structure with the abnormal node as a root node, wherein the abnormal tree structure includes the newly added node; In the abnormal tree structure, if the newly added node is in the left subtree of the left child node of the abnormal node, it is necessary to perform an LL-type rotation on the abnormal tree structure to obtain a second search tree; If the newly added node is in the right subtree of the right child node of the abnormal node, it is necessary to perform RR type rotation on the abnormal tree structure to obtain a second search tree; If the newly added node is in the right subtree of the left child node of the abnormal node, it is necessary to perform an LR rotation on the abnormal tree structure to obtain a second search tree; If the newly added node is in the left subtree of the right child node of the abnormal node, it is necessary to perform an RL type rotation on the abnormal tree structure to obtain a second search tree.
5. The efficient data retrieval method based on artificial intelligence as claimed in claim 1, characterized in that: When the target database has new data, searching the balanced search tree based on the index value of the new data to obtain the target data file includes: When there is new data in the target database, the index value of the new data is used as the new index value, and the root node of the balanced search tree is used as the search node; Comparing the newly added index value with the node information of the search node to search for the target data file, wherein the node information of the search node includes a maximum index value and a minimum index value; If the newly added index value is not greater than the maximum index value in the search node and not less than the minimum index value in the search node, the data file corresponding to the index tag in the search node is used as the target data file and the search is stopped; If the newly added index value is greater than the maximum index value in the search node, the right child node of the search node is used as a new search node to continue searching for the target data file until the target data file is obtained or all nodes of the balanced search tree are traversed; If the newly added index value is less than the minimum index value in the search node, the left child node of the search node is used as a new search node to continue searching for the target data file until the target data file is obtained or all nodes of the balanced search tree are traversed; When the search is stopped, if the target data file is not obtained, a new data file with a preset storage capacity is generated as the target data file, and the preset storage capacity reflects the amount of quantity information stored in the new data file.
6. The efficient data retrieval method based on artificial intelligence according to claim 1, characterized in that: The updating of the balanced search tree based on the updated target data file for next retrieval includes: Acquire a matching node in the balanced search tree based on the index tag of the target data file; If there is a matching node, obtaining the maximum index value and the minimum index value in the updated target data file as an updated index label, and using the updated index label as the node information of the matching node to update the balanced search tree; If there is no matching node, the index label of the target data file is used as the node information to obtain a newly added node, the node information of the newly added node is compared with the node information of all nodes in the balanced search tree to obtain a comparison result, and based on the comparison result, the newly added node is inserted into the balanced search tree to obtain an updated balanced search tree.
7. An efficient data retrieval device based on artificial intelligence, characterized in that: The device comprises: An extraction unit is used to read all data files in the target database, extract the maximum index value and the minimum index value in the same data file as the index label of each data file, wherein the data file contains multiple pieces of data information, and the data information includes index values and data content; A construction unit, used to use the index label as node information to construct a balanced search tree, including: A1, randomly selecting an index label from all index labels as the node information of the root node to construct an initial search tree; A2, randomly selecting an index label from the unselected index labels as the node information as a newly added node; A3, comparing the node information of the newly added node with the node in the initial search tree to obtain a comparison result, and inserting the newly added node into the initial search tree based on the comparison result to obtain a first search tree; A4, calculating the balance coefficient of the nodes in the first search tree to screen abnormal nodes; A5, if no abnormal node is screened, using the first search tree as a new initial search tree, if an abnormal node is screened, rotating the abnormal node according to a preset rule to obtain a second search tree, and using the second search tree as a new initial search tree; A6, repeating steps A2-A5 to continuously obtain new nodes from the remaining index labels to update the initial search tree, until all index labels are traversed and the update is stopped to obtain a balanced search tree; A search unit, configured to search the balanced search tree based on the index value of the newly added data to obtain the target data file when the target database has newly added data; a retrieval unit, configured to retrieve the target data file based on the index value of the newly added data to obtain a retrieval result, and update the target data file based on the retrieval result to obtain an updated target data file; An updating unit is used to update the balanced search tree based on the updated target data file for the next retrieval.
8. An electronic device, characterized in that: The electronic device comprises: a memory storing computer-readable instructions; and A processor executes computer-readable instructions stored in the memory to implement the artificial intelligence-based efficient data retrieval method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the efficient data retrieval method based on artificial intelligence as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Mass data united storage method based on unified indexing and search method
CN103390015A
Data index searching method and device, and related equipment
CN111984649A