A data query method for a graph database and related devices

By designing an execution plan in a graph database in which the output of each query operator includes all its previous results, the problem of acyclic path traversal is solved, and efficient data querying is achieved.

CN119848284BActive Publication Date: 2026-01-02ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510068760.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-15
Publication Date
2026-01-02
Estimated Expiration
2045-01-15

AI Technical Summary

Technical Problem

In graph databases, existing technologies struggle to effectively traverse acyclic paths, resulting in inefficient data querying and an inability to prevent infinite loops.

Method used

Design a data query method to generate an execution plan corresponding to the query statement, which includes multiple query operators. The output of each operator includes the query results of all the operators before it. By checking for duplicate results, the method ensures that there is no loop path traversal and generates the final query result.

Benefits of technology

It achieves efficient data querying, avoids repeated traversal in acyclic paths, meets the path traversal requirements of acyclic mode, and improves query efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119848284B_ABST
    Figure CN119848284B_ABST
Patent Text Reader

Abstract

The specification provides a data query method for a graph database and related equipment. The method comprises: generating an execution plan corresponding to a query statement for a graph database; the execution plan contains a plurality of query operators executed in sequence; the output result of any query operator contains the query result of the query operator and the query results of all query operators executed before the query operator; when the first query operator in the sequence is executed, it is determined whether there is a query result identical to the query result of the first query operator in all query results contained in the output result of the second query operator; the second query operator is a neighboring operator executed before the first query operator; if not, the output result of the first query operator is generated based on the query result of the first query operator and all query results contained in the output result of the second query operator.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] One or more embodiments of the present specification relate to the technical field of graph database, and in particular to a data query method for a graph database and related equipment. BACKGROUND

[0002] A graph database is a database system specially designed for storing and querying graph data. Graph data mainly contains nodes and edges, where nodes represent entities and edges represent the relationships between entities. Nodes and edges each correspond to a number of properties. Properties are usually key-value pairs (KV) attached to nodes or edges, used to describe the characteristics of nodes or edges.

[0003] In some graph data query scenarios, an acyclic mode of path traversal method is often used to implement data query. The acyclic mode refers to path traversal without loops, that is, nodes and edges on the path do not appear repeatedly. This mode is very important for ensuring traversal efficiency and preventing infinite loops. In actual execution, data query based on the acyclic mode can be implemented by multiple operators executed in sequence. The input data relied on by each operator during execution usually comes from the output of the previous operator. Therefore, how to reasonably design the organization structure of the data transmitted between operators to meet the query requirements of efficient data query based on the acyclic mode of path traversal is a problem to be solved. SUMMARY

[0004] In view of this, one or more embodiments of the present specification provide a data query method for a graph database and related equipment.

[0005] In a first aspect, the present specification provides a data query method for a graph database, comprising:

[0006] generating an execution plan corresponding to a query statement for the graph database; the execution plan contains multiple query operators executed in sequence; wherein the output result of any query operator in the multiple query operators contains the query result of the query operator and the query results of all query operators executed before the query operator;

[0007] executing the multiple query operators in sequence, and when the first query operator in the multiple query operators is executed, determining whether there is a query result identical to the query result of the first query operator in all query results contained in the output result of the second query operator; wherein the second query operator is the adjacent operator executed before the first query operator;

[0008] If no, generating the output result of the first query operator based on the query result of the first query operator and all query results contained in the output result of the second query operator.

[0009] In a second aspect, the present specification provides a data query device for a graph database, the device comprising:

[0010] an execution plan generation unit configured to generate an execution plan corresponding to a query statement for the graph database; the execution plan comprising a plurality of query operators executed in sequence; wherein the output result of any query operator in the plurality of query operators contains the query result of the query operator and the query results of all query operators executed before the query operator;

[0011] a determination unit configured to execute the plurality of query operators in sequence, and determine whether there is a query result identical to the query result of the first query operator among all query results contained in the output result of the second query operator when executing the first query operator in the plurality of query operators; wherein the second query operator is a neighboring operator executed before the first query operator;

[0012] an output result generation unit configured to generate the output result of the first query operator based on the query result of the first query operator and all query results contained in the output result of the second query operator if no.

[0013] Correspondingly, the present specification also provides a computing device comprising a memory and a processor; the memory stores a computer program / instruction executable by the processor; when the processor executes the computer program / instruction, the data query method for a graph database in the first aspect is executed.

[0014] Correspondingly, the present specification also provides a computer readable storage medium having a computer program / instruction stored thereon, wherein the computer program / instruction is executed by a processor to execute the data query method for a graph database in the first aspect.

[0015] Correspondingly, the present specification also provides a computer program product comprising a computer program / instruction, wherein the computer program / instruction is executed by a processor to execute the data query method for a graph database in the first aspect.

[0016] In summary, after obtaining a query statement for a graph database, an execution plan corresponding to the query statement can be generated, which can include a plurality of query operators executed in sequence. The present specification designs a data structure for the output result of an operator, wherein the output result of each operator includes not only its own query result, but also the query results of all operators executed before it. In this way, when the current query operator is executed in sequence, it can be determined whether there is a query result identical to the query result of the current query operator in all query results included in the output result of the previous query operator. If not, the output result of the current query operator can be generated based on its own query result and the query results of all previously executed query operators. This process is repeated until the execution of the last query operator is completed. Through the above-mentioned data structure designed for the output result of an operator and the corresponding operator execution process, it can be effectively ensured that the nodes or edges that have been traversed in the data query process will not appear repeatedly, thereby meeting the demand for efficient data query based on Acyclic pattern path traversal. BRIEF DESCRIPTION OF DRAWINGS

[0017] Figure 1 FIG. 1 is a schematic diagram of an architecture of a data query system for a graph database provided by an example embodiment;

[0018] Figure 2 FIG. 2 is a schematic diagram of a data structure of an output result provided by an example embodiment;

[0019] Figure 3 FIG. 3 is a schematic diagram of a flow of a data query method for a graph database provided by an example embodiment;

[0020] Figure 4 FIG. 4 is a schematic diagram of a data structure of a query result provided by an example embodiment;

[0021] Figure 5 FIG. 5 is a schematic diagram of graph data provided by an example embodiment;

[0022] Figure 6 FIG. 6 is a schematic diagram of a physical execution plan provided by an example embodiment;

[0023] Figure 7 FIG. 7 is a schematic diagram of an output result of a point query operator provided by an example embodiment;

[0024] Figure 8 FIG. 8 is a schematic diagram of an output result of an edge query operator provided by an example embodiment;

[0025] Figure 9 FIG. 9 is a schematic diagram of another output result of a point query operator provided by an example embodiment;

[0026] Figure 10 FIG. 6 is a schematic diagram of an output result of another edge query operator according to an example embodiment;

[0027] Figure 11 FIG. 7 is a schematic diagram of an output result of another edge query operator according to an example embodiment;

[0028] Figure 12 FIG. 8 is a schematic diagram of an output result of another point query operator according to an example embodiment;

[0029] Figure 13 FIG. 9 is a schematic diagram of an output result of a Projection operator according to an example embodiment;

[0030] Figure 14 FIG. 10 is a schematic diagram of a structure of a data query device for a graph database according to an example embodiment;

[0031] Figure 15 FIG. 11 is a schematic diagram of a structure of a computing device according to an example embodiment. DETAILED DESCRIPTION

[0032] The example embodiments will be described in detail herein with reference to the attached drawings. The following description is made with reference to the accompanying drawings in which like reference numerals refer to like elements, unless the context of use indicates otherwise. The following description of example embodiments is not representative of all embodiments consistent with one or more aspects of the present specification. Rather, they are merely examples of apparatuses and methods consistent with some aspects of one or more embodiments of the present specification as detailed in the appended claims.

[0033] It should be noted that the steps of the methods described in other embodiments need not necessarily be performed in the order described in this specification. In some other embodiments, the steps of the methods described therein can be more or less than those described in this specification. Furthermore, a single step described in this specification can in other embodiments be split into multiple steps to be described; and multiple steps described in this specification can in other embodiments be combined into a single step to be described.

[0034] It should be noted that the term "plurality" as used in this specification means two or more.

[0035] In addition, the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of countries and regions, and provide corresponding operation portal for user to choose authorization or refusal.

[0036] The specification provides a technical solution, which designs a data structure of output result of an operator, wherein the output result of each operator contains query results of all operators executed before itself in addition to its own query result, so that the subsequent executed operator can accurately check whether its query result is repeated with the previous query result, thereby ensuring that the nodes or edges that have been traversed will not appear repeatedly.

[0037] In implementation, first, a query statement for a graph database is acquired, and then an execution plan corresponding to the query statement is generated. The execution plan can contain multiple query operators executed in sequence; wherein the output result of any query operator in the multiple query operators contains query results of all query operators executed before the query operator. Further, the multiple query operators can be executed in sequence, and when the first query operator in the multiple query operators is executed, it is determined whether there is a query result identical to the query result of the first query operator in all query results contained in the output result of the second query operator. The second query operator is the adjacent operator executed before the first query operator. Further, if it is determined that there is no query result identical to the query result of the first query operator in all query results contained in the output result of the second query operator, the output result of the first query operator can be generated based on the query result of the first query operator and all query results contained in the output result of the second query operator. Similarly, until the execution of the last query operator ends. Finally, the query result of the query statement can be generated based on the output result of the last query operator.

[0038] In the above technical solution, the execution plan corresponding to the query statement can include multiple query operators to be executed in sequence. The present specification designs a data structure for the output result of an operator, wherein the output result of each operator includes not only its own query result but also the query results of all the operators executed before it. In this way, when execution proceeds to the current query operator, it can be determined whether there is a query result identical to the query result of the current query operator in all the query results included in the output result of the previous query operator. If not, the output result of the current query operator can be generated based on its own query result and the query results of all the operators executed before it, and so on, until the execution of the last query operator ends, and then the final query result of the query statement can be obtained based on the output result of the last query operator. Through the above data structure designed for the output result of an operator and the corresponding operator execution process, it can be effectively ensured that the nodes or edges that have been traversed in the data query process will not appear repeatedly, thereby meeting the demand for efficient data query based on Acyclic pattern path traversal.

[0039] Referring to Figure 1 , Figure 1 is an exemplary embodiment provides a kind of data query system of the architecture schematic diagram of graph database provided for. One or more embodiments provided in the present specification can be implemented in the system architecture shown in Figure 1 Or similar system architecture. As shown in Figure 1 , the system architecture can include computing device 100 and computing device 200, wherein computing device 100 and computing device 200 can be connected by any possible way, and the present specification does not make specific limitation to this.

[0040] As shown in Figure 1 , the server of graph database system can be carried in computing device 100, and the client of graph database system can be carried in computing device 200. User can initiate data query to graph database through the client in computing device 200, correspondingly, the server in computing device 100 can obtain the query statement for the graph database, and execute corresponding data query, to generate the query result corresponding to the query statement and return to the client, etc., and the present specification does not make specific limitation to this.

[0041] In an illustrated embodiment, after obtaining a query statement for a graph database, the computing device 100 can generate an execution plan corresponding to the query statement. The query statement can be a Graph Query Language Row (GQL) statement, and specifically a GQL statement for data query based on path traversal of an acyclic pattern. The execution plan corresponding to the query statement can include a plurality of query operators to be executed in sequence, and each query operator can depend on the output of a previous query operator when performing data query.

[0042] In an illustrated embodiment, the output of any query operator in the plurality of query operators can include the query result of the query operator, and the query results of all query operators executed before the query operator. Please refer to Figure 2 , Figure 2 is a schematic diagram of a data structure of an output result according to an example embodiment. As shown in Figure 2 , the output result of each query operator includes not only its own query result, but also the query results of all query operators executed before the query operator. In an illustrated embodiment, the plurality of query results included in the output result can be sorted according to their generation order (or the execution order of the query operators), for example, the leftmost query result can be the query result of the last query operator, and the rightmost query result can be the query result of the first executed query operator, which is not limited in the present specification.

[0043] Further, the computing device 100 can execute the plurality of query operators in the execution plan in sequence based on the generated execution plan. When executing the first query operator in the plurality of query operators, the computing device 100 can determine whether there is a query result identical to the query result of the first query operator in all query results included in the output result of a second query operator executed before the first query operator, which can be referred to the description of the corresponding embodiments below, and will not be repeated here. Figure 3

[0044] Further, if it is determined that there is no query result identical to the query result of the first query operator in all query results included in the output result of the second query operator, the computing device 100 can generate the output result of the first query operator based on the query result of the first query operator and all query results included in the output result of the second query operator, and so on until the execution of the last query operator is completed.

[0045] Finally, the computing device 100 can generate the final query result of the query statement based on the output result of the last query operator, and return the final query result to the user, which is not limited in the present specification.​

[0046] As described above, the data structure of the output result of the operator is reasonably designed in the specification, wherein the output result of each operator contains the query results of all the operators executed before itself in addition to its own query result, so that the subsequent executed operator can accurately check whether its query result is duplicated with the previous query result, thereby ensuring that the traversed nodes or edges will not be repeated, thereby meeting the demand of efficient data query based on Acyclic pattern-based path traversal.

[0047] In an illustrated embodiment, the computing device 100 can be a smart wearable device, a smart phone, a tablet computer, a notebook computer, a desktop computer, etc. with the above functions, and the specification does not make specific limitations thereto. In an illustrated embodiment, the computing device 200 can be a desktop computer, a server or a server cluster composed of multiple servers, etc. with the above functions, and the specification does not make specific limitations thereto.

[0048] It should be noted that, Figure 1 It should be noted that,

[0049] Please refer to Figure 3 , Figure 3 is a flowchart of a data query method for a graph database provided by an exemplary embodiment. The method can be applied to Figure 1 The illustrated graph database system, specifically the computing device 100 in the graph database system. As Figure 3 The method specifically can include the following steps S301-S303.

[0050] Step S301, generating an execution plan corresponding to a query statement for the graph database; the execution plan contains a plurality of query operators executed in sequence; wherein the output result of any query operator in the plurality of query operators contains the query result of the query operator, and the query results of all the query operators executed before the query operator.

[0051] In an illustrated implementation, the graph database system can first obtain a query statement for the graph database, then parse the query statement and generate an execution plan corresponding to the query statement based on the parsing result. The query statement can be a GQL statement for data query based on path traversal of Acyclic pattern. The generated execution plan corresponding to the query statement can be a physical execution plan. In an illustrated implementation, a logical execution plan can be first generated based on the parsing result of the query statement, and then a physical execution plan can be further generated based on the logical execution plan, which is not specifically limited in the present specification.

[0052] It should be noted that the physical execution plan is usually a tree composed of multiple operators, which can include multiple query operators executed in sequence, and the input data of each query operator when executing data query can come from the output of the previous query operator.

[0053] In an illustrated implementation, the output result of any query operator in the multiple query operators can include the query result of the query operator and the query results of all query operators executed before the query operator. The query result of each query operator can include the graph data queried from the graph database, including node data or edge data.

[0054] In an illustrated implementation, the multiple query operators can include a point query operator (VertexGet) for querying node data and an edge query operator (Traverse) for querying edge data. Correspondingly, the query result of the point query operator can include the queried node data, such as several attribute values of the node, such as id: A, name: Zhang San, phone: 12345, etc.; the query result of the edge query operator can include the queried edge data, such as the start point id (src_id) : A, the end point id (dst_id) : B, the edge type (edge_type) : transfer, etc., which is not specifically limited in the present specification.

[0055] In an illustrated implementation, in addition to the above-mentioned multiple query operators, the physical execution plan can also include a projection operator, such as a Projection operator, executed after the last query operator, for expression calculation, such as can be used to return the final query result of the query statement, which is not specifically limited in the present specification.

[0056] In step S302, the plurality of query operators are executed in sequence, and when a first query operator in the plurality of query operators is executed, it is determined whether there is a same query result as a query result of the first query operator in all query results contained in an output result of a second query operator; the second query operator is a neighboring operator executed before the first query operator.

[0057] Further, after the physical execution plan corresponding to the query statement is generated, the graph database system can execute the plurality of query operators contained in the physical execution plan in sequence.

[0058] In an illustrated embodiment, the execution process of the physical execution plan can include cyclically calling the getNextRow method to obtain the output result.

[0059] In an illustrated embodiment, in the process of executing the plurality of query operators in sequence, when a first query operator in the plurality of query operators is executed, an output result of a second query operator can be obtained. For example, the first query operator can obtain the output result of the second query operator by calling the getNextRow method of the second query operator.

[0060] The second query operator is a neighboring operator executed before the first query operator, the output result of the second query operator contains the query result of the second query operator, and the query results of all query operators executed before the second query operator. It should be noted that "first" and "second" in the present specification are only used to distinguish different objects, and do not directly limit the sequence or priority thereof.

[0061] Further, after the output result of the second query operator is obtained, the graph database can be further queried based on the query result of the second query operator contained in the output result of the second query operator to obtain the query result of the first query operator.

[0062] In an illustrated embodiment, if the second query operator is a point query operator and the first query operator is an edge query operator, the first query operator can further query the edge data associated with the node data from the graph database based on the node data contained in the query result of the second query operator. That is, the first query operator further performs path traversal with the node queried by the second query operator as input data to traverse the edge connected to the node, i.e., the edge with the node as the starting point.

[0063] In an illustrated embodiment, if the second query operator is an edge query operator and the first query operator is a vertex query operator, the first query operator can further query the point data associated with the edge data contained in the query result of the second query operator from the graph database. That is, the first query operator further performs path traversal with the edge obtained by the second query operator as input data to traverse to the point connected to the edge, i.e., the end point of the edge.

[0064] Further, after obtaining the query result of the first query operator, it can be determined whether there is a same query result as the query result of the first query operator in all query results contained in the output result of the second query operator.

[0065] It should be noted that the specific implementation of determining whether there is a same query result is not particularly limited in the present specification.

[0066] In an illustrated embodiment, in addition to the above node data / edge data, the query result of any query operator can further contain the operator identifier (which can be denoted as Flag) of the query operator and the metadata (which can be denoted as GraphKey) corresponding to the graph data queried by the query operator.

[0067] The operator identifier can be used to indicate that the operator type of the query operator is a vertex query operator or an edge query operator. For example, the value of the operator identifier can be 0, 1 or 2, the value of the operator identifier being 0 can represent that the query operator is neither a vertex query operator nor an edge query operator, the value of the operator identifier being 1 can represent that the query operator is a vertex query operator, and the value of the operator identifier being 2 can represent that the query operator is an edge query operator. For example, the value of 1 can also be used to represent an edge query operator, and the value of 2 can be used to represent a vertex query operator, which is not particularly limited in the present specification. In the following embodiments, the value of 1 is used to represent a vertex query operator, and the value of 2 is used to represent an edge query operator.

[0068] The metadata corresponding to the graph data can be divided into metadata corresponding to node data and metadata corresponding to edge data. In the query result of the vertex query operator, the metadata corresponding to the node data can include the node type (vertex_type) and the node identifier (e.g., node id), which can be denoted as <id, vertex_type>, which is not particularly limited in the present specification. In the query result of the edge query operator, the metadata corresponding to the edge data can include the edge type, the start point identifier and the end point identifier of the edge, which can be denoted as <src_id, edge_type, dst_id>, which is not particularly limited in the present specification.

[0069] In an illustrated embodiment, please refer to Figure 4 ,Figure 4 is a data structure of a query result provided by an example embodiment. As shown in Figure 4 , the query result of a query operator can be divided into two parts, a header and data. As shown in Figure 4 , the header can include the operator identifier and metadata described above, and the data includes a plurality of cells, each of which can store graph data in the form of KV. For example, one cell stores key: id and value: A, and another cell stores key: name and value: Zhang San, and the like, which are not limited in the present specification.

[0070] Based on the data structure of the query result shown in Figure 4 , if the first query operator is a point query operator, when determining whether there is a query result identical to the query result of the first query operator in all query results included in the output result of the second query operator, the method can specifically include:

[0071] traversing all query results included in the output result of the second query operator, and determining whether the operator type indicated by the operator identifier included in the target query result of the target query operator currently traversed is a point query operator. In an example embodiment, if the operator type indicated by the operator identifier included in the target query result is not a point query operator (for example, the value of the operator identifier is 0 or 2), the next query result is traversed. In an example embodiment, if the operator type indicated by the operator identifier included in the target query result is a point query operator (for example, the value of the operator identifier is 1), it is further determined whether the target query result is identical to the query result of the first query operator. Specifically, the metadata corresponding to the node data queried by the target query operator included in the target query result can be read out first; then, it is determined whether the node type and node identifier included in the metadata are identical to the node type and node identifier included in the query result of the first query operator one by one. If yes, it is determined that the target query result is identical to the query result of the first query operator, and the traversal is ended. If not, it is determined that the target query result is not identical to the query result of the first query operator, and the next query result is traversed, and so on.

[0072] Based on the data structure of the query result shown in Figure 4 , if the first query operator is an edge query operator, when determining whether there is a query result identical to the query result of the first query operator in all query results included in the output result of the second query operator, the method can specifically include:

[0073] The output result of the second query operator is traversed, and for a target query result of a target query operator currently traversed, it is determined whether the operator type indicated by the operator identifier contained in the target query result is an edge query operator. In an illustrated embodiment, if the operator type indicated by the operator identifier contained in the target query result is not an edge query operator (for example, the value of the operator identifier is 0 or 1), the next query result is then traversed. In an illustrated embodiment, if the operator type indicated by the operator identifier contained in the target query result is an edge query operator (for example, the value of the operator identifier is 2), it is further determined whether the target query result is the same as the query result of the first query operator. Specifically, the metadata corresponding to the edge data queried by the target query operator can be read out first from the target query result; then, it can be determined whether the edge type, the start point identifier and the end point identifier contained in the metadata correspond to the edge type, the start point identifier and the end point identifier contained in the query result of the first query operator one by one. If yes, it is determined that the target query result is the same as the query result of the first query operator, and the traversal is ended; if not, it is determined that the target query result is not the same as the query result of the first query operator, and the next query result is then traversed, and so on.

[0074] In addition, it should be noted that each query operator may obtain one query result or multiple different query results (i.e., one node / edge may be traversed or multiple nodes / edges may be traversed) when performing data query based on graph path traversal. Correspondingly, the output result of each query operator may be one output result or multiple output results corresponding to multiple query results queried by the query operator. In an illustrated embodiment, each output result of a query operator can be denoted as GQLRow, and each query result contained in the output result can be denoted as ContigousRow, where Row means a row, indicating a result.

[0075] Based on this, the first query operator can specifically include the following steps when obtaining the output result of the second query operator: sequentially obtaining each output result in the multiple output results of the second query operator. Correspondingly, the above step S302 and the following step S303 are performed for each output data obtained.

[0076] In an illustrated embodiment, if there is a query result same as the query result of the first query operator in all query results contained in a certain output result of the second query operator currently obtained, the next output result in the multiple output results of the second query operator can be further obtained, and so on, until the last output result of the second query operator is obtained.

[0077] In an illustrated embodiment, if each output result of the second query operator contains the same query result as the query result of the first query operator, it can be determined that the final query result of the query statement is empty.

[0078] In step S303, if no, the output result of the first query operator is generated based on the query result of the first query operator and all query results contained in the output result of the second query operator.

[0079] In an illustrated embodiment, if it is determined that there is no query result in all query results contained in the output result of the second query operator that is the same as the query result of the first query operator, the output result of the first query operator can be generated based on the query result of the first query operator and all query results contained in the output result of the second query operator.

[0080] In an illustrated embodiment, if the second query operator generates multiple output results, the first query operator can further obtain the next output result in the multiple output results of the second query operator and perform similar operations after generating an output result, and so on, until the last output result of the second query operator is obtained, and the execution of the first query operator ends, and so on, until the last query operator is executed.

[0081] Further, after the execution of the last query operator in the physical execution plan ends, the output result of the last query operator can be obtained, and the final query result of the query statement can be generated based on the output result of the last query operator. It should be understood that the output result of the last query operator contains the query results of all query operators in the physical execution plan.

[0082] In an illustrated embodiment, when the final query result of the query statement is generated based on the output result of the last query operator, it can specifically include: obtaining the query result of the last query operator contained in the output result of the last query operator; then, reading the node data or edge data contained in the query result of the last query operator, and taking the node data or edge data as the final query result of the query statement.

[0083] In an illustrated embodiment, the physical execution plan can further include a Projection operator executed after the last query operator. Accordingly, the Projection operator can obtain the output result of the last query operator, and extract the node data or edge data contained in the data part of the output result, and generate the corresponding output result based on the node data or edge data. Further, the physical execution plan can finally extract the node data or edge data from the output result of the Projection operator as the query result, and return the query result to the user, and the like, and thus the present specification does not limit the same.

[0084] The data query method for a graph database provided by the present specification will be described below through specific examples.

[0085] In an illustrated embodiment, referring to Figure 5 , Figure 5 is a schematic diagram of graph data provided by an exemplary embodiment. As shown in Figure 5 , the graph data includes a plurality of nodes, which are user (User) A, user B and user C. Among them, there are two directed edges between user A and user B, and the type of the edge is transfer. User A→user B indicates that user A transfers money to user B, and user B→user A indicates that user B transfers money to user A. Among them, there is a directed edge between user B and user C, and the type of the edge is transfer. User B→user C indicates that user B transfers money to user C.

[0086] In an illustrated embodiment, the current data query requirement of the user can be to query which user accounts the money transferred by user A reaches after 2 hops, and the result should exclude user A itself, i.e., the final correct query result should only be user C.

[0087] In an illustrated embodiment, the above data query requirement can be implemented using the path traversal method of Acyclic mode. Exemplarily, the query statement for implementing the above data query requirement using the path traversal method of Acyclic mode in the graph query language can be as follows:

[0088] MATCH ACYCLIC(a:User where id(a)=’A’)-[r1:transfer]->(b:User)-[r2:transfer]->(x:User)RETURN x.id;

[0089] The syntax of the above query statement can be divided into two parts: MATCH (match) and RETURN (return).

[0090] The MATCH part includes: MATCH ACYCLIC (a:User where id(a)='A')-[rl:transfer]->(b:User)-[r2:transfer]->(x:User), where a, b, and x are variables. The MATCH part is used to describe the path to be matched in the graph, in particular: the starting node of the path is node a, the id of a is 'A', then from node a, go to node b through a 1-degree transfer edge, and then go to node x through a transfer edge from node b, and all paths meeting the conditions in the process will be matched. The keyword ACYCLIC is used to indicate that the matched path cannot have repeated edges and nodes.

[0091] The RETURN part includes: RETURN x, id, which is used to indicate that for each path matched by the MATCH part, the id attribute of node x in the path is output.

[0092] Further, after obtaining the query statement, the graph database system can parse the query statement and generate a physical execution plan corresponding to the query statement based on the parsing result. In an illustrative embodiment, please refer to Figure 6 , Figure 6 is a schematic diagram of a physical execution plan provided by an exemplary embodiment. As shown in Figure 6 , the physical execution plan generated based on the query statement can include multiple operators executed in sequence, such as VertexGet(a) operator, Traverse(rl) operator, VertexGet(b) operator, Traverse(r2) operator, VertexGet(x) operator, and Projection(x, id) operator.

[0093] Next, the execution process of each operator will be described in conjunction with the physical execution plan shown in Figure 6 .

[0094] 1. Execution process of VertexGet(a) operator

[0095] VertexGet(a) operator is a leaf node in the entire physical execution plan. The user specifies the condition for querying the User point table in the statement: Where id(a)='A', so VertexGet(a) operator can directly query the point data with id equal to 'A' in the User point table, obtain the query result of VertexGet(a) operator, and generate the corresponding output result (GQLRow).

[0096] For example, please refer to Figure 7 , Figure 7This is a schematic diagram illustrating the output result of a point query operator provided in an exemplary embodiment. For example... Figure 7 As shown, the output of the VerterxGet(a) operator can include the query result (ContigousRow) of the VerterxGet(a) operator. The operator identifier in the Haeder of the query result of the VerterxGet(a) operator is set to 1, indicating that the VerterxGet(a) operator is a point query operator. The Haeder also contains metadata corresponding to the retrieved point data.<A,User> The query result's Data contains the retrieved point data, which can specifically include Key:id, Value:A, etc.

[0097] 2. Execution process of the Traverse(r1) operator

[0098] First, the getNextRow method of the VerterxGet(a) operator is called to obtain the output result of the VerterGet(a) operator, where the VerterxGet(a) operator is a sub-operator of the Traverse(r1) operator. The obtained output result can be called oneChildResult, but this specification does not specify a particular term for it.

[0099] Then, the `id` value (i.e., `A`) in the `Data` of the `VerterGet(a)` operator's query result is extracted from the output of the `VerterGet(a)` operator. This value is represented by the variable `src_id`. Then, `src_id` is used as the starting point of the edge to query the `transfer` edge table, obtaining the query result of the `Traverse(r1)` operator. In one illustrated implementation, the operator identifier in the `Haeder` of the `Traverse(r1)` operator's query result is set to 2, indicating that the `Traverse(r1)` operator is an edge query operator. The `Haeder` also contains metadata corresponding to the queried edge data.<A,transfer,B> The query result's Data contains the edge data found, which can specifically include Key:dst_id, Value:B, etc.

[0100] Then, each query result contained in the output result of the VerterGet(a) operator is traversed. If the operator identifier in the Header of the currently traversed query result is 2, the metadata in the Header is taken out, and it is judged whether the metadata and the <A, transfer, B> in the query result of the Traverse(r1) operator are the same. If not, the next query result is traversed. If yes, it indicates that the edge <A, transfer, B> has been visited, and the currently obtained output result cannot produce new results, and then the Traverse(r1) operator can continue to obtain the next output result of the VerterGet(a) operator.

[0101] As shown in Figure 7 , since the only output result of the VerterGet(a) operator only contains the query result of the VerterGet(a) operator, and the operator identifier in the Header of the query result of the VerterGet(a) operator is 1, it indicates that the edge <A, transfer, B> has not been visited, and then the Traverse(r1) operator can generate an output result based on its own query result and the query result of the VerterGet(a) operator.

[0102] For example, please refer to Figure 8 , Figure 8 , which is a schematic diagram of an output result of an edge query operator provided by an example embodiment. As shown in Figure 8 , in the output result of the Traverse(r1) operator, the query result of the Traverse(r1) operator and the query result of the VerterGet(a) operator are contained in sequence from left to right, and details are described in Figure 8 , which will not be described here.

[0103] 3. Execution process of the VertexGet(b) operator

[0104] Firstly, the getNextRow method of the Traverse(r1) operator is called to obtain the output result of the Traverse(r1) operator, wherein the Traverse(r1) operator is a child operator of the VertexGet(b) operator.

[0105] Then, the dst_id value (i.e., B) contained in the Data of the query result of the Traverse (r1) operator in the output result of the Traverse (r1) operator is extracted, and is denoted by a variable vid, and then the vid is used as the id attribute value of a point to query the User point table, to obtain the query result of the VertexGet (b) operator. In an illustrative embodiment, the operator identifier in the Haeder of the query result of the VertexGet (b) operator is 1, indicating that the VertexGet (b) operator is a point query operator, and the Haeder also contains metadata <B, User> corresponding to the queried point data; the Data of the query result contains the queried point data, and can specifically contain Key: id, Value: B, etc.

[0106] Then, each query result contained in the output result of the Traverse (r1) operator is traversed, and if the operator identifier in the Header of the currently traversed query result is 1, the metadata in the Header is taken out, and it is determined whether the metadata is the same as <B, User> in the query result of the VertexGet (b) operator. If not, the next query result is traversed. If yes, it indicates that the point <B, User> has been visited, and the currently obtained output result cannot produce new results, and then the VertexGet (b) operator can continue to obtain the next output result of the Traverse (r1) operator.

[0107] As shown in Figure 8 , in the only output result of the Traverse (r1) operator, only the operator identifier in the Header of the VertexGet (a) operator is 1, and <A, User> recorded in the Header is inconsistent with <B, User>, indicating that the point <B, User> has not been visited, and then the VertexGet (b) operator can generate an output result based on the query result of the VertexGet (b) operator, the query result of the Traverse (r1) operator and the query result of the VertexGet (a) operator.

[0108] For example, please refer to Figure 9 , Figure 9 is a schematic diagram of an output result of another point query operator provided in an illustrative embodiment. As shown in Figure 9 , in the output result of the VertexGet (b) operator, the query result of the VertexGet (b) operator, the query result of the Traverse (r1) operator and the query result of the VertexGet (a) operator are contained in sequence from left to right, and details can be referred to Figure 9 , which will not be described here.

[0109] 4. Execution process of Traverse(r2) operator

[0110] Firstly, the getNextRow method of VertexGet(b) operator is called to obtain the output result of VertexGet(b) operator, wherein VertexGet(b) operator is a sub-operator of Traverse(r2) operator.

[0111] Then, the id value (i.e. B) in the Data of the query result of VertexGet(b) operator contained in the output result of VertexGet(b) operator is extracted and represented by variable src_id, and then the src_id is used as the start point of the edge to query the transfer edge table to obtain the query result of Traverse(r2) operator.

[0112] As shown in Figure 5 , there exists a transfer relationship between user B and user A and user C, and therefore Traverse(r2) operator can obtain two query results corresponding to user A and user C. In the query result corresponding to user A, the metadata <B, transfer, A> corresponding to the queried edge data is contained in the Haeder, and the edge data Key: dst_id, Value: A is contained in the Data, in the embodiment. In the query result corresponding to user C, the metadata <B, transfer, C> corresponding to the other queried edge data is also contained in the Haeder, and the edge data Key: dst_id, Value: C is contained in the Data, in the embodiment.

[0113] Then, similar to the execution process of Traverse(r1) operator, Traverse(r2) operator can traverse each query result contained in the output result of VertexGet(b) operator, and since there is no edge <B, transfer, A> or edge <B, transfer, C> in each query result, Traverse(r2) operator can generate two output results based on the two query results of itself, and the query result of VertexGet(b) operator, the query result of Traverse(r1) operator and the query result of VertexGet(a) operator.

[0114] For example, please refer to Figure 10 , Figure 10 is a schematic diagram of the output result of another edge query operator provided in an exemplary embodiment. As shown in Figure 10As shown, in one output of the Traverse(r2) operator, from left to right, the results contain the edges retrieved by the Traverse(r2) operator.<B,transfer,A> For the corresponding query results, the query results of the VertexGet(b) operator, the query results of the Traverse(r1) operator, and the query results of the VertexGet(a) operator, please refer to [link / reference]. Figure 10 This will not be elaborated upon here.

[0115] For example, please refer to Figure 11 , Figure 11 This is a schematic diagram illustrating the output result of another edge query operator provided in an exemplary embodiment. For example... Figure 11 As shown, another output of the Traverse(r2) operator contains, from left to right, the edges retrieved by the Traverse(r2) operator.<B,transfer,C> For the corresponding query results, the query results of the VertexGet(b) operator, the query results of the Traverse(r1) operator, and the query results of the VertexGet(a) operator, please refer to [link / reference]. Figure 11 This will not be elaborated upon here.

[0116] 5. Execution process of the VertexGet(x) operator

[0117] First, call the getNextRow method of the Traverse(r2) operator to obtain, as follows: Figure 10 The output of the Traverse(r2) operator is shown, where the Traverse(r2) operator is a sub-operator of the VertexGet(x) operator.

[0118] Then, extract as follows Figure 10 The output of the Traverse(r2) operator shown contains the dst_id value (i.e., A) in the Data of the query result of the Traverse(r2) operator, represented by the variable vid. Then, vid is used as the id attribute value of the point to query the User point table, obtaining a query result of the VertexGet(x) operator, i.e.<A,User> .

[0119] Then, similar to the execution process of the VertexGet(b) operator mentioned above, in traversing as... Figure 10 When the output of the Traverse(r2) operator is included in each query result, it is because the query results of the VerterGet(a) operator contain the same...<A,User> Then the VertexGet(x) operator can then obtain, as shown below. Figure 11Another output result of the Traverse(r2) operator.

[0120] Similarly, the VertexGet(x) operator can query the User point table according to the dst_id value (i.e. C) in the Data of the query result of the Traverse(r2) operator contained in the output result of the Traverse(r2) operator, to obtain another query result of the VertexGet(x) operator, i.e. <C, User>. Figure 11

[0121] Similarly, when traversing each query result contained in the output result of the Traverse(r2) operator as shown in Figure 11 Since <C, User> does not exist in each query result, the VertexGet(x) operator can generate an output result based on the query result corresponding to <C, User>, and the query result of the Traverse(r2) operator, the query result of the VertexGet(b) operator, the query result of the Traverse(r1) operator and the query result of the VerterGet(a) operator, as shown in Figure 11

[0122] For example, please refer to Figure 12 , Figure 12 is a schematic diagram of an output result of another point query operator provided in an example embodiment. As shown in Figure 12 , the output result of the VertexGet(x) operator contains, from left to right, the query result corresponding to <C, User> queried by the VertexGet(x) operator, the query result corresponding to the edge <B, transfer, C> queried by the Traverse(r2) operator, the query result of the VertexGet(b) operator, the query result of the Traverse(r1) operator and the query result of the VerterGet(a) operator. For details, please refer to Figure 12 , which will not be described here again.

[0123] 6. Execution process of the Projection(x, id) operator

[0124] First, the getNextRow method of the VertexGet(x) operator is called to obtain the output result of the VertexGet(x) operator, wherein the VertexGet(x) operator is a sub-operator of the Projection(x, id) operator.

[0125] ​​Then, the Data part in the query result of the VertexGet(x) operator contained in the output result of the VertexGet(x) operator is extracted, and a corresponding output result is generated based on this.

[0126] For example, refer to Figure 13 , Figure 13 is a schematic diagram of an output result of a Projection operator provided by an example embodiment. As shown in Figure 13 , the output result of the Projection operator only contains the query result of the Projection operator. Among them, the operator identifier in the Haeder of the query result is 0, indicating that it is neither a point query operator nor an edge query operator, and accordingly, the metadata in the Haeder is empty; the Data in the query result contains the final queried point data, which can specifically include Key:id, Value:C, etc.

[0127] Further, the physical execution plan can extract the data of node C from the output result returned by the Projection operator as shown in Figure 13 , and return the data of node C as the final query result of the query statement to the user.

[0128] In summary, the present specification designs a data structure of an output result of an operator, wherein the output result of each operator contains the query results of all operators executed before itself in addition to its own query result, so that the subsequent executed operator can accurately check whether its query result is duplicated with the previous query result, thereby ensuring that the nodes or edges that have been traversed will not appear repeatedly. The acyclic semantic requirement of the query result is achieved, and the correctness of the query result is ensured.

[0129] Corresponding to the above method flow implementation, the embodiment of the present specification also provides a data query device for a graph database. Please refer to Figure 14 , Figure 14 is a structural schematic diagram of a data query device for a graph database provided by an example embodiment. The device 140 can be applied to Figure 1 the graph database system as shown, and specifically can be applied to the computing device 100 in the graph database system. As shown in Figure 14 , the device 140 comprises:

[0130] an execution plan generation unit 1401 configured to generate an execution plan corresponding to a query statement for the graph database; the execution plan contains a plurality of query operators executed in sequence; wherein the output result of any query operator in the plurality of query operators contains the query result of the query operator, and the query results of all query operators executed before the query operator.

[0131] The determination unit 1402 is configured to execute the plurality of query operators in sequence, and determine whether there is a same query result as the query result of the first query operator in all query results contained in the output result of the second query operator when the first query operator is executed, the second query operator being a neighboring operator executed before the first query operator.

[0132] The output result generation unit 1403 is configured to generate the output result of the first query operator based on the query result of the first query operator and all query results contained in the output result of the second query operator if the determination result is negative.

[0133] In an illustrated embodiment, the determination unit 1402 is specifically configured to:

[0134] obtain the output result of the second query operator;

[0135] further perform data query on the graph database based on the query result of the second query operator contained in the output result of the second query operator, to obtain the query result of the first query operator;

[0136] determine whether there is a same query result as the query result of the first query operator in all query results contained in the output result of the second query operator.

[0137] In an illustrated embodiment, the plurality of query operators include a point query operator for querying node data and an edge query operator for querying edge data.

[0138] In an illustrated embodiment, the query result of any query operator contains node data or edge data queried by the query operator, and the determination unit 1402 is specifically configured to:

[0139] further query edge data associated with the node data from the graph database based on the node data contained in the query result of the second query operator, or further query node data associated with the edge data from the graph database based on the edge data contained in the query result of the second query operator.

[0140] In an illustrated embodiment, the query result of any query operator further contains an operator identifier of the query operator, the operator identifier being used to indicate that the operator type of the query operator is a point query operator or an edge query operator.

[0141] In an illustrated embodiment, the first query operator is a point query operator, and the determination unit 1402 is specifically configured to:

[0142] traverse all query results contained in the output result of the second query operator, and determine, for a target query result of a target query operator currently traversed, whether an operator type indicated by an operator identifier contained in the target query result is a point query operator;

[0143] If yes, it is further determined whether the target query result is the same as the query result of the first query operator, and if no, the next query result is traversed.

[0144] In an illustrated embodiment, the first query operator is an edge query operator, and the determination unit 1402 is specifically configured to:

[0145] traverse all query results contained in the output result of the second query operator, and determine, for a target query result of a target query operator currently traversed, whether an operator type indicated by an operator identifier contained in the target query result is an edge query operator;

[0146] If yes, it is further determined whether the target query result is the same as the query result of the first query operator, and if no, the next query result is traversed.

[0147] In an illustrated embodiment, the query result of the point query operator further contains metadata corresponding to the queried node data; wherein the metadata corresponding to the node data includes a node type and a node identifier;

[0148] The determination unit 1402 is specifically configured to:

[0149] read the metadata corresponding to the node data queried by the target query operator contained in the target query result;

[0150] determine whether the node type and the node identifier contained in the metadata are one-to-one corresponding to the node type and the node identifier contained in the query result of the first query operator, and if yes, determine that the target query result is the same as the query result of the first query operator.

[0151] In an illustrated embodiment, the query result of the edge query operator further contains metadata corresponding to the queried edge data; wherein the metadata corresponding to the edge data includes an edge type, a start point identifier and an end point identifier of the edge;

[0152] The determination unit 1402 is specifically configured to:

[0153] read the metadata corresponding to the edge data queried by the target query operator contained in the target query result;

[0154] determining whether the edge type, the start point identifier of the edge and the end point identifier of the edge contained in the metadata are identical to the edge type, the start point identifier of the edge and the end point identifier of the edge contained in the query result of the first query operator, and if yes, determining that the target query result is identical to the query result of the first query operator.

[0155] In an illustrated embodiment, the apparatus further includes a query result generation unit 1404 configured to:

[0156] obtaining the query result of the last query operator contained in the output result of the last query operator;

[0157] reading the node data or the edge data contained in the query result of the last query operator, and taking the node data or the edge data as the query result of the query statement.

[0158] In an illustrated embodiment, the apparatus 140 further includes a result determination unit 1405 configured to:

[0159] if there is a query result identical to the query result of the first query operator in all query results contained in the output result of the second query operator, determining that the query result of the query statement is empty.

[0160] In an illustrated embodiment, the output result of the second query operator includes at least one output result corresponding to at least one query result queried by the second query operator.

[0161] In an illustrated embodiment, the result determination unit 1405 is specifically configured to:

[0162] sequentially obtaining each output result in the at least one output result of the second query operator, and if there is a query result identical to the query result of the first query operator in all query results contained in the currently obtained output result, further obtaining a next output result in the at least one output result.

[0163] if there is a query result identical to the query result of the first query operator in all query results contained in each output result of the second query operator, determining that the query result of the query statement is empty.

[0164] In an illustrated embodiment, the query statement is a query statement for data query based on path traversal of an Acyclic pattern.

[0165] The implementation process of the functions and roles of each unit in the apparatus 140 is specifically described in the above embodiments, and will not be repeated here. It should be understood that the apparatus 140 can be implemented by software, or by hardware or a combination of software and hardware. For example, in software, as a logical device, it is formed by reading corresponding computer program instructions into memory and running by the processor (CPU) of the device. From the hardware level, in addition to the CPU and the memory, the device where the apparatus is located usually also includes other hardware such as a chip for wireless signal transceiving and / or other hardware such as a board for realizing network communication function.

[0166] The apparatus embodiments described above are only schematic, and the units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical modules, i.e., they can be located in one place, or distributed on multiple network modules. Some or all of the units or modules can be selected according to actual needs to achieve the purposes of the schemes of the present specification. Those skilled in the art can understand and implement without creative labor.

[0167] The apparatus, units and modules illustrated in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, and the specific form of the computer can be a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver device, a game console, a tablet computer, a wearable device, a vehicle-mounted computer or a combination of any of these devices.

[0168] Corresponding to the above method embodiments, the embodiments of the present specification also provide a computing device. Please refer to Figure 15 , Figure 15 is a structural schematic diagram of a computing device provided by an example embodiment. Figure 15 The computing device shown can be the computing device 100 in the graph database system shown in the above Figure 1 The computing device 100 in the graph database system shown in the above Figure 15 As shown, the computing device includes a processor 1001 and a memory 1002, and can further include an input device 1004 (such as a keyboard, etc.) and an output device 1005 (such as a display, etc.). The processor 1001, the memory 1002, the input device 1004 and the output device 1005 can be connected by a bus or other means. As shown in Figure 15As shown, the memory 1002 includes a computer readable storage medium 1003 having stored thereon computer program capable of being run by the processor 1001. The processor 1001 can be a CPU, a microprocessor, or an integrated circuit for controlling execution of the above method embodiments. The processor 1001, when running the stored computer program, can execute each step of the data query method for a graph database in the embodiments of the present specification, including: generating an execution plan corresponding to a query statement for the graph database; the execution plan contains a plurality of query operators executed in sequence; wherein the output result of any query operator in the plurality of query operators contains the query results of all query operators executed before the query operator; executing the plurality of query operators in sequence, and when executing to a first query operator in the plurality of query operators, determining whether there is a query result identical to the query result of the first query operator in all query results contained in the output result of a second query operator; wherein the second query operator is a neighboring operator executed before the first query operator; if not, generating the output result of the first query operator based on the query result of the first query operator and all query results contained in the output result of the second query operator, and so on until the execution of the last query operator ends; generating the query result of the query statement based on the output result of the last query operator, and the like. For detailed description of each step of the above data query method for a graph database, please refer to the previous content, which will not be described here.

[0169] Corresponding to the above method embodiments, the embodiments of the present specification also provide a computer readable storage medium, the storage medium having stored thereon computer programs, which when run by a processor, execute each step of the data query method for a graph database in the embodiments of the present specification. For specific description, please refer to the description of the above embodiments, which will not be described here.

[0170] The above only provides preferred embodiments of the present specification and should not be used to limit the present specification. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification shall be included in the protection scope of the present specification.

[0171] In a typical configuration, the terminal device includes one or more CPUs, input / output interfaces, network interfaces, and memories.

[0172] The memory can include non-persistent memory in computer readable media, random access memory (RAM), and / or non-volatile memory, such as read-only memory (ROM) or flash memory (flash RAM). The memory is an example of computer readable media.

[0173] Computer-readable media includes permanent and non-permanent, movable and non-movable media that can implement information storage by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data.

[0174] Examples of computer-readable media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile discs (DVDs) or other optical storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible to computing devices. According to the definition herein, computer-readable media does not include transitory media, such as modulated data signals and carrier waves.

[0175] It should also be noted that the terms "comprising", "containing", or any other variant thereof, are intended to cover non-exclusive inclusion, such that a process, method, article or apparatus that comprises a list of elements does not include only those elements, but can also include other elements not expressly listed or inherent to such process, method, article or apparatus. Without more limitations, the element defined by the statement "comprising a" does not exclude the presence of additional identical elements in the process, method, article or apparatus that includes the element.

[0176] Those skilled in the art will appreciate that embodiments of the present specification can be provided as methods, systems or computer program products. Therefore, embodiments of the present specification can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Moreover, embodiments of the present specification can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk memory, CD-ROM, optical memory, etc.) containing computer-usable program code.

Claims

1. A data query method for graph databases, characterized in that, The method comprises: generating an execution plan corresponding to a query statement for the graph database; the execution plan comprises a plurality of query operators executed in sequence; wherein the output result of any query operator in the plurality of query operators comprises the query result of the query operator and the query results of all query operators executed before the query operator; sequentially executing the plurality of query operators, and when executing to a first query operator in the plurality of query operators, determining whether there is a query result identical to the query result of the first query operator in all query results contained in the output result of a second query operator; wherein the second query operator is a neighboring operator executed before the first query operator; if not, generating the output result of the first query operator based on the query result of the first query operator and all query results contained in the output result of the second query operator.

2. The method of claim 1, wherein, The determination of whether there is a query result identical to the query result of the first query operator in all query results contained in the output result of the second query operator comprises: obtaining the output result of the second query operator; further querying the graph database based on the query result of the second query operator contained in the output result of the second query operator to obtain the query result of the first query operator; determining whether there is a query result identical to the query result of the first query operator in all query results contained in the output result of the second query operator.

3. The method of claim 2, wherein, The plurality of query operators comprise a point query operator for querying node data and an edge query operator for querying edge data.

4. The method of claim 3, wherein, The query result of any query operator comprises node data or edge data queried by the query operator; and the further querying the graph database based on the query result of the second query operator comprises: further querying edge data associated with the node data from the graph database based on the node data contained in the query result of the second query operator; or further querying node data associated with the edge data from the graph database based on the edge data contained in the query result of the second query operator.

5. The method of claim 4, wherein, The query result of any query operator further comprises an operator identifier of the query operator, the operator identifier being used to indicate that the operator type of the query operator is a point query operator or an edge query operator.

6. The method of claim 5, wherein, The first query operator is a point query operator, and the determination of whether there is a query result identical to the query result of the first query operator in all query results contained in the output result of the second query operator comprises: traversing all query results contained in the output result of the second query operator, and for a target query result of a target query operator currently traversed, determining whether the operator type indicated by the operator identifier contained in the target query result is a point query operator; if yes, further determining whether the target query result is identical to the query result of the first query operator, and if not, traversing to a next query result.

7. The method of claim 5, wherein, The first query operator is an edge query operator, and the determining whether there is a same query result as the query result of the first query operator in all query results contained in the output result of the second query operator comprises: traversing all query results contained in the output result of the second query operator, and determining, for a target query result of a target query operator currently traversed, whether an operator type indicated by an operator identifier contained in the target query result is an edge query operator; if yes, further determining whether the target query result is same as the query result of the first query operator, and if no, traversing to a next query result.

8. The method of claim 6, wherein, The query result of the point query operator further contains metadata corresponding to the queried node data; wherein the metadata corresponding to the node data comprises a node type and a node identifier; The determining whether the target query result is same as the query result of the first query operator comprises: reading metadata corresponding to the node data queried by the target query operator and contained in the target query result; determining whether the node type and the node identifier contained in the metadata are one-to-one same as the node type and the node identifier contained in the query result of the first query operator, and if yes, determining that the target query result is same as the query result of the first query operator.

9. The method of claim 7, wherein, The query result of the edge query operator further contains metadata corresponding to the queried edge data; wherein the metadata corresponding to the edge data comprises an edge type, a start point identifier and an end point identifier of the edge; The determining whether the target query result is same as the query result of the first query operator comprises: reading metadata corresponding to the edge data queried by the target query operator and contained in the target query result; determining whether the edge type, the start point identifier and the end point identifier of the edge contained in the metadata are one-to-one same as the edge type, the start point identifier and the end point identifier of the edge contained in the query result of the first query operator, and if yes, determining that the target query result is same as the query result of the first query operator.

10. The method of claim 1, wherein, The method further comprises: if there is a same query result as the query result of the first query operator in all query results contained in the output result of the second query operator, determining that the query result of the query statement is empty.

11. The method of claim 10, wherein, The output result of the second query operator comprises at least one output result corresponding to at least one query result queried by the second query operator; The if there is a same query result as the query result of the first query operator in all query results contained in the output result of the second query operator, determining that the query result of the query statement is empty, comprises: sequentially obtaining each output result in the at least one output result of the second query operator, and if there is a same query result as the query result of the first query operator in all query results contained in a currently obtained output result, further obtaining a next output result in the at least one output result; If all query results contained in the output result of the second query operator each contain the same query result as the query result of the first query operator, it is determined that the query result of the query statement is empty.

12. The method of claim 4, wherein, The method further includes: acquiring the query result of the last query operator contained in the output result of the last query operator; reading the node data or edge data contained in the query result of the last query operator, and taking the node data or edge data as the query result of the query statement.

13. The method according to any one of claims 1 to 12, characterized in that, The query statement is a query statement for data query based on path traversal of an Acyclic pattern.

14. A data query device for a graph database, characterized in that, The apparatus includes: an execution plan generation unit configured to generate an execution plan corresponding to a query statement for the graph database; the execution plan contains a plurality of query operators executed in sequence; wherein the output result of any query operator of the plurality of query operators contains the query result of the query operator and the query results of all query operators executed before the query operator; a determination unit configured to execute the plurality of query operators in sequence, and when the first query operator of the plurality of query operators is executed, determine whether there is a query result identical to the query result of the first query operator among all query results contained in the output result of the second query operator; wherein the second query operator is a neighboring operator executed before the first query operator; an output result generation unit configured to, if not, generate the output result of the first query operator based on the query result of the first query operator and all query results contained in the output result of the second query operator.

15. A computing device, comprising: including: a memory and a processor; the memory has stored thereon a computer program / instruction executable by the processor; the processor executes the computer program / instruction to perform the method of any one of claims 1-13.

16. A computer readable storage medium characterized by: having stored thereon a computer program / instruction, the computer program / instruction being executed by a processor to implement the method of any one of claims 1-13.

17. A computer program product, characterised in that, the computer program product includes a computer program / instruction, the computer program / instruction being executed by a processor to implement the method of any one of claims 1-13.

Citation Information

Patent Citations

  • Data query method and device, storage medium and electronic equipment

    CN115391426A

  • Data processing method and device, readable storage medium and electronic equipment

    CN115982416A