Search

CN-114417071-B - Node state determining method, device, equipment and storage medium

CN114417071BCN 114417071 BCN114417071 BCN 114417071BCN-114417071-B

Abstract

The disclosure provides a node state determining method, device, equipment and storage medium, relates to the technical field of data processing, and particularly relates to the field of data structures and cloud services. The method comprises the steps of determining the selected number of child nodes of a father node of a target node based on the selected state of the target node under the condition that the selected state of the target node in tree data changes, and determining the selected state of the father node of the target node based on the selected number of child nodes of the father node of the target node. According to the technology disclosed by the invention, the calculation efficiency of determining the tree data selected state can be improved, and the phenomenon of calculation blocking can be reduced.

Inventors

  • LI YUAN

Assignees

  • 北京百度网讯科技有限公司

Dates

Publication Date
20260512
Application Date
20220129

Claims (9)

  1. 1. A node state determination method, comprising: Flattening the data of the tree structure to obtain tree data stored in a list form, wherein the tree data comprises a node list corresponding to a plurality of tree depth levels, and the child node information of each node and the selected number of child nodes are stored in a persistence mode in the information of each node; Responding to the determination that the selected state of the target node in the tree data changes, and acquiring a changed first selected state; determining and updating the selected number of child nodes stored in the information of the parent node of the target node based on the first selected state; determining a second selected state of the parent node based on the updated selected number of child nodes; the method further comprises the steps of: determining a second tree depth of a parent layer based on the first tree depth of the target node; And determining the father node in the nodes of the father layer by utilizing the child node information stored in the node information of each node in the father layer according to the second tree depth.
  2. 2. The method of claim 1, wherein the determining the second selected state of the parent node based on the updated number of child node selections comprises: and determining the second selected state based on the total number of child nodes of the parent node and the selected number of child nodes.
  3. 3. The method of claim 2, wherein the determining the second selected state based on the total number of child nodes of the parent node and the selected number of child nodes comprises: under the condition that the selected number of the child nodes is equal to 0, determining that the second selected state is unselected; determining the second selected state as selected if the selected number of child nodes is equal to the total number; and determining that the second selected state is half-selected in the case that the number of the selected child nodes is more than 0 and less than the total number.
  4. 4. The node state determining device comprises a preprocessing module, a processing module and a processing module, wherein the preprocessing module is used for flattening data of a tree structure to obtain tree data stored in a list form, the tree data comprises a node list corresponding to a plurality of tree depth levels, and child node information and a selected number of child nodes of each node are stored in a persistence mode in the information of each node; the first selected state acquisition module is used for responding to the determination that the selected state of the target node in the tree data changes and acquiring the changed first selected state; the child node selection quantity determining module is used for determining and updating the child node selection quantity stored in the parent node information of the target node based on the first selection state; a second selected state determining module, configured to determine a second selected state of the parent node based on the updated number of child nodes selected; the apparatus further comprises: A tree depth determining module, configured to determine a second tree depth of a parent layer based on the first tree depth of the target node; And the father node determining module is used for determining the father node in the nodes of the father layer by utilizing the child node information stored in the node information of each node in the father layer according to the second tree depth.
  5. 5. The apparatus of claim 4, wherein the second selected state determination module comprises: and the state determining unit is used for determining the second selected state based on the total number of the child nodes of the father node and the selected number of the child nodes.
  6. 6. The apparatus of claim 5, wherein the state determination unit is specifically configured to: under the condition that the selected number of the child nodes is equal to 0, determining that the second selected state is unselected; determining the second selected state as selected if the selected number of child nodes is equal to the total number; and determining that the second selected state is half-selected in the case that the number of the selected child nodes is more than 0 and less than the total number.
  7. 7. An electronic device, comprising: at least one processor, and A memory communicatively coupled to the at least one processor, wherein, The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-3.
  8. 8. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of any one of claims 1-3.
  9. 9.A computer program product comprising computer programs/instructions which, when executed by a processor, implement the method according to any of claims 1-3.

Description

Node state determining method, device, equipment and storage medium Technical Field The present disclosure relates to the field of data processing technologies, and in particular, to the field of data structures and cloud services. Background In the field of data processing, the use of tree data structures for data storage is an important means of managing one-to-many relationships between data. The tree data structure is a data structure for expressing the hierarchical relationship between data, a branch relationship is adopted to define the hierarchical structure, each node may have a plurality of child nodes, each child node has only one father node, the father node is an empty node and is a root node, each tree data structure has only one root node, and when non-root nodes are selected or cancelled in the tree data structure, the selected states of all nodes need to be calculated recursively. Disclosure of Invention The disclosure provides a node state determining method, device, equipment and storage medium. According to an aspect of the present disclosure, there is provided a node status determining method, including: Responding to the determination that the selected state of the target node in the tree data changes, and acquiring a changed first selected state; Determining the selected number of child nodes of the parent node of the target node based on the first selected state; based on the number of selections, a second selected state of the parent node is determined. According to another aspect of the present disclosure, there is provided a node status determining apparatus including: the first selected state acquisition module is used for responding to the change of the selected state of the target node in the determined tree data and acquiring the changed first selected state; The child node selection quantity determining module is used for determining the selection quantity of child nodes of the father node of the target node based on the first selection state; And the second selected state determining module is used for determining the second selected state of the father node based on the selected quantity. According to another aspect of the present disclosure, there is provided an electronic device including: at least one processor, and A memory communicatively coupled to the at least one processor, wherein, The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of the embodiments of the present disclosure. According to another aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing a computer to perform the method of any of the embodiments of the present disclosure. According to another aspect of the present disclosure, there is provided a computer program product comprising a computer program/instruction which, when executed by a processor, implements the method in any of the embodiments of the present disclosure. According to the technology disclosed by the invention, when the selected state of the target node changes, only the father node of the target node is required to be searched, and the selected state of the father node is updated by updating the selected number of the child nodes, so that the selected state update of the ancestor nodes of the target node can be recursively realized, all nodes on the whole tree do not need to be traversed and calculated, the calculation efficiency for determining the selected state of the tree data is greatly improved, and the phenomenon of calculation blocking is reduced. It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the disclosure, nor is it intended to be used to limit the scope of the disclosure. Other features of the present disclosure will become apparent from the following specification. Drawings The drawings are for a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein: FIG. 1 is a schematic diagram of a tree data structure; FIG. 2 is a flow diagram of a method of determining a node status according to an embodiment of the present disclosure; FIGS. 3A and 3B show the structure of tree data before and after flattening the tree data in FIG. 1; FIG. 4 is a second flow chart diagram of a method of determining a node status according to an embodiment of the present disclosure; FIG. 5 is a flowchart third of a node status determination method according to an embodiment of the present disclosure; FIG. 6 is a schematic diagram of a node status determining device according to an embodiment of the present disclosure; FIG. 7 is a second schematic diagram of a node status determination device according to an embodiment of the present disclosure; Fig. 8 is a block diagram of an electronic device used to implement a node status det