CN113590348A - Parameter transmission method, device, equipment and medium based on tree structure - Google Patents
Parameter transmission method, device, equipment and medium based on tree structure Download PDFInfo
- Publication number
- CN113590348A CN113590348A CN202110844172.7A CN202110844172A CN113590348A CN 113590348 A CN113590348 A CN 113590348A CN 202110844172 A CN202110844172 A CN 202110844172A CN 113590348 A CN113590348 A CN 113590348A
- Authority
- CN
- China
- Prior art keywords
- node
- data
- tree
- leaf
- leaf node
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 42
- 230000005540 biological transmission Effects 0.000 title claims abstract description 20
- 238000013507 mapping Methods 0.000 claims abstract description 80
- 238000004891 communication Methods 0.000 claims description 16
- 238000004590 computer program Methods 0.000 claims description 7
- 238000010276 construction Methods 0.000 claims description 5
- 238000002716 delivery method Methods 0.000 description 10
- 238000010586 diagram Methods 0.000 description 10
- 230000008569 process Effects 0.000 description 10
- 230000003993 interaction Effects 0.000 description 9
- 238000012546 transfer Methods 0.000 description 8
- 230000009471 action Effects 0.000 description 3
- 230000008859 change Effects 0.000 description 3
- 230000007547 defect Effects 0.000 description 2
- 238000011161 development Methods 0.000 description 2
- 238000007726 management method Methods 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 238000004458 analytical method Methods 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000004806 packaging method and process Methods 0.000 description 1
- 238000007493 shaping process Methods 0.000 description 1
- 239000000758 substrate Substances 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/546—Message passing systems or structures, e.g. queues
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/901—Indexing; Data structures therefor; Storage structures
- G06F16/9027—Trees
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The embodiment of the invention relates to a parameter transmission method based on a tree structure, which comprises the following steps: respectively constructing tree-shaped data structures for the source end parameters and the target end parameters to obtain a source end data tree and a target end data tree; each leaf node of the tree-shaped data structure records a node path and node data; determining a node path and node data of each leaf node of a source-end data tree; and for each leaf node of the target end data tree, assigning the node data of the leaf node of the target end data tree by utilizing the node data of the leaf node of the source end data tree according to the known mapping relation between the leaf node of the source end data tree and the leaf node of the target end data tree. The method is suitable for parameter transmission among multiple systems related to parameters of multiple different structure types without changing the structure types of the parameters, effectively improves the flexibility, reduces the complexity, reduces the time consumption, effectively improves the efficiency and reduces the cost.
Description
Technical Field
The present invention relates to the field of computers, and in particular, to a method and an apparatus for transferring parameters based on a tree structure, an electronic device, and a computer-readable storage medium.
Background
As computer software systems develop, multi-system interaction becomes generalized, and in the process of realizing the concept of the invention, the inventor finds that at least the following technical problems exist in the related technology: when interaction is carried out between multiple ends, parameters need to be transmitted for interaction of a source end and a target end, the prior art only supports transmission among parameters of the same type, or carries out simple conversion on the parameter structure type, and cannot support transmission of parameters of complex structure type, the prior art usually adopts a manual coding mode to code the parameter mapping relations of the two ends one by one, and the problems of high configuration complexity, long time consumption and low efficiency exist, and independent development is needed when the customized requirement is met, and the problem of poor flexibility exists.
Disclosure of Invention
In order to solve the technical problem or at least partially solve the technical problem, embodiments of the present invention provide a method, an apparatus, an electronic device, and a computer-readable storage medium for parameter delivery based on a tree structure.
In a first aspect, an embodiment of the present invention provides a parameter delivery method based on a tree structure. The method comprises the following steps: respectively constructing tree-shaped data structures for the source end parameters and the target end parameters to obtain a source end data tree and a target end data tree; wherein, each leaf node of the tree-shaped data structure records a node path and node data; determining a node path and node data of each leaf node of a source-end data tree; and for each leaf node of the target end data tree, assigning the node data of the leaf node of the target end data tree by utilizing the node data of the leaf node of the source end data tree according to the known mapping relation between the leaf node of the source end data tree and the leaf node of the target end data tree.
According to an embodiment of the present invention, the assigning, according to a known mapping relationship between leaf nodes of a source data tree and leaf nodes of a target data tree, node data of the leaf nodes of the source data tree to node data of the leaf nodes of the target data tree includes: determining a node path of a leaf node of a source end data tree corresponding to the leaf node of a target end data tree according to a known mapping relation between the leaf node of the source end data tree and the leaf node of the target end data tree, acquiring node data of the leaf node of the source end data tree corresponding to the leaf node of the target end data tree according to the node path, and assigning value to the node data of the leaf node of the target end data tree by using the node data according to the known mapping relation between the leaf node of the source end data tree and the leaf node of the target end data tree.
According to the embodiment of the invention, each leaf node of the tree-shaped data structure records the node path and the node data in the form of a key value structure.
According to the embodiment of the present invention, before assigning a value to each leaf node of the target-end data tree, the method further includes: and traversing from the root node of the target end data tree, executing a stacking operation on each node and judging whether the node is a leaf node, wherein if the node is the leaf node, executing a step of assigning the node data of the node, and then executing the stacking operation on the node.
According to the embodiment of the invention, the mapping relation is dynamically configurable; and/or the mapping relation comprises a one-to-one mapping relation and/or a many-to-one mapping relation; the one-to-one mapping relation comprises that node data of a leaf node of the source end data tree corresponds to node data of a leaf node of the target end data tree; the many-to-one mapping relationship comprises that node data of a plurality of leaf nodes of the source end data tree corresponds to node data of one leaf node of the target end data tree.
According to the embodiment of the invention, the mapping relation is dynamically configurable; and/or the mapping relationship comprises one-to-one mapping and many-to-one mapping, wherein the one-to-one mapping is that one source end parameter leaf node corresponds to one target end parameter leaf node, and the many-to-one mapping is that a plurality of source end parameter leaf nodes correspond to one target end parameter leaf node.
According to an embodiment of the present invention, when the mapping relationship is a one-to-one mapping, assigning the node data of the leaf node of the target end data tree includes: the node data of the leaf node of the target end data tree is equal to the node data of the corresponding leaf node of the source end data tree; when the mapping relation is many-to-one mapping, the assigning the node data of the leaf node of the target end data tree includes: and calculating the logical operation result of the node data of the corresponding leaf nodes of the source end data tree, and enabling the node data of the leaf nodes of the target end data tree to be equal to the logical operation result.
According to an embodiment of the present invention, the tree-like data structure includes one or more multi-way trees.
According to the embodiment of the present invention, the data structure types of the source-side parameter and the target-side parameter are the same or different.
In a second aspect, an embodiment of the present invention provides a parameter passing apparatus based on a tree structure. The above-mentioned device includes: the structure construction module is used for respectively constructing a tree-shaped data structure for the source end parameters and the target end parameters so as to obtain a source end data tree and a target end data tree; wherein, each leaf node of the tree-shaped data structure records a node path and node data; the node determining module is used for determining a node path and node data of each leaf node of the source end data tree; and the node assignment module is used for assigning the node data of the leaf nodes of the target end data tree by utilizing the node data of the leaf nodes of the source end data tree according to the known mapping relation between the leaf nodes of the source end data tree and the leaf nodes of the target end data tree.
In a third aspect, an embodiment of the present invention provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
a processor for implementing the method as described above when executing the program stored in the memory.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the method as described above.
Compared with the prior art, the technical scheme provided by the embodiment of the invention at least has part or all of the following advantages:
the method comprises the steps of constructing a tree-shaped data structure by using source end parameters and target end parameters, obtaining a source end data tree, a target end data tree and leaf nodes recording node paths and node data of the source end data tree and the target end data tree, determining the node paths of the leaf nodes of the source end data tree corresponding to the leaf nodes of the target end data tree according to the mapping relation between the leaf nodes of the source end data tree and the target end data tree for each leaf node of the target end data tree, obtaining the node data in the leaf nodes, assigning values to the node data of the leaf nodes of the target end data tree by using the node data, transmitting the node data of the source end parameters to the nodes of the target end parameters, traversing all the leaf nodes of the target end data tree, and realizing the parameter transmission from the source end parameters to the target end parameters.
The technical scheme realizes that the parameter transmission between the source end and the target end can be realized even in the face of parameters with different data structure types and parameters with complex data structure types during multi-end interaction, overcomes the problem that the transmission of the parameters with complex structure types cannot be supported, clearly expresses the parameters of the source end and the target end by constructing a clear tree structure, traverses leaf nodes according to a dynamically configurable mapping relation and assigns the node data of the parameters of the source end to the nodes of the parameters of the target end, automatically and configuratively realizes the multi-end parameter transmission, improves the efficiency, reduces the complexity, reduces the time consumption, effectively reduces the cost, and overcomes the defects that the complexity is high, the time consumption is long, the problem that the mapping relation of two ends is realized one by manual coding and the mapping relation of every two ends is coded one by one when the multi-end interaction is realized, The problem of inefficiency to, above-mentioned technical scheme is applicable to the parameter transmission that relates to between the parameter multiple system of multiple different structure type, and need not to change parameter structure type, thereby has effectively promoted the flexibility, has overcome and need carry out the poor problem of flexibility that singly develops when meetting the customization demand.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
In order to more clearly illustrate the embodiments or technical solutions in the prior art of the present invention, the drawings used in the description of the embodiments or prior art will be briefly described below, and it is obvious for those skilled in the art to obtain other drawings without inventive exercise.
FIG. 1 schematically illustrates a system architecture of a tree-based parameter delivery method and apparatus suitable for use in embodiments of the present invention;
FIG. 2 schematically shows a flowchart of a tree-based parameter passing method according to an embodiment of the present invention;
fig. 3 schematically shows a detailed implementation flowchart of operation S203 according to an embodiment of the present invention;
FIG. 4 is a tree structure diagram schematically illustrating source parameters according to an embodiment of the present invention;
FIG. 5 is a tree structure diagram that schematically illustrates target parameters, in accordance with an embodiment of the present invention;
FIG. 6 is a diagram illustrating a mapping relationship between leaf nodes of a source data tree and leaf nodes of a target data tree, according to an embodiment of the present invention;
FIG. 7 is a block diagram schematically illustrating a structure of a tree-based parameter passing apparatus according to an embodiment of the present invention; and
fig. 8 schematically shows a block diagram of an electronic device provided in an embodiment of the present invention.
Detailed Description
In the related art, when interaction is performed between multiple ends, parameter transmission needs to be performed on interaction of a source end and a target end, the prior art only supports transmission between some parameters of the same type, or performs some simple structural changes on the parameter type, and cannot support transmission of parameters with complex data types, the prior art generally adopts a manual coding mode to code parameter mapping relationships at two ends one by one, and the problems of high configuration complexity, long time consumption and low efficiency exist, and the problem of poor flexibility exists because independent development is needed when a customized requirement is met. For parameter transmission among multiple systems, for example, multiple systems with different parameter types, encoding the mapping relationships one by one in a manual encoding manner cannot flexibly and efficiently implement parameter transmission.
In view of this, an embodiment of the present invention provides a parameter transfer method based on a tree structure, which performs value transfer between a source-side parameter and a target-side parameter, where the source-side parameter may also be referred to as an input parameter (abbreviated as "entry parameter"), and the target-side parameter may also be referred to as an output parameter (abbreviated as "exit parameter"), and the method includes: respectively constructing tree-shaped data structures for the source end parameters and the target end parameters to obtain a source end data tree (a parameter structure) and a target end data tree (a parameter structure); each leaf node of the tree-shaped data structure records a node path and node data; determining a node path and node data of each leaf node of a source-end data tree; for each leaf node of the target end data tree, assigning the node data thereof through the following steps: determining a node path of a leaf node of a source end data tree corresponding to the leaf node of a target end data tree according to a known mapping relation between the leaf node of the source end data tree and the leaf node of the target end data tree, acquiring node data of the leaf node of the source end data tree corresponding to the leaf node of the target end data tree according to the node path, and assigning value to the node data of the leaf node of the target end data tree by using the node data according to the known mapping relation between the leaf node of the source end data tree and the leaf node of the target end data tree.
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention.
Fig. 1 schematically shows a system architecture of a tree-based parameter delivery method and apparatus suitable for use in an embodiment of the present invention.
Referring to fig. 1, a system architecture 100 of a parameter delivery method and apparatus based on a tree structure according to an embodiment of the present invention includes: terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. Various types of messaging client applications may be installed on the terminal devices 101, 102, 103, such as shopping-like applications, web browser applications, search-like applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 101, 102, 103 may be various electronic devices that display screens and support web browsing, such as electronic devices including but not limited to smart phones, tablet computers, notebook computers, desktop computers, and the like.
The server 105 may be a server providing various services, such as a background management server (for example only) providing service support for websites browsed by users using the terminal devices 101, 102, 103. The background management server may analyze and perform other processing on the received data such as the user request, and feed back a processing result (e.g., a webpage, information, or data obtained or generated according to the user request) to the terminal device.
It should be noted that the parameter delivery method based on the tree structure provided in the embodiment of the present invention can be generally executed by the terminal devices 101, 102, and 103, the server 105, or a terminal device with a certain computing capability. Accordingly, the parameter transmission apparatus based on the tree structure provided in the embodiment of the present invention may be generally disposed in the terminal devices 101, 102, and 103, the server 105, or the cloud device. The parameter delivery method based on the tree structure provided by the embodiment of the present invention may also be executed by a server or a server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and/or the server 105. Correspondingly, the parameter delivery apparatus based on the tree structure provided in the embodiment of the present invention may also be disposed in a server or a server cluster that is different from the server 105 and is capable of communicating with the terminal devices 101, 102, 103 and/or the server 105.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
A first exemplary embodiment of the present invention provides a parameter delivery method based on a tree structure.
Fig. 2 schematically shows a flowchart of a tree structure based parameter delivery method according to an embodiment of the present invention.
Referring to fig. 2, a parameter delivery method based on a tree structure according to an embodiment of the present invention includes the following operations: s201, S202 and S203. For example, the operations S201 to S203 may be performed by a terminal device or a server.
In operation S201, a tree-like data structure is respectively constructed for the source-end parameter and the target-end parameter to obtain a source-end data tree and a target-end data tree. Wherein, each leaf node of the tree-shaped data structure records a node path and node data.
Specifically, each leaf node of the tree-like data structure may record a node path and node data in the form of a key value structure. Based on a tree structure or a forest structure, leaf nodes can be expressed in a key-value structure, and each leaf node records a node path (node _ path) and node data (value), so that a leaf node can be expressed in a key-value structure of { node _ path: value }, where node _ path can be a full path of a node, node data value can be null, and can be various data such as a character string. For example, if a node path node _ path of a leaf node of the tree structure is a.a.1 and a node data value (i.e., a node value) is a "hello" string, the leaf node may be represented as a key value structure of { "a.a.1": hello "}.
Specifically, the tree-like data structure may include one or more multi-way trees, and the structure of the multi-way trees may also be referred to as a forest structure.
In operation S202, a node path and node data of each leaf node of the source data tree are determined.
In operation S203, for each leaf node of the target-side data tree, the node data of each leaf node of the target-side data tree is assigned by using the node data of the leaf node of the source-side data tree according to the known mapping relationship between the leaf node of the source-side data tree and the leaf node of the target-side data tree.
Fig. 3 schematically shows a detailed implementation flowchart of operation S203 according to an embodiment of the present invention.
Referring to fig. 3, the operation S203 for assigning node data of each leaf node of the target-end data tree includes the following operations: s2031, S2032, and S2033.
In operation S2031, a node path of a leaf node of the source data tree corresponding to the leaf node of the target data tree is determined according to a known mapping relationship between the leaf node of the source data tree and the leaf node of the target data tree.
In operation S2032, node data of a leaf node of the source-end data tree corresponding to the leaf node of the target-end data tree is obtained according to the node path.
In operation S2033, node data of a leaf node of the target end data tree is assigned by using the node data according to a known mapping relationship between the leaf node of the source end data tree and the leaf node of the target end data tree.
Based on the operations S201 to S203 and S2031 to S2033, parameter transfer from the source end parameter to the target end parameter is realized, the source end and the target end parameter are explicitly expressed by constructing a clear tree structure, and according to a dynamically configurable mapping relationship, the leaf nodes are traversed so as to assign the node data of the source end parameter to the node of the target end parameter, so that the parameter transfer from the source end to the target end is realized automatically and configurably, the efficiency is improved, the complexity is reduced, the time consumption is reduced, the cost is effectively reduced, and the flexibility is improved. The embodiment of the invention is also suitable for the source end and target end parameters expressed based on the forest structure of a plurality of multi-way trees, so that the parameter transmission from the source end parameters to the target end parameters is realized, the transmission efficiency of a large number of parameters, namely the parameters with large number of nodes, is effectively improved, and the flexibility is strong.
The operations S201 to S203 and S2031 to S2033 may be performed by a terminal device or a server of the source end, a terminal device or a server of the target end, or a device or a server such as a gateway and a cloud end that can be accessed by the source end and the target end.
Fig. 4 is a tree structure diagram schematically illustrating source parameters according to an embodiment of the present invention.
FIG. 5 is a tree structure diagram schematically illustrating target parameters according to an embodiment of the present invention.
FIG. 6 is a diagram schematically illustrating a mapping relationship between leaf nodes of a source-end data tree and leaf nodes of a target-end data tree, according to a specific embodiment of the present invention.
In the following, with reference to fig. 4 to fig. 6, an example of a process, for example, a process of passing data in a source end parameter to a target end parameter, is performed in a specific embodiment, where the tree structures in fig. 4 and fig. 5 are a source end data tree and a target end data tree that have been built, respectively.
Illustratively, the construction of the source data tree in fig. 4 may be accomplished by the following expression:
illustratively, the source-end data tree shown in fig. 4 includes two multi-way trees, i.e. A, B, where a is a complex structure including three child nodes a, B, and c, the child nodes include descendant nodes, and the node B has no child nodes, and B is a simple basic structure. The construction and the expression of the source-end data tree in the form of key values can be understood as the analysis and the explicit expression of the source-end parameter structure. The source data tree in fig. 4 clearly expresses the parameter structure of the source parameter A, B, so that the node path and node data of each leaf node of the source data tree can be determined, and the node path and node data of each node can be recorded in the form of a key value structure, for example, each leaf node of the source data tree in fig. 4 can be represented as: { "A.a.1": value "}, {" A.a.2 ": value" }, { "A.a.3": value "}, {" A.b ": value" }, { "A.c.1": value "}, {" A.c.2 ": value" }, { "B": value "}, value denotes node data of each leaf node, and may be various types of data such as a character string" world ", integer type data" 8 ", and the like, which are stored in the node. The process of constructing the source-end data tree and expressing the node path and the node data of each leaf node in the form of a key value structure can be regarded as the process of disassembling all leaf nodes based on a tree structure and assembling the node path and the node data of each leaf node.
Similarly, the target-end data tree can also be constructed and expressed through the above process, and for the case that there is no value in the leaf node of the target-end data tree, i.e. the value is empty, the target-end data tree can also be represented by a key value structure, for example, a leaf node in fig. 5 can be represented by { "a.c.3": value "}, where value is an empty value, and" a.c.3 "is a full path of the leaf node.
Illustratively, it is intended that the node data of one leaf node in fig. 5 { "a.c.3": value "}, may be assigned as follows,
firstly, according to the mapping relationship between the leaf node of the source data tree and the leaf node of the target data tree in fig. 6, determining the node path of the leaf node of the source data tree corresponding to the leaf node { "a.c.3": value "} of the target data tree, that is, according to the one-to-one mapping relationship between the leaf node path" a.c.3 "of the source data tree and the leaf node path" a.a.3 "of the target data tree queried in fig. 6, determining that the node path of the leaf node of the source data tree corresponding to the leaf node {" a.c.3 ": value" } of the target data tree is "a.a.3";
secondly, obtaining node data of leaf nodes { "a.a.3": value1 "} of the source end data tree corresponding to the leaf nodes {" a.c.3 ": value" } of the target end data tree according to the node path "a.a.3", that is, data stored in the leaf node with the path "a.c.3" in the tree structure on the left side in fig. 5, for example, the data is "value 1";
finally, according to the mapping relationship between the leaf nodes { "a.a.3": value1 "} of the source data tree and the leaf nodes {" a.c.3 ": value" } of the target data tree, assigning the node data of the leaf nodes of the target data tree by using the node data "value 1", making the node data of the leaf nodes of the target data tree equal to the node data of the corresponding leaf nodes of the source data tree, making the assigned leaf nodes of the target data tree be { "a.c.3": value1 "}, namely completing the assembly of the node paths and the node data of the leaf nodes.
In the above operation, the mapping relationship shown in fig. 6 is dynamically configurable, that is, the mapping relationship may be changed through configuration, and the specific mapping relationship may be changed according to the actual requirement in the application scenario. For example, after the parameter passing is completed for the target end data tree of one tree structure, the mapping relationship changes, if one or more corresponding relationships change, no matter what the change occurs, when the parameter passing is performed for the target end data tree of the next tree structure, corresponding operation is performed according to the current mapping relationship, that is, the changed mapping relationship.
As shown in the mapping relationship in fig. 6, it can be seen that the node data of one leaf node of the source end data tree corresponds to the node data of one leaf node of the target end data tree, i.e. one-to-one mapping. For example, the source-end data tree in fig. 6 includes 7 leaf nodes, the target-end data tree includes 8 leaf nodes, and the leaf node "a.a.2" of the source-end data tree does not have a corresponding target-end leaf node, that is, the node data in the leaf node "a.a.2" of the source-end data tree is discarded, and the value of the node "a.a.2" is not required to be assigned according to the mapping relationship. Therefore, in an actual application scenario, the parameter is transferred only by taking each leaf node of the traversal target-end data tree as a reference, the mapping relation is queried to find the corresponding leaf node of the source-end data tree, and then the parameter value is transferred, so that the technical scheme is also applicable to the situation that the number of the leaf nodes of the source-end data tree is more than that of the leaf nodes of the target-end data tree.
Optionally, in addition to the one-to-one mapping relationship shown in fig. 6, the mapping relationship further includes a many-to-one mapping relationship, that is, node data of a plurality of leaf nodes of the source end data tree corresponds to node data of one leaf node of the target end data tree. For example, when the leaf node M and the leaf node N of the source data tree in the mapping relationship are related in a certain logical relationship and correspond to one leaf node T of the target data tree, i.e., two-to-one mapping, the logical operation result of the node data of the leaf nodes M and N of the source data tree may be calculated first, if the logical relationship is addition, the values in the nodes M and N are added to obtain the operation result, and then the node data of the leaf node P of the target data tree is made equal to the logical operation result. It should be noted that, in an actual application scenario, the mapping relationship may further include a one-to-one mapping relationship, a many-to-one mapping relationship, a one-to-many mapping relationship, and various combinations of the above mapping relationships.
For example, before assigning a value to each leaf node of the target-end data tree, the above technical solution may further include, first, traversing from a root node of the target-end data tree, in this embodiment, a method of performing a preface traversal may be adopted, for example, performing a preface traversal from the root node a in fig. 5, stacking a node a, determining whether the node a is a leaf node, and finds that the node a is not a leaf node, then continuing to stack a child node c of the node a, determining whether the node c is a leaf node, and finds that the node c is not a leaf node, then continuing to stack a child node 3 of the node c, determining whether the node 3 is a leaf node, and if the node c is a leaf node, performing the foregoing assignment on the node data of the leaf node whose path is "a.c.3", that is to determine a leaf node path "a.a.3" of the data tree corresponding to the node whose path is "a.c.3" of the target-end data tree according to the mapping relationship in fig. 6, then, node data "value 1" of the leaf node { "a.a.3": value1 "is obtained according to the node path" a.a.3 ", and finally, the node data" value1 "is used to assign the node data of the leaf node of the target end data tree according to the mapping relationship, so that the leaf node of the target end data tree is {" a.c.3 ": value 1". And after the assignment operation is completed, the pop operation is executed on the node 3.
Then, the other nodes are continuously traversed, after the 3 is popped, the other child nodes of the node c are continuously pushed, such as the child node B, the child node 1, and the child node B in fig. 5 c, and the operations of pushing, assigning, and popping are sequentially performed on the three child nodes according to the sequence of the preface traversal, which is not described herein again. When the left tree structure (i.e., the left sub-tree in the forest structure) in fig. 5 is completed, traversal continues through the right tree structure (i.e., the right sub-tree).
The forest structures of the two subtrees in fig. 5 are only examples, and the tree structure according to the embodiment of the present invention may include one or more multi-way trees, that is, multiple subtrees, and after traversing all the subtrees in sequence, the traversal of the target-end data tree is completed, so that the node data in all the leaf nodes of the target-end data tree is replaced with the node data of the corresponding leaf node of the source-end data tree, that is, the transfer of the parameter from the source end to the target end is completed. In the case that the node data of the target-end data tree is empty, the node data replacement process may be further understood as placing the node data of the leaf nodes of the corresponding source-end data tree into all the leaf nodes of the target-end data tree.
Illustratively, the data structure types of the source-side parameters and the target-side parameters may be the same or different. In a practical application scenario, for example, there are three different systems: the system X, the system Y and the system Z have different parameter structure types, which are respectively as follows: shaping (belonging to a basic data type), an object data type and an object data type (object data type and character type belonging to the basic data type are nested), so that when the three systems are interacted, for example, when a system X parameter value is transmitted to a system Y parameter, the system X is a source end, the system Y is a target end, and when a system Y parameter value is transmitted to parameters of the system X and the system Z respectively, the system Y is a source end, and the system X and the system Z are both target ends.
Therefore, the parameter transfer method provided by the embodiment of the invention supports parameter transfer among a plurality of systems with different data structure types, has strong compatibility, overcomes the defects of high cost, low efficiency and the like caused by manual coding and customization of interaction among a plurality of systems with different parameter structure types in the prior art, has strong portability and wide application range, can automatically and configuratively realize parameter transfer from a source end to a target end, improves the efficiency, reduces the complexity, reduces the time consumption, effectively reduces the cost and improves the flexibility.
A second exemplary embodiment of the present invention provides a tree-structure-based parameter delivery apparatus.
Fig. 7 is a block diagram schematically illustrating a structure of a tree-based parameter passing apparatus according to an embodiment of the present invention.
Referring to fig. 7, a parameter delivery apparatus 700 based on a tree structure according to an embodiment of the present invention includes: a structure building module 701, a node determining module 702 and a node assigning module 703.
The structure building module 701 is configured to build tree-like data structures for the source end parameter and the target end parameter, respectively, so as to obtain a source end data tree and a target end data tree; wherein, each leaf node of the tree-shaped data structure records a node path and node data;
the node determining module 702 is configured to determine a node path and node data of each leaf node of the source-end data tree;
the node assignment module 703 is configured to assign a value to each leaf node of the target-end data tree by the following steps: determining a node path of a leaf node of the source end data tree corresponding to the leaf node of the target end data tree according to a known mapping relation between the leaf node of the source end data tree and the leaf node of the target end data tree, acquiring node data of the leaf node of the source end data tree corresponding to the leaf node of the target end data tree according to the node path, and assigning value to the node data of the leaf node of the target end data tree by using the node data according to the known mapping relation between the leaf node of the source end data tree and the leaf node of the target end data tree.
According to an embodiment of the present invention, the parameter passing apparatus 700 may further include a node stacking module, configured to traverse from a root node of the target-end data tree before assigning each leaf node of the target-end data tree, perform a stacking operation on each node, and determine whether the node is a leaf node, where if the node is a leaf node, the step of assigning the node data is performed, and then perform a pop operation on the node.
Any plurality of the structure building module 701, the node determining module 702, and the node assigning module 703 may be combined into one module to be implemented, or any one of the modules may be split into a plurality of modules. Alternatively, at least part of the functionality of one or more of these modules may be combined with at least part of the functionality of the other modules and implemented in one module. At least one of the structure building module 701, the node determining module 702, and the node assigning module 703 may be implemented at least partially as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented in hardware or firmware in any other reasonable manner of integrating or packaging a circuit, or may be implemented in any one of three implementations of software, hardware, and firmware, or in any suitable combination of any of them. Alternatively, at least one of the structure construction module 701, the node determination module 702 and the node assignment module 703 may be at least partially implemented as a computer program module, which when executed, may perform a corresponding function.
It should be noted that the parameter transferring apparatus 700 may be applied to multi-system interaction, and may be configured in a gateway system, or any one of multiple systems, and does not limit which of the multiple systems is specifically the source end system or the target end system in the embodiment of the present invention.
A third exemplary embodiment of the present invention provides an electronic apparatus.
Fig. 8 schematically shows a block diagram of an electronic device provided in an embodiment of the present invention.
Referring to fig. 8, an electronic device 800 according to an embodiment of the present invention includes a processor 801, a communication interface 802, a memory 803, and a communication bus 804, where the processor 801, the communication interface 802, and the memory 803 complete communication with each other through the communication bus 804; a memory 803 for storing a computer program; the processor 801 is configured to implement the parameter passing method based on the tree structure as described above when executing the program stored in the memory.
The fourth exemplary embodiment of the present invention also provides a computer-readable storage medium. The computer readable storage medium stores thereon a computer program, which when executed by a processor implements the tree structure-based parameter delivery method as described above.
The computer-readable storage medium may be contained in the apparatus/device described in the above embodiments; or may be present alone without being assembled into the device/apparatus. The computer-readable storage medium carries one or more programs which, when executed, implement the method according to an embodiment of the present invention.
According to embodiments of the present invention, the computer readable storage medium may be a non-volatile computer readable storage medium, which may include, for example but is not limited to: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In embodiments of the invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The foregoing are merely exemplary embodiments of the present invention, which enable those skilled in the art to understand or practice the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims (11)
1. A parameter transmission method based on a tree structure is characterized by comprising the following steps:
respectively constructing tree-shaped data structures for the source end parameters and the target end parameters to obtain a source end data tree and a target end data tree; each leaf node of the tree-shaped data structure records a node path and node data;
determining a node path and node data of each leaf node of a source-end data tree;
and for each leaf node of the target end data tree, assigning the node data of the leaf node of the target end data tree by utilizing the node data of the leaf node of the source end data tree according to the known mapping relation between the leaf node of the source end data tree and the leaf node of the target end data tree.
2. The method of claim 1, wherein assigning the node data of the leaf node of the target-side data tree with the node data of the leaf node of the source-side data tree according to the known mapping relationship between the leaf node of the source-side data tree and the leaf node of the target-side data tree comprises:
determining a node path of a leaf node of the source end data tree corresponding to the leaf node of the target end data tree according to the known mapping relation between the leaf node of the source end data tree and the leaf node of the target end data tree,
acquiring node data of leaf nodes of a source end data tree corresponding to the leaf nodes of the target end data tree according to the node paths,
and assigning the node data of the leaf node of the target end data tree by utilizing the node data according to the known mapping relation between the leaf node of the source end data tree and the leaf node of the target end data tree.
3. The method of claim 1, wherein each leaf node of the tree data structure records node paths and node data in the form of a key value structure.
4. The method as claimed in claim 1, before assigning, for each leaf node of the target-side data tree, a value to the node data of the leaf node of the target-side data tree using the node data of the leaf node of the source-side data tree according to a known mapping relationship between the leaf node of the source-side data tree and the leaf node of the target-side data tree, the method further comprises:
and traversing from the root node of the target end data tree, executing a stacking operation on each node and judging whether the node is a leaf node, wherein if the node is the leaf node, executing a step of assigning the node data of the node, and then executing the stacking operation on the node.
5. The method according to any of claims 1-4, wherein the mapping is dynamically configurable; and/or
The mapping relation comprises a one-to-one mapping relation and/or a many-to-one mapping relation;
the one-to-one mapping relation comprises that node data of a leaf node of the source end data tree corresponds to node data of a leaf node of the target end data tree;
the many-to-one mapping relation comprises that node data of a plurality of leaf nodes of the source end data tree correspond to node data of one leaf node of the target end data tree.
6. The method of claim 5,
when the mapping relationship is one-to-one mapping, assigning the node data of the leaf node of the target end data tree, including:
the node data of the leaf node of the target end data tree is equal to the node data of the corresponding leaf node of the source end data tree;
when the mapping relation is a many-to-one mapping, the assigning the node data of the leaf node of the target end data tree includes:
and calculating the logical operation result of the node data of the corresponding leaf nodes of the source end data tree, and enabling the node data of the leaf nodes of the target end data tree to be equal to the logical operation result.
7. A method according to any of claims 1-4, characterized in that said tree-like data structure comprises one or more multi-way trees.
8. The method according to any of claims 1-4, wherein the data structure types of the source side parameters and the target side parameters are the same or different.
9. A tree-based parameter delivery apparatus, comprising:
the structure construction module is used for respectively constructing a tree-shaped data structure for the source end parameters and the target end parameters so as to obtain a source end data tree and a target end data tree; each leaf node of the tree-shaped data structure records a node path and node data;
the node determining module is used for determining a node path and node data of each leaf node of the source end data tree;
and the node assignment module is used for assigning the node data of the leaf nodes of the target end data tree by utilizing the node data of the leaf nodes of the source end data tree according to the known mapping relation between the leaf nodes of the source end data tree and the leaf nodes of the target end data tree.
10. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor for implementing the method of any one of claims 1 to 8 when executing a program stored on a memory.
11. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the method of any one of claims 1-8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110844172.7A CN113590348B (en) | 2021-07-26 | 2021-07-26 | Parameter transmission method, device, equipment and medium based on tree structure |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110844172.7A CN113590348B (en) | 2021-07-26 | 2021-07-26 | Parameter transmission method, device, equipment and medium based on tree structure |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113590348A true CN113590348A (en) | 2021-11-02 |
CN113590348B CN113590348B (en) | 2024-05-17 |
Family
ID=78250012
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110844172.7A Active CN113590348B (en) | 2021-07-26 | 2021-07-26 | Parameter transmission method, device, equipment and medium based on tree structure |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113590348B (en) |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5632031A (en) * | 1991-03-28 | 1997-05-20 | International Business Machines Corporation | Method and means for encoding storing and retrieving hierarchical data processing information for a computer system |
CN1892602A (en) * | 2005-07-01 | 2007-01-10 | 中国科学院计算技术研究所 | Method for processing library function call in binary translation |
US20140241161A1 (en) * | 2011-09-30 | 2014-08-28 | Telefonaktiebolaget L M Ericsson (Publ) | Method and Apparatus for Controlling Data Transmission in a Communication System |
US20150317335A1 (en) * | 2014-04-30 | 2015-11-05 | International Business Machines Corporation | Generating a schema of a not-only-structured-query-language database |
CN106844877A (en) * | 2016-12-28 | 2017-06-13 | 中国人民解放军军械工程学院 | The analysis method of multimode phased mission systems dependability parameter |
CN108171283A (en) * | 2017-12-31 | 2018-06-15 | 厦门大学 | A kind of picture material automatic describing method based on structuring semantic embedding |
US20200204652A1 (en) * | 2018-12-21 | 2020-06-25 | Beijing Baidu Netcom Science And Technology Co., Ltd. | Method, apparatus and system for processing data |
CN111475511A (en) * | 2020-04-03 | 2020-07-31 | 弦子科技(北京)有限公司 | Data storage method, data access method, data storage device, data access device and data access equipment based on tree structure |
-
2021
- 2021-07-26 CN CN202110844172.7A patent/CN113590348B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5632031A (en) * | 1991-03-28 | 1997-05-20 | International Business Machines Corporation | Method and means for encoding storing and retrieving hierarchical data processing information for a computer system |
CN1892602A (en) * | 2005-07-01 | 2007-01-10 | 中国科学院计算技术研究所 | Method for processing library function call in binary translation |
US20140241161A1 (en) * | 2011-09-30 | 2014-08-28 | Telefonaktiebolaget L M Ericsson (Publ) | Method and Apparatus for Controlling Data Transmission in a Communication System |
US20150317335A1 (en) * | 2014-04-30 | 2015-11-05 | International Business Machines Corporation | Generating a schema of a not-only-structured-query-language database |
CN106844877A (en) * | 2016-12-28 | 2017-06-13 | 中国人民解放军军械工程学院 | The analysis method of multimode phased mission systems dependability parameter |
CN108171283A (en) * | 2017-12-31 | 2018-06-15 | 厦门大学 | A kind of picture material automatic describing method based on structuring semantic embedding |
US20200204652A1 (en) * | 2018-12-21 | 2020-06-25 | Beijing Baidu Netcom Science And Technology Co., Ltd. | Method, apparatus and system for processing data |
CN111475511A (en) * | 2020-04-03 | 2020-07-31 | 弦子科技(北京)有限公司 | Data storage method, data access method, data storage device, data access device and data access equipment based on tree structure |
Also Published As
Publication number | Publication date |
---|---|
CN113590348B (en) | 2024-05-17 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10447772B2 (en) | Managed function execution for processing data streams in real time | |
CN111344693B (en) | Aggregation in dynamic and distributed computing systems | |
US9634902B1 (en) | Bloom filter index for device discovery | |
US10445334B1 (en) | Query transmission in type-limited interchange formats | |
CN110019080B (en) | Data access method and device | |
WO2021023149A1 (en) | Method and apparatus for dynamically returning message | |
US11249885B2 (en) | Test case generator and user interface | |
CN107276912B (en) | Memory, message processing method and distributed storage system | |
CN113590348B (en) | Parameter transmission method, device, equipment and medium based on tree structure | |
CN107977381B (en) | Data configuration method, index management method, related device and computing equipment | |
CN109408467A (en) | A kind of method and device for realizing data storage | |
US10366059B2 (en) | Record schemas identification in non-relational database | |
US20180046656A1 (en) | Constructing filterable hierarchy based on multidimensional key | |
CN113934510A (en) | Mirror image processing method and device, electronic equipment and computer readable storage medium | |
CN115905274A (en) | Data processing method and device, electronic equipment and medium | |
CN112988738A (en) | Data slicing method and device for block chain | |
CN112311833B (en) | Data updating method and device | |
KR102648743B1 (en) | Apparatus for determining of tree, network switch apparatus, system of in-network data aggregation including the same and method thereof | |
US11514016B2 (en) | Paging row-based data stored as objects | |
US11797561B2 (en) | Reducing character set conversion | |
US20230131681A1 (en) | Extraction of relationship graphs from relational databases | |
Li et al. | A multidimensional index for range queries over Cayley‐based DHT | |
WO2023143061A1 (en) | Data access method and data access system thereof | |
US7346756B2 (en) | System, computer readable medium and method for multi-tiered data access | |
KR20220081833A (en) | Device and method for management container for process migration in orchestrator |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant |