Tree data depth calculation and level control method and system based on mapping table

By constructing a parent-child relationship mapping table and using key-value lookup to backtrack the calculation node depth value, the computational performance and user interaction issues in large-scale tree structure data scenarios are solved, achieving efficient hierarchical control and rule maintenance.

CN123178368APending Publication Date: 2026-11-27GUANGZHOU JIXIN AUTOMOBILE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611437866.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-16
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Existing technologies suffer from low computational performance, poor rule maintainability, and unsatisfactory user experience in deep computing and hierarchical management scenarios, especially as the number of nodes increases. The risk of recursive call stack overflow is high, and the hierarchical judgment logic is highly coupled and has high maintenance costs.

Method used

A mapping table-based approach is adopted to construct a parent-child relationship mapping table. The node depth value is calculated by looking up the table with key values ​​and then compared with the preset level threshold to determine the level control. This decouples the depth calculation logic from the level control rules and supports dynamic configuration and fast response.

Benefits of technology

It reduces the risk of stack overflow from recursive calls, improves computational performance and rule maintainability, enhances user interaction experience, and supports efficient hierarchical management in large-scale data scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123178368A_ABST
    Figure CN123178368A_ABST
Patent Text Reader

Abstract

The application discloses a tree data depth calculation and level control method and system based on a mapping table, relates to the technical field of data processing, and comprises the following steps: acquiring a flat node list, and constructing tree structure data based on the flat node list; constructing a parent-child relationship mapping table based on the tree structure data, wherein the parent-child relationship mapping table is used for storing a key-value mapping relationship with a node identifier as a key and a parent node identifier as a value; performing table lookup and backtracking in the parent-child relationship mapping table along a parent node chain based on a parent node identifier of a target node, and calculating a depth value of the target node in the tree structure data; and obtaining a level control judgment result of the target node according to a comparison result of the depth value and a preset level threshold, wherein the level control judgment result is used for controlling an executable state of a child node adding operation. The application improves the usability of a tree structure data management system in a large-scale data scene, and takes into account the calculation performance, rule maintainability and user interactive experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and in particular to a method and system for depth calculation and hierarchical management of tree data based on mapping tables. Background Technology

[0002] In enterprise management systems, tree-structured data is a common organizational form for business objects such as product categories, organizational structures, and knowledge base directories. In order to control the complexity of the hierarchy and standardize data entry, the system usually needs to determine whether each node is allowed to continue adding child nodes, thereby dynamically managing the overall hierarchical depth of the tree-structured data.

[0003] Current practices typically involve recursively manipulating nested tree structure objects, traversing the child node chain from the root node down layer by layer to obtain the depth of the target node in the tree, and comparing the obtained depth value with the pre-agreed maximum allowed level to determine the executable state of the child node addition operation.

[0004] As the scale of tree-structured data expands and the hierarchy deepens, the depth of the recursive call stack grows synchronously. When the number of nodes exceeds a thousand, there is a risk of triggering the call stack limit. Furthermore, each depth retrieval for a single node requires traversing the entire subtree again. Its time complexity is positively correlated with the total number of nodes in the subtree. In high-frequency scenarios such as list rendering and button display, where each node needs to be repeatedly determined, the computational overhead is significantly amplified, resulting in sluggish interface operation response and reduced user interaction smoothness.

[0005] Furthermore, the logic used to determine the hierarchy is usually written in conjunction with the button show / hide conditions in the template. The maximum allowed hierarchy is scattered in multiple conditional expressions in literal form. When the hierarchy control rules are adjusted, they need to be modified synchronously in multiple places across files, which is easy to miss and has high maintenance costs. In the tree selection control that carries the parent selection, the top level relies on the implicit convention that "not selecting any parent node means creating a new top level node". Users cannot intuitively distinguish between "top level" and "a certain level of child" in the control, resulting in a high error rate in parent selection.

[0006] The aforementioned issues collectively cause the deep computation and hierarchical management of tree-structured data to fail to balance computational performance, rule maintainability, and user interaction experience as the node scale grows, thus restricting the usability of tree-structured data management systems in large-scale data scenarios. Summary of the Invention

[0007] To overcome the shortcomings of existing technologies and improve the usability of tree-structured data management systems in large-scale data scenarios, this application provides a method and system for deep computation and hierarchical management of tree-structured data based on mapping tables, which can balance computational performance, rule maintainability, and user interaction experience as the node scale grows.

[0008] Firstly, the objective of this invention is achieved through the following technical solution: Methods for depth calculation and hierarchical management of tree-structured data based on mapping tables include: Get a list of flat nodes, and construct a tree-structured data based on the list of flat nodes; A parent-child relationship mapping table is constructed based on the tree structure data. The parent-child relationship mapping table is used to store key-value mapping relationships with node identifiers as keys and parent node identifiers as values. Based on the parent node identifier of the target node, a lookup and backtracking is performed along the parent node chain in the parent-child relationship mapping table to calculate the depth value of the target node in the tree structure data; Based on the comparison between the depth value and the preset level threshold, the level control determination result of the target node is obtained. The level control determination result is used to control the executable state of the child node addition operation.

[0009] By adopting the above technical solution, the flat node list is constructed as a tree structure data, and a parent-child relationship mapping table is built on it with node identifier as key and parent node identifier as value. This separates the parent-child relationship between nodes from the nested subtree structure, forming an independent key-value retrieval structure. Based on this, for any target node, its depth value in the tree structure data can be obtained by performing a step-by-step lookup and backtracking along the parent node chain from its parent node identifier. There is no need to recursively traverse the entire subtree. The time cost of obtaining the depth of a single node is reduced from the order of magnitude related to the total number of subtree nodes to the order of magnitude related to the level of the target node itself. In high-frequency scenarios such as list rendering and button state refresh where the number of nodes reaches tens of thousands or more, and where a single node is repeatedly judged, the interface response latency is significantly reduced, and the risk of stack overflow is avoided. Furthermore, this application encapsulates the comparison result between the depth value and the preset level threshold into an independent level control judgment result, which is used to carry out the executable state of the child node addition operation, thereby decoupling the depth calculation logic from the level control rules. When the business side needs to adjust the maximum allowed level, the level control judgment results of all nodes can be updated synchronously by modifying the single-point parameter of the preset level threshold. This avoids the omissions and maintenance costs caused by repeatedly modifying multiple conditional expressions. Ultimately, in the scenario of large-scale tree structure data, it takes into account the performance of depth calculation, the dynamic configurability of level control rules, and the overall maintainability of the tree structure data management system, which is conducive to improving the user interaction experience.

[0010] In a preferred embodiment of this application, the construction of the parent-child relationship mapping table based on the tree structure data includes: The tree structure data is flattened to obtain a linear list of nodes with a depth-first preorder traversal order. Traverse the list of linear nodes and establish the key-value mapping relationship for each node in the parent-child relationship mapping table to obtain the parent-child relationship mapping table covering all nodes; The parent-child relationship mapping table is constructed in the form of a responsive computed attribute, which depends on the tree structure data. When the tree structure data undergoes a change event such as adding, deleting, or modifying nodes, the generation of the linear node list and the establishment of the key-value mapping relationship are re-executed based on the changed tree structure data to obtain the reconstructed parent-child relationship mapping table.

[0011] By adopting the above technical solution, a parent-child relationship mapping table constructed in the form of reactive computed attributes is disclosed, which directly binds the dependency relationship to the tree structure data itself. When the tree structure data undergoes changes such as adding, deleting, or modifying nodes, the linear node list is automatically regenerated and the key-value mapping relationship is re-established without the need for explicit triggering of synchronization logic in the business code. This eliminates the risk of inconsistency between the mapping table and the tree data caused by manual synchronization omissions. Furthermore, the flattening process strictly follows the depth-first preorder traversal order to output the linear node list, ensuring that the establishment order of the key-value mapping relationship is consistent with the parent-child topology, providing a topologically consistent data foundation for subsequent table lookup and backtracking along the parent node chain.

[0012] In a preferred embodiment of this application: the method of calculating the depth value of the target node in the tree structure data by looking up and backtracking along the parent node chain in the parent-child relationship mapping table based on the parent node identifier of the target node includes: Initialize the depth accumulation variable to 1, and use the parent node identifier of the target node as the current trace identifier; Based on the current traceability identifier, a lookup operation is performed in the parent-child relationship mapping table. When the current traceability identifier satisfies the conditions of being non-empty, non-root termination value, and existing in the parent-child relationship mapping table, the depth accumulation variable is incremented by 1, and the parent node identifier obtained from the lookup is updated to the new current traceability identifier, and the next round of lookup backtracking begins. When the current traceability identifier does not meet the aforementioned conditions, the backtracking is terminated, and the value of the depth accumulation variable is obtained as the depth value; During the table lookup backtracking process, an access node set is maintained simultaneously. The access node set is used to record the identifiers of ancestor nodes that have been visited. Before each round of the table lookup operation, it is determined whether the current tracing identifier already exists in the access node set. If it exists, it is determined that the tree structure data has a parent ring structure, the backtracking is immediately terminated, and the current depth accumulation variable is returned as the depth value. If it does not exist, the current tracing identifier is added to the access node set, and the next round of table lookup backtracking begins.

[0013] By adopting the above technical solution, the depth acquisition is transformed from recursive calls to key-value lookup within a loop, so that the call stack depth does not accumulate with the growth of the target node level, avoiding the risk of stack overflow in large-scale tree structure data scenarios. Furthermore, the access node set maintained synchronously during the backtracking process deduplicates the ancestor node identifiers that have been visited. Once a duplicate identifier is hit, it is immediately determined that a parent cycle exists and the backtracking is terminated. The worst-case execution steps under dirty data are strictly limited to the height range of the tree structure data, avoiding the main thread from getting stuck in an infinite loop under the circular parent relationship due to the naive table lookup backtracking.

[0014] In a preferred embodiment of this application, obtaining the hierarchical control determination result of the target node based on the comparison result between the depth value and the preset hierarchical threshold includes: The independently encapsulated layer determination function is called to compare the depth value with the preset layer threshold and obtain the Boolean layer control determination result. Based on the hierarchical control judgment result, control the display and response states of operation controls added to child nodes in the page rendering layer; The preset level threshold is defined in the form of configurable parameters, and the maximum allowed level can be dynamically changed based on the adjustment of the parameter value; When the tree structure data changes, the parent-child relationship mapping table is reconstructed based on the changed tree structure data, and the depth value of each target node and the hierarchical control judgment result are recalculated based on the reconstructed parent-child relationship mapping table.

[0015] By adopting the above technical solution, the independently encapsulated layer determination function concentrates the comparison operation between the depth value and the preset layer threshold into a single function output. This creates a one-way connection between the output logic of the layer control determination result and the display and response states of the operation controls added to the child nodes in the page rendering layer. This avoids the layer determination conditions being scattered across multiple conditional expressions in the template. Furthermore, the preset layer threshold is defined as a configurable parameter. Adjusting the maximum allowed layer only requires changing the value of a single parameter to affect the layer control determination result of all target nodes, significantly reducing the cross-file maintenance cost when changing layer control rules.

[0016] In a preferred embodiment, this application also includes a virtual root node injection step: A virtual root node is constructed based on the original tree data. The virtual root node has a preset root node identifier and a root node display name, and the preset root node identifier is consistent with the root termination value in the parent-child relationship mapping table. The original tree data is mounted as a set of child nodes of the virtual root node to obtain display tree data containing the virtual root node; The tree selection control is rendered based on the displayed tree data, and the virtual root node is set to the default expanded state to provide a top-level visual guidance entry point in the parent node selection operation. When the selected item of the tree selection control is the virtual root node, the parent node identifier of the target node is assigned the root termination value, and the level of the target node is positioned as the top level.

[0017] By adopting the above technical solution, the virtual root node injection step maintains consistency between the preset root node identifier and the root termination value in the parent-child relationship mapping table. This ensures that the original tree data, after being mounted as a set of virtual root node child nodes, remains naturally compatible with the termination conditions of table lookup backtracking, without introducing additional branching logic for top-level selection scenarios. Furthermore, the virtual root node is presented in a default expanded state in the tree selection control, transforming the original top-level selection, which relied on the implicit convention of "not selecting a parent node means creating a new top-level node," into an explicit and clickable visual guidance entry. This eliminates semantic ambiguity in the user's parent node selection operation and reduces the error rate of top-level creation.

[0018] In a preferred embodiment of this application: the query front-end of the parent-child relationship mapping table is configured with a prefetch weight vector, which is obtained through the following method: Based on the number of descendant nodes, current depth, and historical query hit count of each node in the tree structure data, a baseline prefetch weight vector is established. Collect the short-term fluctuation amplitude of the frequency of the child node addition operation and the density of the occurrence of the hierarchical control judgment result of the over-limit state, and establish a modulation mapping from the short-term fluctuation amplitude and the density of occurrence to the pre-fetched weight perturbation amount; The output of the modulation mapping is superimposed on the reference prefetch weight vector to obtain the prefetch weight vector that is dynamically updated as the child node is added. The set of top ancestor node identifiers is selected in descending order of the weights of the prefetched weight vector and preloaded into the memory cache. The prefetched weight vector is then dynamically updated based on the deviation feedback.

[0019] By adopting the above technical solution, the prefetch weight vector adopts a hierarchical construction mechanism. The benchmark matrix, combined with the number of descendant nodes of each node, the current depth value, and the historical query hit count, depicts the static distribution of query hotspots in the parent-child relationship mapping table. The modulation mapping adds the short-term fluctuation amplitude of the frequency of child node addition operations and the density of occurrence of the hierarchical control judgment result of the over-limit state to the benchmark matrix in real time, so that the prefetch weight dynamically drifts with the rhythm of business operations. Furthermore, the set of top ancestor node identifiers selected in descending order of weight is preloaded into the memory cache, which significantly improves the key-value table lookup hit rate on the high-frequency backtracking path and reduces the single memory access overhead of table lookup backtracking in large-scale tree structure data scenarios.

[0020] In a preferred embodiment of this application: the visualization display terminal for the tree structure data is configured with a multi-level rendering detail module with adjustable detail levels. The multi-level rendering detail module includes multiple detail levels, each of which is sequentially configured as one or more combinations of full attribute rendering, partial attribute omission, deep node placeholders, and deep subtree folding aggregation; the method further includes: Based on the tree structure data, the proportion of nodes with a depth value greater than the set interest depth and the rate of change of the node proportion within a set time window are used to predict the arrival time of deep node expansion and the covered subtree in subsequent time slices, thus forming the spatiotemporal distribution prediction result of deep node expansion. Among the candidate detail levels that meet the display requirements of the deep node expansion spatiotemporal distribution prediction results, the one with the highest rendering energy efficiency ratio is taken as the target detail level. The rendering energy efficiency ratio is the ratio of the total number of node attribute fields participating in the final rendering to the view rendering time. Based on the arrival time of the deep node expansion and the set rendering advance, the start time of the switching of the target level of detail is determined. The set rendering advance is not less than the sum of the switching response time and the view redraw duration, and the set rendering advance is dynamically updated according to the deviation feedback. At the start of the switching, the system switches to the target level of detail and then switches back to the high level of detail level step by step after the deep node expansion is complete.

[0021] By adopting the above technical solutions, in order to improve the user interaction experience and display effect of the visualization of tree structure data, the multi-level rendering detail level module predicts the spatiotemporal distribution of the arrival time of deep node expansion and the covered subtree by the proportion of nodes with depth values ​​greater than the set attention depth and the rate of change of the node proportion. This aligns the timing of the detail level switching with the subtree expansion rhythm, avoiding the adaptation imbalance of the fixed folding threshold on different topological subtrees. Furthermore, the ratio of the total number of node attribute fields participating in the final rendering to the view rendering time is used as the rendering energy efficiency ratio for selection, taking into account both the completeness of the displayed information and the view rendering overhead. Combined with a set rendering lead of not less than the sum of the switching response time and the view redrawing time, the target detail level is switched before the deep node expansion actually arrives, avoiding instantaneous lag on the display end.

[0022] Secondly, the objective of this invention is achieved through the following technical solution: A tree-structured data depth calculation and hierarchical management system based on mapping tables includes: The tree data construction module is used to obtain a list of flat nodes and construct a tree structure data based on the list of flat nodes. The mapping table construction module is used to construct a parent-child relationship mapping table based on the tree structure data. The parent-child relationship mapping table is used to store key-value mapping relationships with node identifiers as keys and parent node identifiers as values. The depth calculation module is used to perform a lookup and backtracking along the parent node chain in the parent-child relationship mapping table based on the parent node identifier of the target node, and calculate the depth value of the target node in the tree structure data. The hierarchical control module is used to obtain the hierarchical control judgment result of the target node based on the comparison result between the depth value and the preset hierarchical threshold. The hierarchical control judgment result is used to control the executable state of the child node addition operation.

[0023] Thirdly, the objective of this invention is achieved through the following technical solution: A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described method for depth calculation and hierarchical management of tree data based on a mapping table.

[0024] Fourthly, the objective of this invention is achieved through the following technical solution: A computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the above-described method for tree-based data depth calculation and hierarchical management based on a mapping table.

[0025] In summary, this application includes at least one of the following beneficial technical effects: 1. This application constructs a parent-child relationship mapping table based on a flat node list, with node identifiers as keys and parent node identifiers as values. It transforms the acquisition of node depth from a recursive traversal of the entire subtree to a key-value lookup backtracking along the parent node chain. This reduces the computational complexity of a single node's depth from an order of magnitude related to the total number of subtree nodes to an order of magnitude related to the target node's own level, avoiding the risk of stack overflow caused by the expansion of the recursive call stack as the node size grows. At the same time, the comparison result between the depth value and the preset level threshold is output as an independent level control judgment result, decoupled from the executable state of the child node addition operation. This allows the adjustment of the maximum allowed level to take effect globally by changing only a single threshold parameter, without the need to modify multiple conditional expressions simultaneously, thus balancing computational performance and the maintainability of level control rules in large-scale tree structure data scenarios. 2. The technical solution of this application takes into account the performance of deep computing, the dynamic configurability of hierarchical control rules, and the overall maintainability of the tree structure data management system in the scenario of large-scale tree structure data, which is conducive to improving the user interaction experience. Attached Figure Description

[0026] Figure 1 This is a flowchart of a tree-based data depth calculation and hierarchical management method based on a mapping table in one embodiment of this application; Figure 2 This is another flowchart in one embodiment of the tree data depth calculation and hierarchical control method based on mapping table in this application; Figure 3 This is a schematic diagram of a device according to one embodiment of this application. Detailed Implementation

[0027] The present application will be further described in detail below with reference to the accompanying drawings.

[0028] In the field of tree-structured data management in computer software, tree-structured data is a common organizational form for enterprise-level business objects such as product categories, organizational structures, and knowledge base directories. The hierarchical control of node addition operations directly determines the standardization of the data structure and the smoothness of the system interaction experience.

[0029] In related technologies, a recursive approach is generally used to traverse the child node chain from the root node downwards layer by layer to obtain the depth of the target node in the tree. As the node size expands, the recursive call stack expands synchronously, and there is a risk of triggering the call stack limit when the number of nodes exceeds a thousand. At the same time, the logic used to determine the level is usually written in conjunction with the button display conditions in the template. The maximum allowed level is scattered in multiple conditional expressions in literal form, and rule adjustments require synchronous modification in multiple places across files. In addition, the top level relies on the implicit convention that "not selecting any parent node means creating a new top level node", and users cannot intuitively distinguish between the top level and the child level in the parent selection control.

[0030] This application is primarily applied to hierarchical management scenarios for tree-like data such as product categories and organizational structures in enterprise-level management systems. In these scenarios, the number of tree nodes often reaches thousands or even tens of thousands. In these applications, each scroll or page turn on the list page triggers a depth determination of all visible nodes and a refresh of button states. If the overhead of obtaining the depth of a single node cannot be reduced, interface lag is unavoidable. Simultaneously, the maximum allowed hierarchy needs to be flexibly adjusted according to business evolution, and the selection of the parent of the top-level hierarchy also requires an intuitive visual entry point. To solve the above technical problems, this application provides a method for tree-like data depth calculation and hierarchical management based on a mapping table. The following example demonstrates this method in conjunction with... Figure 1 This application describes a method for calculating the depth and hierarchy of tree data based on a mapping table, which specifically includes the following steps: S1: Obtain the list of flat nodes and construct a tree structure data based on the list of flat nodes.

[0031] In this embodiment, step S1 transforms the relational data format on the backend storage side into a hierarchical data format that can be directly consumed by the frontend presentation layer. A flat node list refers to a one-dimensional set of nodes returned by the backend interface, with node identifiers and parent node identifiers as the smallest units; tree structure data refers to an array of objects with nested hierarchical forms, where parent and child nodes are linked by a child node set field.

[0032] Specifically, the process first retrieves a list of flat nodes from the backend via a pagination request interface. Each entry in the list must contain at least the fields of node identifier, parent node identifier, display name, and sorting number. The returned results are then deserialized and validated to remove entries with missing key fields. Next, a mature "flat-to-tree" conversion utility function (such as handleTree in an open-source project) is called with the node identifier as the primary key and the parent node identifier as the foreign key. After two traversals, the parent and child nodes are mounted, generating a tree structure data with a complete set of child node fields. Finally, the tree structure data is bound to a reactive data source for subsequent display and computation processes to share and consume.

[0033] S2: Construct a parent-child relationship mapping table based on tree structure data. The parent-child relationship mapping table is used to store key-value mapping relationships with node identifier as the key and parent node identifier as the value.

[0034] In this embodiment, the parent-child relationship mapping table refers to a key-value retrieval container that strips the nested structure of child node sets and only carries parent-level attribution information; internally, it uses node identifiers as keys and parent node identifiers as values, supporting single-step O(1) average complexity retrieval with node identifiers as input parameters and corresponding parent node identifiers as output parameters; the key-value mapping relationship refers to a one-way mapping pair that is uniquely located by node identifiers and uses parent node identifiers as lookup results. One-way means that it only supports "child→parent" retrieval and does not assume the responsibility of "parent→child" reverse retrieval, the latter of which is carried by the child node set field of the tree structure data itself; the linear node list refers to a one-dimensional node sequence that is output in depth-first preorder traversal order, ensuring that any parent node is located before a child node; the responsive computational attribute refers to a derived data structure that automatically triggers re-evaluation based on changes in source data, and its core feature is dependency tracking and lazy evaluation; the change event of the tree structure data refers to the collective term for three types of discrete events triggered by business operations: adding nodes, deleting nodes, or modifying nodes.

[0035] Specifically, step S2 includes: S21: Flatten the tree structure data to obtain a linear list of nodes with a depth-first preorder traversal order.

[0036] In this embodiment, starting from the root node of the tree structure data, the current node is visited first and written to the end of the linear node list. Then, each child node in the child node set of the current node is recursively visited in turn. The child nodes are also recursively expanded according to the aforementioned rules until all nodes have been visited once. At this time, the index of any parent node in the linear node list must be less than the index of its descendant nodes.

[0037] S22: Traverse the list of linear nodes and establish a key-value mapping relationship for each node in the parent-child relationship mapping table to obtain a parent-child relationship mapping table covering all nodes.

[0038] S23: The parent-child relationship mapping table is constructed in the form of a reactive computed property, which depends on the tree structure data. When the tree structure data undergoes changes such as adding, deleting, or modifying nodes, the linear node list is regenerated and the key-value mapping relationship is established based on the changed tree structure data to obtain the reconstructed parent-child relationship mapping table.

[0039] In this embodiment, each node is traversed in the order of the linear node list. For each node, an insertion operation is performed in the parent-child relationship mapping table container (preferably using ES6 native Map) with its own node identifier as the key and its parent node identifier as the value. After traversal, a parent-child relationship mapping table covering all nodes in the tree structure data is obtained. Then, the complete process of the above flattening and key-value mapping establishment is encapsulated in the reactive computed property. The reactive computed property exposes only a read-only value retrieval interface to the outside world, and internally implements dependency binding for the tree structure data. The registration of dependency binding is automatically completed by the framework's dependency collection mechanism when the reactive computed property is first read downstream. Finally, when the tree structure data triggers a change event due to the addition, deletion, or modification of nodes, the framework's reactive scheduler detects the change of dependency source, automatically marks the reactive computed property as dirty, and re-executes the generation of the linear node list and the establishment of key-value mapping relationship on the next read, to obtain the reconstructed parent-child relationship mapping table. The reconstruction result is transparent and visible to the downstream table lookup backtracking process.

[0040] Specifically, the specific carrier for reactive computed properties should be selected based on the front-end framework ecosystem. Parallel implementation methods include: in the Vue ecosystem, implementation using computed properties, with dependency tracking automatically handled by Vue's reactive system; in the React ecosystem, implementation using the useMemo hook or a selector provided by the reselect library, with dependencies explicitly declared as an array; and in the MobX ecosystem, implementation using getters decorated with @computed, with dependency tracking automatically handled by MobX's observer mechanism. All three carriers can satisfy the core semantics of "automatic recalculation triggered by changes in source data." The choice primarily depends on the framework stack of the host application and does not constitute a substantial impact on the technical solution of this step. There are also several parallel implementation methods for the storage container of the parent-child relationship mapping table. ES6 native Map, ordinary object literals, or WeakMap can be used. Among them, Map is more suitable for large-scale node scenarios because it has a stable key-value enumeration order, O(1) average query complexity, and native support for keys of any type. Ordinary object literals have comparable performance in scenarios where all key-value pairs are strings, but there is a risk of prototype chain pollution. WeakMap cannot be enumerated due to the weak reference characteristics of key-value pairs, and is not suitable for scenarios that require a full traversal of the mapping table. The depth-first preorder traversal order on which the flattening process is based is necessary: ​​this order ensures that when any node is written to the mapping table, its parent node identifier has been established in the tree structure data, avoiding the inversion of key-value mapping relationships. If the breadth-first traversal order is used instead, the parent node may be processed later than the child node. Although the result is equivalent for pure key-value insertion operations, once subsequent extended logic that needs to read the parent node's already entered state is introduced (such as synchronously calculating the descendant count of the parent node), a timing defect of reading null values ​​will occur.

[0041] The output of linear node lists can be implemented in several parallel ways, including recursive stack traversal, explicit stack iteration traversal, and in-situ expansion using existing open-source utility functions (such as the depth-first traversal tool in the lodash library or the treeToList utility function encapsulated within the project). All three methods are completely equivalent in the key-value mapping establishment process. The choice mainly depends on whether the tree depth might trigger the upper limit of the recursive call stack; in extremely deep tree scenarios, the explicit stack iteration method should be preferred. Once bound, reactive computed properties form a unidirectional dependency link of "tree structure data → parent-child relationship mapping table." Business code does not need to explicitly call any synchronization logic after adding, deleting, or modifying nodes, eliminating the risk of the mapping table becoming disconnected from the tree data due to missed manual synchronization. Furthermore, the lazy evaluation characteristic of reactive computed properties ensures that reconstruction is only triggered when the downstream actually reads the data. In scenarios where tree structure data is modified multiple times consecutively within a single business transaction, repeated reconstruction will not occur, naturally possessing batching capabilities aligned with the granularity of business transactions. Furthermore, the granularity of change events can be either whole-tree replacement (reassigning the entire tree to a new reference) or partial field modification (modifying only the child node collection field of a node). The reactive framework can correctly capture dependency changes and trigger rebuilds under both granularities, without requiring business code to handle them separately for different granularities.

[0042] S3: Based on the parent node identifier of the target node, perform a table lookup and backtracking along the parent node chain in the parent-child relationship mapping table to calculate the depth value of the target node in the tree structure data.

[0043] In this embodiment, the parent node chain refers to the sequence of ancestor node identifiers starting from the parent node of the target node, passing through its ancestor nodes, and ending at the root node; table lookup backtracking refers to the iterative process of repeatedly taking values ​​in the parent-child relationship mapping table with the current trace identifier as the query key to jump upwards level by level; the depth accumulation variable refers to a positive integer counter that carries the number of levels traversed during the backtracking process, with an initial value of 1 corresponding to the depth value of the root node; the current trace identifier refers to the ancestor node identifier to be looked up in this iteration, with an initial value of the parent node identifier of the target node; the root termination value refers to a special value in the parent-child relationship mapping table that is used to identify the end point of the backtracking, generally zero or an empty string, consistent with the encoding convention of the top-level node parent node identifier in the back-end storage layer; the access node set refers to a deduplication container used to carry the ancestor node identifiers that have been traversed and supporting O(1) complexity member determination; the parent ring structure refers to an A→B→A type or longer cyclic parent reference chain that appears in the tree structure data under abnormal conditions.

[0044] Specifically, step S3 includes: S31: Initialize the depth accumulation variable to 1, and use the parent node identifier of the target node as the current trace identifier.

[0045] In this embodiment, the initial value of the depth accumulation variable is set to 1, the parent node identifier of the target node is extracted and assigned to the current trace identifier, and an empty access node set (preferably an ES6 Set instance) is created to carry the ancestor node identifiers of subsequent paths; then the main loop of table lookup and backtracking is entered.

[0046] S32: Perform a lookup operation in the parent-child relationship mapping table based on the current traceability identifier. When the current traceability identifier satisfies the conditions of being non-empty, non-root termination value, and existing in the parent-child relationship mapping table, increment the depth accumulation variable by 1, update the parent node identifier obtained from the lookup table to the new current traceability identifier, and enter the next round of table lookup backtracking.

[0047] S33: If the current traceability identifier does not meet the aforementioned conditions, terminate the backtracking and obtain the value of the depth cumulative variable as the depth value.

[0048] S34: During the table lookup backtracking process, the access node set is maintained synchronously. The access node set is used to record the ancestor node identifiers that have been visited. Before each round of table lookup operation, it is determined whether the current trace identifier already exists in the access node set. If it exists, it is determined that the tree structure data has a parent ring structure, the backtracking is terminated immediately and the current depth accumulation variable is returned as the depth value. If it does not exist, the current trace identifier is added to the access node set and the next round of table lookup backtracking is entered.

[0049] In this embodiment, before each round of table lookup operation begins, a parent loop detection is performed (i.e., S34): it is determined whether the current traceability identifier already exists in the access node set. If it already exists, it is determined that the tree structure data has a parent loop structure, the backtracking is immediately terminated, and the current value of the depth accumulation variable is returned as the depth value. If it does not exist, the current traceability identifier is inserted into the access node set. Then, the current round of table lookup operation and termination condition determination are performed (i.e., S32 and S33): it is determined whether the current traceability identifier simultaneously satisfies the three conditions of being non-empty, non-root termination value, and existing in the parent-child relationship mapping table. If all three conditions are met, the key-value query result corresponding to the current traceability identifier in the parent-child relationship mapping table is used as the new current traceability identifier, and the depth accumulation variable is incremented by 1 to enter the next round of loop. Otherwise, the iteration is terminated if any condition is not met. Finally, the current value of the depth accumulation variable is output as the depth value of the target node to S4. The output depth value is semantically equivalent to the hierarchical index of the target node counting down the child node chain from the root node.

[0050] It should be noted that the implementation of the access node set should preferably use ES6 Set, which has an average complexity of O(1) for both member determination and insertion operations. This is consistent with the O(1) average complexity of each round of table lookup and backtracking, and will not violate the upper bound of the overall algorithm's complexity. In extremely restricted operating environments, it can also degenerate into a fixed-length array combined with linear scanning or use a bitmap as a member identifier container, but this is only suitable for scenarios where the tree height does not exceed several dozen levels. The former will degenerate the member determination complexity to O(N), while the latter requires that the node identifier can be mapped to a compact integer index. The three termination conditions for table lookup backtracking cover three mutually exclusive boundary scenarios: 1) The current trace identifier is null, corresponding to the target node itself being the top-level node (its parent node identifier is null) or the current traceback has already passed the root node; 2) The current trace identifier equals the root termination value, corresponding to the backtracking reaching the root node, which is the normal termination path when the tree structure data is complete; 3) The current trace identifier does not exist in the parent-child relationship mapping table, corresponding to an orphan node, which may be caused by the deletion of the parent node, broken links in cross-page data, or inconsistent parent-child affiliation between the front-end and back-end. Meeting any one of these three conditions terminates the iteration, ensuring that the algorithm returns the currently calculated depth value instead of throwing an exception when descending to dirty data, thus guaranteeing the continuity of interface interaction. The order in which the three conditions are judged does not affect the result, but from an execution efficiency perspective, the non-null condition should be placed first so that in the common scenario where the target node is the top-level node, the iteration can terminate with a single judgment, avoiding unnecessary hash table lookup calls.

[0051] The necessity of parent cycle detection lies in the following: without the introduction of an access node set, naive table lookup backtracking will fall into an infinite loop and block the browser's main thread when encountering a circular parent relationship of type A→B→A, thus causing the interface to freeze. After introducing the access node set for deduplication, any duplicate ancestor identifier is immediately captured. Together with three conventional termination conditions, this strictly limits the worst-case execution steps to within the upper bound of the height of the tree structure data. This upper bound is not affected by the existence of the parent cycle structure, thereby decoupling the algorithm's time upper bound from data integrity. There are two parallel implementation methods for the placement of parent cycle detection: placing it before the table lookup operation (the method adopted in this embodiment) can terminate immediately when a duplicate identifier is encountered for the first time; placing it after the table lookup operation can also capture the circular relationship but will perform an additional table lookup. The former has a better worst-case overhead in dirty data scenarios where circular relationships occur frequently.

[0052] Furthermore, the depth calculation for lookup backtracking relies solely on the parent node chain and does not require the target node itself to exist in the parent-child relationship mapping table. This characteristic is particularly important in optimistic update scenarios on the front end: before a new node is submitted to the back end and the mapping table is rebuilt, although it has not yet entered the table, as long as its parent node identifier points to the real node that has entered the table, S3 can still return the correct depth value, supporting S4's real-time hierarchical control and judgment of new nodes; when the data actually takes the form of multiple independent trees, i.e., a forest structure, each backtracking chain is independent of each other and terminates at the root node of its respective subtree, without the need for any algorithm adaptation for the forest structure.

[0053] The initial value of the depth accumulation variable is agreed to be 1 instead of 0. This convention is consistent with the industry practice of tree structure management (the root node is located at level 1, its child nodes are located at level 2, and so on). If there is a difference from the depth encoding convention of the back-end storage layer, it can be corrected by a unified bias before the comparison operation in S4, without affecting the core logic of this step.

[0054] S4: Based on the comparison between the depth value and the preset level threshold, the level control judgment result of the target node is obtained. The level control judgment result is used to control the executable status of the child node addition operation.

[0055] In this embodiment, the preset level threshold refers to the maximum allowed level value agreed upon by the business side, that is, the depth value of any node in the tree structure data must not exceed this threshold; the level determination function refers to an independently encapsulated determination unit that takes a node (or its depth value) as input and a Boolean value as output. The function body only carries the comparison operation between the depth value and the preset level threshold without mixing any view layer coupling logic; the level control determination result refers to a Boolean value used to receive the control state. A true value means that adding child nodes to the target node is allowed, and a false value means that adding child nodes to the target node is prohibited; the display state and the response state correspond to the visibility dimension and clickability dimension of the control in the view layer, respectively. The display state controls whether the control is rendered to the DOM tree, and the response state controls whether the control responds to interactive events such as clicks and keyboard inputs; the configurable parameter refers to the carrier form of the preset level threshold, which supports changing the parameter value through external input without modifying the main code.

[0056] Specifically, step S4 includes: S41: Call the independently encapsulated layer determination function to compare the depth value with the preset layer threshold and obtain a Boolean layer control determination result.

[0057] Specifically, the independently encapsulated layer determination function is called: The layer determination function receives the depth value output by S3 as input parameter, internally reads the preset layer threshold, performs a comparison operation on the depth value being less than the preset layer threshold, and returns the comparison result as a boolean layer control determination result. The function body does not assume any view rendering responsibility and only returns a pure determination boolean value.

[0058] S42: Based on the hierarchical control judgment result, control the display and response status of operation controls added to child nodes in the page rendering layer.

[0059] Specifically, in the page rendering layer, the hierarchical control judgment result is bound to the display and response states of the operation control added to the child node: when the hierarchical control judgment result is true, the operation control added to the child node is visible and clickable; when the hierarchical control judgment result is false, the control is hidden or disabled in a gray state and does not respond to click events. The disabled state is more suitable for business scenarios that need to clearly prompt the user that "the level limit has been reached" compared to the hidden state.

[0060] S43: The preset level threshold is defined as a configurable parameter, and the maximum allowed level can be dynamically changed based on the adjustment of the parameter value.

[0061] Specifically, preset level thresholds are defined in the form of configurable parameters. The physical carrier of the preset level thresholds is carried by a front-end constant file in static scenarios, injected through environment variables in multi-environment differentiated scenarios, and distributed through the back-end configuration center interface in scenarios that are dynamically adjusted by tenant or by business line. The level determination function accesses the preset level thresholds through a unified parameter reading interface and is unaware of the specific carrier form. When the business side needs to adjust the maximum allowed level, it only needs to change the value of a single parameter in the carrier to apply it to all calling points.

[0062] S44: When a tree structure data change event occurs, the parent-child relationship mapping table is reconstructed based on the changed tree structure data, and the depth value and hierarchical control judgment result of each target node are recalculated based on the reconstructed parent-child relationship mapping table.

[0063] Specifically, when a change event occurs in the tree structure data, such as adding, deleting, or modifying nodes, the automatic reconstruction mechanism of the responsive computed attributes in S2 is used to obtain the reconstructed parent-child relationship mapping table. Based on this, the system re-triggers the execution links of S3 and S41 to S42 for all target nodes, obtains the latest depth value and hierarchical control judgment result of each target node, and synchronously refreshes it to the page rendering layer through the responsive binding of the view layer.

[0064] Furthermore, the hierarchical decision function provides a unified extension entry point for the business side to subsequently overlay more complex decision rules on top of the comparison operation (such as differentiating the maximum allowed level by role or by branch). The extension logic only needs to be incrementally modified within the function body without eroding the calling side code. There are multiple parallel implementation methods for the configurable parameter form of the preset hierarchical threshold. In static scenarios, it can be carried by a front-end constant file and solidified during the build phase. In scenarios that support multi-environment differentiation, it can be injected through environment variables and read when the application starts. In scenarios that need to be dynamically adjusted by tenant or business line, it can be issued through the back-end configuration center interface and hot-updated at runtime. The three methods are completely equivalent in integration semantics with the hierarchical decision function, and only differ in the granularity of effectiveness (global / environment level / tenant level) and the timeliness of change (build time / startup time / runtime). The business side can choose the appropriate carrying form according to the actual governance requirements, or it can be combined and used within the same application through a multi-level parameter overriding mechanism. There are several parallel implementation methods for binding the hierarchical control judgment results with the display and response states of controls: Template-level conditional rendering directives (such as Vue's v-if and v-show, and React's ternary expressions and short-circuit operations) directly receive the judgment results, suitable for single-control scenarios; a button state dispatcher distributes multiple types of operation controls uniformly, suitable for scenarios with multiple hierarchically restricted controls, such as "add child," "batch import child," and "copy child from template"; the dispatcher receives the judgment results and synchronously updates the display and response states of its subscribers, further reducing the redundancy of binding; both binding methods fall within the technical scope of this step, and the selection mainly depends on the number of hierarchically restricted controls.

[0065] In one embodiment, a virtual root node injection step is also included: S10: Construct a virtual root node based on the original tree data. The virtual root node has a preset root node identifier and root node display name, and the preset root node identifier is consistent with the root termination value in the parent-child relationship mapping table.

[0066] In this embodiment, the virtual root node injection steps S10 to S40 are parallel to the main process S1 to S4. After the main process completes one level control judgment, when the user triggers the child node addition operation, the virtual root node injection step is entered, and the selection result falls back to the next iteration of the main process. The original tree data refers to the tree structure data directly returned by the backend tree interface without being wrapped by the virtual root node; the virtual root node refers to the level guidance construction that only exists in the front-end presentation layer and does not participate in the backend persistence; the presentation tree data refers to the composite tree with the virtual root node as the only top level and the original tree data as its child node set; the root termination value refers to the parent belonging zero value that is consistent with the termination condition of the table lookup backtracking in S3.

[0067] Specifically, when the output hierarchical control judgment result of S4 is true and the user triggers the addition of operation controls to the child node, thus requiring the opening of the parent selection control, steps S10 to S40 are executed to receive the top-level selection intent and feed the selection result back to the next round of flat node list construction in S1.

[0068] S20: Mount the original tree data as a set of child nodes of the virtual root node to obtain the display tree data containing the virtual root node.

[0069] S30: Renders a tree selection control based on the displayed tree data and sets the virtual root node to the default expanded state, which is used to provide a top-level visual guide entry point in the parent node selection operation.

[0070] S40: When the selected item in the tree selection control is a virtual root node, the parent node identifier of the target node is assigned the root termination value, and the level of the target node is set to the top level.

[0071] In this embodiment, a virtual root node is first constructed based on the original tree data. The preset root node identifier of the virtual root node is consistent with the root termination value in the parent-child relationship mapping table. The preset root node display name is a string with top-level semantics, such as "main category". Then, the original tree data is mounted as a collection of child nodes of the virtual root node to obtain the display tree data containing the virtual root node. Next, the tree selection control is rendered using the display tree data as the data source, and the virtual root node is set to the default expanded state, so that the virtual root node can be seen as the top-level visual guide entry after the control is loaded. Finally, when the selected item of the tree selection control is the virtual root node, the system assigns the parent node identifier of the newly created target node to the root termination value and positions the level of the newly created target node as the top level. When the selected item is a real node in the original tree data, the node identifier of the real node is used as the parent node identifier of the newly created target node.

[0072] It should be noted that the preset root node identifier of the virtual root node must be strictly consistent with the root termination value in the parent-child relationship mapping table. This consistency ensures that when the newly generated node based on the virtual root node selection result constructs the parent-child relationship mapping table in the next round S2, its parent node identifier naturally corresponds to the conventional termination condition of the table lookup backtracking in S3 (i.e., the current traceback identifier equals the root termination value). There is no need to introduce additional branch decision logic for the top-level selection path. The selection result of the interaction layer and the termination convention of the algorithm layer are closed on the same value. The virtual root node only exists in the front-end presentation layer and does not participate in the back-end persistence. The back-end storage layer still uses the root termination value as the unique identification mark of the top-level. The two form a semantic closed loop between the front-end and back-end through the bidirectional mapping of "virtual root node selection state ↔ root termination value". When the parent node identifier is the root termination value during the submission phase, the front-end can normalize it to an empty value and then fall back to the back-end, avoiding the submission body carrying literal zero values ​​that do not conform to the back-end field specifications. The default expanded state setting of the virtual root node eliminates the extra operation that users need to manually expand the root node to reach the first-level child nodes, making the top-level and first-level child nodes visible on the same screen after the control is loaded. The semantic ambiguity of parent selection (whether not selecting the parent node means creating a new top-level node) is thus made explicit at the interaction entry point.

[0073] In one embodiment, such as Figure 2 As shown, the query front-end of the parent-child relationship mapping table is configured with a prefetch weight vector, which is obtained in the following way: S201: Establish a baseline prefetch weight vector based on the number of descendant nodes of each node in the tree structure data, the current depth value, and the number of historical query hits.

[0074] In this embodiment, the number of descendant nodes refers to the sum of the number of all nodes in the subtree rooted at a certain node, excluding the node itself, reflecting the prior probability that the node is traversed as an ancestor; the number of historical query hits refers to the cumulative number of times the node has been accessed by S3 table lookup backtracking as an ancestor node within the past sliding statistics window, reflecting the empirical frequency of the node as a hotspot ancestor.

[0075] Specifically, for each node, the number of its descendant nodes is calculated. This calculation can reuse the linear node list produced in the flattening stage and can be completed by bottom-up accumulation, avoiding the introduction of an additional independent tree traversal for this metric. Then, the historical query hit count of each node is read from the query counter maintained in the S4 stage, and the current depth value of each node in the tree structure data is read (shallow nodes are visited by more target nodes in the table lookup backtracking, so the current depth value needs to participate in the weighting in a negative correlation manner). Next, the three metrics are weighted and combined according to the rules of positive correlation of descendant node count, positive correlation of historical query hit count, and negative correlation of current depth value to obtain the baseline prefetch weight value of each node. Finally, the baseline prefetch weight vector is filled with node identifier as index and baseline prefetch weight value as element, and the matrix remains in a steady state under the current snapshot of the tree structure data.

[0076] There are several parallel implementation methods for the weighted combination of the three indicators, including linear weighted summation (multiplying the normalized values ​​of the three indicators by the corresponding weight coefficients and then summing them), piecewise function mapping (mapping the number of descendant nodes into discrete weight levels after dividing them into quantile levels), and multiplicative combination (combining the three indicators by multiplication to amplify the advantage of nodes that are simultaneously dominant).

[0077] For example, the baseline prefetch weight vector can be expressed as w = α·log(1 + number of descendant nodes) + β·historical query hit count - γ·current depth value, where α, β, and γ are non-negative weight coefficients, with initial typical value ranges of 0.3 to 1.0, 0.5 to 1.5, and 0.2 to 0.8, respectively. The weight coefficients are continuously fine-tuned under the bias feedback of S204.

[0078] S202: Collect the short-term fluctuation amplitude of the frequency of adding operations to the sub-nodes and the density of the occurrence of the hierarchical control judgment result as the state of exceeding the limit, and establish a modulation mapping from the short-term fluctuation amplitude and density of occurrence to the pre-fetched weight perturbation amount.

[0079] In this embodiment, the short-term fluctuation amplitude of the frequency of child node addition operations refers to the standard deviation or range of the frequency sequence of the operation within a preset short-term sliding window, reflecting the intensity of sudden changes in the rhythm of business operations; the density of over-limit states refers to the ratio of the number of events in the same window where the S4 output level control judgment result is false to the total number of events in the window, reflecting the spatial density of the user's current operation reaching the upper limit of the level; the prefetch weight disturbance amount refers to the real-time correction amount of superimposing or decreasing the baseline prefetch weight value.

[0080] Specifically, two types of events are subscribed to on the front-end event bus: child node addition operations and hierarchical control judgment results. These events are categorized and accumulated using a preset short-term sliding window (generally set to several seconds to tens of seconds in implementation) to obtain real-time estimates of two business characteristics: short-term fluctuation amplitude and the density of over-limit states. Based on the combined state of short-term fluctuation amplitude and the density of over-limit states, the target of the disturbance is selected. A significant increase in short-term fluctuation amplitude indicates that the operations side may be creating classes in batches; in this case, a positive disturbance should be applied to the ancestor of the branch with a large number of descendant nodes. A significant increase in the density of over-limit states indicates that deep subtrees are being triggered intensively; in this case, a positive disturbance should be applied to the direct ancestor of the deep subtree. A modulation mapping from the two business characteristics to the pre-fetched weighted disturbance is established using a lookup table method or a shallow regression function. The lookup table method discretizes the two business characteristics and directly retrieves the disturbance through a two-dimensional table. The shallow regression function uses the two business characteristics as dual inputs and the disturbance as a single output. Finally, the modulation mapping continuously outputs the disturbance vector, with the output frequency aligned with the advancement rhythm of the short-term sliding window, and the result is output.

[0081] Furthermore, there are two parallel implementation methods for selecting the carrier of modulation mapping: the table lookup method has low implementation cost, strong interpretability, and is suitable for deployment scenarios where the range of business feature values ​​is limited and the number of gears after discretization is controllable; shallow regression functions (such as polynomial regression with two inputs and one output, or simple weighted fusion functions) respond more smoothly in scenarios where business features change continuously, avoiding the jump in disturbance caused by discrete gear switching.

[0082] S203: The output of the modulation mapping is superimposed on the reference prefetch weight vector to obtain a prefetch weight vector that is dynamically updated as child node addition operations are performed.

[0083] In this embodiment, a perturbation matrix with the same index structure is established as a superposition buffer, using the reference prefetched weight vector as the underlying structure. Then, the perturbation vector output by S202 is filled into the corresponding positions of the perturbation matrix according to the node identifier index. The corresponding positions of the node identifiers not hit by S202 are set to zero, without introducing bias. Next, a bitwise addition operation is performed to add the perturbation matrix and the reference prefetched weight vector one by one according to the matrix coordinates to obtain the fused prefetched weight vector. Finally, to avoid excessive perturbation causing the weight values ​​of some positions to overflow the reasonable range, the value domain of the fused matrix is ​​truncated (limiting the values ​​to between a preset lower and upper bound), resulting in the final prefetched weight vector that is dynamically updated with the addition of child nodes. In practical applications, the upper bound of the value domain truncation is generally set to two to three times the value domain of the reference matrix, and the lower bound is set to zero or negative one to negative two times the value domain of the reference matrix.

[0084] S204: Select the set of top ancestor node identifiers in descending order of the weights of the prefetched weight vector and load them into the memory cache in advance, and dynamically update the prefetched weight vector based on the deviation feedback.

[0085] In this embodiment, the top ancestor node identifier set refers to the set of ancestor node identifiers that are located in the first K positions after being sorted in descending order according to the prefetch weight value, where K is the prefetch capacity parameter; the memory cache refers to a high-speed access container located at the query front end that carries the hot ancestor node identifiers and their parent node identifier mappings, supporting key-value retrieval with O(1) complexity; the deviation feedback signal refers to the closed-loop adjustment amount constructed by the difference between the actual cache hit rate and the expected prefetch sorting.

[0086] Specifically, the prefetch weight vector is sorted in descending order according to its weight value, and the first K bits of the sorted result are used to obtain the top ancestor node identifier set. Then, for each node identifier in the top ancestor node identifier set, its corresponding parent node identifier key-value pair is read from the parent-child relationship mapping table and loaded into the memory cache in batches via an asynchronous task. The loading process does not block the main thread, avoiding competition for CPU time with front-end interaction events. Next, when the table lookup backtracking occurs in S3, the query front-end prioritizes accessing the memory cache. If the cache misses, it is downgraded to directly accessing the parent-child relationship mapping table. At the same time, the hit or miss result of each cache query is recorded to obtain the actual hit rate. Finally, the difference between the actual hit rate and the "expected high hit rate of the top ancestor node identifier set" is used as a deviation feedback signal to adjust the weight coefficients of the three indicators in S201, the perturbation amplitude of the modulation mapping in S202, and the prefetch capacity parameter K of this sub-step. The initial value of K can be set proportionally to the available heap memory of the deployment environment and the total size of the parent-child relationship mapping table, and K can be allowed to participate in the deviation feedback adjustment as a hyperparameter. The typical value for a high hit rate expectation is between 0.75 and 0.9. When the actual hit rate is consistently lower than this expectation, the bias feedback signal drives the weight coefficient of S201 to tilt towards the "structural heat" direction, while driving the K value to gradually increase. When the actual hit rate is significantly higher than this expectation, the bias feedback signal drives the K value to fall back moderately to release memory overhead.

[0087] In one embodiment, the visualization terminal for tree-structured data is configured with a multi-level rendering detail module with adjustable detail levels. This module includes multiple detail levels, each configured sequentially as one or more combinations of full attribute rendering, partial attribute omission, deep node placeholders, and deep subtree folding aggregation. The method further includes: S100: Based on the proportion of nodes with depth values ​​greater than the set interest depth and the rate of change of the node proportion within a set time window, the arrival time of deep node expansion and the covered subtrees in subsequent time slices are predicted, thus forming the spatiotemporal distribution prediction result of deep node expansion.

[0088] In this embodiment, the multi-level rendering detail module refers to the display component that carries multiple switchable attribute field rendering strategies and subtree aggregation strategies. Complete attribute rendering refers to drawing all business fields of a node; partial attribute omission refers to retaining only key fields such as node identifier and display name while omitting auxiliary fields; deep node placeholders refer to using fixed-size placeholder blocks to replace the actual content of deep nodes; deep subtree folding aggregation refers to folding the entire deep subtree into an expandable aggregation entry point; setting the attention depth refers to the hierarchical boundary value used to distinguish between deep and shallow nodes. Deep node proportion refers to the ratio of nodes with a depth value greater than the set attention depth in the tree structure data to the total number of nodes; the node proportion change rate refers to the change in this proportion per unit time within a set time window; the deep node expansion arrival time refers to the expected time when deep nodes will appear in concentrated bursts in subsequent time slices; and the covered subtree refers to the subtree range affected by the deep node expansion.

[0089] Specifically, within a set time window, the current snapshot of the tree structure data is read at a fixed sampling period. The number of nodes with a depth value greater than the set depth of interest and the total number of nodes are counted to obtain the deep node proportion sequence. Then, the adjacent sampling point difference is performed on the deep node proportion sequence to obtain the node proportion change rate sequence. Next, based on the proportion value and change rate value at the current moment, linear extrapolation is performed to estimate the moment when the deep node proportion reaches the preset expansion threshold. This moment is taken as the deep node expansion arrival time. At the same time, the target parent node identifier of the most recent child node addition operation is combined to back locate its subtree. This subtree is taken as the covering subtree. Finally, the deep node expansion arrival time and the covering subtree estimation are packaged into the deep node expansion spatiotemporal distribution prediction result.

[0090] The typical value of the preset inflation threshold is between 0.3 and 0.5 when the proportion of deep nodes reaches this range. Exceeding this range will trigger the inflation prediction process. The inflation threshold can be dynamically calibrated based on the initial rendering baseline of the visualization display terminal after a cold start measurement. The inflation threshold may vary by orders of magnitude under different device forms.

[0091] It should be noted that the generation of the deep node expansion spatiotemporal distribution prediction results does not rely on complex time-series prediction models. Linear extrapolation of node proportions based on a sliding window is sufficient to meet the prediction accuracy requirements of the front-end interaction layer and is adequate to support the location of the S300's switching start time. Several parallel prediction implementation methods exist: linear extrapolation based on the proportions of a sliding window is suitable for scenarios where the proportion changes relatively smoothly; weighted count extrapolation based on the most recent child node addition operation events is more sensitive in scenarios with significant batch operations; trajectory-based prediction based on user operation paths (predicting the user's subsequent expansion intentions based on the expansion path in the tree selection control) is more accurate in scenarios that deeply depend on the interaction sequence.

[0092] S200: Among the candidate detail level levels that meet the display requirements of the deep node expansion spatiotemporal distribution prediction results, the one with the highest rendering energy efficiency ratio is selected as the target detail level level. The rendering energy efficiency ratio is the ratio of the total number of node attribute fields participating in the final rendering to the view rendering time.

[0093] In this embodiment, the information coverage refers to the completeness of information reflected by the total number of node attribute fields participating in rendering at a certain level of detail; the rendering energy efficiency ratio refers to the ratio of the total number of node attribute fields participating in the final rendering to the time consumed by view rendering, taking into account both the completeness of information display and the overhead of view rendering; the candidate level of detail refers to the set of all switchable levels within the multi-level rendering level of detail module.

[0094] Specifically, based on the size of the overlay subtree output by S100, the minimum information completeness required for its display is evaluated to obtain the lower limit of information coverage for "representing display requirements". Then, all candidate detail level levels of the multi-level rendering detail level module are traversed, and the levels with display information coverage not lower than the lower limit are selected to form a subset of candidate levels. Next, for each level in the subset of candidate levels, its view rendering time on the overlay subtree is read or estimated by sampling, and the total number of node attribute fields participating in the final rendering is counted. The ratio of the two is used as the rendering energy efficiency ratio of the level. Finally, the level with the highest rendering energy efficiency ratio in the subset of candidate levels is taken as the target detail level.

[0095] There are several parallel implementation methods for obtaining view rendering time: the browser's Performance API can be used to collect the actual time taken at the same level in the previous test and use it as an estimation basis; a preset level-time mapping table can be fixed during the initialization phase; or the mapping table can be updated on a rolling basis based on the actual time taken after each switch to adapt to differences in device performance.

[0096] S300: Based on the arrival time of deep node expansion and the set rendering lead, determine the start time of switching the target detail level, set the rendering lead to be no less than the sum of the switching response time and the view redraw duration, and dynamically update the set rendering lead based on deviation feedback.

[0097] In this embodiment, the set rendering lead time refers to the amount of time in advance between the start time of the target level of detail switching and the arrival time of the deep node inflation; the switching start time refers to the time when the system actually issues the level of detail switching command; the switching response time refers to the delay experienced from the issuance of the level of detail switching command to its effective date; the view redraw duration refers to the time consumed by the first frame being drawn under the new level of detail; and the deviation feedback refers to the closed-loop signal that corrects the set rendering lead time based on the difference between the actual switching completion time and the actual arrival time of the deep node inflation.

[0098] Specifically, the arrival time of deep node inflation output by S100 is read, and the value of this time minus the set rendering advance is used as the start time of the target detail level switch. Then, it is checked whether the set rendering advance meets the lower bound constraint, that is, the set rendering advance must not be less than the sum of the switch response time and the view redraw duration. If it does not meet the constraint, the set rendering advance is forcibly increased to this lower bound to avoid the switch command taking effect only after the inflation actually arrives due to insufficient advance. Next, the verified switch start time is registered to the front-end scheduler, and the scheduler triggers the switch execution of S400 when this time is reached. Finally, after each switch, the deviation between the actual switch completion time and the actual arrival time of deep node inflation is collected, and this deviation is used as a feedback signal to dynamically update the set rendering advance: when the actual switch completion time is later than the actual arrival time of deep node inflation, the advance is increased; when the actual switch completion time is earlier than the actual arrival time of deep node inflation and the advance is significantly greater than the lower bound, the advance is appropriately decreased, so that the set rendering advance converges to the device adaptive value. The scheduling vehicle for switching the start time can be requestAnimationFrame, setTimeout, or the delayed task queue in the front-end task scheduler.

[0099] S400: Switch to the target level of detail at the start of the switch and gradually switch back to the high level of detail after the deep node expansion is complete.

[0100] In this embodiment, switching refers to replacing the current effective level of the multi-level rendering detail level module with the target detail level, and causing the display end to redraw the view according to the new level's attribute field rendering strategy and subtree aggregation strategy; the end of deep node expansion means that the proportion of deep nodes falls back below the expansion threshold, and the rate of change of the node proportion turns negative or close to zero; switching back to a high detail level step by step means resetting in stages from low to high according to the detail level sequence, rather than switching back to full attribute rendering all at once; a high detail level refers to a level with higher information coverage than the current effective level.

[0101] Specifically, at the start of the switch, a switch command is sent to the multi-level rendering detail level module to replace the currently effective level with the target detail level output by S200. The display end then redraws the covered subtree according to the rendering strategy corresponding to the new level: if the target detail level omits some attributes, only key fields such as node identifier and display name are retained; if the target detail level omits deep node placeholders, fixed-size placeholders replace the actual content of deep nodes; if the target detail level omits deep subtree collapse aggregation, the entire deep subtree is collapsed into an expandable aggregation entry. Then, the proportion of deep nodes and the rate of change of the node proportion are continuously monitored. When the proportion of deep nodes falls below the expansion threshold and the rate of change turns negative or close to zero, the expansion of deep nodes is determined to be over. After the expansion is over, the nodes are reset step by step from low to high according to the level of detail sequence. Each level of reset waits for the current level of view to be redrawn before triggering the next level, until the full attribute rendering or the steady-state high level of detail specified by the business side is restored. Finally, the actual rendering time, the actual time of completion of the switch and the actual time of expansion in this switching cycle are written back to the deviation feedback channel of S300.

[0102] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0103] In one embodiment, a tree-based data depth calculation and hierarchical management system based on a mapping table is provided, which corresponds to the tree-based data depth calculation and hierarchical management method based on a mapping table in the above embodiment.

[0104] The tree-structured data depth calculation and hierarchy management system based on mapping tables includes a tree data construction module, a mapping table construction module, a depth calculation module, and a hierarchy management module. Detailed descriptions of each functional module are as follows: The tree data construction module is used to obtain a list of flat nodes and construct a tree structure data based on the list of flat nodes. The mapping table construction module is used to build a parent-child relationship mapping table based on tree structure data. The parent-child relationship mapping table is used to store key-value mapping relationships with node identifier as the key and parent node identifier as the value. The depth calculation module is used to calculate the depth value of the target node in the tree structure data by looking up and backtracking along the parent node chain in the parent-child relationship mapping table based on the parent node identifier of the target node. The hierarchical control module is used to obtain the hierarchical control judgment result of the target node based on the comparison result between the depth value and the preset hierarchical threshold. The hierarchical control judgment result is used to control the executable status of the child node addition operation.

[0105] For specific limitations regarding the tree-based data depth calculation and hierarchical management system based on mapping tables, please refer to the limitations of the tree-based data depth calculation and hierarchical management method based on mapping tables mentioned above, which will not be repeated here. Each module in the above-mentioned tree-based data depth calculation and hierarchical management system based on mapping tables can be implemented entirely or partially through software, hardware, or a combination thereof. Each module can be embedded in the processor of the computer device in hardware form or independent of the processor, or it can be stored in the memory of the computer device in software form, so that the processor can call and execute the corresponding operations of each module.

[0106] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 3 As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides the environment for the operation of the operating system and computer programs in the non-volatile storage media. The database stores tree-structured data, hierarchical control judgment results, etc. The network interface communicates with external terminals via a network connection. When executed by the processor, the computer program implements a tree-structured data depth calculation and hierarchical control method based on a mapping table.

[0107] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the tree-like data depth calculation and hierarchical management method based on the mapping table described above.

[0108] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described method for tree-like data depth calculation and hierarchical management based on a mapping table.

[0109] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0110] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.

[0111] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A method for depth calculation and hierarchical management of tree-shaped data based on mapping tables, characterized in that, include: Obtain a list of flat nodes and construct a tree-structured data based on the list of flat nodes; A parent-child relationship mapping table is constructed based on the tree structure data. The parent-child relationship mapping table is used to store key-value mapping relationships with node identifiers as keys and parent node identifiers as values. Based on the parent node identifier of the target node, a lookup and backtracking is performed along the parent node chain in the parent-child relationship mapping table to calculate the depth value of the target node in the tree structure data; Based on the comparison between the depth value and the preset level threshold, the level control determination result of the target node is obtained. The level control determination result is used to control the executable state of the child node addition operation.

2. The method according to claim 1, characterized in that, The construction of the parent-child relationship mapping table based on the tree structure data includes: The tree structure data is flattened to obtain a linear list of nodes with a depth-first preorder traversal order. Traverse the list of linear nodes and establish the key-value mapping relationship for each node in the parent-child relationship mapping table to obtain the parent-child relationship mapping table covering all nodes; The parent-child relationship mapping table is constructed in the form of a responsive computed attribute, which depends on the tree structure data. When the tree structure data undergoes a change event such as adding, deleting, or modifying nodes, the generation of the linear node list and the establishment of the key-value mapping relationship are re-executed based on the changed tree structure data to obtain the reconstructed parent-child relationship mapping table.

3. The method according to claim 1, characterized in that, The depth value of the target node in the tree structure data is calculated by backtracking along the parent node chain in the parent-child relationship mapping table based on the parent node identifier of the target node, including: Initialize the depth accumulation variable to 1, and use the parent node identifier of the target node as the current trace identifier; Based on the current traceability identifier, a lookup operation is performed in the parent-child relationship mapping table. When the current traceability identifier satisfies the conditions of being non-empty, non-root termination value, and existing in the parent-child relationship mapping table, the depth accumulation variable is incremented by 1, and the parent node identifier obtained from the lookup is updated to the new current traceability identifier, and the next round of lookup backtracking begins. When the current traceability identifier does not meet the aforementioned conditions, the backtracking is terminated, and the value of the depth accumulation variable is obtained as the depth value; During the table lookup backtracking process, an access node set is maintained simultaneously. The access node set is used to record the identifiers of ancestor nodes that have been visited. Before each round of the table lookup operation, it is determined whether the current tracing identifier already exists in the access node set. If it exists, it is determined that the tree structure data has a parent ring structure, the backtracking is immediately terminated, and the current depth accumulation variable is returned as the depth value. If it does not exist, the current tracing identifier is added to the access node set, and the next round of table lookup backtracking begins.

4. The method according to claim 1, characterized in that, The step of obtaining the hierarchical control determination result of the target node based on the comparison result between the depth value and the preset hierarchical threshold includes: The independently encapsulated layer determination function is called to compare the depth value with the preset layer threshold to obtain the Boolean layer control determination result; Based on the hierarchical control judgment result, control the display and response states of operation controls added to child nodes in the page rendering layer; The preset level threshold is defined in the form of configurable parameters, and the maximum allowed level can be dynamically changed based on the adjustment of the parameter value; When the tree structure data changes, the parent-child relationship mapping table is reconstructed based on the changed tree structure data, and the depth value of each target node and the hierarchical control judgment result are recalculated based on the reconstructed parent-child relationship mapping table.

5. The method according to claim 1, characterized in that, It also includes the virtual root node injection step: A virtual root node is constructed based on the original tree data. The virtual root node has a preset root node identifier and a root node display name, and the preset root node identifier is consistent with the root termination value in the parent-child relationship mapping table. The original tree data is mounted as a set of child nodes of the virtual root node to obtain display tree data containing the virtual root node; The tree selection control is rendered based on the displayed tree data, and the virtual root node is set to the default expanded state to provide a top-level visual guidance entry point in the parent node selection operation. When the selected item of the tree selection control is the virtual root node, the parent node identifier of the target node is assigned the root termination value, and the level of the target node is positioned as the top level.

6. The method according to claim 5, characterized in that, The query front-end of the parent-child relationship mapping table is configured with a prefetch weight vector, which is obtained in the following way: Based on the number of descendant nodes, current depth, and historical query hit count of each node in the tree structure data, a baseline prefetch weight vector is established. Collect the short-term fluctuation amplitude of the frequency of the child node addition operation and the density of the occurrence of the hierarchical control judgment result of the over-limit state, and establish a modulation mapping from the short-term fluctuation amplitude and the density of occurrence to the pre-fetched weight perturbation amount; The output of the modulation mapping is superimposed on the reference prefetch weight vector to obtain the prefetch weight vector that is dynamically updated as the child node is added. The set of top ancestor node identifiers is selected in descending order of the weights of the prefetched weight vector and preloaded into the memory cache. The prefetched weight vector is then dynamically updated based on the deviation feedback.

7. The method according to claim 2, characterized in that, The visualization terminal for the tree structure data is configured with a multi-level rendering detail module with adjustable detail levels. This module includes multiple detail levels, each configured sequentially as one or more combinations of full attribute rendering, partial attribute omission, deep node placeholders, and deep subtree folding aggregation. The method further includes: Based on the tree structure data, the proportion of nodes with a depth value greater than the set interest depth and the rate of change of the node proportion within a set time window are used to predict the arrival time of deep node expansion and the covered subtree in subsequent time slices, thus forming the spatiotemporal distribution prediction result of deep node expansion. Among the candidate detail levels that meet the display requirements of the deep node expansion spatiotemporal distribution prediction results, the one with the highest rendering energy efficiency ratio is taken as the target detail level. The rendering energy efficiency ratio is the ratio of the total number of node attribute fields participating in the final rendering to the view rendering time. Based on the arrival time of the deep node expansion and the set rendering advance, the start time of the switching of the target level of detail is determined. The set rendering advance is not less than the sum of the switching response time and the view redraw duration, and the set rendering advance is dynamically updated according to the deviation feedback. At the start of the switching, the system switches to the target level of detail and then switches back to the high level of detail level step by step after the deep node expansion is complete.

8. A tree-structured data depth calculation and hierarchical management system based on mapping tables, characterized in that, include: The tree data construction module is used to obtain a list of flat nodes and construct a tree structure data based on the list of flat nodes. The mapping table construction module is used to construct a parent-child relationship mapping table based on the tree structure data. The parent-child relationship mapping table is used to store key-value mapping relationships with node identifiers as keys and parent node identifiers as values. The depth calculation module is used to perform a lookup and backtracking along the parent node chain in the parent-child relationship mapping table based on the parent node identifier of the target node, and calculate the depth value of the target node in the tree structure data. The hierarchical control module is used to obtain the hierarchical control judgment result of the target node based on the comparison result between the depth value and the preset hierarchical threshold. The hierarchical control judgment result is used to control the executable state of the child node addition operation.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the tree-based data depth calculation and hierarchical management method as described in any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the tree-based data depth calculation and hierarchical management method as described in any one of claims 1 to 7.