A method, device, equipment and storage medium for establishing an index structure
By adopting a double-layer index structure in power data retrieval, combined with B+ tree and graph storage strategies, the problem of cross-data range retrieval and disordered data processing is solved, efficient access and correlation retrieval of power data are achieved, and power efficiency is improved. System operating efficiency and stability.
Patent Information
- Application Number
- CN202110597931.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-31
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2041-05-31
AI Technical Summary
The existing inverted index and B+ tree index structures have problems such as insufficient cross-data range retrieval capabilities and difficulty in processing disordered data in power data retrieval, resulting in the data access speed and efficiency of the power information system being unable to meet the needs.
Using a double-layer index structure, by obtaining the data attributes and attribute values of power data, the upper-layer B+ tree index structure and the lower-layer index structure are established, and the orderliness of the B+ tree index structure and the correlation of the graph storage structure are used to achieve cross-data range retrieval. and efficient processing of unordered data.
It achieves efficient retrieval of power data, improves data access speed and efficiency, can effectively mine correlations between data, and improves the operational stability and performance of the power system.
Smart Images

Figure CN113190645B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of computer technology, and in particular to a method, device, equipment and storage medium for establishing an index structure. Background Art
[0002] Traditional data retrieval methods for character and numerical data are mainly divided into the following two types: inverted index and B+ tree index structure retrieval. The inverted index structure has good performance for character data retrieval, but it does not provide a good processing method for weighted index terms and cannot meet the retrieval requirements of numerical data across data ranges. The B+ tree is essentially a multi-branch tree that can effectively store data information through child nodes. The orderliness of the leaf nodes ensures that it has advantages for ordered numerical data retrieval. However, the B+ tree is not suitable for character data retrieval.
[0003] With the continuous deployment of "digital new infrastructure" decisions, the continuous growth of electricity consumption, and the large number of electrical equipment put into use, the complexity of working conditions has increased, and the volume of system information is becoming increasingly large. These data and information are diverse, with a wide range of sources, information storage types, information collection and transmission methods also showing diverse characteristics, and the demand for power data storage and access is also increasing. However, the data access speed and efficiency of the current power information system cannot meet the demand.
[0004] B+ tree is a balanced search tree designed for disks and other storage auxiliary devices. In the B+ tree, all record nodes are stored in the leaf nodes of the same layer in order of size, and each leaf node is connected by a pointer. The B+ tree algorithm can achieve the data indexing requirements of less disk I / O times involved in a single request, stable query efficiency, and efficient traversal efficiency. However, the data in the power system has obvious big data characteristics and association characteristics. Traditional retrieval methods have become stretched in the process of achieving efficient access to the massive high-frequency data generated by various businesses during the operation of the power grid. In terms of tuning the speed of power data access, the traditional approach is often to optimize a single database index or adjust a single factor. For the scenario of real-time access to massive high-frequency data, the industry's leading method is to use the storage structure of time series data in a distributed message queue to achieve high-speed writing. However, it cannot represent the association between data, and it is difficult to mine the data value information.
[0005] The inverted index cannot meet the cross-data range retrieval requirements for numerical data, and the inverted file cannot process index terms with assigned weights. Since the number of addresses required by different index terms is not fixed, it is impossible to reserve storage space of appropriate length for each data in the inverted file. In the inverted index, since the addresses listed by any index term are arranged in order, it is necessary to move half of the addresses on average when inserting and deleting data. What is more serious is that when the number of addresses exceeds the original reserved length when inserting new addresses, either an overflow area is created or the inverted file is reorganized. Both of these processes require a lot of time, resulting in a slow update speed of the inverted file. The creation of an overflow area also seriously affects the retrieval speed. The B+ tree index cannot process disordered character data. Summary of the invention
[0006] The embodiments of the present invention provide an index structure establishment method, device, equipment and storage medium to achieve the construction of a double-layer index structure based on the characteristics of power data, which can not only solve the problem of cross-data range retrieval, but also search for disordered data.
[0007] In a first aspect, an embodiment of the present invention provides a method for establishing an index structure, comprising:
[0008] Obtain data attributes and attribute values of power data;
[0009] Based on the data attributes, the attribute values, and the association relationship between the data attributes and the attribute values, an upper-level B+ tree index structure and a lower-level index structure for associative retrieval are established, wherein each leaf node in the upper-level B+ tree index structure stores keywords and link information between the leaf node and the lower-level index node and / or subgraph.
[0010] In a second aspect, an embodiment of the present invention further provides an index structure establishment device, the device comprising:
[0011] An acquisition module, used to acquire data attributes and attribute values of power data;
[0012] A module is provided for establishing an upper-level B+ tree index structure and a lower-level index structure for associative retrieval according to the data attributes, the attribute values, and the association relationship between the data attributes and the attribute values; wherein each leaf node in the upper-level B+ tree index structure stores keywords and link information between the leaf node and the lower-level index node and / or subgraph.
[0013] In a third aspect, an embodiment of the present invention further provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, an index structure establishment method as described in any one of the embodiments of the present invention is implemented.
[0014] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the index structure establishment method as described in any one of the embodiments of the present invention.
[0015] The embodiment of the present invention obtains data attributes and attribute values of power data; and establishes an upper-level B+ tree index structure and a lower-level index structure for associative retrieval according to the data attributes, the attribute values, and the association relationship between the data attributes and the attribute values, wherein each leaf node in the upper-level B+ tree index structure stores keywords and link information between the leaf node and the lower-level index node and / or subgraph, which can not only solve the problem of cross-data range retrieval, but also retrieve unordered data. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0017] Figure 1 is a flow chart of a method for establishing an index structure in an embodiment of the present invention;
[0018] Figure 1a Schematic diagram of an improved B+ tree hybrid index structure in an embodiment of the present invention;
[0019] Figure 1b It is a flow chart of the improved B+ tree hybrid indexing method in an embodiment of the present invention;
[0020] Figure 1c It is a flowchart of searching keywords for an improved B+ tree index structure in an embodiment of the present invention;
[0021] Figure 1d This is a flow chart of inserting a keyword into an improved B+ tree index structure in an embodiment of the present invention;
[0022] Figure 1e This is a flowchart of inserting a keyword into another improved B+ tree index structure in an embodiment of the present invention;
[0023] Figure 2 is a structural schematic diagram of an index structure establishment device in an embodiment of the present invention;
[0024] Figure 3 is a schematic structural diagram of an electronic device in an embodiment of the present invention;
[0025] Figure 4 It is a schematic diagram of the structure of a computer-readable storage medium containing a computer program in an embodiment of the present invention. DETAILED DESCRIPTION
[0026] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only the parts related to the present invention, rather than all structures, are shown in the accompanying drawings. In addition, the embodiments of the present invention and the features in the embodiments may be combined with each other without conflict.
[0027] It should be mentioned before discussing exemplary embodiments in more detail that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow charts describe various operations (or steps) as sequential processes, many operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of various operations can be rearranged. The process can be terminated when its operation is completed, but can also have additional steps not included in the accompanying drawings. The process can correspond to methods, functions, procedures, subroutines, subprograms, etc. In addition, the embodiments in the present invention and the features in the embodiments can be combined with each other without conflict.
[0028] The term “including” and its variations used in the present invention are open inclusions, that is, “including but not limited to.” The term “based on” means “based at least in part on.” The term “one embodiment” means “at least one embodiment.”
[0029] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings. At the same time, in the description of the present invention, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0030] Figure 1 A flowchart of a method for establishing an index structure provided by an embodiment of the present invention. This embodiment is applicable to the case of power data retrieval. The method can be executed by an index structure establishment device in an embodiment of the present invention. The device can be implemented in software and / or hardware. Figure 1 As shown, the method specifically comprises the following steps:
[0031] S110, obtaining data attributes and attribute values of power data.
[0032] The data attribute of the power data may be a data source or a data type, and the data type may be at least one of text, picture, and audio, which is not limited in the embodiment of the present invention.
[0033] Among them, the attribute value of the power data and the data attribute of the power data correspond one to one. For example, a database of the correspondence between the data attributes and attribute values of the power data is pre-established. After the data attributes of the power data are acquired, the attribute value corresponding to the data attribute of the power data is obtained by querying the database.
[0034] S120, based on the data attributes, the attribute values, and the association relationship between the data attributes and the attribute values, establish an upper-level B+ tree index structure and a lower-level index structure for associative retrieval, wherein each leaf node in the upper-level B+ tree index structure stores keywords and link information between the leaf node and the lower-level index node and / or subgraph.
[0035] Exemplarily, according to the data attributes, the attribute values, and the association relationship between the data attributes and the attribute values, the method of establishing the upper layer B+ tree index structure and the lower layer index structure for associative retrieval may be: establishing the lower layer index structure according to the attribute values; obtaining the number of folded nodes in the lower layer index structure; determining the number of leaf nodes according to the number of folded nodes; obtaining link information between folded nodes and leaf nodes; and establishing the upper layer B+ tree index structure according to the number of leaf nodes and the link information. According to the data attributes, the attribute values, and the association relationship between the data attributes and the attribute values, the method of establishing the upper layer B+ tree index structure and the lower layer index structure for associative retrieval may also be: establishing a knowledge graph according to the attribute values, wherein the knowledge graph includes: nodes representing entities or concepts and edges representing relationships, obtaining the number of folded nodes in the knowledge graph, determining the number of leaf nodes according to the number of folded nodes; obtaining link information between folded nodes and leaf nodes; and establishing the upper layer B+ tree index structure according to the number of leaf nodes and the link information. According to the data attributes, the attribute values, and the association relationship between the data attributes and the attribute values, the method of establishing the upper layer B+ tree index structure and the lower layer index structure for association retrieval can be: establishing the lower layer index structure according to the attribute values; obtaining the number of subgraphs in the lower layer index structure; determining the number of leaf nodes according to the number of subgraphs; obtaining the link information between the subgraphs and the leaf nodes; and establishing the upper layer B+ tree index structure according to the number of leaf nodes and the link information. The embodiment of the present invention does not limit this.
[0036] Optionally, according to the data attributes, the attribute values, and the association relationship between the data attributes and the attribute values, an upper layer B+ tree index structure and a lower layer index structure for associated retrieval are established, including:
[0037] Establishing a lower index structure according to the attribute value;
[0038] Obtaining the number of collapsed nodes in the lower index structure;
[0039] Determine the number of leaf nodes according to the number of folded nodes;
[0040] Get the link information of collapsed nodes and leaf nodes;
[0041] An upper-level B+ tree index structure is established according to the leaf node quantity and link information.
[0042] The method of determining the number of leaf nodes according to the number of folded nodes may be that the number of folded nodes is the same as the number of leaf nodes. For example, if the number of folded nodes is 4, the number of leaf nodes is 4.
[0043] The method for obtaining the number of folded nodes in the lower index structure may be: obtaining the attribute information of each node in the lower index structure, and selecting one node from the nodes with the same attribute as a folded node. The method for obtaining the number of folded nodes in the lower index structure may also be: presetting a folding rule, and determining the number of folded nodes in the lower index structure according to the folding rule and the lower index structure, which is not limited in the embodiment of the present invention.
[0044] Among them, the method for obtaining the link information of the folding node and the leaf node can be: obtaining the link relationship between the folding node and the corresponding leaf node, generating link information according to the link relationship between the folding node and the corresponding leaf node, for example, it can be folding node A, folding node B, folding node C and folding node D, establishing 4 leaf nodes: leaf node E, leaf node F, leaf node G and leaf node H, obtaining the link information between folding node A and leaf node E, the link information between folding node B and leaf node F, the link information between folding node C and leaf node F, and the link information between folding node D and leaf node G.
[0045] Exemplarily, an upper-level B+ tree index structure is established according to the number of leaf nodes and link information, for example, it may include: folding node A, folding node B, folding node C and folding node D. According to the number of folding nodes being 4, 4 leaf nodes are established: leaf node E, leaf node F, leaf node G and leaf node H. The link information of folding node A and leaf node E is obtained, and the keywords and link information in folding node A are stored in leaf node E. The link information of folding node B and leaf node F is obtained, and the keywords and link information in folding node B are stored in leaf node F. The link information of folding node C and leaf node F is obtained, and the keywords and link information in folding node C are stored in leaf node F. The link information of folding node D and leaf node G is obtained, and the keywords and link information in folding node D are stored in leaf node G.
[0046] Exemplarily, data attributes and attribute values of power data are obtained, and a knowledge graph is constructed according to the attribute values, wherein the knowledge graph includes nodes representing entities or concepts and edges representing relationships; a folding rule is established, wherein the folding rule can be for selecting nodes with the same attributes to form a subgraph in the knowledge graph structure, and selecting one of the nodes as a folding node; the number of folded nodes is obtained according to the knowledge graph structure, and the corresponding number of leaf nodes in the upper-level B+ tree structure is allocated according to the number of folded nodes; according to the space required for each leaf node, the corresponding memory space is divided for the upper-level B+ tree index structure to store the node domain and control domain of each leaf node; the keywords stored in the folded nodes are stored in the node domain of the corresponding leaf nodes, link information is generated according to the link relationship between the leaf nodes and the folded nodes, and the link information is stored in the control domain of the leaf nodes.
[0047] In the embodiment of the present invention, in view of the characteristics of power data, the index structure is designed to create indexes of different structures for data of different data types. On the basis of traditional indexes, the idea of hierarchical indexing is introduced to separate the data attributes and attribute values in the power data set to construct a double-layer index structure. Figure 1aAs shown, the number of subtrees of each leaf node in the B+ tree index structure generated by the first layer is less than or equal to the order of the B+ tree index structure, the number of subtrees included in each branch of the B+ tree index structure is greater than or equal to the order of the B+ tree index structure, and the B+ tree index structure has at least two subtrees except for the leaf nodes. In the B+ tree index structure, the number of each leaf node is the same as the number of keywords of the leaf node, and the number of keywords contained in the leaf node is greater than or equal to one-half of the subtree. The leaf node is used to store the keyword of the node and the pointer to the subgraph or node corresponding to the keyword. The leaf nodes are linked in order of the size of the keyword value, and all leaf nodes are in one layer. All branch nodes include the demarcation value of the keyword with the largest value or the keyword with the smallest value in the child node of the branch node and a pointer to the demarcation value. The second-level index is a knowledge graph of electric power data established for the attribute values corresponding to the first-level attributes, which can reasonably integrate and utilize electric power information, and save time and cost when the relevant data platform retrieves electric power information as needed. The knowledge graph includes nodes representing entities or concepts and edges representing relationships, where both nodes and edges of the knowledge graph have attributes. The nodes of the knowledge graph can be entities: referring to something that is distinguishable and exists independently. Such as a person, a city, a plant, a commodity, etc. It can also be a concept, which mainly refers to a collection, a category, an object type, a type of thing, such as people, geography, etc. The nodes of the knowledge graph can also be content; usually the names, descriptions, explanations, etc. of entities and semantic classes can be expressed by text, images, audio and video, etc. The node attributes of the knowledge graph point from an entity to its attributes. "Area", "Population", "Capital" are several different attributes. The attribute value mainly refers to the value of the object's specified attribute, such as 9.6 million square kilometers. The edges of the knowledge graph represent the relationship between nodes. Furthermore, the relationship can be the relationship between two people. For example, the relationship between two people includes: father and daughter, teacher and student, friends, etc. The relationship of the knowledge graph can also be a general relationship between concepts. Further, it can be the relationship between "occupation" and "gender". The attributes of edges in the knowledge graph include strength values, which represent the strength of the relationship between two nodes. For example, if the communication and email exchanges between a user and his / her associates are relatively close, the edge strength value is high.
[0048] In a specific example, Figure 1bAs shown, the power data is obtained through knowledge extraction, knowledge fusion, data model construction and quality assessment to form a power information graph. Knowledge fusion is the process of integrating multiple knowledge bases to form a knowledge base, and the main problem to be solved is entity alignment. The data model is the data framework of the knowledge graph, and different knowledge graphs will use different data models. For the knowledge graph of the power industry, the industry terms and industry data are relatively clear, and the knowledge graph can be constructed in a top-down manner, that is, the data model of the knowledge graph is first determined, and then the data is supplemented according to the agreed framework of the data model to complete the construction of the knowledge graph. The final result data is evaluated and the qualified data is put into the knowledge graph. A folding rule is established, and nodes with the same attributes are selected to form a subgraph in the knowledge graph structure, and one of the nodes is selected as a folding node. The folding rules described here can be determined according to different application fields. For example, for power data, it can be divided according to the different categories of information described by the data. Transformer information can be used as a folding point, and nodes with the same attributes as it constitute a subgraph in the knowledge graph structure. The number of folded nodes is obtained according to the knowledge graph structure. The number of leaf nodes of the first-layer B+ tree is allocated according to the number of collapsed nodes, and the node includes a node domain and a control domain. In the example of the present invention, since the index can be either a subgraph index in the knowledge graph or an index of each node in the knowledge graph. If the index of the subgraph is created, the number of nodes is obtained according to the number of subgraphs; if the index of the node in the graph is created, the number of leaf nodes is obtained according to the number of node records. In the example of the present invention, the node includes a node domain and a control domain. The node domain is used to store node information, which is the collapsed node or the keyword of the node; the control domain is used to store pointer information, and the pointer information here includes but is not limited to pointers to other nodes and pointers to subgraphs or nodes corresponding to the keyword. According to the memory space required for each node, the corresponding memory space is divided to store the node domain and control domain of each node. In the example of the present invention, due to the different sizes of nodes, the size of the occupied storage space is different. After calculating the memory space occupied by each node, the corresponding memory space is divided to store the node domain and control domain of each node. For example, the memory space from memory address 0X00 to 0X11 is used to store the node domain of the first node. The keyword of the folding point is stored in the node domain of the node, and the pointer information is stored in the control domain of the node, so as to generate indexes of each node and B+ tree. In the example of the present invention, the leaf node is used to store the node keyword and the pointer to the subgraph or node record corresponding to the keyword, or to store the maximum keyword of each file after the data file is segmented and the pointer to the maximum keyword record. The link relationship between the upper B+ tree leaf node domain and the folding node is established according to the corresponding relationship. In the example of the present invention, an efficient and stable indexing method is provided through an improved B+ tree hybrid index.It not only improves the stability of the graph database, but also improves the performance of the graph database, allowing users to access the real-time database more quickly.
[0049] Optionally, also include:
[0050] Determine the space occupied by each leaf node according to the upper B+ tree index structure;
[0051] Divide the node domain and control domain of each leaf node according to the space occupied by each leaf node;
[0052] storing the power data stored in the folded node in the node domain of the leaf node corresponding to the folded node;
[0053] The link information is stored in a control field of a leaf node corresponding to the link information.
[0054] Optionally, also include:
[0055] Get the keywords to be searched entered by the user;
[0056] Query the upper layer B+ tree index structure according to the keyword to be searched, and obtain the target leaf node corresponding to the keyword to be searched;
[0057] The lower index structure is queried according to the link information stored in the target leaf node to obtain the power data corresponding to the keyword to be retrieved.
[0058] Exemplarily, the upper-level B+ tree index structure may be queried according to the keyword to be retrieved, and the target leaf node corresponding to the keyword to be retrieved may be obtained by comparing the keyword to be retrieved corresponding to the subgraph or node to be retrieved with all the keywords of each leaf node in the B+ tree index structure layer by layer until a keyword identical to the keyword to be retrieved is retrieved in the target leaf node.
[0059] Get the keyword to be deleted, query the node where the keyword to be deleted is located, if the number of keywords in the node where the keyword to be deleted is located is greater than half of the order of the node, directly delete the pointer of the subgraph or node corresponding to the keyword; if the number of keywords in the node where the keyword to be deleted is located is equal to half of the order of the node, move one or more keywords from the sibling nodes of the node where the keyword to be deleted is located to the node where the keyword to be deleted is located, so that the number of keywords contained in the node where the keyword to be deleted and its sibling nodes are basically the same.
[0060] The embodiment of the present invention creates an improved B+ tree hybrid index structure retrieval method based on a graph storage strategy, comparing the keyword to be retrieved with all the keywords of each leaf node in the B+ tree layer by layer until a keyword identical to the keyword to be retrieved is retrieved in the leaf node.
[0061] In a specific example, the B+ tree index structure established is as follows Figure 1c As shown in the figure, the keywords of the subgraphs or nodes in the knowledge graph are represented by English letters, and the leaf nodes are linked according to the size of the keyword value. It is necessary to search for the keyword G to be searched in this B+ tree. The specific search method is as follows:
[0062] Compare the keyword G to be searched with the keyword P in the root node. If G is less than P, jump to the node in the second layer containing keywords F and J according to the pointer in the node. Compare the keyword G to be searched with keywords F and J. After it is found that G is greater than F and less than J, follow the pointer to the node in the third layer and search for keyword G in the node in the third layer. Find a pointer to the corresponding keyword in the leaf node containing keyword G.
[0063] Compare the keyword V to be searched with the keyword P in the root node. If V is greater than P, jump to the node containing keyword U according to the pointer in the node, compare the keyword G to be searched with keyword U. If the keyword V to be searched is greater than keyword U, follow the pointer to enter the node of the third layer and search for keyword V in the node of the third layer. And find a pointer pointing to the corresponding keyword in the leaf node containing keyword V.
[0064] Compare the keyword Q to be searched with the keyword P in the root node. If Q is greater than P, jump to the node containing keyword U according to the pointer in the node, and compare the keyword Q to be searched with keyword U. If the keyword Q to be searched is less than keyword U, follow the pointer to enter the node of the third layer and search for keyword Q in the node of the third layer. And find a pointer pointing to the corresponding keyword in the leaf node containing keyword Q.
[0065] Compare the keyword B to be searched with the keyword P in the root node. If B is less than P, jump to the node in the second layer containing keywords F and J according to the pointer in the node. Compare the keyword B to be searched with keywords F and J. After it is found that B is less than F, follow the pointer to the node in the third layer and search for keyword B in the node in the third layer. Find a pointer to the corresponding keyword in the leaf node containing keyword B.
[0066] Compare the keyword M to be searched with the keyword P in the root node. If M is less than P, jump to the node in the second layer containing keywords F and J according to the pointer in the node. Compare the keyword B to be searched with keywords F and J. After M is greater than F, follow the pointer to the node in the third layer and search for keyword M in the node in the third layer. Find a pointer to the corresponding keyword in the leaf node containing keyword M.
[0067] In the example of the present invention, since only leaf nodes are used to store the keywords of nodes and the pointers corresponding to the keywords, when searching in the B+ tree index structure, if the keywords contained in the leaf nodes are equal to the keywords to be searched, the search is not terminated. Instead, the search continues downward in the graph storage structure until the information to be searched is found or the corresponding storage area is traversed.
[0068] Optionally, querying the upper B+ tree index structure according to the keyword to be searched to obtain a target leaf node corresponding to the keyword to be searched includes:
[0069] Compare the keyword to be retrieved with the root node in the upper B+ tree index structure;
[0070] The target leaf node corresponding to the keyword to be searched is determined according to the comparison result.
[0071] Optionally, also include:
[0072] Get the keyword to be inserted entered by the user;
[0073] Compare the keyword to be inserted with the root node in the upper B+ tree index structure;
[0074] Determine the insertion position of the keyword to be inserted according to the comparison result;
[0075] According to the insertion position, the keyword is inserted into the corresponding leaf node.
[0076] Exemplarily, the method of comparing the keyword to be inserted with the root node in the upper B+ tree index structure can be: compare the keyword G to be inserted with the keyword P in the root node, and if it is found that G is less than P, then jump to the node in the second layer containing keywords F and J according to the pointer in the node. Compare the keyword G to be inserted with keywords F and J, and after it is found that G is greater than F and less than J, follow the pointer to enter the node of the third layer, and insert the keyword G to be inserted into the node of the third layer.
[0077] Compare the keyword V to be inserted with the keyword P in the root node. If V is greater than P, jump to the node containing the keyword U according to the pointer in the node, and compare the keyword G to be inserted with the keyword U. If the keyword V to be inserted is greater than the keyword U, follow the pointer to enter the node of the third layer and insert the keyword V to be inserted into the node of the third layer.
[0078] Compare the keyword Q to be inserted with the keyword P in the root node. If Q is greater than P, jump to the node containing keyword U according to the pointer in the node and compare the keyword Q to be inserted with keyword U. If the keyword Q to be inserted is less than keyword U, follow the pointer to enter the node of the third layer and insert the keyword Q to be inserted into the node of the third layer.
[0079] Compare the keyword B to be inserted with the keyword P in the root node. If B is less than P, jump to the node in the second layer containing keywords F and J according to the pointer in the node. Compare the keyword B to be inserted with keywords F and J. After it is found that B is less than F, follow the pointer to enter the node in the third layer and insert the keyword B to be inserted into the node in the third layer.
[0080] Compare the keyword M to be inserted with the keyword P in the root node. If M is less than P, jump to the node in the second layer containing keywords F and J according to the pointer in the node. Compare the keyword B to be inserted with keywords F and J. After M is greater than F, follow the pointer to enter the node in the third layer and insert the keyword M to be inserted into the node in the third layer.
[0081] In a specific example, since the leaf nodes are linked in the order of the size of the keywords, the keywords to be inserted are inserted into the corresponding leaf nodes according to the size of their values. There are two points to note:
[0082] First, if the leaf node corresponding to the keyword to be inserted contains the number of keywords less than or equal to the order of the leaf node after adding the keyword to be inserted, then the keyword is directly inserted into the corresponding leaf node.
[0083] Second, if the leaf node corresponding to the keyword to be inserted plus the keyword to be inserted contains more keywords than the order of the leaf node, the leaf node needs to be split. The specific splitting method is:
[0084] The leaf node corresponding to the keyword to be inserted is split into two nodes. The number of keywords contained in these two nodes is: (m+1) / 2 is an integer obtained by rounding down, and (m+1) / 2 is an integer obtained by rounding up. Among them, m is the node order. At this time, it is judged whether the parent node of the leaf node satisfies the condition that the number of keywords contained in the parent node is less than or equal to the order of the parent node. If it is satisfied, the insertion process ends; if not, the parent node is split according to the above method until all nodes meet the condition that the number of keywords contained is less than or equal to the node order.
[0085] like Figure 1d and Figure 1e As shown, if according to Figure 1dAs shown in the figure, if E is directly inserted into the first leaf node on the left, the leaf node will not satisfy the requirement that the number of keywords contained in the node is less than or equal to the order of the node, causing an error. Figure 1e The method shown splits the leaf node where E is located, so that the leaf node where E is located is divided into two nodes, one containing keywords A and B, and the other containing keywords C, D and E, so that the number of keywords contained in these two leaf nodes is less than or equal to the node order.
[0086] Optionally, establishing a lower-level index structure according to the attribute value includes:
[0087] A knowledge graph is established according to the attribute values, wherein the knowledge graph includes: nodes representing entities or concepts and edges representing relationships.
[0088] In a specific example, in view of the characteristics of power data, a knowledge graph is constructed based on the acquired power data. The knowledge graph consists of nodes representing entities or concepts and edges representing relationships. A hierarchical indexing idea is introduced on the basis of traditional indexing to construct a double-layer index structure. According to the data attributes, the attribute values, and the association relationship between the data attributes and the attribute values, an upper B+ tree index structure and a lower index structure for associated retrieval are established. In the process of establishing the upper B+ tree index structure, each index word appears only once in the leaf node of the B+ tree, eliminating the phenomenon of keyword duplication in the general B+ tree index structure. The pointer corresponding to each index word in the leaf node points to the node and / or subgraph with the same attribute in the next layer of knowledge graph. The lower index structure can be a knowledge graph, and the nodes of the knowledge graph can be entities: refers to something that is distinguishable and exists independently. Such as a certain person, a certain city, a certain plant, and a certain commodity. It can also be a concept, which mainly refers to a collection, a category, an object type, and a type of thing, such as a person, a geography, etc. The nodes of the knowledge graph can also be content: usually as the names, descriptions, explanations, etc. of entities and semantic classes, which can be expressed by text, images, audio and video, etc. The attributes of the edges in the knowledge graph include directionality and strength values. Among them, the strength value of the edge indicates the strength of the relationship between the two nodes, and different attributes correspond to different types of attribute edges. Since the B+ tree index has no corresponding solution for the retrieval of unordered character data, in order to better represent the association characteristics between data, the structure of the B+ tree is integrated with the graph storage structure, providing a new method and new idea for data retrieval.
[0089] Since the inverted index cannot complete the retrieval requirements of numerical values across data ranges, the problem of cross-data range retrieval is effectively solved by constructing a knowledge graph structure between power data to establish the association relationship between data.
[0090] Efficient access to power big data can ensure the normal operation of the power system and is also one of the key supporting technologies for improving the operational efficiency of power grid enterprises. Since the traditional B+ tree does not take into account the relevance of power information fragments and cannot flexibly design data indexes, an improved B+ tree hybrid index structure indexing method based on a graph storage strategy is proposed, that is, the first layer of the index structure uses a B+ tree structure to store attributes, and the second layer uses a graph storage structure to store attribute values, thereby realizing the associative indexing of power data. The improved B+ tree hybrid index structure can realize the index retrieval method of power big data covering associative information without affecting the retrieval efficiency, providing a technical reference for the future efficient retrieval of multimodal data.
[0091] The technical solution of this embodiment is to obtain data attributes and attribute values of power data; and establish an upper-level B+ tree index structure and a lower-level index structure for associative retrieval based on the data attributes, the attribute values, and the association relationship between the data attributes and the attribute values, wherein each leaf node in the upper-level B+ tree index structure stores keywords and link information between the leaf node and the lower-level index node and / or subgraph, which can not only solve the problem of cross-data range retrieval, but also retrieve unordered data.
[0092] Figure 2 This is a schematic diagram of a structure of an index structure establishment device provided by an embodiment of the present invention. This embodiment is applicable to the case of power data retrieval. The device can be implemented in software and / or hardware. The device can be integrated in any device that provides an index structure establishment function, such as Figure 2 As shown, the index structure establishing device specifically includes: an acquisition module 210 and a establishing module 220.
[0093] Wherein, the acquisition module is used to obtain data attributes and attribute values of power data;
[0094] A module is provided for establishing an upper-level B+ tree index structure and a lower-level index structure for associative retrieval according to the data attributes, the attribute values, and the association relationship between the data attributes and the attribute values; wherein each leaf node in the upper-level B+ tree index structure stores keywords and link information between the leaf node and the lower-level index node and / or subgraph.
[0095] The above-mentioned product can execute the method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0096] The technical solution of this embodiment is to obtain data attributes and attribute values of power data; and establish an upper-level B+ tree index structure and a lower-level index structure for associative retrieval based on the data attributes, the attribute values, and the association relationship between the data attributes and the attribute values, wherein each leaf node in the upper-level B+ tree index structure stores keywords and link information between the leaf node and the lower-level index node and / or subgraph, which can not only solve the problem of cross-data range retrieval, but also retrieve unordered data.
[0097] Figure 3 FIG. 4 is a schematic diagram of the structure of an electronic device in an embodiment of the present invention. Figure 3 A block diagram of an exemplary electronic device 12 suitable for use in implementing embodiments of the present invention is shown. Figure 3 The electronic device 12 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0098] like Figure 3 As shown, the electronic device 12 is in the form of a general purpose computing device. The components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that connects various system components (including the system memory 28 and the processing unit 16).
[0099] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures. For example, these architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MCA) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
[0100] The electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.
[0101] The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 3 not shown, usually called a "hard drive"). Although Figure 3 Not shown in the figure, a disk drive for reading and writing a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing a removable non-volatile optical disk (Compact Disc-Read Only Memory, CD-ROM, Digital Video Disc-Read Only Memory, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The system memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of various embodiments of the present invention.
[0102] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. Program modules 42 generally perform the functions and / or methods of the embodiments described herein.
[0103] The electronic device 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), and may also communicate with one or more devices that enable a user to interact with the electronic device 12, and / or communicate with any device that enables the electronic device 12 to communicate with one or more other computing devices (e.g., network card, modem, etc.). Such communication may be performed through an input / output (I / O) interface 22. In addition, the electronic device 12 in this embodiment, the display 24 does not exist as an independent individual, but is embedded in the mirror surface. When the display surface of the display 24 is not displayed, the display surface of the display 24 and the mirror surface are visually integrated. In addition, the electronic device 12 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN) and / or a public network, such as the Internet) through a network adapter 20. As shown in the figure, the network adapter 20 communicates with other modules of the electronic device 12 through a bus 18. It should be understood that although not shown in the figures, other hardware and / or software modules may be used in conjunction with the electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, disk arrays (Redundant Arrays of Independent Disks, RAID) systems, tape drives, and data backup storage systems.
[0104] The processing unit 16 executes various functional applications and data processing by running the programs stored in the system memory 28, for example, implementing the index structure establishment method provided in the embodiment of the present invention:
[0105] Obtain data attributes and attribute values of power data;
[0106] Based on the data attributes, the attribute values, and the association relationship between the data attributes and the attribute values, an upper-level B+ tree index structure and a lower-level index structure for associative retrieval are established, wherein each leaf node in the upper-level B+ tree index structure stores keywords and link information between the leaf node and the lower-level index node and / or subgraph.
[0107] Figure 4 Schematic diagram of the structure of a computer-readable storage medium containing a computer program in an embodiment of the present invention. The embodiment of the present invention provides a computer-readable storage medium 61 on which a computer program 610 is stored. When the program is executed by one or more processors, the index structure establishment method provided in all the embodiments of the present invention is implemented:
[0108] Obtain data attributes and attribute values of power data;
[0109] Based on the data attributes, the attribute values, and the association relationship between the data attributes and the attribute values, an upper-level B+ tree index structure and a lower-level index structure for associative retrieval are established, wherein each leaf node in the upper-level B+ tree index structure stores keywords and link information between the leaf node and the lower-level index node and / or subgraph.
[0110] Any combination of one or more computer-readable media can be used. Computer-readable media can be computer-readable signal media or computer-readable storage media or any combination of the above two. Computer-readable storage media can be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: electrical connections with one or more wires, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In this document, computer-readable storage media can be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device.
[0111] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0112] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0113] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (Hyper Text Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0114] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0115] Computer program code for performing the operation of the present invention may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0116] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0117] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, limit the unit itself.
[0118] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0119] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0120] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A method for establishing an index structure, characterized in that: include: Obtain data attributes and attribute values of power data; According to the data attributes, the attribute values, and the association relationship between the data attributes and the attribute values, an upper layer B+ tree index structure and a lower layer index structure for associative retrieval are established, wherein each leaf node in the upper layer B+ tree index structure stores a keyword and link information between the leaf node and the lower layer index node and the subgraph; The step of establishing an upper layer B+ tree index structure and a lower layer index structure for associative retrieval according to the data attributes, the attribute values, and the associative relationship between the data attributes and the attribute values includes: Establishing a lower index structure according to the attribute value; Obtaining the number of collapsed nodes in the lower index structure; Determine the number of leaf nodes according to the number of folded nodes; Get the link information of collapsed nodes and leaf nodes; Establishing an upper layer B+ tree index structure according to the leaf node quantity and link information; Among them, a folding rule is established, and the folding rule is to select nodes with the same attributes to form a subgraph in the knowledge graph structure, and select one of the nodes as a folding node; obtain the number of folding nodes according to the knowledge graph structure, allocate the corresponding number of leaf nodes in the upper B+ tree structure according to the number of folding nodes, and divide the corresponding memory space for the upper B+ tree index structure to store the node domain and control domain of each leaf node according to the space required for each leaf node; wherein the space occupied by each leaf node is determined according to the upper B+ tree index structure; store the keywords stored in the folding node in the node domain of the corresponding leaf node, generate link information according to the link relationship between the leaf node and the folding node, and store the link information in the control domain of the leaf node.
2. The method according to claim 1, characterized in that Also includes: Get the keywords to be searched entered by the user; According to the keyword to be searched, the upper layer B+ tree index structure is queried to obtain a target leaf node corresponding to the keyword to be searched; The lower index structure is queried according to the link information stored in the target leaf node to obtain the power data corresponding to the keyword to be retrieved.
3. The method according to claim 2, characterized in that Querying the upper layer B+ tree index structure according to the keyword to be searched, obtaining the target leaf node corresponding to the keyword to be searched includes: Compare the keyword to be retrieved with the root node in the upper B+ tree index structure; The target leaf node corresponding to the keyword to be searched is determined according to the comparison result.
4. The method according to claim 1, characterized in that: Also includes: Get the keyword to be inserted entered by the user; Compare the keyword to be inserted with the root node in the upper B+ tree index structure; Determine the insertion position of the keyword to be inserted according to the comparison result; According to the insertion position, the keyword is inserted into the corresponding leaf node.
5. The method according to claim 1, characterized in that Establishing a lower index structure according to the attribute value includes: A knowledge graph is established according to the attribute values, wherein the knowledge graph includes: nodes representing entities or concepts and edges representing relationships.
6. An index structure establishment device, characterized in that: include: An acquisition module, used to acquire data attributes and attribute values of power data; An establishment module is used to establish an upper layer B+ tree index structure and a lower layer index structure for associative retrieval according to the data attributes, the attribute values, and the association relationship between the data attributes and the attribute values; wherein each leaf node in the upper layer B+ tree index structure stores a keyword and link information between the leaf node and the lower layer index node and the subgraph; The establishment module is specifically used for: Establishing a lower index structure according to the attribute value; Obtaining the number of collapsed nodes in the lower index structure; Determine the number of leaf nodes according to the number of folded nodes; Get the link information of collapsed nodes and leaf nodes; Establishing an upper layer B+ tree index structure according to the leaf node quantity and link information; Among them, a folding rule is established, and the folding rule is to select nodes with the same attributes to form a subgraph in the knowledge graph structure, and select one of the nodes as a folding node; obtain the number of folding nodes according to the knowledge graph structure, allocate the corresponding number of leaf nodes in the upper B+ tree structure according to the number of folding nodes, and divide the corresponding memory space for the upper B+ tree index structure to store the node domain and control domain of each leaf node according to the space required for each leaf node; wherein the space occupied by each leaf node is determined according to the upper B+ tree index structure; store the keywords stored in the folding node in the node domain of the corresponding leaf node, generate link information according to the link relationship between the leaf node and the folding node, and store the link information in the control domain of the leaf node.
7. An electronic device, characterized in that: include: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the processors are enabled to implement the method according to any one of claims 1 to 5.
8. A computer-readable storage medium containing a computer program, wherein the computer program is stored thereon, characterized in that: When the program is executed by one or more processors, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
B+ tree indexing method and device of real-time database
CN102402602A
Vector retrieval technology combining spatial division tree and neighbor graph
CN110110186A
