Node replication method and device
By querying the node path in the database and modifying it in memory, the number of database accesses is reduced, the impact of node replication on database performance is solved, and efficient node replication operations are achieved.
Patent Information
- Application Number
- CN202310266056.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-13
- Publication Date
- 2024-09-13
AI Technical Summary
In relational databases, node replication operations frequently access the database, resulting in performance degradation.
By querying the node path to be copied from the database, modify the path field, identification field and parent node field based on the parent-child relationship of each node in the node path to form the target node path and add it to the database to reduce the number of database accesses.
The impact of node replication on database performance is reduced. Only one query and one add operation are needed to complete node replication, which improves database performance.
Smart Images

Figure CN118643095A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a node replication method and device. Background Art
[0002] Relational databases are widely used to store data. In relational databases, nodes are stored in a tree form. When a new node needs to be added to a relational database, in order to improve the efficiency of adding nodes, the new node is usually added to the database by copying the existing nodes in the database.
[0003] Currently, when copying a node, each node needs to be queried, modified, and written to the database, so that the node can be copied and added to the database. This operation method of copying nodes causes a large number of database accesses, which greatly reduces database performance. Summary of the invention
[0004] In view of this, the present application proposes a node replication method and device, the main purpose of which is to reduce the impact of node replication on database performance.
[0005] In order to achieve the above objectives, this application mainly provides the following technical solutions:
[0006] In a first aspect, the present application provides a node replication method, the node replication method comprising:
[0007] Querying a node path to be copied from a database, wherein the node path is composed of a plurality of nodes having a parent-child relationship;
[0008] Based on the parent-child relationship of each node in the node path, modify the path field, identification field and parent node field of each node in the node path to form a target node path;
[0009] The target node path is added to the database.
[0010] In some embodiments, based on the parent-child relationship of each node in the node path, the path field of each node in the node path is modified, including: extracting the node at the head of the update queue as the target node, wherein the update queue is used to add nodes in the node path whose path fields have not been modified; modifying the path field of the target node according to the path field and node name of the parent node of the target node; if the target node still has a leaf node in the node path, adding the leaf node as a node whose path field has not been modified to the update queue.
[0011] In some embodiments, after extracting the node at the head of the update queue as the target node, the method further includes: setting a mapping relationship between the target node and a parent node of the target node;
[0012] Based on the parent-child relationship of each node in the node path, modify the identification field and parent node field of each node in the node path, including: if there is no node in the update queue whose path field has not been modified, then execute for each node in the node path in turn according to the parent-child relationship between the nodes: modify the identification field of the node, and based on the mapping relationship involved in the node, modify the parent node field of the node to the latest identification field currently possessed by the parent node of the node.
[0013] In some embodiments, the path field of the target node is modified according to the path field and node name of the parent node of the target node, including: concatenating the node name of the parent node after the path field of the parent node to form a target path field; and modifying the path field of the target node to the target path field.
[0014] In some embodiments, before modifying the path field of the target node according to the path field and node name of the parent node of the target node, the method includes: if the target node is a non-leaf node in the node path, determining that the parent node of the target node is the node to be connected to the node path in the database; if the target node is a leaf node in the node path, determining that the parent node of the target node is the parent node of the target node in the node path.
[0015] In some embodiments, adding the target node path to the database includes: determining a node in the database to which the node path is to be connected; and adding a non-leaf node in the target node path as a leaf node of the determined node.
[0016] In some embodiments, the node replication method further includes: querying the database for attribute data corresponding to each node in the node path; adding corresponding attribute data to each node in the target node path based on the corresponding relationship between the target node path and the nodes in the node path;
[0017] When the target node path is added to the database, the attribute data corresponding to each node in the target node path is added to the database accordingly.
[0018] In a second aspect, the present application provides a node replication device, the node replication device comprising:
[0019] A query module, used to query a node path to be copied from a database, wherein the node path is composed of a plurality of nodes having a parent-child relationship;
[0020] A modification module, used to modify the path field, identification field and parent node field of each node in the node path based on the parent-child relationship of each node in the node path to form a target node path;
[0021] An adding module is used to add the target node path to the database.
[0022] In a third aspect, the present application provides a computer-readable storage medium, wherein the storage medium includes a stored program, wherein when the program is executed, the device where the storage medium is located is controlled to execute the node replication method of the first aspect.
[0023] In a fourth aspect, the present application provides an electronic device, comprising: a memory for storing a program; and a processor, coupled to the memory, for running the program to execute the node replication method of the first aspect.
[0024] The node replication method and device provided by the present application, when it is necessary to replicate the nodes in the database, first query the node path to be replicated from the database, and then based on the parent-child relationship of each node in the node path, modify the path field, identification field and parent node field of each node in the node path to form the target node path. Finally, add the target node path to the database. It can be seen that the solution provided by the present application can query the node path to be replicated from the database, and then modify the queried nodes outside the database, and finally add the modified node path to the database, thereby completing the replication of the node. When replicating the nodes in the database, it is only necessary to perform one query operation and one add operation on the database, which can reduce the number of times the node replication accesses the database, thereby reducing the degree of influence of the node replication on the database performance.
[0025] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0027] Figure 1 A flowchart of a node replication method provided by an embodiment of the present application is shown;
[0028] Figure 2 A schematic diagram of a tree storage structure provided by an embodiment of the present application is shown;
[0029] Figure 3 A schematic diagram of a node path provided by an embodiment of the present application is shown;
[0030] Figure 4 A schematic diagram of a tree storage structure provided by another embodiment of the present application is shown;
[0031] Figure 5 A schematic diagram of the structure of a node replication device provided by an embodiment of the present application is shown;
[0032] Figure 6 A schematic structural diagram of a node replication device provided in another embodiment of the present application is shown. DETAILED DESCRIPTION
[0033] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0034] At present, when a new node needs to be added to a relational database, in order to improve the efficiency of adding nodes, the new node is usually added to the database by copying the existing nodes in the database. When copying a node, each copy of a node requires query, modification and write operations to be performed in the database, so that the node is copied and added to the database through these operations. The existing operation method of copying nodes will cause a large number of database accesses, thereby significantly reducing database performance.
[0035] The inventor has found through research that when copying a node in a database, the node path to be copied can be queried from the database, and then the queried node can be modified outside the database (for example, in memory), and finally the modified node path is added to the database to complete the node copy. In this way, when copying a node in the database, only one query operation and one add operation need to be performed on the database, which can reduce the number of times the node copy accesses the database, thereby reducing the impact of the node copy on the database performance.
[0036] Based on the above considerations, the present invention provides a node replication method and device. The node replication method and device provided in the present invention can be applied to any database that needs to replicate nodes to reduce the impact of node replication on database performance.
[0037] The node replication method and device provided in the embodiments of the present application are described in detail below.
[0038] like Figure 1 As shown, the embodiment of the present application provides a node replication method, which mainly includes the following steps 101 to 103:
[0039] 101. Query a node path to be copied from a database, wherein the node path consists of multiple nodes having a parent-child relationship.
[0040] The database provided in the embodiment of the present application is a relational database, in which nodes are stored in a tree form through a parent-child relationship. The type of node is determined based on specific business requirements and is not specifically limited in this embodiment. Exemplarily, the type of node is any one of the following: folder type, file type.
[0041] When copying a node in a database, multiple nodes with a parent-child relationship are usually copied, and these nodes form a node path. In order to reduce the number of times the database is accessed by node replication, after determining the node path to be copied, a query operation is performed on the database to read out all the nodes involved in the node path. As a storage system, the database, all business access data operations will be converted into the IO behavior of the underlying database system, that is, read and write disk behavior. If the number of read and write disk behaviors is too many, the database performance will inevitably be greatly reduced. Therefore, the embodiment of the present application uses a query statement to batch query all the nodes involved in the node path to be copied from the database, which can reduce the number of accesses to the database and avoid affecting the performance of the database.
[0042] For example, Figure 2 As shown, Figure 2 A schematic diagram of a tree storage structure is shown. Figure 2The node information includes nodes 11 to 14. Among them, node 11 is the root node, and its corresponding node information is: the node name is root, the path field is / , the identification field is 1, and the parent node field parentuuid is none. The node information corresponding to node 12 is: the node name is c1, the path field is / root / , the identification field is 2, and the parent node field parentuuid is 1. The node information corresponding to node 13 is: the node name is c2, the path field is / root / , the identification field is uuid 3, and the parent node field parentuuid is 1. The node information corresponding to node 14 is: the node name is c3, the path field is / root / c1 / , the identification field is uuid 4, and the parent node field parentuuid is
[0043] The parentuuid field of the point is 2. Now it is determined that nodes 12 and 14 are to be copied to node 13, so the node path to be copied queried from the database is a node path composed of nodes 12 and 14, and node 12 in the node path is the parent node of node 14.
[0044] 102. Based on the parent-child relationship of each node in the node path, modify the path field, identification field and parent node field of each node in the node path to form a target node path.
[0045] In order to reduce the impact of node replication on database performance, all nodes queried from the database will be stored in memory outside the database so that replication-related modifications can be made to the nodes in memory. After the node path to be replicated is queried from the database, the path field, identification field, and parent node field of each node in the node path need to be modified.
[0046] The specific process of modifying the path field of each node in the node path based on the parent-child relationship of each node in the node path is described below. The process includes the following steps 102A to 102C:
[0047] 102A. Extract the node at the head of the update queue as the target node, wherein the update queue is used to add nodes whose path fields have not been modified in the node path.
[0048] Considering that the modification of the node path field is related to the position of the node in the node path, in order to avoid the occurrence of path field modification confusion, an update queue is constructed to realize the modification of the node path field through the node entry and exit. The update queue is used to add nodes in the node path whose path fields have not been modified.
[0049] The first node to be queued in the update queue is a non-leaf node in the node path to be copied. This non-leaf node does not have a parent node in the node path. It needs to be connected to the node in the database to be connected to the node path, so it is the first node to be queued. The subsequent nodes to be queued in the update queue are the leaf nodes of the target node that was last dequeued.
[0050] The node at the head of the update queue has its parent node in the node path modified by the path field, while its leaf node in the node path has not had its path field modified. Therefore, the node at the head of the update queue is extracted as the target node to modify the path field of the target node.
[0051] 102B. Modify the path field of the target node according to the path field and node name of the parent node of the target node.
[0052] The path field of a node reflects the position of the node in the tree storage structure. After a node is copied, its position in the tree storage structure will inevitably change. Therefore, the path field of the node needs to be modified to correspond to its position after copying.
[0053] The specific process of modifying the path field of the target node according to the path field and node name of the parent node of the target node includes: concatenating the node name of the parent node after the path field of the parent node to form the target path field; and modifying the path field of the target node to the target path field.
[0054] Before modifying the path field of the target node according to the path field and node name of the parent node of the target node, the parent node of the target node needs to be determined. The parent node of the target node is related to the position of the target node in the node path to be copied, so the method for determining the parent node of the target node includes the following two methods:
[0055] One is that, if the target node is a non-leaf node in the node path, the parent node of the target node is determined to be a node in the node path to be connected in the database.
[0056] If the target node is a non-leaf node in the node path to be copied, it means that the target node has no parent node in the node path, and it needs to be a leaf node of the node in the database to be connected to the node path. Therefore, the parent node of the target node is determined to be the node in the node path to be connected in the database.
[0057] For example, Figure 2 As shown, the node path to be copied is a node path composed of node 12 and node 14. Node 12 in the node path is the parent node of node 14. The currently selected target node is node 12, which is a non-leaf node in the node path. Figure 2The node 13 in the tree storage structure shown is connected, so the parent node of the node 12 is determined to be the node "node 13" of the node path to be connected in the database.
[0058] Another is that, if the target node is a leaf node in the node path, the parent node of the target node is determined to be the parent node of the target node in the node path.
[0059] If the target node is a leaf node in the node path to be copied, it means that the target node has a parent node in the node path, and the parent node of the target node is determined to be the parent node of the target node in the node path.
[0060] For example, Figure 2 As shown, the node path to be copied is a node path composed of node 12 and node 14, and node 12 in the node path is the parent node of node 14. The currently selected target node is node 14, and node 14 is the leaf node of node 12, so the parent node of node 14 is determined to be node 12.
[0061] The path field of the target node reflects the position of the target node in the tree storage structure. Therefore, after determining the parent node of the target node, the node name of the parent node of the target node is concatenated after the path field of the parent node of the target node to form the target path field, and the path field of the target node is modified to the target path field.
[0062] For example, the currently selected target node is node 12, and the parent node of node 12 is the node "node 13" of the node path to be connected in the database. The path field of node 13 is determined to be " / root / " and the node name of node 13 is determined to be "c2", so the node name "c2" of the parent node "node 13" of the target node "node 12" is concatenated after the path field " / root / " of the parent node "node 13", forming the target path field " / root / c2 / ". Figure 3 As shown, the path field of the target node "node 12" is modified to the target path field " / root / c2 / .
[0063] For example, the currently selected target node is node 14, and the parent node of node 14 is "node 12" in the node path. Figure 3 It is determined that the latest path field of node 12 is " / root / c2 / " and the node name of node 12 is "c1", so the node name "c1" of the parent node "node 12" of the target node "node 14" is concatenated after the path field " / root / c2 / " of the parent node "node 12" to form the target path field " / root / c2 / c1 / ". Figure 3As shown, the path field of the target node "node 14" is modified to the target path field " / root / c2 / c1 / ".
[0064] 102C. If there are leaf nodes in the node path of the target node, the leaf nodes are added to the update queue as nodes whose path fields have not been modified.
[0065] If there are still leaf nodes in the node path of the target node, it means that there are still nodes whose path fields have not been modified in the node path to be copied. Therefore, the leaf nodes are added to the update queue as nodes whose path fields have not been modified, and step 102A is continued to be executed to continue to modify the path fields of the nodes in the node path.
[0066] Furthermore, after extracting the node at the head of the update queue as the target node in the above step 102A, the node replication method may further include the following steps: setting a mapping relationship between the target node and the parent node of the target node. The mapping relationship is used to guide the update of the identification field and the parent node field of each node in the node path.
[0067] Based on the parent-child relationship of each node in the node path, modifying the identification field and the parent node field of each node in the node path specifically includes the following steps 102D:
[0068] 102D. If there is no node in the update queue whose path field has not been modified, then execute the following steps for each node in the node path in turn according to the parent-child relationship between the nodes: modify the node's identification field, and based on the mapping relationship involved in the node, modify the node's parent node field to the latest identification field currently possessed by the node's parent node.
[0069] If there is no node whose path field has not been modified in the update queue, it means that the path fields of all nodes in the node path to be copied have been modified, so the identification field and parent node field of each node in the node path can continue to be modified.
[0070] The modification order of the identification field and parent node field of the node in the node path is carried out according to the parent-child relationship between the nodes, that is, starting from the non-leaf nodes in the node path, the identification field and parent node field of the nodes in the node path are modified in turn according to the parent-child relationship between the nodes.
[0071] For the node to be modified currently: determine the identification field corresponding to the parent node of the node, and modify the identification field of the node based on the obtained identification field. In order to reflect the parent-child relationship between nodes, determine the latest identification field corresponding to the parent node of the node, and modify the parent node field of the node to the latest identification field currently possessed by the parent node of the node. In addition, it should be noted that in order to facilitate the management and control of the identification field of the node, the identification field of the node in the embodiment of the present application adopts a universal unique identification code.
[0072] For example, Figure 3 As shown, the node to be modified is "node 12". Figure 2 The identification fields of all nodes in the tree storage structure shown in , modify the identification field of node 12 to 5, that is, "the identification field uuid is 5". Determine that the parent node of "node 12" is "node 13", and the latest identification field corresponding to "node 13" is "3", then modify the parent node field of "node 12" to the latest identification field "3" currently possessed by "node 13".
[0073] For example, Figure 3 As shown, the node to be modified is "node 14". Figure 2 The identification fields of all nodes in the tree storage structure shown in the figure, modify the identification field of node 14 to 6, that is, "the identification field uuid is 6. Determine that the parent node of "node 14" is "node 12", and the latest identification field corresponding to "node 12" is "5", then modify the parent node field of "node 14" to the latest identification field "5" currently possessed by "node 12".
[0074] 103. Add the target node path to the database.
[0075] When modifying the path field, identification field and parent node field of each node in the node path, a target node path is formed. The path field, identification field and parent node field of each node in the target node path can reflect its position in the tree storage structure after copying, so the target node path is added to the database. Therefore, after forming the target node path, it is necessary to add the target node path to the database to complete the copying of the node path to be copied. The specific process of adding the target node path to the database includes: determining the nodes of the node path to be connected in the database; adding the non-leaf nodes in the target node path as leaf nodes of the determined nodes.
[0076] For example, Figure 3 The target node path is formed after modifying the path field, identification field and parent node field of each node in the node path, such as Figure 2 As shown in FIG. 1 , the node of the node path to be connected in the database is determined to be “node 13”. Figure 3 The non-leaf nodes in the target node path shown are Figure 2 , thereby completing the replication of the node path to be replicated, forming the following Figure 4 The tree storage structure shown.
[0077] Furthermore, the nodes in the database will also carry attribute data, so in order to ensure the integrity of the node replication, the attribute data of the node needs to be replicated while replicating the node. Therefore, the node replication method also includes the following steps: querying the attribute data corresponding to each node in the node path from the database; adding corresponding attribute data to the target node path based on the corresponding relationship between the target node path and the nodes in the node path; when the target node path is added to the database, the attribute data corresponding to each node in the target node path is added to the database accordingly.
[0078] After querying the node path from the database, it is also necessary to query the attribute data of each node in the node path. After obtaining the target node path, based on the correspondence between the target node path and each node in the node path, add corresponding attribute data for each node in the target node path. While adding the target node path to the database, the attributes corresponding to each node in the target node path are also added to the database accordingly, which not only completes the reuse of the node, but also ensures the integrity of the node data when reusing the node.
[0079] The node replication method provided by the embodiment of the present application, when it is necessary to replicate the nodes in the database, firstly queries the node path to be replicated from the database, and then based on the parent-child relationship of each node in the node path, modifies the path field, identification field and parent node field of each node in the node path to form the target node path. Finally, the target node path is added to the database. It can be seen that the scheme provided by the embodiment of the present application can query the node path to be replicated from the database, and then modify the node queried out outside the database, and finally add the node path formed after the modification to the database, thereby completing the replication of the node. When the database is replicated, it is only necessary to perform a query operation and an add operation on the database, so that the number of accesses to the database by node replication can be reduced, thereby reducing the degree of influence of node replication on database performance.
[0080] Furthermore, another embodiment of the present application also provides a node replication device, such as Figure 5 As shown, the node replication device includes:
[0081] A query module 21, used to query a node path to be copied from a database, wherein the node path is composed of a plurality of nodes having a parent-child relationship;
[0082] A modification module 22, configured to modify the path field, the identification field and the parent node field of each node in the node path based on the parent-child relationship of each node in the node path, so as to form a target node path;
[0083] The adding module 23 is used to add the target node path to the database.
[0084] The node replication device provided by the embodiment of the present application, when it is necessary to replicate the nodes in the database, firstly queries the node path to be replicated from the database, and then based on the parent-child relationship of each node in the node path, modifies the path field, identification field and parent node field of each node in the node path to form the target node path. Finally, the target node path is added to the database. It can be seen that the scheme provided by the embodiment of the present application can query the node path to be replicated from the database, and then modify the node queried out outside the database, and finally add the node path formed after the modification to the database, thereby completing the replication of the node. When the database is replicated, it is only necessary to perform a query operation and an add operation on the database, so that the number of accesses to the database by node replication can be reduced, thereby reducing the degree of influence of node replication on database performance.
[0085] In some embodiments of the present application, Figure 6 As shown, the modification module 22 includes:
[0086] An extracting unit 221 is used to extract the node at the head of the update queue as the target node, wherein the update queue is used to add the node whose path field has not been modified in the node path;
[0087] A modifying unit 222, configured to modify the path field of the target node according to the path field and the node name of the parent node of the target node;
[0088] The adding unit 223 is used to add the leaf node to the update queue as a node whose path field has not been modified if there is still a leaf node in the node path of the target node.
[0089] In some embodiments of the present application, Figure 6 As shown, the extraction unit 221 is further used to set a mapping relationship between the target node and the parent node of the target node after extracting the node at the head of the update queue as the target node;
[0090] The modification unit 222 is also used to execute the following steps on each node in the node path in turn according to the parent-child relationship between the nodes if there is no node in the update queue whose path field has not been modified: modify the identification field of the node, and based on the mapping relationship involved in the node, modify the parent node field of the node to the latest identification field currently possessed by the parent node of the node.
[0091] In some embodiments of the present application, Figure 6 As shown, the modification unit 222 is specifically used to concatenate the node name of the parent node after the path field of the parent node to form a target path field; and modify the path field of the target node to the target path field.
[0092] In some embodiments of the present application, Figure 6 As shown, the modification unit 222 is also used to, before modifying the path field of the target node according to the path field and node name of the parent node of the target node, if the target node is a non-leaf node in the node path, determine that the parent node of the target node is the node to be connected to the node path in the database; if the target node is a leaf node in the node path, determine that the parent node of the target node is the parent node of the target node in the node path.
[0093] In some embodiments of the present application, Figure 6 As shown, the adding unit 223 is specifically used to determine the node to be connected to the node path in the database; and add the non-leaf node in the target node path as the leaf node of the determined node.
[0094] In some embodiments of the present application, Figure 6 As shown, the query module 21 is also used to query the attribute data corresponding to each node in the node path from the database; based on the corresponding relationship between the target node path and the nodes in the node path, add corresponding attribute data to each node in the target node path;
[0095] The adding module 23 is further configured to add the attribute data corresponding to each node in the target node path to the database when the target node path is added to the database.
[0096] In the node replication device provided in the embodiment of the present application, the detailed description of the methods adopted during the operation of each functional module can be found in the corresponding detailed description of the method in the above-mentioned node replication method embodiment, which will not be repeated here.
[0097] Further, based on the above-mentioned embodiment, another embodiment of the present application also provides a computer-readable storage medium, wherein the storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the above-mentioned node replication method.
[0098] The beneficial effects of the computer-readable storage medium provided in the embodiment of the present application are substantially the same as the beneficial effects of the above-mentioned node replication method, and therefore will not be described in detail here.
[0099] Further, according to the above embodiment, another embodiment of the present application also provides an electronic device, which includes: a memory for storing programs; a processor, coupled to the memory, for running the program to execute the above node replication method.
[0100] The beneficial effects of the electronic device provided in the embodiment of the present application are basically the same as the beneficial effects of the above-mentioned node replication method, so they will not be repeated here.
[0101] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0102] It is understandable that the related features in the above methods and devices can be referenced to each other. In addition, the "first", "second" and the like in the above embodiments are used to distinguish the embodiments, but do not represent the advantages and disadvantages of the embodiments.
[0103] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0104] The algorithm and display provided herein are not inherently related to any particular computer, virtual system or other device. Various general purpose systems can also be used together with the teachings based on this. According to the above description, it is obvious to construct the structure required for this type of system. In addition, the application is not directed to any specific programming language either. It should be understood that various programming languages can be utilized to realize the content of the application described herein, and the description of the above specific language is to disclose the preferred embodiment of the application.
[0105] In addition, the memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0106] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0107] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data cutover device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data cutover device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0108] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data switching device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0109] These computer program instructions can also be loaded onto a computer or other programmable data transfer device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0110] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0111] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0112] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0113] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0114] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0115] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A node replication method, characterized in that: The method comprises: Querying a node path to be copied from a database, wherein the node path is composed of a plurality of nodes having a parent-child relationship; Based on the parent-child relationship of each node in the node path, modify the path field, identification field and parent node field of each node in the node path to form a target node path; The target node path is added to the database.
2. The method according to claim 1, characterized in that Based on the parent-child relationship of each node in the node path, modifying the path field of each node in the node path includes: Extracting the node at the head of the update queue as the target node, wherein the update queue is used to add the node whose path field has not been modified in the node path; Modify the path field of the target node according to the path field and the node name of the parent node of the target node; If there are leaf nodes in the node path of the target node, the leaf nodes are added to the update queue as nodes whose path fields have not been modified.
3. The method according to claim 2, characterized in that After extracting the node at the head of the update queue as the target node, the method further includes: setting a mapping relationship between the target node and a parent node of the target node; Based on the parent-child relationship of each node in the node path, modifying the identification field and the parent node field of each node in the node path includes: If there are no nodes in the update queue whose path fields have not been modified, then the following operations are executed for each node in the node path in turn according to the parent-child relationship between the nodes: modify the identification field of the node, and based on the mapping relationship involved in the node, modify the parent node field of the node to the latest identification field currently possessed by the parent node of the node.
4. The method according to claim 2, characterized in that: Modifying the path field of the target node according to the path field and the node name of the parent node of the target node includes: Concatenate the node name of the parent node after the path field of the parent node to form a target path field; The path field of the target node is modified to the target path field.
5. The method according to claim 2, characterized in that: Before modifying the path field of the target node according to the path field and the node name of the parent node of the target node, the method includes: If the target node is a non-leaf node in the node path, determining that the parent node of the target node is a node in the database to be connected to the node path; If the target node is a leaf node in the node path, the parent node of the target node is determined to be the parent node of the target node in the node path.
6. The method according to any one of claims 1 to 5, characterized in that Adding the target node path to the database comprises: Determine a node in the database to be connected to the node path; The non-leaf nodes in the target node path are added as leaf nodes of the determined node.
7. The method according to any one of claims 1 to 5, characterized in that The method further comprises: Query the database for attribute data corresponding to each node in the node path; Based on the correspondence between the target node path and the nodes of the node path, adding corresponding attribute data to each node in the target node path; When the target node path is added to the database, the attribute data corresponding to each node in the target node path is added to the database accordingly.
8. A node replication device, characterized in that: The device comprises: A query module, used to query a node path to be copied from a database, wherein the node path is composed of a plurality of nodes having a parent-child relationship; A modification module, used to modify the path field, identification field and parent node field of each node in the node path based on the parent-child relationship of each node in the node path to form a target node path; An adding module is used to add the target node path to the database.
9. A computer-readable storage medium, characterized in that: The storage medium includes a stored program, wherein when the program is executed, the device where the storage medium is located is controlled to execute the node replication method described in any one of claims 1 to 7.
10. An electronic device, characterized in that: The electronic device comprises: Memory, used to store programs; A processor, coupled to the memory, is used to run the program to execute the node replication method described in any one of claims 1 to claim 7.
Citation Information
Patent Citations
Data update method for distributed storage system and server
CN103518364A
Data processing method and device, electronic equipment and storage medium
CN113704294A
Method and device for efficiently maintaining full path of node and application
CN114896271A
Network data model for relational database management system
US20050097108A1
Rapid replication of sub-hierarchies from server to client computers
WO2010029540A1
