Resource query method, device, equipment and medium based on resource tree
By dividing resource query requests into resource node acquisition and resource subtree construction requests, obtaining target resource nodes and their ancestors or descendants nodes, and building target resource subtree, solving the problem of resource tree query robustness and realizing flexible resource query.
Patent Information
- Application Number
- CN202010607676.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-29
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2040-06-29
AI Technical Summary
When the existing resource tree query method changes, it is necessary to frequently add or modify query conditions, which affects the robustness of the query.
Divide the resource query request into resource node acquisition request and resource subtree construction request, obtain the target resource node and its ancestor node and/or descendant node respectively, and build the target resource subtree.
It realizes any subtree query of the resource tree, meets the user's changing resource query needs, and improves the query robustness of the resource tree.
Smart Images

Figure CN113934915B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of big data technology, and in particular to a resource query method, apparatus, device, and medium based on a resource tree. Background Art
[0002] A resource tree is a control that displays resources in a tree-like structure, providing users with functions such as resource navigation and resource search. Different resource tree systems may have different query requirements. Therefore, a common query method is to define query conditions based on user needs and then perform resource searches based on these conditions. Changing user needs often require adding or modifying existing query conditions, which can affect the robustness of resource tree queries. Summary of the Invention
[0003] The embodiments of the present invention provide a resource query method, apparatus, device and medium based on a resource tree, which improve the robustness of resource query of the resource tree.
[0004] In a first aspect, an embodiment of the present invention provides a resource query method based on a resource tree, the method comprising:
[0005] When a resource query request is obtained, the resource query request is divided into a resource node acquisition request and a resource subtree construction request;
[0006] Acquire at least one target resource node from a resource tree according to the resource node acquisition request;
[0007] According to the resource subtree construction request, obtaining a target ancestor node and / or a target descendant node of each target resource node from the resource tree;
[0008] A target resource subtree is constructed according to each target resource node and the target ancestor node and / or target descendant node of each target resource node.
[0009] In a second aspect, an embodiment of the present invention further provides a resource query device based on a resource tree, the device comprising:
[0010] A query request division module is used to divide the resource query request into a resource node acquisition request and a resource subtree construction request when obtaining the resource query request;
[0011] A first node acquisition module, configured to acquire at least one target resource node from a resource tree according to the resource node acquisition request;
[0012] A second node acquisition module is configured to acquire a target ancestor node and / or a target descendant node of each target resource node from the resource tree according to the resource subtree construction request;
[0013] The resource subtree construction module is configured to construct a target resource subtree according to each target resource node and a target ancestor node and / or a target descendant node of each target resource node.
[0014] In a third aspect, an embodiment of the present invention further provides an electronic device, including:
[0015] one or more processors;
[0016] a storage device for storing one or more programs,
[0017] When the one or more programs are executed by the one or more processors, the one or more processors implement any resource query method based on a resource tree according to any one of the embodiments of the present invention.
[0018] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any resource query method based on a resource tree described in any of the embodiments of the present invention.
[0019] The technical solution disclosed in the embodiments of the present invention has the following beneficial effects:
[0020] By dividing the obtained resource query request into a resource node acquisition request and a resource subtree construction request, at least one target resource node is obtained from the resource tree according to the resource node acquisition request, and the target ancestor node and / or target descendant node of each target resource node is obtained from the resource tree according to the resource subtree construction request. Then, a target resource subtree is constructed based on each target resource node and each target ancestor node and / or target descendant node of each target resource node. Thus, by dividing the resource query request into the resource node acquisition request and the resource subtree construction request, the purpose of querying any resource subtree of the resource tree is achieved, thereby meeting the user's resource query needs and improving the resource query robustness of the resource tree. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 This is a flow chart of a resource query method based on a resource tree provided by an embodiment of the present invention;
[0022] Figure 2 This is a flow chart of another resource query method based on a resource tree provided by an embodiment of the present invention;
[0023] Figure 2 (a) is a schematic diagram of a resource tree provided by an embodiment of the present invention;
[0024] Figure 2(b) is a schematic diagram of a first target resource subtree constructed based on a resource tree provided by an embodiment of the present invention;
[0025] Figure 2 (c) is a schematic diagram of a second target resource subtree constructed based on a resource tree provided by an embodiment of the present invention;
[0026] Figure 2 (d) is a schematic diagram of a third target resource subtree constructed based on a resource tree provided by an embodiment of the present invention;
[0027] Figure 2 (e) is a schematic diagram of a fourth target resource subtree constructed based on a resource tree provided by an embodiment of the present invention;
[0028] Figure 2 (f) is a schematic diagram of a fifth target resource subtree constructed based on a resource tree provided by an embodiment of the present invention;
[0029] Figure 3 1 is a flow chart of another resource query method based on a resource tree provided by an embodiment of the present invention;
[0030] Figure 3 (a) is a schematic diagram of another resource tree provided by an embodiment of the present invention;
[0031] Figure 3 (b) is a schematic diagram of a target resource subtree constructed based on a resource tree provided by an embodiment of the present invention;
[0032] Figure 4 1 is a schematic structural diagram of a resource query device based on a resource tree provided by an embodiment of the present invention;
[0033] Figure 5 It is a structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0034] The following is a further detailed description of the embodiments of the present invention in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely illustrative of the embodiments of the present invention and are not intended to limit the embodiments of the present invention. It should also be noted that, for ease of description, the accompanying drawings only illustrate portions of the embodiments of the present invention, rather than all structures.
[0035] The resource query method, apparatus, device and medium based on a resource tree provided by embodiments of the present invention are described below with reference to the accompanying drawings.
[0036] Figure 1This is a flow chart of a resource query method based on a resource tree provided by an embodiment of the present invention. This embodiment is applicable to the case of performing resource query in a resource tree. The method can be executed by a resource query device based on a resource tree. The device can be composed of hardware and / or software and can generally be integrated into an electronic device. Figure 1 As shown, the method specifically includes the following:
[0037] S101 : When a resource query request is obtained, the resource query request is divided into a resource node acquisition request and a resource subtree construction request.
[0038] In this embodiment, a resource query request refers to a resource query request sent by a user to a device having a resource tree based on business needs. Generally, a user can send a resource query request in various ways, such as entering a query keyword in a query box or using voice, which are not specifically limited here.
[0039] For example, after receiving a resource query request sent by a user, the resource query request can be parsed to obtain the resource query parameters carried in the resource query request. Based on the resource query parameters, the resource query request is divided into a resource node acquisition request and a resource subtree construction request according to a preset division rule. The preset division rule can be a general rule set according to resource query requirements.
[0040] Among them, the resource query parameters carried by the resource query request may include: the target resource identifier, the target resource type or the target resource parent node identifier, as well as the ancestor traversal identifier value of the target resource, the ancestor traversal depth value of the target resource, the descendant traversal identifier value of the target resource and / or the descendant traversal depth value of the target resource.
[0041] In this embodiment, the target resource identifier refers to information that can uniquely identify the target resource. For example, the resource name or resource ID. The target resource parent node identifier refers to information that can uniquely identify the target resource parent node, such as the parent node name or parent node ID. The target resource's ancestor traversal identifier value represents whether to traverse the target resource's ancestor nodes; the target resource's ancestor traversal depth value represents the traversal depth when traversing the target resource's ancestor nodes; the target resource's descendant traversal identifier value represents whether to traverse the resource's descendant nodes; the target resource's descendant traversal depth value represents the traversal depth when traversing the target resource's descendant nodes.
[0042] It can be understood that the ancestor traversal identification value of the target resource, the ancestor traversal depth value of the target resource, the descendant traversal identification value of the target resource and / or the descendant traversal depth value of the target resource in this embodiment may refer to: the ancestor traversal identification value of the target resource; or, the ancestor traversal identification value of the target resource and the ancestor traversal depth value of the target resource; or, the descendant traversal identification value of the target resource; or, the descendant traversal identification value of the target resource and the descendant traversal depth value of the target resource; or, the ancestor traversal identification value of the target resource and the descendant traversal identification value of the target resource; or, the ancestor traversal identification value of the target resource, the ancestor traversal depth value of the target resource and the descendant traversal identification value of the target resource; or, the ancestor traversal identification value of the target resource, the descendant traversal identification value of the target resource and the descendant traversal depth value of the target resource; or, the ancestor traversal identification value of the target resource, the descendant traversal identification value of the target resource and the descendant traversal depth value of the target resource, etc., and no specific limitation is made here.
[0043] S102: Acquire at least one target resource node from a resource tree according to the resource node acquisition request.
[0044] In this embodiment, the resource tree can be a tree applied to any business scenario. Nodes in the resource tree are resource nodes. A resource node, together with all its predecessor nodes and / or successor nodes, constitutes a resource subtree.
[0045] For example, if a local area network is taken as the root node of the tree, its child nodes can be the hosts in the local area network, and the child nodes of each host are the file system or database system on the host. The child nodes of each file system are the subdirectories under the root directory, and so on. The final leaf node may be a file, a data block, or a byte, etc., which is determined by the division granularity.
[0046] Optionally, in this embodiment, the resource node acquisition request carries target resource information, wherein the target resource information may be a target resource identifier, a target resource type, or a target resource parent node identifier, etc., which is not specifically limited here.
[0047] In a specific implementation, if it is determined that the resource node acquisition request carries target resource information, at least one target resource node corresponding to the target resource information is acquired from the resource tree according to the target resource information.
[0048] S103 : Acquire a target ancestor node and / or a target descendant node of each target resource node from the resource tree according to the resource subtree construction request.
[0049] Optionally, after acquiring at least one target resource node, embodiments of the present invention may determine, based on a resource subtree construction request, whether each target resource node has a need to acquire a corresponding ancestor node and / or descendant node. If any target resource node has a need to acquire its own corresponding ancestor node and / or descendant node, the target ancestor node and / or target descendant node for each target resource node is acquired from the resource tree based on the resource subtree construction request.
[0050] It can be understood that in this embodiment, obtaining the target ancestor node and / or target descendant node of each target resource node may refer to obtaining the target ancestor node of each target resource node; or, it may refer to obtaining the target descendant node of each target resource node; or, it may refer to obtaining the target ancestor node and target descendant node of each target resource node, which is not specifically limited here.
[0051] S104: Construct a target resource subtree according to each target resource node and the target ancestor node and / or target descendant node of each target resource node.
[0052] Optionally, after obtaining the target resource node and its target ancestor node and / or target descendant node, a target resource subtree may be constructed based on the target resource node together with its target ancestor node and / or target descendant node.
[0053] Then, the constructed target resource subtree is displayed, so that the user can obtain resource query results based on the displayed target resource subtree.
[0054] The technical solution provided by an embodiment of the present invention divides an acquired resource query request into a resource node acquisition request and a resource subtree construction request. Based on the resource node acquisition request, at least one target resource node is acquired from the resource tree. Based on the resource subtree construction request, the target ancestor node and / or target descendant node of each target resource node are acquired from the resource tree. Then, based on each target resource node and each target ancestor node and / or target descendant node of each target resource node, a target resource subtree is constructed. Thus, by dividing the resource query request into the resource node acquisition request and the resource subtree construction request, the purpose of querying any subtree of the resource tree is achieved, thereby meeting the user's resource query needs and improving the resource query robustness of the resource tree.
[0055] Based on the above embodiment, in an optional embodiment of the present invention, the number of resource trees may be multiple, and the resource query parameter carried in the obtained resource query request further includes: a target resource tree identifier.
[0056] In this embodiment, the target resource tree identifier refers to information that can uniquely identify the resource tree, such as a resource tree ID or a resource tree name, which is not specifically limited herein.
[0057] That is, when a resource query request is obtained, the resource query request may be parsed, and if it is determined that the parsing result includes a target resource tree identifier, the target resource tree is obtained from multiple resource trees according to the target resource tree identifier, and a resource query is performed in the target resource tree.
[0058] Figure 2 This is a flow chart of another resource query method based on a resource tree provided by an embodiment of the present invention. This embodiment is further optimized based on the above embodiment. Figure 2 As shown, the method specifically includes the following:
[0059] S201: When a resource query request is obtained, the resource query request is parsed to obtain resource query parameters carried in the resource query request.
[0060] The resource query parameters include: target resource identifier, target resource type or target resource parent node identifier, and the target resource's ancestor traversal identifier, the target resource's ancestor traversal depth, the target resource's descendant traversal identifier and / or the target resource's descendant traversal depth.
[0061] S202: Construct the resource node acquisition request according to the target resource identifier, target resource type or target resource parent node identifier in the resource query request.
[0062] S203: Construct the resource subtree construction request according to the ancestor traversal identifier of the target resource, the ancestor traversal depth of the target resource, the target resource descendant traversal identifier and / or the target resource descendant traversal depth in the resource query request.
[0063] To facilitate description of resource node acquisition requests and resource subtree construction requests, in this embodiment, set C may represent resource node acquisition requests, and set D may represent resource subtree construction requests.
[0064] S204: Acquire at least one target resource node from a resource tree according to the resource node acquisition request.
[0065] Optionally, at least one target resource node may be obtained from the resource tree in the following manner.
[0066] Method 1
[0067] According to the target resource identifier, target resource type or target resource parent node identifier carried in the resource node acquisition request, the resource tree is traversed to acquire at least one target resource node.
[0068] Method 2
[0069] According to the target resource identifier, target resource type or target resource parent node identifier carried in the resource node acquisition request, the resource node list of the resource tree is queried to acquire at least one target resource node.
[0070] The resource node list may be created in advance based on the resource tree, and the resource node list includes: a resource node identifier, a resource type, and a resource parent node identifier.
[0071] It should be noted that the above two methods are merely exemplary descriptions of the embodiments of the present invention and are not intended to be specific limitations of the embodiments of the present invention.
[0072] For example, if the target resource is identified as ID2, the resource tree is traversed according to ID2 to obtain the resource node identified as ID2 as the target resource node.
[0073] For another example, if the target resource identifier includes vehicle assessment and analysis services, then based on the vehicle assessment and analysis services, the resource node for vehicle assessment and the resource node for analysis services are queried from the resource node list of the resource tree respectively, and the queried resource node for vehicle assessment is used as the first target resource node, and the resource node for analysis services is used as the second target resource node.
[0074] S205 : acquiring a target ancestor node and / or a target descendant node of each target resource node from the resource tree according to the resource subtree construction request.
[0075] Optionally, the resource tree can be traversed based on the ancestor traversal identification value of the target resource, the ancestor traversal depth value of the target resource, the target resource descendant traversal identification value and / or the target resource descendant traversal depth value carried in the resource subtree construction request to obtain the target ancestor node and / or target descendant node of each target resource node.
[0076] S206: Construct a target resource subtree according to each target resource node and the target ancestor node and / or target descendant node of each target resource node.
[0077] In order to clearly illustrate the embodiments of the present invention, the following specific examples are provided for illustration.
[0078] For example, suppose the resource tree is Figure 2As shown in (a), resource types may include: directory (dir), job (job), workflow (flow), interactive (sql), file (file), and schedule (schedule); resource names include: assessment business, analysis business, vehicle query, time query, vehicle assessment, face, retrieval, traffic analysis, early morning scheduling, retrieval by time, retrieval by license plate, and spark jar (Spark application dependent jar package); resource IDs include: rootID0, assessment business ID1, analysis business ID2, vehicle query ID3, time query ID4, vehicle assessment ID5, face ID6, retrieval ID7, traffic analysis ID8, early morning scheduling ID9, retrieval by time ID10, retrieval by license plate ID11, and spark jar (Spark application dependent jar package) ID12.
[0079] If the resource query request does not carry a resource query parameter, that is, C=null, indicating that all nodes of the resource tree are queried, the entire resource tree is the target resource subtree.
[0080] If the resource query request carries the target resource parent node identifier, and the target resource parent node identifier is: p_ID=0, that is, C={p_ID=0}, it means querying the resource node with the parent node ID of 0, such as Figure 2 (a) It can be seen that the ID of the root node (root) is 0, so the successor node of the root node (judgment business, analysis business, vehicle query and time query) is determined to be the target resource node. Further, if the resource query request does not carry other resource query parameters except the target resource parent node identifier, then it is determined that the ancestor node and descendant node traversal parameters of the target resource node are not carried in the resource subtree construction request, that is, D = {null} or D = {p_recursive = false, s_recursive = false}, indicating that there is no need to traverse the ancestor node and descendant node of the target resource node. Among them, p_recursive = false means that the target resource ancestor traversal identifier value is false, and s_recursive means that the target resource descendant traversal identifier value is false. Therefore, based on Figure 2 (a) Four target resource subtrees can be obtained, namely: Subtree 0: Research and judgment business, Subtree 1: Analysis business, Subtree 2: Vehicle query, Subtree 3: Time query, see Figure 2 (b) In this example, the target resource subtree set can be obtained based on the four subtrees: {Subtree 0: Research and judgment business, Subtree 1: Analysis business, Subtree 2: Vehicle query, Subtree 3: Time query}.
[0081] If the resource query request carries the target resource parent node identifier, and the target resource parent node identifier is: p_ID=1, that is, C={p_ID=1}, it means querying the resource node with the parent node ID of 1, such as Figure 2 (a) It can be seen that the ID of the analysis and judgment business node is 1, so the successor node of the analysis and judgment business node (vehicle analysis and face) is determined to be the target resource node. Further, if the resource query request carries the target resource parent node identifier in addition to the descendant node traversal parameter of the target resource node, then the set D corresponding to the resource subtree construction request is determined to be {s_recursive=true}, where s_recursive is the target resource descendant traversal identifier value of true, indicating traversing all descendant nodes of the target resource node. Therefore, based on the descendant node traversal parameter of the target resource node and Figure 2 (a) We can get all descendant nodes of the target resource node "Vehicle Analysis" as: Traffic Analysis, Midnight Scheduling, and Spark Jar, and all descendant nodes of the target resource node "Face" as: None. Accordingly, based on the target resource nodes: "Vehicle Analysis" and "Face", as well as all descendant nodes of "Vehicle Analysis", we get two target resource subtrees: Subtree 4 and Subtree 5. For details, see Figure 2 (c) In this example, based on the two subtrees, the target resource subtree set can be obtained: {subtree 4, subtree 5}.
[0082] If the resource query request carries the target resource type, and the target resource type is: job, that is, C = {type = job}, it means querying resource nodes of job type, such as Figure 2 (a) It can be seen that the resource nodes of the job type include: business analysis, face, traffic analysis and retrieval by license plate, so business analysis, face, traffic analysis and retrieval by license plate are determined as target resource nodes. Further, if the resource query request does not carry other resource query parameters except the target resource type, then it is determined that the ancestor node and descendant node traversal parameters of the target resource node are not carried in the resource subtree construction request, that is, D = {null} or D = {p_recursive = false, s_recursive = false}, indicating that there is no need to traverse the ancestor node and descendant node of the target resource node. Therefore, it can be obtained that there are 4 target resource subtrees, namely: Subtree 6: Business Analysis, Subtree 7: Face, Subtree 8: Traffic Analysis, Subtree 9: Retrieval by License Plate, see Figure 2 (d) In this example, based on the four subtrees, a target resource subtree set can be obtained: {Subtree 6: Analysis Service, Subtree 7: Face, Subtree 8: Traffic Analysis, Subtree 9: Retrieval by License Plate}.
[0083] If the resource query request carries the target resource type, and the target resource type is flow, that is, C = {type = flow}, it means querying resource nodes of flow type, such as Figure 2 (a) It can be seen that the resource nodes of flow type include: vehicle analysis, so the vehicle analysis is determined to be the target resource node. Further, if the resource query request carries the ancestor node and descendant node traversal parameters of the target resource node in addition to the target resource type, then the set D = {p_recursive = true, s_recursive = true} corresponding to the resource subtree construction request is determined, indicating that all ancestor nodes and all descendant nodes of the target resource node need to be traversed. Therefore, based on the ancestor node and descendant node traversal parameters of the target resource node and Figure 2 (a) All ancestor nodes of the target resource node "vehicle analysis" are: analysis business and root, and all descendant nodes are: traffic analysis, early morning scheduling, and spark Jar. Then, based on "vehicle analysis", "analysis business", "root", "traffic analysis", "early morning scheduling", and "spark Jar", the target resource subtree 10 is obtained. For details, see Figure 2 (e).
[0084] If the resource query request carries the target resource type, and the target resource type is flow, that is, C = {type = flow}, it means querying resource nodes of flow type, such as Figure 2 (a) It can be seen that the resource nodes of flow type include: vehicle analysis, so the vehicle analysis is determined to be the target resource node. Further, if the resource query request carries the ancestor node and descendant node traversal parameters of the target resource node in addition to the target resource type, then the set D corresponding to the resource subtree construction request is determined to be {p_recursive=true, s_recursive=true, p_depth=1, s_depth=1}, indicating that the ancestor node and descendant node of the target resource node need to be traversed, and the depth value of the ancestor node and descendant node of the target resource node is 1. Therefore, based on the ancestor node and descendant node traversal parameters of the target resource node and Figure 2 (a), we can get the ancestor node of the target resource node "vehicle assessment" is: assessment business, and the descendant nodes are: traffic analysis and early morning scheduling. Then, according to "vehicle assessment", "assessment business", "traffic analysis" and "early morning scheduling", we get the target resource subtree 11, see Figure 2 (f).
[0085] The technical solution provided by an embodiment of the present invention divides an acquired resource query request into a resource node acquisition request and a resource subtree construction request. Based on the resource node acquisition request, at least one target resource node is acquired from the resource tree. Based on the resource subtree construction request, the target ancestor node and / or target descendant node of each target resource node are acquired from the resource tree. Then, based on each target resource node and each target ancestor node and / or target descendant node of each target resource node, a target resource subtree is constructed. Thus, by dividing the resource query request into the resource node acquisition request and the resource subtree construction request, the purpose of querying any subtree of the resource tree is achieved, thereby meeting the user's resource query needs and improving the resource query robustness of the resource tree.
[0086] Figure 3 This is a flow chart of another resource query method based on a resource tree provided by an embodiment of the present invention. This embodiment is further optimized on the basis of the above embodiment. Specifically, if there are multiple target resource nodes, then before constructing the target resource subtree based on each target resource node and the target ancestor node and / or target descendant node of each resource node, it also includes: determining whether there are duplicate nodes in the target ancestor nodes and / or target descendant nodes of multiple target resource nodes; if so, deduplication is performed on the duplicate target ancestor nodes and / or target descendant nodes. Figure 3 As shown, the method specifically includes:
[0087] S301 : When a resource query request is obtained, the resource query request is divided into a resource node acquisition request and a resource subtree construction request.
[0088] S302: Acquire multiple target resource nodes from a resource tree according to the resource node acquisition request.
[0089] S303: According to the resource subtree construction request, obtain the target ancestor node and / or target descendant node of each target resource node from the resource tree.
[0090] S304: Determine whether there are duplicate nodes among the target ancestor nodes and / or target descendant nodes of the multiple target resource nodes.
[0091] S305: If so, perform deduplication processing on the repeated target ancestor nodes and / or target descendant nodes.
[0092] S306 : Construct a target resource subtree according to the multiple target resource nodes and the target ancestor nodes and / or target descendant nodes of each target resource node after deduplication.
[0093] The following combination Figure 3 (a) An example is given to illustrate the resource query method based on the resource tree provided in this embodiment.
[0094] Assume that the resource tree is Figure 3 As shown in (a), the resource types may include: directory (dir), job (job), workflow (flow), interactive (sql), file (file), and schedule (schedule); the resource names include: business 1, business 2, business 3, business 4, business 5, business 6, business 7, business 8, business 9, business 10, and business 11; the resource IDs include: rootID0, business ID1, business ID2, business ID3, business ID4, business ID5, business ID6, business ID7, business ID8, business ID9, business ID10, and business ID11.
[0095] If the resource query request carries the target resource type, and the target resource type is flow, that is, C = {type = flow}, it means querying resource nodes of flow type, such as Figure 3 (a) It can be seen that the resource nodes of type flow include: business 1 and business 2, so "business 1 and business 2" are determined to be the target resource nodes. Further, if the resource subtree construction request carries the ancestor node and descendant node traversal parameters of the target resource node, that is, D = {p_recursive = true, s_recursive = true, p_depth = 1, s_depth = 2}, it means that the ancestor node and descendant node of the target resource node need to be traversed, and the depth value of the ancestor node of the target resource node is 1, and the depth value of the descendant node of the target resource node is 2. Therefore, based on the ancestor node and descendant node traversal parameters of the target resource node and Figure 3 (a) The ancestor node of the target resource node "Business 1" is: "root"; the descendant nodes are: "Business 5, Business 6, Business 9 and Business 10", and the ancestor node of the target resource node "Business 2" is: "root"; the descendant nodes are: "Business 6, Business 7 and Business 11". According to the ancestor nodes and descendant nodes of the target resource nodes "Business 1" and "Business 2", it is determined that the ancestor node "root" and the descendant nodes "Business 6 and Business 11" of "Business 1" and "Business 2" are duplicate nodes, and then "root", "Business 6 and Business 11" are deduplicated. Then, based on the deduplicated ancestor nodes, descendant nodes and target resource nodes, the target resource subtree is constructed. For details, see Figure 3 (b).
[0096] The technical solution provided by the embodiment of the present invention divides the obtained resource query request into a resource node acquisition request and a resource subtree construction request, so as to obtain multiple target resource nodes from the resource tree according to the resource node acquisition request, and obtain the target ancestor node and / or target descendant node of each target resource node from the resource tree according to the resource subtree construction request, determine whether there are duplicate nodes among the target ancestor nodes and / or target descendant nodes of the multiple target resource nodes, and if so, deduplicate the duplicate target ancestor nodes and / or target descendant nodes, and then construct the target resource subtree according to the multiple target resource nodes and the deduplicated target ancestor nodes and / or target descendant nodes of each target resource node. Thus, by dividing the resource query request into the resource node acquisition request and the resource subtree construction request, the purpose of querying any subtree of the resource tree is achieved, thereby meeting the user's resource query needs and improving the resource query robustness of the resource tree. In addition, by deduplicating repeated ancestor nodes and / or descendant nodes, repeated construction of the same ancestor nodes and / or descendant nodes is avoided when the target resource subtree is subsequently constructed, thereby reducing the processing burden of constructing the resource subtree and improving the construction speed of the resource subtree.
[0097] In order to achieve the above-mentioned purpose, an embodiment of the present invention further proposes a resource query device based on a resource tree. Figure 4 FIG is a schematic diagram of a resource query device based on a resource tree provided by an embodiment of the present invention. Figure 4 As shown, the apparatus 400 includes: a query request partitioning module 410 , a first node acquisition module 420 , a second node acquisition module 430 and a resource subtree construction module 440 .
[0098] The query request division module 410 is configured to, upon receiving a resource query request, divide the resource query request into a resource node acquisition request and a resource subtree construction request;
[0099] A first node acquisition module 420 is configured to acquire at least one target resource node from a resource tree according to the resource node acquisition request;
[0100] A second node acquisition module 430 is configured to acquire a target ancestor node and / or a target descendant node of each target resource node from the resource tree according to the resource subtree construction request;
[0101] The resource subtree construction module 440 is configured to construct a target resource subtree according to each target resource node and the target ancestor node and / or target descendant node of each target resource node.
[0102] As an optional implementation of the embodiment of the present invention, the resource query request carries a resource query parameter;
[0103] The resource query parameters include: target resource identifier, target resource type or target resource parent node identifier, and the target resource ancestor traversal identifier value, the target resource ancestor traversal depth value, the target resource descendant traversal identifier value and / or the target resource descendant traversal depth value.
[0104] As an optional implementation of the embodiment of the present invention, the query request division module 410 includes: a first request construction unit and a second request construction unit;
[0105] The first request construction unit is configured to construct the resource node acquisition request according to the target resource identifier, target resource type or target resource parent node identifier in the resource query request;
[0106] The second request construction unit is used to construct the resource subtree construction request according to the ancestor traversal identification value of the target resource, the ancestor traversal depth value of the target resource, the target resource descendant traversal identification value and / or the target resource descendant traversal depth value of the target resource in the resource query request.
[0107] As an optional implementation of the embodiment of the present invention, the first node acquisition module 420 is specifically configured to:
[0108] Traversing the resource tree according to the target resource identifier, target resource type, or target resource parent node identifier carried in the resource node acquisition request to acquire at least one target resource node;
[0109] Alternatively, according to the target resource identifier, target resource type or target resource parent node identifier carried in the resource node acquisition request, the resource node list of the resource tree is queried to acquire at least one target resource node.
[0110] As an optional implementation of the embodiment of the present invention, the second node acquisition module 430 is specifically configured to:
[0111] According to the ancestor traversal identification value of the target resource, the ancestor traversal depth value of the target resource, the target resource descendant traversal identification value and / or the target resource descendant traversal depth value carried in the resource subtree construction request, the resource tree is traversed to obtain the target ancestor node and / or target descendant node of each target resource node.
[0112] As an optional implementation of the embodiment of the present invention, if the number of the target resource nodes is multiple, the apparatus 400 further includes: a duplicate node determination module and a deduplication processing module;
[0113] The duplicate node determination module is used to determine whether there are duplicate nodes among the target ancestor and / or target descendant nodes of the multiple target resource nodes;
[0114] The deduplication processing module is used to perform deduplication processing on repeated target ancestor nodes and / or target descendant nodes if any exist.
[0115] As an optional implementation of the embodiment of the present invention, the resource subtree construction module 440 is specifically configured to:
[0116] A target resource subtree is constructed according to the multiple target resource nodes and the target ancestor nodes and / or target descendant nodes of each target resource node after deduplication.
[0117] As an optional implementation of the embodiment of the present invention, the query request division module 410 is specifically configured to:
[0118] If there are multiple resource trees, the obtained resource query request further includes: a target resource tree identifier.
[0119] It should be noted that the above explanation of the embodiment of the resource query method based on the resource tree is also applicable to the resource query device based on the resource tree of this embodiment. The implementation principles are similar and will not be repeated here.
[0120] The technical solution provided by an embodiment of the present invention divides an acquired resource query request into a resource node acquisition request and a resource subtree construction request. Based on the resource node acquisition request, at least one target resource node is acquired from the resource tree. Based on the resource subtree construction request, the target ancestor node and / or target descendant node of each target resource node are acquired from the resource tree. Then, based on each target resource node and each target ancestor node and / or target descendant node of each target resource node, a target resource subtree is constructed. Thus, by dividing the resource query request into the resource node acquisition request and the resource subtree construction request, the purpose of querying any subtree of the resource tree is achieved, thereby meeting the user's resource query needs and improving the resource query robustness of the resource tree.
[0121] In order to achieve the above objectives, an embodiment of the present invention further provides an electronic device.
[0122] Figure 5 It is a structural diagram of an electronic device provided by an embodiment of the present invention. Figure 5 A block diagram of an exemplary electronic device 500 suitable for implementing embodiments of the present invention is shown. Figure 5 The electronic device 500 shown is merely an example and should not limit the functions and scope of use of the embodiments of the present invention.
[0123] like Figure 5As shown, electronic device 500 is implemented as a general-purpose computing device. Components of electronic device 500 may include, but are not limited to, one or more processors or processing units 510, system memory 520, and a bus 530 connecting various system components (including system memory 520 and processing unit 510).
[0124] Bus 530 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures. Examples of these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.
[0125] The electronic device 500 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 500, including volatile and non-volatile media, removable and non-removable media.
[0126] The system memory 520 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 521 and / or cache memory 522. The electronic device 500 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 523 may be used to read and write non-removable, non-volatile magnetic media ( Figure 5 Not shown, often called a "hard drive"). Although Figure 5 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 530 via one or more data medium interfaces. Memory 520 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of various embodiments of the present invention.
[0127] A program / utility 524 having a set (at least one) of program modules 525 may be stored, for example, in memory 520. Such program modules 525 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may include an implementation of a network environment. Program modules 525 generally implement the functions and / or methods of the embodiments described herein.
[0128] The electronic device 500 can also communicate with one or more external devices 540 (e.g., a keyboard, a pointing device, a display 541, etc.), one or more devices that enable a user to interact with the electronic device 500, and / or any device that enables the electronic device 500 to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). Such communication can occur via an input / output (I / O) interface 550. Furthermore, the electronic device 500 can communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network such as the Internet) via a network adapter 560. As shown, the network adapter 560 communicates with other modules of the electronic device 500 via a bus 530. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the electronic device 500, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0129] The processing unit 510 executes various functional applications and data processing by running programs stored in the system memory 520, such as implementing the resource query method based on the resource tree provided in an embodiment of the present invention, including:
[0130] When a resource query request is obtained, the resource query request is divided into a resource node acquisition request and a resource subtree construction request;
[0131] Acquire at least one target resource node from a resource tree according to the resource node acquisition request;
[0132] According to the resource subtree construction request, obtaining a target ancestor node and / or a target descendant node of each target resource node from the resource tree;
[0133] A target resource subtree is constructed according to each target resource node and the target ancestor node and / or target descendant node of each target resource node.
[0134] It should be noted that the above explanation of the embodiment of the resource query method based on the resource tree is also applicable to the electronic device of this embodiment. The implementation principle is similar and will not be repeated here.
[0135] The technical solution provided by an embodiment of the present invention divides an acquired resource query request into a resource node acquisition request and a resource subtree construction request. Based on the resource node acquisition request, at least one target resource node is acquired from the resource tree. Based on the resource subtree construction request, the target ancestor node and / or target descendant node of each target resource node are acquired from the resource tree. Then, based on each target resource node and each target ancestor node and / or target descendant node of each target resource node, a target resource subtree is constructed. Thus, by dividing the resource query request into the resource node acquisition request and the resource subtree construction request, the purpose of querying any subtree of the resource tree is achieved, thereby meeting the user's resource query needs and improving the resource query robustness of the resource tree.
[0136] In order to achieve the above object, the present invention also provides a computer-readable storage medium.
[0137] An embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, the method for querying resources based on a resource tree according to an embodiment of the present invention is implemented. The method includes:
[0138] When a resource query request is obtained, the resource query request is divided into a resource node acquisition request and a resource subtree construction request;
[0139] Acquire at least one target resource node from a resource tree according to the resource node acquisition request;
[0140] According to the resource subtree construction request, obtaining a target ancestor node and / or a target descendant node of each target resource node from the resource tree;
[0141] A target resource subtree is constructed according to each target resource node and the target ancestor node and / or target descendant node of each target resource node.
[0142] The computer storage medium of the embodiment of the present invention may adopt any combination of one or more computer-readable media. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device.
[0143] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0144] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0145] Computer program code for performing the operations of the present invention may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0146] Note that the above are only preferred embodiments of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments, and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments and may include many other equivalent embodiments without departing from the concept of the present invention. The scope of the present invention is determined by the scope of the appended claims.
Claims
1. A resource query method based on a resource tree, characterized in that: include: When a resource query request is obtained, the resource query request is divided into a resource node acquisition request and a resource subtree construction request; The resource query request carries resource query parameters; The resource query parameters include: a target resource identifier, a target resource type or a target resource parent node identifier, and an ancestor traversal identifier value of the target resource, an ancestor traversal depth value of the target resource, a descendant traversal identifier value of the target resource, and / or a descendant traversal depth value of the target resource; wherein the target resource identifier is an identifier of information that uniquely identifies the identity of the target resource, and the target resource identifier includes a resource name or a resource ID; Acquire at least one target resource node from a resource tree according to the resource node acquisition request; According to the resource subtree construction request, obtaining a target ancestor node and / or a target descendant node of each target resource node from the resource tree; Constructing a target resource subtree according to each target resource node and a target ancestor node and / or a target descendant node of each target resource node; The dividing the resource query request into a resource node acquisition request and a resource subtree construction request includes: Constructing the resource node acquisition request according to the target resource identifier, target resource type or target resource parent node identifier in the resource query request; The resource subtree construction request is constructed according to the ancestor traversal identification value of the target resource, the ancestor traversal depth value of the target resource, the target resource descendant traversal identification value and / or the target resource descendant traversal depth value in the resource query request.
2. The method according to claim 1, characterized in that The acquiring at least one target resource node from the resource tree according to the resource node acquisition request includes: Traversing the resource tree according to the target resource identifier, target resource type, or target resource parent node identifier carried in the resource node acquisition request to acquire at least one target resource node; Alternatively, according to the target resource identifier, target resource type or target resource parent node identifier carried in the resource node acquisition request, the resource node list of the resource tree is queried to acquire at least one target resource node.
3. The method according to claim 1, characterized in that The step of acquiring a target ancestor node and / or a target descendant node of each target resource node from the resource tree according to the resource subtree construction request includes: According to the ancestor traversal identification value of the target resource, the ancestor traversal depth value of the target resource, the target resource descendant traversal identification value and / or the target resource descendant traversal depth value carried in the resource subtree construction request, the resource tree is traversed to obtain the target ancestor node and / or target descendant node of each target resource node.
4. The method according to any one of claims 1 to 3, characterized in that If there are multiple target resource nodes, before constructing the target resource subtree based on each target resource node and the target ancestor node and / or target descendant node of each target resource node, the method further includes: Determine whether there are duplicate nodes among target ancestor nodes and / or target descendant nodes of the plurality of target resource nodes; If so, duplicate target ancestor nodes and / or target descendant nodes are deduplicated.
5. The method according to claim 4, characterized in that The step of constructing a target resource subtree according to each target resource node and a target ancestor node and / or a target descendant node of each target resource node includes: A target resource subtree is constructed according to the multiple target resource nodes and the target ancestor nodes and / or target descendant nodes of each target resource node after deduplication.
6. A resource query device based on a resource tree, characterized in that: include: A query request division module is used to divide the resource query request into a resource node acquisition request and a resource subtree construction request when obtaining the resource query request; The resource query request carries resource query parameters; The resource query parameters include: a target resource identifier, a target resource type or a target resource parent node identifier, and an ancestor traversal identifier value of the target resource, an ancestor traversal depth value of the target resource, a descendant traversal identifier value of the target resource, and / or a descendant traversal depth value of the target resource; wherein the target resource identifier is an identifier of information that uniquely identifies the identity of the target resource, and the target resource identifier includes a resource name or a resource ID; A first node acquisition module, configured to acquire at least one target resource node from a resource tree according to the resource node acquisition request; A second node acquisition module is configured to acquire a target ancestor node and / or a target descendant node of each target resource node from the resource tree according to the resource subtree construction request; A resource subtree construction module, configured to construct a target resource subtree according to each target resource node and a target ancestor node and / or a target descendant node of each target resource node; The query request division module includes: a first request construction unit and a second request construction unit; The first request construction unit is configured to construct the resource node acquisition request according to the target resource identifier, target resource type or target resource parent node identifier in the resource query request; The second request construction unit is used to construct the resource subtree construction request according to the ancestor traversal identification value of the target resource, the ancestor traversal depth value of the target resource, the target resource descendant traversal identification value and / or the target resource descendant traversal depth value in the resource query request.
7. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the resource query method based on the resource tree as described in any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the resource query method based on the resource tree as described in any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Electronic certificate prompting method and device, computer equipment and storage medium
CN110532437A