A general tree structure data search method and system based on map

Through a general tree-structured data search method based on map, using unique index values ​​and indexDB cache, the problems of high computational cost and slow query speed in tree-structured data search are solved, and efficient and flexible data retrieval and search are achieved.

CN116303455BActive Publication Date: 2025-09-23SHANGHAI DATATOM INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310265159.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-16
Publication Date
2025-09-23
Estimated Expiration
2043-03-16

AI Technical Summary

Technical Problem

Multiple recursive operations in existing tree-structured data searches lead to high computational costs and slow query speeds.

Method used

A general tree-structured data search method based on map is adopted. By obtaining unique index values ​​and flattening data, the characteristics of MAP key/value pairs are utilized, combined with indexDB cache, to achieve efficient data retrieval and flexible search.

Benefits of technology

Effectively save computing costs, improve data retrieval speed, implement highly flexible advanced search architecture, and avoid redundant computing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116303455B_ABST
    Figure CN116303455B_ABST
Patent Text Reader

Abstract

The present invention discloses a general tree structure data search method and system based on map. The method comprises the following steps: obtaining and obtaining a unique index value according to the relationship between each node and the ancestor node in the tree structure data, and post-processing to obtain flattened data; deduplicating attributes to obtain a searchable attribute set, and obtaining m actual search attributes therein to obtain an actual search attribute set; obtaining search content and associating it with the actual search attribute set to obtain an object to be searched, and serializing and saving it as SearchJSON; using it as a query condition to index and match the query in the indexDB object warehouse to obtain a query result, and saving it as a search result object output; if the query result is empty, formatting the actual search attribute set and the flattened data to obtain a formatted search object, and performing fuzzy matching processing on the formatted search object and the search content to obtain a unique index value set; tracing the unique index value to obtain tree structure data, and saving it as a search result object.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of tree structure data search, and in particular to a general tree structure data search method and system based on map. Background Art

[0002] After searching on the basis of tree-structured data, it is also necessary to obtain the interactive scenarios of the tree-structured data, especially when the data has a hierarchical structure, such as the departmental personnel structure in a company, the provincial and municipal levels in my country, and other data with organizational relationships. Usually, when accessing related pages, it is indispensable to provide related search functions so that users can have a better experience when using related products. During the research and development process, the present invention mainly relies on the Map data structure of JAVASCIPT, which is a new feature brought by ECMA in the ES6 standard released in 2015. Map is an object that stores key-value pairs and can remember the original insertion order of the keys. Any value (object or basic type) can be used as a key or a value. Compared with the traditional Object key-value pairs, the key-value pairs generated by Map will be more "clean", and the key name is not restricted by the string, and has the characteristic that any data type can be used as a key name. Summary of the Invention

[0003] The technical problem to be solved by the present invention is the problem that multiple recursive operations on tree-structured data in existing tree-structured searches generate high computing costs and slow query speeds. The present invention provides a general tree-structured data search method based on map. The present invention also provides a general tree-structured data search system based on map, which can use unique index values ​​to efficiently restore the tree structure of the node and all its ancestor nodes; use the one-to-one correspondence between the key and the value of the MAP key / value pair to effectively save computing costs and improve data retrieval speed; use the actual search range within the searchable range to match the specific search content to achieve a highly flexible advanced search architecture; use it in conjunction with the indexDB cache to immediately obtain results for the searched content, avoiding redundant calculations, thereby solving the defects caused by the existing technology.

[0004] In order to solve the above technical problems, the present invention provides the following technical solutions:

[0005] In a first aspect, a general tree structure data search method based on a map comprises the following steps:

[0006] Step 1: Obtain tree structure data, where the tree structure data is hierarchical and non-empty data, each layer of the tree structure data has n nodes (n>0), and each node has x attributes (x>0);

[0007] Step 2: obtaining a unique index value based on the relationship between each node and its ancestor node in the tree structure data, and processing the tree structure data based on the unique index value and the corresponding node to obtain flattened data having a MAP key / value pair structure, wherein the key is the unique index value and the value is the node;

[0008] Step 3: Deduplication is performed on the attributes of all the nodes to obtain a searchable attribute set, and m actual search attributes in the searchable attribute set are obtained to obtain an actual search attribute set (m>0);

[0009] Step 4: Obtain non-empty search content, and associate the search content with the actual search attribute set to obtain a search object with a MAP key / value pair structure, and serialize and save it as SearchJSON, where the key is the actual search attribute and the value is the search content;

[0010] Step 5: Using the SearchJSON as the query condition, perform an index matching query in the indexDB object repository in the local browser to obtain a query result, deserialize the value in the query result and save it as a search result object for output. If the query result is empty, execute step 6;

[0011] Step 6: Formatting the actual search attribute set and the flattened data to obtain a formatted search object;

[0012] Step 7: Perform fuzzy matching on the formatted search object and the search content, and obtain all the unique index values ​​that are successfully matched to obtain a unique index value set;

[0013] Step 8: Traverse the unique index value set, trace the source according to the unique index value to obtain tree structure data, save it as a search result object, and serialize it and save it as ResultJSON, save the ResultJSON to the indexDB object warehouse and output it.

[0014] The above-mentioned general tree structure data search method based on map, wherein the relationship between each node in the tree structure data and the ancestor node of the node is obtained by depth-first traversal.

[0015] The above-mentioned general tree-structured data search method based on map, wherein the value corresponding to the node and the actual search attribute is obtained through a comparison algorithm as formatted search content, and then the formatted search content is combined with the unique index value to generate a one-to-one corresponding formatted search object.

[0016] In a second aspect, a general tree-structured data search system based on a map is characterized by comprising a data processing module and an indexDB object repository;

[0017] The data processing module is used to obtain tree structure data, wherein the tree structure data is hierarchical and non-empty data, each layer of the tree structure data has n nodes, (n>0), and each node has x attributes, (x>0);

[0018] It is also used to obtain a unique index value based on the relationship between each node and the ancestor node of the node in the tree structure data, and process the tree structure data according to the unique index value and the corresponding node to obtain flattened data with a MAP key / value pair structure, wherein the key is the unique index value and the value is the node;

[0019] It is also used to perform deduplication processing on the attributes of all the nodes to obtain a searchable attribute set, and obtain m actual search attributes in the searchable attribute set to obtain an actual search attribute set, (m>0);

[0020] It is also used to obtain non-empty search content, associate the search content with the actual search attribute set to obtain a search object with a structure of MAP key / value pairs, and serialize and save it as SearchJSON, where the key is the actual search attribute and the value is the search content;

[0021] It is also used to perform index matching query in the indexDB object warehouse in the local browser with the SearchJSON as the query condition to obtain query results, deserialize the values ​​in the query results and save them as search result objects for output. If the query result is empty, the actual search attribute set and the flattened data are formatted to obtain a formatted search object; the formatted search object is fuzzy matched with the search content to obtain all the unique index values ​​that are successfully matched to obtain a unique index value set; the unique index value set is traversed, and tree structure data is obtained based on the unique index value, which is saved as a search result object and serialized and saved as ResultJSON. The ResultJSON is saved in the indexDB object warehouse and output.

[0022] In a third aspect, a chip comprises: a processor for calling and running a computer program from a memory, so that a device equipped with the chip executes: a method as described in any one of the first aspects.

[0023] The technical solution provided by the general tree-structured data search method and system based on a map of the present invention has the following technical effects:

[0024] 1. Use unique index values ​​to efficiently restore the tree structure of the node and all its ancestor nodes;

[0025] 2. By utilizing the one-to-one correspondence between MAP key / value pairs, computing costs can be effectively saved and data retrieval speed can be improved;

[0026] 3. Use the actual search scope within the searchable range and the specific search content to achieve a highly flexible advanced search architecture;

[0027] 4. Used with indexDB cache, results can be obtained immediately for searched content, avoiding redundant calculations. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 This is a flow chart of a general tree structure data search method based on map of the present invention. DETAILED DESCRIPTION

[0029] In order to make the technical means, creative features, objectives and effects of the invention easy to understand, the technical solutions in the embodiments of the present invention are clearly and completely described below in combination with specific illustrations. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments.

[0030] Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making any creative work shall fall within the scope of protection of the present invention.

[0031] It should be noted that the structures, proportions, sizes, etc. illustrated in the drawings in this specification are only used to match the contents disclosed in the specification so that people familiar with this technology can understand and read them. They are not used to limit the conditions under which the present invention can be implemented. Therefore, they have no substantive technical significance. Any modification of the structure, change in the proportion relationship or adjustment of the size should still fall within the scope of the technical content disclosed in the present invention without affecting the efficacy and purpose that can be achieved by the present invention.

[0032] At the same time, the terms such as "upper", "lower", "left", "right", "middle" and "one" quoted in this specification are only for the convenience of description and are not used to limit the scope of implementation of the present invention. Changes or adjustments to their relative relationships should be regarded as the scope of implementation of the present invention without substantially changing the technical content.

[0033] like Figure 1 As shown, in the first aspect, the first embodiment, a general tree structure data search method based on map, which includes the following steps:

[0034] Step 1: Get tree structure data. Tree structure data is hierarchical and non-empty data. Each layer of the tree structure data has n nodes (n>0), and each node has x attributes (x>0).

[0035] Step 2: Obtain a unique index value based on the relationship between each node in the tree structure data and its ancestor node. Process the tree structure data based on the unique index value and the corresponding node to obtain flattened data with a MAP key / value pair structure, where the key is the unique index value and the value is the node.

[0036] Step 3: De-duplicate the attributes of all nodes to obtain a searchable attribute set, and obtain m actual search attributes in the searchable attribute set to obtain an actual search attribute set (m>0);

[0037] Step 4: Get the non-empty search content and associate it with the actual search attribute set to obtain the search object with the structure of MAP key / value pairs. Serialize it and save it as SearchJSON, where the key is the actual search attribute and the value is the search content.

[0038] Step 5: Use SearchJSON as the query condition to perform an index matching query in the indexDB object warehouse in the local browser to obtain the query results. Deserialize the values ​​in the query results and save them as search result objects for output. If the query results are empty, proceed to step 6.

[0039] Step 6: Format the actual search attribute set and the flattened data to obtain a formatted search object;

[0040] Step 7: Perform fuzzy matching on the formatted search object and the search content, and obtain all the unique index values ​​that are successfully matched to obtain a unique index value set;

[0041] Step 8: Traverse the unique index value set, trace the source based on the unique index value to obtain the tree structure data, save it as a search result object, and serialize it to save it as ResultJSON. Save the ResultJSON to the indexDB object warehouse and output it.

[0042] The above-mentioned general tree structure data search method based on map adopts a depth-first traversal method to obtain a unique index value from the relationship between each node in the tree structure data and the ancestor node of the node.

[0043] The above-mentioned general tree structure data search method based on map, wherein the value corresponding to the node and the actual search attribute is obtained through a comparison algorithm as formatted search content, and then the formatted search content is combined with the unique index value to generate a one-to-one corresponding formatted search object.

[0044] In a second aspect, a general tree-structured data search system based on a map is characterized by comprising a data processing module and an indexDB object repository;

[0045] The data processing module is used to obtain tree structure data. The tree structure data is hierarchical and non-empty data. Each layer of the tree structure data has n nodes, (n>0), and each node has x attributes, (x>0);

[0046] It is also used to obtain a unique index value based on the relationship between each node in the tree structure data and the ancestor node of the node, and process the tree structure data according to the unique index value and the corresponding node to obtain flattened data with a structure of MAP key / value pairs, wherein the key is the unique index value and the value is the node;

[0047] It is also used to perform deduplication processing on the attributes of all nodes to obtain a searchable attribute set, and obtain m actual search attributes in the searchable attribute set to obtain an actual search attribute set, (m>0);

[0048] It is also used to obtain non-empty search content, associate the search content with the actual search attribute set to obtain a search object with a structure of MAP key / value pairs, and serialize it and save it as SearchJSON, where the key is the actual search attribute and the value is the search content;

[0049] It is also used to perform index matching queries in the indexDB object repository in the local browser with SearchJSON as the query condition to obtain query results, deserialize the values ​​in the query results and save them as search result objects for output. If the query result is empty, the actual search attribute set and flattened data are formatted to obtain a formatted search object; the formatted search object is fuzzy matched with the search content to obtain all unique index values ​​that successfully match to obtain a unique index value set; the unique index value set is traversed, and tree structure data is obtained based on the unique index value for traversal, which is saved as a search result object and serialized and saved as ResultJSON. The ResultJSON is saved in the indexDB object repository and output.

[0050] In a third aspect, a chip comprises: a processor for calling and running a computer program from a memory, so that a device equipped with the chip executes: a method as in any one of the first aspects.

[0051] For example, the memory may include random access memory, flash memory, read-only memory, programmable read-only memory, non-volatile memory or registers;

[0052] The processor may be a central processing unit (CPU) or a graphics processing unit (GPU). The memory may store executable instructions.

[0053] The processor may execute the execution instructions stored in the memory to implement the various processes described herein.

[0054] It can be understood that the memory in this embodiment may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories;

[0055] Among them, the non-volatile memory can be ROM (Read-Only Memory), PROM (Programmable ROM), EPROM (Erasable PROM), EEPROM (Electrically EPROM) or flash memory.

[0056] The volatile memory may be RAM (Random Access Memory), which is used as an external cache;

[0057] By way of example and not limitation, many forms of RAM are available, such as SRAM (Static RAM), DRAM (Dynamic RAM), SDRAM (Synchronous DRAM), DDR SDRAM (Double Data Rate SDRAM), ESDRAM (Enhanced SDRAM), SLDRAM (Synchlink DRAM), and DRRAM (Direct Rambus RAM). The memory described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0058] In some embodiments, the memory stores the following elements, upgrade packages, executable units or data structures, or a subset thereof, or an extended set thereof: an operating system and applications;

[0059] The operating system includes various system programs, such as the framework layer, core library layer, and driver layer, which are used to implement various basic services and process hardware-based tasks.

[0060] The application program includes various application programs for implementing various application services. The program for implementing the method of the embodiment of the present invention can be included in the application program.

[0061] It will be apparent to those skilled in the art that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of software and electronic hardware;

[0062] Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution;

[0063] Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0064] In the embodiments of the present application, the disclosed systems, devices, and methods may be implemented in other ways;

[0065] For example, the division of units or modules is only a logical function division, and there may be other division methods in actual implementation;

[0066] For example, multiple units or modules or components may be combined or may be integrated into another system;

[0067] In addition, each functional unit or module in the embodiment of the present application may be integrated into one processing unit or module, or may exist as a separate physical entity, etc.

[0068] It should be understood that in the various embodiments of the present application, the size of the serial number of each process does not mean 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 the present application.

[0069] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a machine-readable storage medium;

[0070] Therefore, the technical solution of the present application may be embodied in the form of a software product, which may be stored in a machine-readable storage medium and may include several instructions for enabling an electronic device to execute all or part of the processes of the technical solution described in the embodiments of the present application;

[0071] The above-mentioned storage medium may include various media that can store program codes, such as ROM, RAM, removable disk, hard disk, magnetic disk or optical disk.

[0072] In summary, the present invention provides a general tree-structured data search method based on map, which can efficiently restore the tree structure of the node and all its ancestor nodes by using unique index values; utilizes the one-to-one correspondence between the key and the value of the MAP key / value pair, which can effectively save computing costs and improve data retrieval speed; utilizes the actual search range within the searchable range and the specific search content to achieve a highly flexible advanced search architecture; and is used in conjunction with the indexDB cache to immediately produce results for the searched content, avoiding redundant calculations.

[0073] The above describes specific embodiments of the invention. It should be understood that the invention is not limited to the specific embodiments described above. Devices and structures not described in detail should be understood to be implemented in a common manner in the art. Those skilled in the art may make various modifications, variations, or simple deductions, deformations, or substitutions within the scope of the claims, without affecting the essence of the invention.

Claims

1. A general tree structure data search method based on map, characterized in that: The following steps are involved: Step 1: Obtain tree structure data, wherein the tree structure data is hierarchical and non-empty data, each layer of the tree structure data has n nodes, n>0, and each node has x attributes, x>0; Step 2: obtaining a unique index value based on the relationship between each node and its ancestor node in the tree structure data, and processing the tree structure data based on the unique index value and the corresponding node to obtain flattened data having a MAP key / value pair structure, wherein the key is the unique index value and the value is the node; Step 3: Deduplication is performed on the attributes of all the nodes to obtain a searchable attribute set, and m actual search attributes in the searchable attribute set are obtained to obtain an actual search attribute set, where m>0; Step 4: Obtain non-empty search content, and associate the search content with the actual search attribute set to obtain a search object with a MAP key / value pair structure, and serialize and save it as SearchJSON, where the key is the actual search attribute and the value is the search content; Step 5: Using the SearchJSON as the query condition, perform an index matching query in the indexDB object repository in the local browser to obtain a query result, deserialize the value in the query result and save it as a search result object for output. If the query result is empty, execute step 6; Step 6: Formatting the actual search attribute set and the flattened data to obtain a formatted search object; Step 7: Perform fuzzy matching on the formatted search object and the search content, and obtain all the unique index values ​​that are successfully matched to obtain a unique index value set; Step 8: Traverse the unique index value set, trace the source according to the unique index value to obtain tree structure data, save it as a search result object, and serialize it and save it as ResultJSON, save the ResultJSON to the indexDB object warehouse and output it.

2. A general tree structure data search method based on map according to claim 1, characterized in that: The unique index value is obtained by traversing the relationship between each node and its ancestor node in the tree structure data in a depth-first traversal manner.

3. A general tree structure data search method based on map according to claim 2, characterized in that: The value corresponding to the node and the actual search attribute is obtained through a comparison algorithm as formatted search content, and then the formatted search content is combined with the unique index value to generate the one-to-one corresponding formatted search object.

4. A general tree structure data search system based on map, characterized in that: Contains data processing module and indexDB object warehouse; The data processing module is used to obtain tree structure data, the tree structure data is hierarchical and non-empty data, each layer of the tree structure data has n nodes, n>0, and each node has x attributes, x>0; It is also used to obtain a unique index value based on the relationship between each node and the ancestor node of the node in the tree structure data, and process the tree structure data according to the unique index value and the corresponding node to obtain flattened data with a MAP key / value pair structure, wherein the key is the unique index value and the value is the node; It is also used to perform deduplication processing on the attributes of all the nodes to obtain a searchable attribute set, and obtain m actual search attributes in the searchable attribute set to obtain an actual search attribute set, where m>0; It is also used to obtain non-empty search content, associate the search content with the actual search attribute set to obtain a search object with a structure of MAP key / value pairs, and serialize and save it as SearchJSON, where the key is the actual search attribute and the value is the search content; It is also used to perform index matching query in the indexDB object warehouse in the local browser with the SearchJSON as the query condition to obtain query results, deserialize the values ​​in the query results and save them as search result objects for output. If the query result is empty, the actual search attribute set and the flattened data are formatted to obtain a formatted search object; the formatted search object is fuzzy matched with the search content to obtain all the unique index values ​​that are successfully matched to obtain a unique index value set; the unique index value set is traversed, and tree structure data is obtained based on the unique index value, which is saved as a search result object and serialized and saved as ResultJSON. The ResultJSON is saved in the indexDB object warehouse and output.

5. A chip, characterized in that: The device comprises: a processor configured to call and run a computer program from a memory, so that a device equipped with the chip executes: a method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Tree data processing method and system

    CN114491164A

  • Adaptive prefix tree based order partitioned data storage system

    US20170212680A1