A method for constructing a universal tree model based on virtual directory

Through the universal tree model construction method based on virtual directories, the problem of inflexible tree structure functions in the existing technology is solved, flexible definition and efficient query of data models are realized, and data storage and query performance are improved.

CN114780799BActive Publication Date: 2025-08-08HANGZHOU INSTRUCTION SET INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210419933.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-21
Publication Date
2025-08-08
Estimated Expiration
2042-04-21

AI Technical Summary

Technical Problem

When developing tree structure functions in the prior art, there is redundant code, inflexible, difficult to dynamically adjust, and it is impossible to implement the general tree grouping function that flexibly defines fields.

Method used

The universal tree model construction method based on virtual directories is adopted. By configuring virtual directory nodes and assembling a general tree structure, flexible definition and rapid access of data are achieved, and storage design of adjacent tables and closure tables is optimized.

Benefits of technology

It improves the flexibility and query performance of the data model, realizes fast access and dynamic adjustment, and improves data query efficiency, especially when multi-level queries and arbitrary node relationships, which significantly improves query speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114780799B_ABST
    Figure CN114780799B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for constructing a universal tree model based on a virtual directory, comprising the following steps: Step A, configuring virtual directory nodes to model tree-like data; Step B, assembling and returning a universal tree structure to provide data query and storage. The method for constructing a universal tree model based on a virtual directory, by configuring virtual directory nodes to model tree-like data, can expand data from another dimension and flexibly utilize data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a model construction method, and more particularly to a general tree model construction method based on a virtual directory. Background Art

[0002] When developing tree-structured functions in a system, a table is often added when a requirement comes in, and the backend implements the function. The code consistency is high, the cycle is long, and it is not dynamic and flexible. Once the requirement needs to be changed, the code must be changed, which is redundant and unintelligent.

[0003] However, many functions can flexibly define fields, so this type of function cannot realize the general tree grouping function. This problem currently exists in many such projects. Summary of the Invention

[0004] In view of the shortcomings of the existing technology, the purpose of the present invention is to provide a method for constructing a universal tree model based on a virtual directory, which has flexible data format, flexible data definition, fast access, and a wide range of usage scenarios.

[0005] To achieve the above object, the present invention provides the following technical solution: a method for constructing a universal tree model based on a virtual directory, comprising the following steps:

[0006] Step A, configuring a virtual directory node to model the tree-like data;

[0007] Step B: Assemble and return a general tree structure to provide data query and storage.

[0008] As a further improvement of the present invention, the specific steps of configuring the virtual directory node in step A are as follows:

[0009] Step 1: Enter the page, create a virtual directory, and define the unique identifier of the virtual directory;

[0010] Step 2: Determine whether to configure a data source. If so, select the data source and configure it before continuing to the next step. If not, define custom fields.

[0011] Step 3: After configuring the data source, determine whether custom fields need to be added. If so, define the custom fields. If not, proceed to the next step.

[0012] Step 4: Verify the necessary tree fields and select the general tree capabilities after verification to complete the configuration;

[0013] Step 5: Perform page association and complete the construction, wherein the general tree capabilities selected in step 4 include multi-level grouping, limiting the number of layers, and sorting rules.

[0014] As a further improvement of the present invention, the general tree structure assembly and return step in step B is specifically as follows:

[0015] Step 1: Call the API.

[0016] Step 2: Get the virtual directory identifier;

[0017] Step 3: Check whether to configure ES / fuzzy query. If so, query in ES and return tree-structured data. At the same time, synchronize the data to ES. If not, proceed to the next step.

[0018] Step 4: The service queries the corresponding virtual node from the database and configures the data source or extends the custom field for the virtual node.

[0019] Step 5, assemble into a tree according to the rules;

[0020] Step 6: Return the tree structure data and end.

[0021] As a further improvement of the present invention, the specific steps of configuring a data source for a virtual node or extending a custom field in step 4 are as follows:

[0022] Step 41: First, determine whether the virtual node needs to be configured with a data source. If not, process the data in the field pool into a directory node and return the data. If the data source needs to be configured, proceed to the next step.

[0023] Step 42, determining whether to expand the custom field, if not to expand the custom field, then return the data, if the custom field is expanded, then process the data source data and the font pool data into a directory node object and then return the data.

[0024] The beneficial effects of the present invention are: first, data nodes are defined in the form of virtual directories, which can be arbitrarily defined without real existence. Each node is a virtual directory, and the relationship between them can be defined. The data entities of each directory can use the universal definition of the data dictionary, and any object data can be defined and used, which improves flexibility and data model capabilities; second, the storage combination capability of the optimized tree structure, the query performance for any number is much higher than the solutions on the market, and the optimized performance improves the query efficiency compared to the fast fuzzy query achieved by integrating es. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 Flowchart for configuring virtual directory nodes;

[0026] Figure 2 Assemble the return flow graph for a general tree structure. DETAILED DESCRIPTION

[0027] The present invention will be further described below with reference to the embodiments shown in the accompanying drawings.

[0028] Reference Figures 1 to 2 As shown, a method for constructing a general tree model based on a virtual directory in this embodiment includes the following steps:

[0029] Step A, configuring a virtual directory node to model the tree-like data;

[0030] Step B, assemble and return a general tree structure to provide data query and storage. Through the settings of the above step A, the tree data can be effectively modeled, and virtual directory nodes can be configured for users to define relationships arbitrarily. Through the settings of step B, the query process and storage solution of optimized data can be effectively realized.

[0031] As an improved specific implementation method, the specific steps of configuring the virtual directory node in step A are as follows:

[0032] Step 1: Enter the page, create a virtual directory, and define the unique identifier of the virtual directory;

[0033] Step 2: Determine whether to configure a data source. If so, select the data source and configure it before continuing to the next step. If not, define custom fields.

[0034] Step 3: After configuring the data source, determine whether custom fields need to be added. If so, define the custom fields. If not, proceed to the next step.

[0035] Step 4: Verify the necessary tree fields and select the general tree capabilities after verification to complete the configuration;

[0036] Step five is to associate pages and complete the construction. In step four, the general tree capabilities selected include multi-level grouping, limiting the number of layers, and sorting rules. Through the settings of the above steps, the data can be effectively abstracted into virtual directory nodes. The underlying implementation of the nodes is composed of the necessary fields for tree business and the fields in the custom field pool. Simply put, the tree data is modeled and the data is expanded and used flexibly from another dimension.

[0037] As an improved specific implementation method, the general tree structure assembly and return step in step B is specifically as follows:

[0038] Step 1: Call the API.

[0039] Step 2: Get the virtual directory identifier;

[0040] Step 3: Check whether to configure ES / fuzzy query. If so, query in ES and return tree-structured data. At the same time, synchronize the data to ES. If not, proceed to the next step.

[0041] Step 4: The service queries the corresponding virtual node from the database and configures the data source or extends the custom field for the virtual node.

[0042] Step 5, assemble into a tree according to the rules;

[0043] Step 6 ends after returning the tree structure data. Most existing systems query data directly from the database, which is far slower than in-memory queries. By using the middleware elasticsearch, the data (assembled tree) exists in es during the query and is returned directly without querying from the background and synchronizing it into es, which greatly increases the query efficiency and achieves the effect of fuzzy query.

[0044] As an improved specific implementation method, the specific steps of configuring a data source or extending a custom field for a virtual node in step 4 are as follows:

[0045] Step 41: First, determine whether the virtual node needs to be configured with a data source. If not, process the data in the field pool into a directory node and return the data. If the data source needs to be configured, proceed to the next step.

[0046] Step 42 determines whether to expand the custom field. If not, the data is returned. If the custom field is to be expanded, the data source data and the character pool data are processed into a directory node object and then the data is returned. By setting the above steps, it is possible to first determine whether the data source needs to be configured and then determine whether to expand the custom field. Compared with the method of directly expanding all custom fields, this effectively saves computing resources. As an improved specific implementation method, the storage solution in step B adopts the form of an adjacency list + closure table. The advantage of the adjacency list is that the structure is simple and easy to understand. The relationship between each other is maintained by only one parent_id, making it very easy to add, delete, and modify. The small amount of information stored is very convenient when checking direct superiors and direct subordinates. It is very practical when the tree has relatively few levels. Disadvantages: It is very difficult to perform multi-level queries, requires continuous recursion, and has high overhead.

[0047] The node relationship of the closure table is clear, the query is fast, and cascade deletion and node movement are also convenient.

[0048] All existing storage solutions on the market use a single approach, each with its own advantages and disadvantages, often with shortcomings that cannot be addressed. This design compares various storage solutions and identifies an adjacency table + closure table storage design as the optimal solution. This approach retains the simple structure of the adjacency table and utilizes closed node relationships for multi-level queries or arbitrary node relationships. This logical implementation significantly improves query flexibility while maintaining high query speeds. This performance is particularly noticeable when querying frequently and writing less frequently.

[0049] To sum up, the construction method of this embodiment adopts the virtual directory node method to effectively model the tree-like data, and defines the data nodes in the form of virtual directories, which can be arbitrarily defined without the need for real existence, thereby improving flexibility and data model capabilities; secondly, the storage combination capability of the optimized tree structure, the query performance for any number is much higher than the solutions on the market.

[0050] The above description is merely a preferred embodiment of the present invention. The scope of protection of the present invention is not limited to the above embodiment. All technical solutions based on the concept of the present invention are within the scope of protection of the present invention. It should be noted that for those skilled in the art, various improvements and modifications that do not depart from the principles of the present invention should also be considered within the scope of protection of the present invention.

Claims

1. A method for constructing a general tree model based on a virtual directory, characterized by: The steps include: Step A, configuring a virtual directory node to model the tree-like data; Step B: assemble and return a general tree structure to provide data query and storage; The specific steps for configuring the virtual directory node in step A are as follows: Step 1: Enter the page, create a virtual directory, and define the unique identifier of the virtual directory; Step 2: Determine whether to configure a data source. If so, select the data source and configure it before continuing to the next step. If not, define custom fields. Step 3: After configuring the data source, determine whether custom fields need to be added. If so, define the custom fields. If not, proceed to the next step. Step 4: Verify the necessary tree fields and select the general tree capabilities after verification to complete the configuration; Step 5: perform page association and complete the construction, wherein the general tree capabilities selected in step 4 include multi-level grouping, limiting the number of levels, and sorting rules; The general tree structure assembly and return steps in step B are specifically as follows: Step 1: Call the API. Step 2: Get the virtual directory identifier; Step 3: Check whether to configure ES fuzzy query. If so, the query in ES will return tree-structured data and synchronize the data to ES. If not, proceed to the next step. In step 4, the service queries the corresponding virtual node from the database and configures the data source or extends the custom field for the virtual node, including: Step 41: First, determine whether the virtual node needs to be configured with a data source. If not, process the data in the field pool into a directory node and return the data. If the data source needs to be configured, proceed to the next step. Step 42, determining whether to expand the custom field, if not to expand the custom field, then return the data, if the custom field is expanded, then process the data source data and the font pool data into a directory node object and then return the data; The storage solution in step B adopts the form of adjacency list + closure table.

2. The method for constructing a universal tree model based on a virtual directory according to claim 1, characterized in that: The general tree structure assembly and return step in step B further includes: Step 5, assemble into a tree according to the rules; Step 6: Return the tree structure data and end.

Citation Information

Patent Citations

  • Method for organizing dummy catalog and managing naming space for distributed file systems

    CN101334785A

  • Method for constructing tree structural directory in database

    CN102096711A