Cross-class query method, system and device for tree structure in object agent database

CN118260331BActive Publication Date: 2026-09-18WUHAN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410438344.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-12
Publication Date
2026-09-18
Estimated Expiration
2044-04-12

AI Technical Summary

Technical Problem

[0007]本申请实施例提供了一种对象代理数据库中树型结构的跨类查询方法、系统及设备,以至少解决对象代理数据库现有的跨类查询功能中,用户无法通过书写一个路径表达式来获取不同终点类上的多个属性值,导致用户输入过于繁琐的问题

Benefits of technology

[0035] This invention allows the output of queried object attributes along the path while sequentially traversing all proxy classes. It also allows simultaneous queries when the source class has multiple different proxy classes. This solves the problem in the existing cross-class query function of object proxy databases in related technologies, where users cannot obtain multiple attribute values ​​on different endpoint classes by writing a path expression, resulting in overly cumbersome user input.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118260331B_ABST
    Figure CN118260331B_ABST
Patent Text Reader

Abstract

The application discloses a cross-class query method, system and device for tree structure in an object proxy database, and is used for solving the problems of low execution efficiency of cross-class query instructions and complicated writing of query statements in the object proxy database. The method accepts user input by using a multi-path cross-class query instruction based on a generalized table representation method, and uses a cross-class query execution mode of tree structure, so that the number of instruction lines input by the user can be effectively reduced, and the query execution efficiency is improved. On this basis, a tree path pointer tracking algorithm and corresponding class structure, a to-be-processed queue and other data structures are proposed, and are used for calculation of a multi-path expression. By using the application, a user can use one multi-path cross-class query instruction based on the generalized table representation method to obtain different attribute information of different terminal classes, without repeatedly writing query instructions, so that repeated search of common paths in the query instructions is reduced, and the query efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of database query optimization technology, and relates to a method, system and device for cross-class query of tree structure in database, specifically a method, system and device for cross-class query of tree structure in object proxy database. Background Technology

[0002] Object proxy databases implement cross-class queries using path expressions as input. However, the syntax support for path expressions in object-oriented database languages ​​is not very good. The basic version can only support basic query input from a single start class to a single end class, and a single query can only output a single attribute of the end class. Furthermore, the FROM clause in the query statement is always the start class, so it is unnecessary to write it, and the WHERE clause can only restrict the start class attribute to a specific value, which has significant limitations.

[0003] After several updates and iterations, existing technology can now support the output of results for multiple different attributes of the endpoint class in a single query by merging multiple attributes into one. In this way, when two paths are exactly the same, the user only needs to enter the path expression once. At the same time, when multiple paths contain a common path but only their endpoint classes are different, some scholars have proposed merging the endpoint classes to achieve writing the common path only once.

[0004] Two execution algorithms have been proposed in the existing technology: Pointer Tracking (PT) and Multi-paths-expressions Pointer Tracking (MPT). Pointer Tracking (PT) is suitable for cross-class queries under a single path, such as... Figure 1 As shown, it starts from the starting class A, sequentially finds the proxy objects in proxy classes B, C, and D, and then outputs the attribute values ​​of the proxy objects in the ending class D. Later, the pointer tracing algorithm MPT, suitable for multi-path expression computation algorithms, was proposed, but strictly speaking, it can only solve the case of branching at the level above the ending class, such as... Figure 2 As shown, it starts from the starting class A, finds the proxy objects in proxy classes B and C in turn, and then retrieves the proxy objects of the search class C in proxy classes D, E and F respectively, and outputs their attribute values.

[0005] Existing cross-class query methods still require users to write multiple queries separately when there are only a few common paths in the query path, which increases the user's input burden and the algorithm has low execution efficiency. Furthermore, existing multi-path query algorithms can only be applied to the special case where multiple query paths are the same except for the destination class, but they are powerless for other general cases.

[0006] In the existing cross-class query function of object proxy databases, users cannot obtain multiple attribute values ​​on different endpoint classes by writing a path expression, resulting in overly cumbersome user input. No effective solution has yet been proposed. Summary of the Invention

[0007] This application provides a method, system, and device for cross-class querying of tree structures in an object proxy database, which at least solves the problem that in the existing cross-class query function of the object proxy database, users cannot obtain multiple attribute values ​​on different endpoint classes by writing a path expression, resulting in overly cumbersome user input.

[0008] The technical solution adopted by the method of the present invention is: a cross-class query method for a tree structure in an object proxy database, which queries attribute information in multiple proxy classes based on a path expression that includes multiple proxy classes; including the following steps:

[0009] Step 1: Receive the path expression and obtain the first proxy class indicated by the root node of the path expression; if there is a predicate condition in the first proxy class, add the first proxy object that meets the predicate condition to the class node structure; if there is no predicate condition in the first proxy class, add all the first proxy objects to the class node structure; add the class node structure to the queue of classes to be processed.

[0010] Step 2: Obtain the first proxy object from the class node structure, process the multiple second proxy classes respectively, and obtain the multiple second proxy classes based on the first proxy object; if a predicate condition exists in the second proxy class, add the second proxy object that meets the predicate condition to the class node structure; if no predicate condition exists in the second proxy class, add all the second proxy objects to the class node structure; add the multiple second proxy classes to the queue of classes to be processed, and delete the first proxy class from the queue of classes to be processed; wherein, the multiple second proxy classes are the next-level subclasses of the first proxy class;

[0011] Step 3: Process the target second proxy class located at the head of the queue of classes to be processed; find the next-level subclass of the target second proxy class and denote it as the third proxy class; obtain the second proxy object of the target second proxy class from the class node structure; and obtain the third proxy object of the third proxy class that meets the predicate condition based on the second proxy object; store the third proxy object in the class node structure and add the third proxy class to the queue of classes to be processed; perform attribute query on the target second proxy class according to the attribute condition of the path expression; add the queried attribute information to the output queue, wait for output, and delete the target second proxy class from the queue of classes to be processed.

[0012] Step 4: Process the remaining proxy classes in the queue of classes to be processed in the same way as in Step 3 until the queue of classes to be processed is empty. Output all the attribute information stored in the output queue to obtain the attribute information that the path expression is looking for.

[0013] Preferably, the path expression including multiple proxy classes is as follows:

[0014] P n =C1[Q1,R1]→(P n-1 );

[0015]

[0016] Where n≥2, C i Represents a node in a directed graph, where C1 represents the starting class; Q i Represents the action on class node C in a directed graph. i The conditional predicate on R has the format: class attribute name = specific value; i Represents the action on class node C in a directed graph. i The query attribute is in the following format: class attribute name; 1≤i≤n;

[0017] Let the maximum depth of the current tree be n, and let P n-1 Represents a subtree or leaf node with a maximum depth of n-1, and it has three forms:

[0018] (1) If it is a leaf node without a right sibling node, the cross-class query can return the calculation result after it reaches this point;

[0019] (2) If it is a leaf node with a right sibling node, it can be expanded into the form of "leaf node, right sibling node". When the leaf node is found, the calculation result of the node can be temporarily stored for later return. For the right sibling node, further recursive consideration is still required.

[0020] (3) If it is a node with children, it can be extended to the form of "current node -> (child node)". After obtaining the proxy object on the current class node, for several proxy classes in the child node, the proxy object in the first child proxy class that meets the predicate condition should be obtained first, and then the calculation should be further recursively based on the first two existence forms.

[0021] Preferably, the class node structure defines the following for any class node in the path expression: `deputyObjectList` is defined to store the proxy objects mapped from all objects in the parent class to the current class; `pathFilterList` is defined to store the predicate filtering expression used by the user in the class; proxy objects that do not meet the predicate filtering requirements will not be stored in `deputyObjectList`; and `pathTargetList` is defined to store all attributes to be queried in the current class.

[0022] Preferably, when the queue of classes to be processed reaches a class node, its proxy class is obtained, all proxy objects of the current class node object in the proxy class are found, and the proxy class node structure is successfully constructed, it is temporarily stored in the PendingNodeList queue, indicating that the proxy class has not yet been executed for subsequent query and output operations.

[0023] Once all proxy classes of a class node have been added to the PendingNodeList queue, the class node can be removed from the pending class queue. Before deletion, it is determined whether there are any user query attribute requirements on the class node. If so, the query attribute information of all objects in the class is saved to the OutputNode structure and output after execution.

[0024] Preferably, in step 3, the step of obtaining the third proxy object that meets the predicate condition in the third proxy class based on the second proxy object firstly involves matching multiple fourth proxy objects in the third proxy class based on the second proxy object, and then determining whether the third proxy class has a predicate condition in the path expression; if a predicate condition exists, the multiple fourth proxy objects are filtered according to the predicate condition, and the multiple fifth proxy objects obtained by the filtering are determined as the third proxy object; if no predicate condition exists, the multiple fourth proxy objects are determined as the third proxy object.

[0025] The technical solution adopted by the system of this invention is: a cross-class query system with a tree structure in an object proxy database, which queries attribute information in multiple proxy classes based on path expressions that include multiple proxy classes; it includes the following modules:

[0026] Module 1 is used to receive a path expression, obtain the first proxy class indicated by the root node of the path expression; if there is a predicate condition in the first proxy class, add the first proxy object that meets the predicate condition to the class node structure; if there is no predicate condition in the first proxy class, add all the first proxy objects to the class node structure; and add the class node structure to the queue of classes to be processed.

[0027] Module 2 is used to obtain the first proxy object from the class node structure, process multiple second proxy classes respectively, and obtain the multiple second proxy classes based on the first proxy object; if a predicate condition exists in the second proxy class, the second proxy object that meets the predicate condition is added to the class node structure; if no predicate condition exists in the second proxy class, all second proxy objects are added to the class node structure; the multiple second proxy classes are added to the queue of classes to be processed, and the first proxy class is deleted from the queue of classes to be processed; wherein, the multiple second proxy classes are the next-level subclasses of the first proxy class;

[0028] Module 3 is used to process the target second proxy class located at the head of the queue of classes to be processed, find the next-level subclass of the target second proxy class, and denote it as the third proxy class; obtain the second proxy object of the target second proxy class from the class node structure, and obtain the third proxy object of the third proxy class that meets the predicate condition based on the second proxy object, store the third proxy object in the class node structure, and add the third proxy class to the queue of classes to be processed; perform attribute query on the target second proxy class according to the attribute condition of the path expression, add the queried attribute information to the output queue, wait for output, and delete the target second proxy class from the queue of classes to be processed;

[0029] Module 4 is used to process the remaining proxy classes in the queue of classes to be processed in the same way as Module 3, until the queue of classes to be processed is empty, and then output all the attribute information stored in the output queue, that is, to obtain the attribute information that the path expression is looking for.

[0030] The technical solution adopted by the device of the present invention is: a cross-class query device with a tree structure in an object proxy database, comprising:

[0031] One or more processors;

[0032] A storage device for storing one or more programs, which, when executed by one or more processors, enable the one or more processors to implement the cross-class query method for a tree structure in the object proxy database.

[0033] The technical solution adopted by the storage medium of the present invention is: a non-volatile computer-readable storage medium containing a computer program, which, when executed by one or more processors, enables the processor to perform a cross-class query method for a tree structure in an object proxy database.

[0034] The technical solution adopted by the program product of the present invention is: a computer program product, including computer program instructions, which, when the computer program instructions are run on a computer, enable the computer to perform a cross-class query method for a tree structure in an object proxy database.

[0035] This invention allows the output of queried object attributes along the path while sequentially traversing all proxy classes. It also allows simultaneous queries when the source class has multiple different proxy classes. This solves the problem in the existing cross-class query function of object proxy databases in related technologies, where users cannot obtain multiple attribute values ​​on different endpoint classes by writing a path expression, resulting in overly cumbersome user input.

[0036] Compared with the prior art, the beneficial effects of the present invention include:

[0037] (1) This invention accepts user input by using a multi-path cross-class query instruction based on generalized table representation and executes the cross-class query using a tree-structured method, which can effectively reduce the number of instructions input by the user. When querying from a starting class to different ending classes, only one query expression needs to be written, without rewriting it. For example, considering outputting the attribute values ​​of C and D in the query sequence A->B->C->D, the existing technical solution requires writing two query instructions, A->B->C and A->B->C->D, while the multi-path cross-class query based on generalized table representation in this invention only requires writing it once.

[0038] (2) This invention accepts user input by using a multi-path cross-class query instruction based on generalized table representation, so that class nodes in the path can also output the required attribute values, instead of having to reach the final leaf node to output the result. For example, consider the query sequence A->B->C->D, which outputs the attribute values ​​of classes B and C in the path. Existing solutions cannot do this, but this invention uses a multi-path cross-class query based on generalized table representation to temporarily store attribute information and output it during the query.

[0039] (3) The tree-structured path pointer tracing algorithm and corresponding class structures, processing queues, and other data structures proposed in this invention are used for the calculation of multi-path expressions. Once a proxy object satisfying the predicate condition for the current class is obtained, it can be directly used for subsequent node queries, reducing the process of repeatedly querying proxy objects and improving the execution efficiency of cross-class queries. For example, consider two queries, A->B->C and A->B->C->D, both of which contain a long common sequence A->B->C. This invention avoids the process of repeatedly searching for proxy objects for the common sequence, requiring only one query statement. The proxy object of class C can be directly used for subsequent queries of class D, improving the execution efficiency of cross-class queries. Attached Figure Description

[0040] The technical solutions of the present invention will be further illustrated below using embodiments and specific implementation methods. In addition, some accompanying drawings are used in the description of the technical solutions. Those skilled in the art can obtain other drawings and the intent of the present invention from these drawings without any creative effort.

[0041] Figure 1 This is a schematic diagram of a cross-class query method under a single path in the prior art of this invention;

[0042] Figure 2 This is a schematic diagram of the pointer tracing algorithm for multi-path expressions in the prior art of this invention;

[0043] Figure 3 This is a flowchart of a method according to an embodiment of the present invention;

[0044] Figure 4 This is a schematic diagram of an optional tree-based path pointer tracing algorithm according to an embodiment of the present invention;

[0045] Figure 5 This is a flowchart (I) of a cross-class query method for a tree structure in an object proxy database according to an embodiment of the present invention;

[0046] Figure 6 This is a flowchart (II) of a cross-class query method for a tree structure in an object proxy database according to an embodiment of the present invention;

[0047] Figure 7 This is a flowchart (III) of a cross-class query method for a tree structure in an object proxy database according to an embodiment of the present invention;

[0048] Figure 8 This is a flowchart (IV) of a cross-class query method for a tree structure in an object proxy database according to an embodiment of the present invention. Detailed Implementation

[0049] To facilitate understanding and implementation of the present invention by those skilled in the art, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the embodiments described herein are for illustration and explanation only and are not intended to limit the present invention.

[0050] Please see Figure 3 This embodiment provides a cross-class query method for a tree-structured object proxy database, which queries attribute information in multiple proxy classes based on path expressions that include multiple proxy classes; it includes the following steps:

[0051] Step 1: Receive the path expression and obtain the first proxy class indicated by the root node of the path expression; if there is a predicate condition in the first proxy class, add the first proxy object that meets the predicate condition to the class node structure; if there is no predicate condition in the first proxy class, add all the first proxy objects to the class node structure; add the class node structure to the queue of classes to be processed.

[0052] In one implementation, the path expression is:

[0053] P n =C1[Q1,R1]→(P n-1 );

[0054]

[0055] Where n≥2, C i Represents a node in a directed graph, where C1 represents the starting class; Q i Represents the action on class node C in a directed graph. i The conditional predicate on R has the format: class attribute name = specific value; i Represents the action on class node C in a directed graph. i The query attribute is in the following format: class attribute name; 1≤i≤n;

[0056] Let the maximum depth of the current tree be n, and let P n-1 Represents a subtree or leaf node with a maximum depth of n-1, and it has three forms:

[0057] (1) If it is a leaf node without a right sibling node, the cross-class query can return the calculation result after it reaches this point;

[0058] (2) If it is a leaf node with a right sibling node, it can be expanded into the form of "leaf node, right sibling node". When the leaf node is found, the calculation result of the node can be temporarily stored for later return. For the right sibling node, further recursive consideration is still required.

[0059] (3) If it is a node with children, it can be extended to the form of "current node -> (child node)". After obtaining the proxy object on the current class node, for several proxy classes in the child node, the proxy object in the first child proxy class that meets the predicate condition should be obtained first, and then the calculation should be further recursively based on the first two existence forms.

[0060] In one implementation, the class node structure, for any class node in the path expression, defines `deputyObjectList` to store proxy objects mapped from all objects in the parent class to the current class; defines `pathFilterList` to store the predicate filtering expression used by the user in the class, and proxy objects that do not meet the predicate filtering requirements will not be stored in `deputyObjectList`; and defines `pathTargetList` to store all attributes to be queried in the current class.

[0061] In one implementation, when the pending class queue reaches a class node, its proxy class is obtained, all proxy objects of the current class node object in the proxy class are found, and the proxy class node structure is successfully constructed, it is temporarily stored in the PendingNodeList queue, indicating that the proxy class has not yet been executed for subsequent query and output operations.

[0062] Once all proxy classes of a class node have been added to the PendingNodeList queue, the class node can be removed from the pending class queue. Before deletion, it is determined whether there are any user query attribute requirements on the class node. If so, the query attribute information of all objects in the class is saved to the OutputNode structure and output after execution.

[0063] Step 2: Obtain the first proxy object from the class node structure, process the multiple second proxy classes respectively, and obtain the multiple second proxy classes based on the first proxy object; if a predicate condition exists in the second proxy class, add the second proxy object that meets the predicate condition to the class node structure; if no predicate condition exists in the second proxy class, add all the second proxy objects to the class node structure; add the multiple second proxy classes to the queue of classes to be processed, and delete the first proxy class from the queue of classes to be processed; wherein, the multiple second proxy classes are the next-level subclasses of the first proxy class;

[0064] Step 3: Process the target second proxy class located at the head of the queue of classes to be processed; find the next-level subclass of the target second proxy class and denote it as the third proxy class; obtain the second proxy object of the target second proxy class from the class node structure; and obtain the third proxy object of the third proxy class that meets the predicate condition based on the second proxy object; store the third proxy object in the class node structure and add the third proxy class to the queue of classes to be processed; perform attribute query on the target second proxy class according to the attribute condition of the path expression; add the queried attribute information to the output queue, wait for output, and delete the target second proxy class from the queue of classes to be processed.

[0065] In one implementation, the step of obtaining the third proxy object that meets the predicate condition in the third proxy class based on the second proxy object firstly involves matching multiple fourth proxy objects in the third proxy class based on the second proxy object, and then determining whether the third proxy class has a predicate condition in the path expression; if a predicate condition exists, the multiple fourth proxy objects are filtered according to the predicate condition, and the multiple fifth proxy objects obtained by the filtering are determined as the third proxy object; if no predicate condition exists, the multiple fourth proxy objects are determined as the third proxy object.

[0066] Step 4: Process the remaining proxy classes in the queue of classes to be processed in the same way as in Step 3 until the queue of classes to be processed is empty. Output all the attribute information stored in the output queue to obtain the attribute information that the path expression is looking for.

[0067] This embodiment also provides a cross-class query system with a tree structure in an object proxy database, which queries attribute information in multiple proxy classes based on path expressions that include multiple proxy classes; it includes the following modules:

[0068] Module 1 is used to receive a path expression, obtain the first proxy class indicated by the root node of the path expression; if there is a predicate condition in the first proxy class, add the first proxy object that meets the predicate condition to the class node structure; if there is no predicate condition in the first proxy class, add all the first proxy objects to the class node structure; and add the class node structure to the queue of classes to be processed.

[0069] Module 2 is used to obtain the first proxy object from the class node structure, process multiple second proxy classes respectively, and obtain the multiple second proxy classes based on the first proxy object; if a predicate condition exists in the second proxy class, the second proxy object that meets the predicate condition is added to the class node structure; if no predicate condition exists in the second proxy class, all second proxy objects are added to the class node structure; the multiple second proxy classes are added to the queue of classes to be processed, and the first proxy class is deleted from the queue of classes to be processed; wherein, the multiple second proxy classes are the next-level subclasses of the first proxy class;

[0070] Module 3 is used to process the target second proxy class located at the head of the queue of classes to be processed, find the next-level subclass of the target second proxy class, and denote it as the third proxy class; obtain the second proxy object of the target second proxy class from the class node structure, and obtain the third proxy object of the third proxy class that meets the predicate condition based on the second proxy object, store the third proxy object in the class node structure, and add the third proxy class to the queue of classes to be processed; perform attribute query on the target second proxy class according to the attribute condition of the path expression, add the queried attribute information to the output queue, wait for output, and delete the target second proxy class from the queue of classes to be processed;

[0071] Module 4 is used to process the remaining proxy classes in the queue of classes to be processed in the same way as Module 3, until the queue of classes to be processed is empty, and then output all the attribute information stored in the output queue, that is, to obtain the attribute information that the path expression is looking for.

[0072] The following combination Figure 4 The solution of this embodiment will be further explained using the attribute structure as an example.

[0073] Figure 4 The tree-paths-expressions-pointer-tracking algorithm (TPT) shown is suitable for general cases, allowing the output of queried object attributes midway through the path, and also allowing simultaneous queries when the source class has multiple different proxy classes. Assuming that all nodes except the root node in the query have predicate conditions and output attribute requirements, the path input expression in the graph should be A→(B[Qb,Rb]→(D[Qd,Rd],E[Qe,Re]),C[Qc,Rc]→(F[Qf,Rf])), and its specific execution flow is as follows:

[0074] (1) Initial state: Add root node A to the processing queue, process A's next-level subclasses B and C respectively, find the proxy objects that meet the predicate conditions, store them in the class structure and then put them into the processing queue, and delete A from the processing queue. The processed result is as follows. Figure 5 As shown.

[0075] (2) The algorithm then processes node B at the head of the queue. It searches for the proxy classes D and E of node B, stores the proxy objects that meet the predicate conditions into a class structure, and adds them to the queue to be processed. Before removing node B from the head of the queue, the attribute information to be output from class B is placed in the output queue, awaiting output. The processed result is as follows: Figure 6 As shown.

[0076] (3) Similarly, the algorithm processes node C at the head of the queue, searches for proxy objects in its proxy class F that satisfy the predicate condition, stores these proxy objects in the class F structure, and adds them to the processing queue. Before removing node C from the head of the queue, the attribute information to be output in class C is placed in the output queue, waiting to be output. The processed result is as follows: Figure 7 As shown.

[0077] (4) Since classes D, E, and F are already located at leaf nodes in the tree, they do not have any proxy classes that need to be accessed. The algorithm searches for the attribute information to be output in classes D, E, and F, stores it in the output queue, and then sequentially deletes the nodes of that class from the queue to be processed. The processed result is as follows: Figure 8 As shown.

[0078] (5) Finally, when the queue to be processed is empty, the algorithm can output all the data in the output queue and complete this cross-class query.

[0079] The core of cross-class query algorithms is the calculation of path expressions; therefore, previous algorithm improvements have all focused on increasing computational efficiency. In TOTEM, the path expression is calculated using the pointer tracing algorithm (PT), whose specific execution flow is as follows: It treats each path expression input by the user as an attribute expression of the starting class. By employing a real-time "one object at a time" calculation method, it traverses all objects in the starting class along the class nodes of the path expression, finding proxy objects that have a proxy relationship with the object and satisfy the predicate conditions on the class nodes. This process is repeated to obtain proxy objects for all objects in the destination class, and finally, the target attribute expression is calculated.

[0080] As explained above, the computational efficiency of path expressions largely depends on the number of object traversals along the path and the planning of the query path. Since multiple path queries often share common parts, the database repeatedly calculates these common parts when executing multiple commands, resulting in a certain degree of performance loss. Consider the following two path expressions: A->B->C and A->B->D. Although the two paths share the common part A->B, the user still needs to write them separately, and the database will repeatedly query and calculate the object proxy relationship between A->B. Most existing optimization methods only consider improving the efficiency of single-path queries. A few consider optimizing queries involving multiple paths, but these only aggregate multiple paths with different endpoint classes, such as writing the two expressions in the above example as A->B->(C,D). However, there are no optimization solutions for more complex situations, such as considering the queries A->B->C and A->B->C->D. Although both contain a long common sequence A->B->C, the current optimization methods are ineffective because their endpoint classes C and D are at different path length positions.

[0081] This embodiment employs a tree-based pointer tracing algorithm, TPT, which combines the advantages of pointer tracing algorithm PT and multi-path pointer tracing algorithm MPT. It utilizes both the "one object at a time" calculation method of pointer tracing algorithm PT and the method of multi-path pointer tracing algorithm MPT that queries multiple endpoint classes separately. The algorithm flow is as follows:

[0082] Add the starting class node to the queue of classes to be processed;

[0083]

[0084]

[0085] In the algorithm described above, the outermost while loop starts from the root node of the input tree expression and iterates through the remaining nodes in the queue of classes to be processed. The middle loops sequentially access the next-level proxy classes of the current class. The innermost loop is where the source object queries the proxy object. By accessing the proxy objects of objects in the current class within the proxy class, proxy objects that meet the predicate conditions are cached, and all data is saved to the class structure. Therefore, by employing a tree-like hierarchical traversal approach, the algorithm avoids any redundant class accesses. Even if the destination class of the query is located at different levels of the tree, it can be expressed by a single tree query expression without causing repeated traversal of common paths.

[0086] The query statement entered by the user is the new OD-SQL (Object Deputy Structured Query Language). In the object proxy database, the process of starting from a starting class and reaching different end classes through the proxy relationships between various proxy classes can be abstracted as the process of starting from a node in a directed graph and visiting different nodes. Essentially, it can be understood as a tree structure: starting from the root of the tree and visiting different leaf nodes of the tree.

[0087] Among the various tree representation methods, the most convenient for users to input via command line is the generalized table representation. Accordingly, this embodiment provides a syntax definition for multi-path cross-class queries based on the generalized table representation:

[0088] P n =C1[Q1, R1]→(P n-1 )

[0089]

[0090] Since multi-path cross-class query based on generalized table representation is a complete rewrite of the original cross-class query process, it is necessary to define corresponding data structures to store data at each stage of the algorithm. The following introduces the important data structures and their meanings during the algorithm execution process.

[0091] (1) Node-like structures;

[0092]

[0093] For any class node in the path expression, deputyObjectList needs to store all objects in the parent class that are mapped to proxy objects in the current class; pathFilterList needs to store the predicate filtering expression of the user in this class. Proxy objects that do not meet the predicate filtering requirements will not be stored in deputyObjectList; pathTargetList stores all the attributes to be queried in the current class.

[0094] (2) Queue of pending processing;

[0095]

[0096] The algorithm as a whole uses a tree level traversal. Therefore, when it executes a class node, obtains its proxy class, finds all proxy objects of the current class node object in the proxy class, and successfully constructs the proxy class PathNode structure, it temporarily stores it in the PendingNodeList queue, indicating that the proxy class has not yet been executed for subsequent query and output operations.

[0097] (3) Output queue;

[0098]

[0099] Once all proxy classes of a class node have been added to the PendingNodeList queue, the class node can be removed from the waiting queue. Before deletion, the algorithm will determine whether there are any user query attribute requirements on the class node. If so, the query attribute information of all objects in the class will be saved to the OutputNode structure and output after the algorithm finishes execution.

[0100] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product includes computer program instructions, which, when executed on a computer, cause the computer to execute the cross-class query method for a tree structure in the object proxy database.

[0101] The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the cross-class query method of the tree structure in the object proxy database.

[0102] Embodiments of this application also provide a storage medium including a stored program, wherein the program, when executed, performs the cross-class query method for a tree structure in the object proxy database.

[0103] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.

[0104] Specific examples in this embodiment can be found in the examples described in the above embodiments and exemplary implementations, and will not be repeated here.

[0105] Embodiments of this application also provide an electronic device including a memory and a processor, the memory storing a computer program, the processor being configured to run the computer program for the cross-class query method of the tree structure in the object proxy database.

[0106] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.

[0107] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated here.

[0108] Obviously, those skilled in the art should understand that the modules or steps of this application described above can be implemented using general-purpose computing systems. They can be centralized on a single computing system or distributed across a network of multiple computing systems. Optionally, they can be implemented using program code executable by a computing system, thereby storing them in a storage system for execution by the computing system. In some cases, the steps shown or described can be performed in a different order than those presented here, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, this application is not limited to any particular combination of hardware and software.

[0109] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the principles of this application should be included within the protection scope of this application.

Claims

1. A method for cross-class querying of a tree structure in an object proxy database, which queries attribute information in multiple proxy classes based on path expressions that include multiple proxy classes; characterized in that: The path expression that includes multiple proxy classes is as follows: ; ; in, , This represents a node in a directed graph. Represents the starting point class; Represents the action on class nodes in a directed graph. The conditional predicate on a class attribute has the format: class attribute name = specific value; Represents the action on class nodes in a directed graph. The query attribute is in the format: class attribute name; ; Let the maximum depth of the current tree be... n , Represents the maximum depth n A subtree or leaf node of -1 has three possible forms: (1) If it is a leaf node without a right sibling node, then the cross-class query can return the calculation result after it reaches this point; (2) If it is a leaf node with a right sibling node, it can be expanded into the form of "leaf node, right sibling node". When the leaf node is found, the calculation result of the node can be temporarily stored for later return. For the right sibling node, further recursive consideration is still required. (3) If it is a node with children, it can be extended to the form of "current node -> child node". After obtaining the proxy object on the current class node, for several proxy classes in the child node, the proxy object that meets the predicate condition in the first child proxy class should be obtained first, and then the calculation should be further recursively based on the first two existence forms. The method includes the following steps: Step 1: Receive the path expression and obtain the first proxy class indicated by the root node of the path expression; if there is a predicate condition in the first proxy class, add the first proxy object that meets the predicate condition to the class node structure; if there is no predicate condition in the first proxy class, add all the first proxy objects to the class node structure; add the class node structure to the queue of classes to be processed. Step 2: Obtain the first proxy object from the class node structure, process the multiple second proxy classes respectively, and obtain the multiple second proxy classes based on the first proxy object; if a predicate condition exists in the second proxy class, add the second proxy object that meets the predicate condition to the class node structure; if no predicate condition exists in the second proxy class, add all the second proxy objects to the class node structure; add the multiple second proxy classes to the queue of classes to be processed, and delete the first proxy class from the queue of classes to be processed; wherein, the multiple second proxy classes are the next-level subclasses of the first proxy class; Step 3: Process the target second proxy class located at the head of the queue of classes to be processed; find the next-level subclass of the target second proxy class and denote it as the third proxy class; obtain the second proxy object of the target second proxy class from the class node structure; and obtain the third proxy object of the third proxy class that meets the predicate condition based on the second proxy object; store the third proxy object in the class node structure and add the third proxy class to the queue of classes to be processed; perform attribute query on the target second proxy class according to the attribute condition of the path expression; add the queried attribute information to the output queue, wait for output, and delete the target second proxy class from the queue of classes to be processed. Step 4: Process the remaining proxy classes in the queue of classes to be processed in the same way as in Step 3 until the queue of classes to be processed is empty. Output all the attribute information stored in the output queue to obtain the attribute information that the path expression is looking for.

2. The cross-class query method for a tree structure in an object proxy database according to claim 1, characterized in that: The class node structure defines `deputyObjectList` for any class node in the path expression, which stores the proxy objects mapped from all objects in the parent class to the current class; `pathFilterList`, which stores the predicate filtering expression used by the user in the class, and proxy objects that do not meet the predicate filtering requirements will not be stored in `deputyObjectList`; and `pathTargetList`, which stores all attributes to be queried in the current class.

3. The cross-class query method for a tree structure in an object proxy database according to claim 1, characterized in that: When the queue of pending classes is executed, its proxy class is obtained, all proxy objects of the current class node object in the proxy class are found, and the proxy class node structure is successfully constructed, and then it is temporarily stored in the PendingNodeList queue, indicating that the proxy class has not yet been executed for subsequent query and output operations. Once all proxy classes of a class node have been added to the PendingNodeList queue, the class node can be removed from the pending class queue. Before deletion, it is determined whether there are any user query attribute requirements on the class node. If so, the query attribute information of all objects in the class is saved to the OutputNode structure and output after execution.

4. The cross-class query method for a tree structure in an object proxy database according to any one of claims 1-3, characterized in that: In step 3, the step of obtaining the third proxy object that meets the predicate condition in the third proxy class based on the second proxy object firstly involves matching multiple fourth proxy objects in the third proxy class based on the second proxy object, and then determining whether the third proxy class has a predicate condition in the path expression; if a predicate condition exists, the multiple fourth proxy objects are filtered according to the predicate condition, and the multiple fifth proxy objects obtained by the filtering are determined as the third proxy object; if no predicate condition exists, the multiple fourth proxy objects are determined as the third proxy object.

5. A cross-class query system with a tree structure in an object proxy database, which queries attribute information in multiple proxy classes based on path expressions that include multiple proxy classes; characterized in that: The path expression that includes multiple proxy classes is as follows: ; ; in, , This represents a node in a directed graph. Represents the starting point class; Represents the action on class nodes in a directed graph. The conditional predicate on a class attribute has the format: class attribute name = specific value; Represents the action on class nodes in a directed graph. The query attribute is in the format: class attribute name; ; Let the maximum depth of the current tree be... n , Represents the maximum depth n A subtree or leaf node of -1 has three possible forms: (1) If it is a leaf node without a right sibling node, then the cross-class query can return the calculation result after it reaches this point; (2) If it is a leaf node with a right sibling node, it can be expanded into the form of "leaf node, right sibling node". When the leaf node is found, the calculation result of the node can be temporarily stored for later return. For the right sibling node, further recursive consideration is still required. (3) If it is a node with children, it can be extended to the form of "current node -> child node". After obtaining the proxy object on the current class node, for several proxy classes in the child node, the proxy object that meets the predicate condition in the first child proxy class should be obtained first, and then the calculation should be further recursively based on the first two existence forms. The system includes the following modules: Module 1 is used to receive a path expression, obtain the first proxy class indicated by the root node of the path expression; if there is a predicate condition in the first proxy class, add the first proxy object that meets the predicate condition to the class node structure; if there is no predicate condition in the first proxy class, add all the first proxy objects to the class node structure; and add the class node structure to the queue of classes to be processed. Module 2 is used to obtain the first proxy object from the class node structure, process multiple second proxy classes respectively, and obtain the multiple second proxy classes based on the first proxy object; if a predicate condition exists in the second proxy class, the second proxy object that meets the predicate condition is added to the class node structure; if no predicate condition exists in the second proxy class, all second proxy objects are added to the class node structure; the multiple second proxy classes are added to the queue of classes to be processed, and the first proxy class is deleted from the queue of classes to be processed; wherein, the multiple second proxy classes are the next-level subclasses of the first proxy class; Module 3 is used to process the target second proxy class located at the head of the queue of classes to be processed, find the next-level subclass of the target second proxy class, and denote it as the third proxy class; obtain the second proxy object of the target second proxy class from the class node structure, and obtain the third proxy object of the third proxy class that meets the predicate condition based on the second proxy object, store the third proxy object in the class node structure, and add the third proxy class to the queue of classes to be processed; perform attribute query on the target second proxy class according to the attribute condition of the path expression, add the queried attribute information to the output queue, wait for output, and delete the target second proxy class from the queue of classes to be processed; Module 4 is used to process the remaining proxy classes in the queue of classes to be processed in the same way as Module 3, until the queue of classes to be processed is empty, and then output all the attribute information stored in the output queue, that is, to obtain the attribute information that the path expression is looking for.

6. A cross-class query device for a tree-structured object proxy database, characterized in that, include: One or more processors; A storage device for storing one or more programs, which, when executed by one or more processors, cause the one or more processors to implement a cross-class query method for a tree structure in an object proxy database as described in any one of claims 1 to 4.

7. A non-volatile computer-readable storage medium containing a computer program, characterized in that: When the computer program is executed by one or more processors, the processors perform a cross-class query method for a tree structure in an object proxy database as described in any one of claims 1 to 4.

8. A computer program product comprising computer program instructions, characterized in that: When the computer program instructions are executed on a computer, the computer performs a cross-class query method for a tree structure in an object proxy database as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Patent knowledge graph construction method based on object agent database

    CN110162642A

  • Multi-path cross-class query and optimization method in object agent database

    CN111797114A