Method for generating graph logic execution plan of graph query statement, data processing method and device
By generating a graph logic execution plan composed of graph logic operators, the problem of differences in the implementation of graph query languages in graph databases is solved, and the compatibility and generation efficiency of graph query languages are improved.
Patent Information
- Application Number
- CN202311853712.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-28
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2043-12-28
AI Technical Summary
In the existing technology, graph databases lack a unified graph query language standard when querying graph data. As a result, the expression forms of graph query statements implemented by each graph query language are different, and it is impossible to generate logical execution plans compatible with graph query languages.
By generating a graph logic execution plan composed of graph logic operators, the abstract syntax tree is used to convert the graph logic, divided into convertible subtree structures, and converted based on the conversion method of the graph logic operators to generate a unified graph logic execution. Plan to implement graph query language compatibility.
It implements graph query statements with the same semantics in different graph query language implementations to obtain the same graph logic execution plan, improving the compatibility and generation efficiency of graph query languages.
Smart Images

Figure CN117785884B
Abstract
Description
Technical Field
[0001] The embodiments of this specification generally relate to the field of graph databases, and in particular to a method for generating a graph logic execution plan for a graph query statement, a data processing method, and a device. Background Art
[0002] As graph databases and graph computing technologies mature, graph databases are increasingly being used in various application scenarios. However, there is no unified graph query language standard for graph data queries in graph databases, which results in differences in the expression of graph query statements implemented in each graph query language. This requires the use of a bound logical execution plan generation scheme to generate different logical execution plans, making it impossible to achieve graph query language compatibility. Summary of the invention
[0003] The embodiments of this specification provide a graph logic execution plan generation method, a data processing method and a device for a graph query statement. Using the graph logic execution plan generation method, a graph logic execution plan composed of graph logic operators is generated for a graph query statement. Since the graph logic operator is used to describe the minimum processing logic execution unit of the graph query task corresponding to the graph query statement, it is independent of the specific graph query language implementation of the graph query statement, and thus the same graph logic execution plan can be obtained for different graph query language implementations of graph query statements with the same semantics, thereby achieving graph query language compatibility of the graph logic execution plan generation solution.
[0004] According to one aspect of an embodiment of the present specification, a method for generating a graph logic execution plan for a graph query statement is provided, comprising: generating an abstract syntax tree for the graph query statement; and performing a graph logic transformation based on a graph logic operator on the abstract syntax tree to obtain a graph logic execution plan for the graph query statement, wherein the graph logic execution plan includes a set of graph logic operators organized into a tree structure.
[0005] Optionally, in an example of the above aspect, performing a graph logic conversion based on a graph logic operator on the abstract syntax tree to obtain a graph logic execution plan for the graph query statement may include: dividing the abstract syntax tree into a plurality of convertible subtree structures according to the node structure and node semantics of the abstract syntax tree, the convertible subtree structure including a subtree structure that can independently complete the graph logic conversion and having a graph logic conversion mode, the graph logic conversion mode including a graph logic operator conversion and a graph logic operator execution order relationship conversion; and performing a graph logic conversion on the convertible subtree structure according to the graph logic conversion mode of the convertible subtree structure to obtain the graph logic execution plan for the graph query statement.
[0006] Optionally, in an example of the above aspect, according to the node structure and node semantics of the abstract syntax tree, dividing the abstract syntax tree into multiple convertible sub-tree structures may include: searching for the multiple convertible sub-tree structures from the abstract syntax tree according to the node structure and node semantics of the abstract syntax tree in a tree traversal manner.
[0007] Optionally, in an example of the above aspect, once a convertible subtree structure is searched out, a graph logic conversion of the searched out convertible subtree structure is performed.
[0008] Optionally, in an example of the above aspect, the convertible subtree structure includes a maximum subtree structure that can independently complete graph logic conversion.
[0009] Optionally, in an example of the above aspect, the method may further include: converting the abstract syntax tree into a general syntax tree, wherein the general syntax tree has a unified description structure for different graph query language implementations of graph query statements with the same semantics. Accordingly, performing a graph logic conversion based on a graph logic operator on the abstract syntax tree to generate a graph logic execution plan for the graph query statement may include: performing a graph logic conversion based on a graph logic operator on the general syntax tree to generate a graph logic execution plan for the graph query statement.
[0010] Optionally, in an example of the above aspect, converting the abstract syntax tree into a general syntax tree may include: determining a difference subtree structure in which there are graph query language implementation differences from the abstract syntax tree; and performing structural conversion on the difference subtree structure according to a structural conversion method corresponding to a difference type of the difference subtree structure.
[0011] Optionally, in an example of the above aspect, the implementation differences of the graph query statements include semantic structure implementation differences and grammatical structure implementation differences. Accordingly, according to the conversion method corresponding to the difference type of the difference subtree structure, the structural conversion of the difference subtree structure may include: in response to the difference type of the difference subtree structure being a semantic structure implementation difference, adding a subtree structure implemented by other graph query languages specified in the standard universal syntax tree under the parent node of the difference subtree structure; in response to the difference type of the difference subtree structure being a grammatical structure implementation difference, converting the difference subtree structure into a unified subtree structure specified in the standard universal syntax tree.
[0012] Optionally, in an example of the above aspect, the method may further include: performing plan optimization on the generated graph logic execution plan.
[0013] Optionally, in an example of the above aspect, plan optimization for the graph logic execution plan is implemented via a pluggable execution plan optimizer.
[0014] According to another aspect of an embodiment of the present specification, a data processing method is provided, comprising: generating an abstract syntax tree of a graph query statement; performing a graph logic transformation based on a graph logic operator on the abstract syntax tree to obtain a graph logic execution plan for the graph query statement, the graph logic execution plan comprising a set of graph logic operators organized into a tree structure; and performing data processing corresponding to the graph query statement according to the graph logic execution plan.
[0015] According to another aspect of an embodiment of the present specification, there is provided an apparatus for generating a graph logic execution plan for a graph query statement, comprising: an abstract syntax tree generator, which generates an abstract syntax tree for the graph query statement; and a graph logic converter, which performs graph logic conversion based on graph logic operators on the abstract syntax tree to generate a graph logic execution plan for the graph query statement, wherein the graph logic execution plan comprises a set of graph logic operators organized into a tree structure.
[0016] Optionally, in an example of the above aspect, the graph logic converter may include: a tree structure segmentation module, which segments the abstract syntax tree into multiple convertible subtree structures according to the node structure and node semantics of the abstract syntax tree, the convertible subtree structure including a subtree structure that can independently complete graph logic conversion and has a graph logic conversion mode, the graph logic conversion mode including graph logic operator conversion and graph logic operator execution order relationship conversion; and a graph logic conversion module, which performs graph logic conversion on the convertible subtree structure according to the graph logic conversion mode of the convertible subtree structure.
[0017] Optionally, in an example of the above aspect, the tree structure segmentation module searches for the multiple convertible subtree structures from the abstract syntax tree in a tree traversal manner according to the node structure and node semantics of the abstract syntax tree.
[0018] Optionally, in an example of the above aspect, the apparatus may further include: a syntax tree converter, which converts the abstract syntax tree into a general syntax tree, wherein the general syntax tree has a unified description structure for different graph query language implementations of graph query statements with the same semantics. Accordingly, the graph logic converter performs a graph logic conversion based on a graph logic operator on the general syntax tree to generate a graph logic execution plan for the graph query statement.
[0019] Optionally, in an example of the above aspect, the syntax tree converter may include: a difference tree structure determination module, which determines a difference subtree structure in which a graph query language implementation difference exists from the abstract syntax tree; and a difference tree structure conversion module, which performs structural conversion on the difference subtree structure according to a structural conversion method corresponding to a difference type of the difference subtree structure.
[0020] Optionally, in an example of the above aspect, the graph query statement implementation differences include semantic structure implementation differences and grammatical structure implementation differences. In response to the difference type of the difference subtree structure being a semantic structure implementation difference, the difference tree structure conversion module adds a subtree structure implemented by other graph query languages specified in the standard universal syntax tree under the parent node of the difference subtree structure; in response to the difference type of the difference subtree structure being a grammatical structure implementation difference, the difference tree structure conversion module converts the difference subtree structure into a unified subtree structure specified in the standard universal syntax tree.
[0021] According to another aspect of an embodiment of the present specification, there is provided a data processing device, comprising: an abstract syntax tree generator, which generates an abstract syntax tree of a graph query statement; a graph logic converter, which performs a graph logic conversion based on a graph logic operator on the abstract syntax tree to obtain a graph logic execution plan of the graph query statement, wherein the graph logic execution plan comprises a set of graph logic operators organized into a tree structure; and a plan executor, which executes data processing corresponding to the graph query statement according to the graph logic execution plan.
[0022] According to another aspect of an embodiment of the present specification, a device for generating a graph logic execution plan for a graph query statement is provided, comprising: at least one processor; a memory coupled to the at least one processor; and a computer program stored in the memory, wherein the at least one processor executes the computer program to implement the method for generating a graph logic execution plan for a graph query statement as described above.
[0023] According to another aspect of an embodiment of the present specification, there is provided a data processing device, comprising: at least one processor; a memory coupled to the at least one processor; and a computer program stored in the memory, wherein the at least one processor executes the computer program to implement the data processing method as described above. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] A further understanding of the nature and advantages of the content of this specification may be achieved by referring to the following drawings. In the drawings, similar components or features may have the same reference numerals.
[0025] Figure 1 An example flowchart of a method for generating a graph logic execution plan according to an embodiment of the present specification is shown.
[0026] Figure 2 An example schematic diagram of a graph query statement according to an embodiment of the present specification is shown.
[0027] Figure 3An example schematic diagram of an abstract syntax tree generation process according to an embodiment of the present specification is shown.
[0028] Figure 4 An example schematic diagram of an abstract syntax tree according to an embodiment of the present specification is shown.
[0029] Figure 5 An example flowchart of a graph logic conversion process according to an embodiment of the present specification is shown.
[0030] Figure 6 An example flowchart of a graph logic conversion process based on tree traversal according to an embodiment of the present specification is shown.
[0031] Figure 7 An example schematic diagram of a graph logic conversion process according to an embodiment of the present specification is shown.
[0032] Figure 8 A comparison diagram showing the differences between the abstract syntax trees of graph query statements written in two different graph query languages is shown.
[0033] Fig. 9 An example flow chart of a syntax tree conversion process according to an embodiment of the present specification is shown.
[0034] Fig. 10A and Fig. 10B An example schematic diagram of difference tree structure conversion according to an embodiment of the present specification is shown.
[0035] Fig.11 An example schematic diagram of a general syntax tree according to an embodiment of the present specification is shown.
[0036] Fig.12 An example schematic diagram of a graph logic execution plan according to an embodiment of the present specification is shown.
[0037] Fig.13 An example schematic diagram of an optimized graph logic execution plan according to an embodiment of the present specification is shown.
[0038] Fig.14 An exemplary flow chart of a data processing method according to an embodiment of the present specification is shown.
[0039] Fig.15 An example block diagram of a graph logic execution plan generating device according to an embodiment of the present specification is shown.
[0040] Fig.16 An example block diagram of a syntax tree converter according to an embodiment of the present specification is shown.
[0041] Fig.17 An example block diagram of a graph-logic converter according to an embodiment of the present description is shown.
[0042] Fig.18 An exemplary block diagram of a data processing device according to an embodiment of the present specification is shown.
[0043] Fig.19 An example schematic diagram of a graph logic execution plan generation device implemented based on a computer system according to an embodiment of the present specification is shown.
[0044] Fig. 20 An exemplary schematic diagram of a data processing device implemented based on a computer system according to an embodiment of the present specification is shown. DETAILED DESCRIPTION
[0045] The subject matter described herein will now be discussed with reference to example embodiments. It should be understood that the discussion of these embodiments is only to enable those skilled in the art to better understand and implement the subject matter described herein, and is not a limitation of the scope of protection, applicability or examples set forth in the claims. The functions and arrangements of the elements discussed can be changed without departing from the scope of protection of the contents of this specification. Various examples can omit, replace or add various processes or components as needed. For example, the described method can be performed in an order different from the described order, and various steps can be added, omitted or combined. In addition, the features described relative to some examples can also be combined in other examples.
[0046] As used herein, the term "including" and its variations represent open terms, meaning "including but not limited to". The term "based on" means "based at least in part on". The terms "one embodiment" and "an embodiment" mean "at least one embodiment". The term "another embodiment" means "at least one other embodiment". The terms "first", "second", etc. may refer to different or the same objects. Other definitions may be included below, whether explicit or implicit. Unless the context clearly indicates otherwise, the definition of a term is consistent throughout the specification.
[0047] The flowcharts used in this specification illustrate the operations implemented by the system according to some embodiments in this specification. It should be clearly understood that the operations of the flowcharts may not be implemented in sequence. On the contrary, the operations may be implemented in reverse order or simultaneously. In addition, one or more other operations may be added to the flowchart. One or more operations may be removed from the flowchart.
[0048] In recent years, with the gradual maturity of graph computing technology and the development of Internet technology, graph databases have been increasingly used in various application fields, such as finance, medical care, security, etc. The graph data in a graph database consists of nodes (vertices) and edges, where nodes represent entities and edges represent relationships between entities. For example, in social graph data, each person represents a node, and their relationships (such as friends, family, colleagues, etc.) constitute edges. Compared with relational databases, graph databases have significant differences in the storage, query, and data structure of graph data.
[0049] When querying data in a graph database, there are multiple graph query statements written in different graph query languages. Each graph query language has its own grammatical characteristics, which results in grammatical differences between the graph query statements written. Due to the grammatical differences between the graph query statements written in various graph query languages, when generating corresponding logical execution plans based on graph query statements, a dedicated logical execution plan generator is bound to each graph query statement written in a graph query language to perform grammatical and semantic analysis on the graph query statement and generate a logical execution plan, and different logical execution plans are generated, making it impossible to achieve graph query language compatibility when generating logical execution plans.
[0050] In view of this, an embodiment of the present specification proposes a graph logic execution plan generation scheme. In the graph logic execution plan generation scheme, a graph logic execution plan composed of graph logic operators is generated for a graph query statement. Since the graph logic operator is used to describe the minimum processing logic execution unit of the graph query task corresponding to the graph query statement, it is independent of the specific graph query language implementation of the graph query statement, and thus the same graph logic execution plan can be obtained for graph query statements with the same semantics based on different graph query languages, thereby achieving the graph query language compatibility of the graph logic execution plan generation scheme.
[0051] The following describes a graph logic execution plan generating method, a data processing method, a graph logic execution plan generating device, and a data processing device according to an embodiment of the present specification with reference to the accompanying drawings.
[0052] Figure 1 An example flow chart of a graph logic execution plan generation method 100 according to an embodiment of the present specification is shown. The graph logic execution plan generation method 100 may be executed by a graph logic execution plan generation device.
[0053] like Figure 1 As shown, at 110, after receiving a graph query statement, an abstract syntax tree of the graph query statement is generated.
[0054] The graph query statement may be received by the graph logic execution plan generating device from other devices (eg, user devices) that can be wirelessly or wired connected. Examples of other devices may include, but are not limited to, servers, terminals, smart devices, and the like. Figure 2 An example schematic diagram of a graph query statement according to an embodiment of the present specification is shown. Figure 2 The graph query statement shown is used to obtain all movies in which a person named Tom has participated from the graph database.
[0055] After receiving the graph query statement, the graph query statement is subjected to lexical analysis and syntax analysis to determine the grammatical structure and hierarchical relationship of the graph query statement, and an abstract syntax tree (AST) is generated based on the determined grammatical structure and hierarchical relationship. The abstract syntax tree is a tree representation of the abstract syntax structure of the source code of the graph query statement. Each node in the abstract syntax tree represents a structure of the source code. The abstract syntax tree does not represent every detail that appears in the actual syntax of the graph query statement. For example, nested brackets are implied in the tree structure and will not be presented as tree nodes in the abstract syntax tree.
[0056] Figure 3 An example schematic diagram of an abstract syntax tree generation process according to an embodiment of the present specification is shown.
[0057] like Figure 3 As shown, after receiving the graph query statement, the graph query statement is lexically analyzed. For example, the graph query statement is scanned character by character from left to right using the lexical analyzer Lex. During the scanning process, if the correct character structure is encountered, the corresponding lexical unit (token) is returned to the syntax tree builder. If an incorrect character structure is encountered, an error message is given, such as escape characters.
[0058] After receiving the lexical unit from the grammar analyzer Lex, the syntax tree builder starts to build the abstract syntax tree from top to bottom. When building the abstract syntax tree, if the lexical unit encountered is a non-operator, the lexical unit is packaged into a syntax tree node structure and pushed into the syntax tree node stack of the syntax tree builder. If the lexical unit encountered is an operator, it is necessary to add a new operator to the operator stack, and the obtained operand is packaged into a syntax tree node and pushed into the syntax tree node stack. Before pushing a new operator into the operator stack each time, it is necessary to check the operation priority between the old operator at the top of the current operator stack and the new operator. If the priority of the old operator is high, the old operator is processed first (the syntax tree nodes in the syntax tree node stack are used up, and the nodes obtained by the operation are pushed back into the syntax tree node stack). After the old operator is processed, it is popped out of the stack, and the subsequent old operator becomes the new top operator of the stack. Repeat the above process for the new top operator and the new operator until the priority of the old operator at the top of the stack is lower than that of the new operator, and the new operator is pushed into the operator stack.
[0059] Figure 4 An example schematic diagram of an abstract syntax tree according to an embodiment of the present specification is shown. Figure 4 The abstract syntax tree in Figure 2 It should be noted that graph query statements can be written based on different graph query languages. For graph query statements with the same semantics (i.e., graph query statements used to implement the same query processing), the expression forms of graph query statements written in different query languages will be different, which will lead to differences in the obtained abstract syntax trees.
[0060] After the abstract syntax tree is obtained as above, at 120, a graph logic conversion based on graph logic operators is performed on the abstract syntax tree to obtain a graph logic execution plan of the graph query statement, and the graph logic operators in the obtained graph logic execution plan are formed into a tree structure.
[0061] Graph logic operators are the smallest execution units used to describe graph query tasks, such as graph logic operators for obtaining points, graph logic operators for obtaining edges, graph logic operators for obtaining indefinite jump paths, etc. For the same graph query task unit, graph logic operators have a unified representation form, which is independent of the specific graph query language representation form of the query task.
[0062] Listed below are example descriptions of graph logic operators designed according to the embodiments of this specification.
[0063] (1) Graph logic operator AllNodesScan, with parameter (binding_var:String) and output result binding_var, is used to obtain all nodes, and the result is bound to the variable binding_var.
[0064] (2) The graph logic operator NodeByLabelsScan takes parameters (binding_var: String, labels: LabelTree) and outputs binding_var. It is used to obtain data that meets the label constraint. The label constraint is labels: LabelTree. LabelTree supports the operations of AND, OR, and NOT. The result is bound to the variable binding_var.
[0065] (3) Graph logic operator NodeSeek, with parameters (binding_var:String, labels:String, field:String, value:Expr), and output result is binding_var, which is used to use index difference nodes, and the result is bound to the variable binding_var.
[0066] (4) Graph logic operator ExpandAll, parameters are (src_ref: String, binding_dst: String, binding_edge: String, dir: Direction, labels: LabelTree, filters: List <expr>), the output results are child.row.columns, binding_dst and binding_edge, which are used to traverse the edges and target points in the given direction dir given the starting point variable src_ref, the obtained edges are bound to the variable binding_edge, and the obtained target points are bound to the variable binding_dst. The operator supports setting edge label filter conditions labels. In addition, the operator supports setting filter conditions filters for PerNodeLimit expansion.
[0067] (5) Graph logic operator VarLengthExpand, parameters are (src_ref:String,binding_dst:String,binding_edges:String,binding_edge:String,dir:Direction,labels:LabelTree,filters:List <expr>,min_hop:Integer,max_hop:Integer), the output results are child.row.columns,binding_dst and binding_edges, which are used to traverse the multi-hop results of the given direction dir under the given starting point variable src_ref. The obtained target point is bound to the variable binding_dst, and there is no corresponding binding for the intermediate node. The variable binding_edges represents all the edges in the path, and the variable binding_edge represents each edge in the path. During the execution of the operator, the edge represented by binding_edge continues to change. When the operator execution ends, the life cycle of binding_edge ends. The operator supports setting edge label filter conditions labels. The operator supports setting filter conditions filters for PerNodeLimit expansion.
[0068] (6)Graph logic operator Create, parameters are (binding_var: String, properties: List<String,Expr> ), the output result is Null, which is used to create a vertex or edge. The created vertex or edge is bound to the variable binding_var.
[0069] (7) Graph logic operator Delete, with parameter (var_ref:String) and output result Null, is used to delete a vertex or edge.
[0070] (8) Graph logic operator SetProperty, with parameters (var_ref:String, field:String, value:Expr), and output result Null, used to set the properties of a vertex or edge.
[0071] (9) The graph logic operator Apply has the following parameters: () and the output results are lhs.row.columns and rhs.row.columns, which are used to provide the row data obtained by the left operator to the right operator. The row data generated by the Apply operator includes the left data and the right data.
[0072] (10) The graph logic operator SemiApply has the parameter () and the output result lhs.row.columns, which is used to provide the row data obtained by the left operator to the right operator. If the right operator generates at least one row of data (result exists), the row data generated by the SemiApply operator only contains the left row data. Otherwise, the SemiApply operator does not generate any data.
[0073] (11) The graph logic operator AntiSemiApply has the following parameters: () and the output result is lhs.row.columns, which is used to provide the row data obtained by the left operator to the right operator. The row data generated by the AntiSemiApply operator only contains the left row data. Otherwise, the AntiSemiApply operator does not generate any data.
[0074] (12) Graph logic operator Argument, parameter is (args: List <string>), the output result is Null, which is used to pass row data from the left to the right.
[0075] (13) Graph logic operator ProcedureCall, parameters are (name: String, args: List <expr>), the output is child.row.columns, which is used to call the stored procedure.
[0076] (14) The graph logic operator CartesianProduct, with parameters (), output results hs.row.columns, rhs.row.columns, is used to generate the Cartesian product of two inputs, where each row from the left operator will be combined with all rows from the right operator.
[0077] (15) The graph logic operator ProduceResults, with parameters (), output result child.row.columns, is used to prepare the results.
[0078] (16) The graph logic operator Optional takes a parameter of () and outputs a result of child.row.columns, which is used for Optional Match queries. Optional will pass along any row provided by the child operator. If the child operator does not provide any data, a row with all columns set to null is generated.
[0079] (17) Graph logic operator Filter, parameter is (filters: List <expr>), the output is child.row.columns, which is used to filter each row of data and only pass rows where the predicate result is true.
[0080] (18)Graph logic operator Projection, parameter is (items:List <tuple<Expr,String> >), the output result is [item[1]for itemin items], which is used to evaluate a set of expressions and generate results.
[0081] (19) Graph logic operator Sort, parameter is (sort: List <Tuple<Expr,Order> >), the output is child.row.columns, which is used to sort the rows by the provided key.
[0082] (20) The graph logic operator Limit, with parameter (limit: Integer) and output result child.row.columns, is used to return the first n rows from the input row.
[0083] (21) The graph logic operator Skip, with parameter (skip:Interger) and output result child.row.columns, is used to skip n rows from the input rows.
[0084] (22) The graph logic operator Distinct takes a parameter of () and outputs a result of child.row.columns, which is used to remove duplicate rows from the input rows.
[0085] (23) Graph logic operator Aggregation, parameter is (group: List <tuple<Expr,String> >,aggregation:List <tuple<Expr,String> >), the output result is [g[1]for g in group]+[a[1]fora in aggregation], which is used to calculate the grouping expression and group according to the result, and calculate the aggregation result for each group through the aggregation function.
[0086] (24) Graph logic operator GetEdges, parameters are (src_ref:String,binding_edge:String,dir:Direction,labels:LabelTree,filters:List <expr>), the output result is child.row.columns,binding_edge, which is used to traverse the edges of the given direction dir given the starting point src_ref, and the obtained edges are bound to the variable binding_edge. The operator supports setting edge label filter conditions labels. The operator supports setting filter conditions filters for PerNodeLimit expansion. Compared with the ExpandAll operator, the GetEdges operator does not obtain the target point and can be used to optimize queries for specific storage engines.
[0087] (25) The graph logic operator ExtractEdge takes the following parameters: (edge_ref: String, binding_dst: String), and the output result is child.row.columns, binding_dst. It is used to obtain the target point of the edge when the edge edge_ref is set, and the result is bound to the variable binding_dst.
[0088] The designed graph logic operators inherit some relational logic operators, such as the Filter operator and the Sort operator, and also design operators specifically for graph database processing, such as the AllNodesScan operator, NodeByLabelsScan operator, NodeSeek operator, ExpandAll operator, VarLengthExpand operator, Create operator, Delete operator, SetProperty operator, Apply operator, SemiApply operator, AntiSemiApply operator, Argument operator, GetEdges operator, ExtractEdge operator, etc.
[0089] Figure 5 An example flow chart of a graph logic conversion process 500 according to an embodiment of the present specification is shown.
[0090] like Figure 5 As shown, at 510, according to the node structure and node semantics of the abstract syntax tree, the abstract syntax tree is divided into a plurality of convertible subtree structures, and the convertible subtree structures divided include subtree structures that can independently complete graph logic conversion and have a graph logic conversion mode. The graph logic conversion mode may include, for example, graph logic operator conversion and graph logic operator execution order relationship conversion. Graph logic operator conversion is used to indicate that the convertible subtree structure is converted into a graph logic operator or a combination (set) of graph logic operators connected in sequence according to the execution order. Graph logic operator execution order relationship conversion is used to indicate that the convertible subtree structure is converted into the execution order relationship between the graph logic operators in the previously converted subtree structure. Here, independently completing the graph logic conversion means that the graph logic conversion for the convertible subtree structure does not require or rely on the abstract syntax tree structure outside the convertible subtree structure. In some embodiments, the convertible subtree structure may include the largest subtree structure that can independently complete the graph logic conversion.
[0091] In some embodiments, the graph logic conversion mode of the convertible subtree structure can be determined based on the node structure and node semantics of the convertible subtree structure. If the convertible subtree structure includes multiple syntax tree nodes, the graph logic conversion mode of the convertible subtree structure is determined to be a graph logic operator conversion. If the convertible subtree structure includes a single syntax tree node and the node semantics of the syntax tree node indicate a corresponding graph logic processing, the graph logic conversion mode of the convertible subtree structure is determined to be a graph logic operator conversion. If the convertible subtree structure includes a single syntax tree node and the node semantics of the syntax tree node indicate the relationship between the graph logic processing of the corresponding downstream child nodes, the graph logic conversion mode of the convertible subtree structure is determined to be a graph logic operator execution order relationship conversion.
[0092] For example, when traversing to a syntax tree node of the abstract syntax tree, such as MatchStatement and PrimitiveResultStatement, it is determined that the syntax tree node can be converted by a graph logic operator based on the node semantics of the syntax tree node (for example, node attributes and node definitions, etc.). Then, the independently executable subtree structure corresponding to the syntax tree node is found based on the node structure of the abstract syntax tree, and the subtree structure is switched to a convertible subtree structure.
[0093] In some embodiments, the abstract syntax tree may be traversed in a tree traversal manner, and a plurality of convertible subtree structures may be searched out from the abstract syntax tree according to the node structure and node semantics of the abstract syntax tree.
[0094] At 520, for each convertible subtree structure, a graph logic conversion is performed on the convertible subtree structure according to the graph logic conversion mode of the convertible subtree structure. After the graph logic conversion of all convertible subtree structures is completed, a graph logic execution plan of the graph query statement can be obtained.
[0095] In some embodiments, after searching for a convertible subtree structure in a tree traversal manner, once a convertible subtree structure is found, the graph logic conversion of the searched convertible subtree structure is immediately performed. In some embodiments, the graph logic conversion of the convertible subtree structure may be performed only after all convertible subtree structures are found.
[0096] Figure 6 An example flowchart of a tree traversal-based graph logic conversion process 600 according to an embodiment of the present specification is shown.
[0097] like Figure 6 As shown, the tree traversal is performed starting from the root node of the abstract syntax tree, and the graph logic conversion process is executed cyclically. At each graph logic conversion, the unprocessed structure of the abstract syntax tree is traversed at 610 to search for the first convertible subtree structure in the current unprocessed structure. For example, starting from the root node of the convertible subtree structure processed by the previous graph logic conversion process, the traversal can be continued in the remaining tree structure of the abstract syntax tree to search for the convertible subtree structure.
[0098] At 620 , after searching for the convertible subtree structure, the convertible subtree structure is subjected to graph logic conversion according to the graph logic conversion mode of the convertible subtree structure.
[0099] At 630, it is determined whether the graph logic conversion has been completed for all syntax tree nodes of the abstract syntax tree. If there are still syntax tree nodes that have not completed the graph logic conversion, return to 610 and execute the next graph logic conversion process. If the graph logic conversion has been completed for all syntax tree nodes, the currently obtained graph logic operator tree structure is output as a graph logic execution plan.
[0100] Figure 7 An example schematic diagram of a graph logic conversion process according to an embodiment of the present specification is shown.
[0101] like Figure 7 As shown, the graph logic conversion is performed starting from the root node of the abstract syntax tree in a tree traversal manner. First, the convertible subtree structure is searched in the left branch structure of the root node. When the left child node of the root node is searched, it is found that the child node is a MatchStatement node. According to the node semantics of the MatchStatement node, it can be determined that there is a subtree structure with the MatchStatement node as the root node that can independently complete the graph logic conversion. Subsequently, based on the node structure of the abstract syntax tree, the convertible subtree structure with the MatchStatement node as the root node is found, as shown in the left dotted box in the figure. Next, the found convertible subtree structure with the MatchStatement node as the root node is converted into the corresponding graph logic operator set. For example, based on the semantic information of the convertible subtree structure corresponding to MatchStatement, the convertible subtree structure is converted into graph logic operators ExpandAll(src_ref:n,binding_dst:m,dir:PointRight) and AllNodesScan(n), and the two graph logic operators form a parent-child relationship, where ExpandAll(src_ref:n,binding_dst:m,dir:PointRight) is the parent graph logic operator, and AllNodesScan(n) is the child graph logic operator, that is, ExpandAll->AllNodesScan.
[0102] After completing the graph logic conversion of the left branch structure of the root node as above, starting from the root node of the convertible subtree structure (i.e., MatchStatement node), a traversal process is performed on the unprocessed structure of the abstract syntax tree, thereby further searching in the right branch of the root node, and then searching for the second convertible subtree structure with PrimitiveStatement as the root node. Based on the semantic information analysis of the second convertible subtree structure, the second convertible subtree structure can be converted into a graph logic operator Projection.
[0103] After completing the graph logic operator Projection conversion, the abstract syntax tree still has the root node left unprocessed. Through the node semantic analysis of the root node, the root node is used to describe the logical execution order relationship between the MatchStatement node and the PrimitiveStatement node, so the graph logic conversion mode of the root node is determined as the graph logic operator execution order relationship conversion, and according to the logical execution order relationship between the MatchStatement node and the PrimitiveStatement node reflected by the root node, the graph logic operator structures corresponding to the MatchStatement node and the PrimitiveStatement node are sequentially connected, that is, the graph logic operator structure ExpandAll->AllNodesScan corresponding to the MatchStatement node and the graph logic operator Projection corresponding to the PrimitiveStatement node are converted into a parent-child relationship, thereby completing the graph logic conversion processing of the abstract syntax tree and obtaining the graph logic execution plan corresponding to the graph query language.
[0104] For the same graph query statement written in different graph query languages, due to the differences in semantic expression and grammatical structure, the generated abstract syntax tree will also have semantic differences caused by different semantic expressions (semantic structure implementation differences) and structural differences caused by the same semantic expression but different grammatical structure (grammatical structure implementation differences).
[0105] Figure 8 The figure shows the difference between the abstract syntax trees of graph query statements written in two different graph query languages. Figure 8 In the figure, the abstract syntax tree of the graph query statement implemented based on the GQL language and the abstract syntax tree of the graph query statement implemented based on the CYPHER language are shown respectively.
[0106] from Figure 8 It can be seen that there are semantic structure implementation differences and grammatical structure implementation differences between the two abstract syntax trees as shown in the figure. In this specification, the term "semantic structure implementation difference" is used to refer to the fact that the graph query semantics described in the overall structure or local structure (subtree structure) of the same graph query function or graph query task (for example, the same object) in the abstract syntax trees corresponding to the graph query statements implemented in different graph query languages are different and cannot be completely converted. For example, for the object "EdgePattern", the abstract syntax tree of the graph query statement implemented based on the GQL language has three nodes "Variable:e", "LabelName:acted_in" and "RIGHT ARROW", while the abstract syntax tree of the graph query statement implemented based on the CYPHER language has two nodes "LabelName:acted_in" and "RIGHT ARROW", so that for the object "EdgePattern", there are semantic structure implementation differences between the two abstract syntax trees.
[0107] The term "syntactic structure implementation difference" is used to refer to the fact that the graph query semantics described by the overall structure or local structure (subtree structure) for the same graph query function or graph query task (for example, the same object) in the abstract syntax trees corresponding to graph query statements implemented in different graph query languages are the same, but the syntactic structures are different due to language characteristics, generation methods, etc. For example, the subtree structure guided by "where clause" in the abstract syntax tree of a graph query statement implemented based on the GQL language and the subtree structure guided by "Property" in the abstract syntax tree of a graph query statement implemented based on the CYPHER language have the same graph query semantics, but different syntactic implementation structures.
[0108] Considering that the conversion process from the abstract syntax tree to the graph logic execution plan is relatively complicated, and the abstract syntax trees corresponding to the graph query statements written in different graph query languages have differences in grammatical structure and semantic structure, a different conversion process from the abstract syntax tree to the graph logic execution plan needs to be executed separately for each graph query statement written in each graph query language, which makes the graph logic execution plan generation solution inefficient when facing different graph query language platforms.
[0109] To this end, a general syntax tree structure is designed, in which the syntax tree substructures corresponding to multiple different graph query languages can be combined and considered in the general syntax tree structure in view of the differences in semantic structure implementation, that is, the syntax tree substructures corresponding to multiple different graph query languages are listed side by side under the same parent node. In view of the differences in syntax structure implementation (same semantics, but different syntax implementation structures), the syntax structures corresponding to multiple different graph query languages can be unified into a standard syntax structure, thereby eliminating the syntax structure differences and semantic structure differences between multiple different graph query languages. The standard syntax structure can be selected from the syntax structures corresponding to multiple different graph query languages, or constructed by comprehensively considering the syntax structures corresponding to multiple different graph query languages, or a syntax structure designed independently.
[0110] In some embodiments, for example, when the graph query statement includes a declarative graph query statement, the abstract syntax tree can also be converted into a general syntax tree, which is designed to have a unified description structure for different graph query language implementations of the same semantic graph query statement. Then, the general syntax tree is subjected to a graph logic conversion based on a graph logic operator to generate a graph logic execution plan for the graph query statement. The graph logic conversion process based on the general syntax tree is similar to the above-mentioned graph logic conversion process based on the abstract syntax tree, and will not be described here.
[0111] Fig. 9 An example flow chart of a syntax tree conversion process 900 according to an embodiment of the present specification is shown.
[0112] like Fig. 9 As shown, at 910, a difference subtree structure in which a graph query language implementation difference exists is determined from the abstract syntax tree. The difference subtree structure may have a difference type. The difference type of the difference subtree structure may include, for example, a semantic structure implementation difference and a grammatical structure implementation difference. For example, the abstract syntax tree may be traversed from the bottom to the bottom, and for the traversed nodes, according to the tree structure provisions of the general syntax tree, it is determined whether there is a difference subtree structure with the node as the root node, and the difference type of the difference subtree structure is determined. Here, the difference subtree structure may include a structure for implementing the graph query semantics represented by the node. For example, according to the tree structure provisions of the general syntax tree, for the node Match, each EdgePattern child node needs to have a corresponding Variable child node. In the current abstract syntax tree, for the node Match, if the child node EdgePattern does not have a child node Variable, then the subtree structure guided by the child node EdgePattern is a difference subtree.
[0113] At 920, the difference subtree structure is structurally transformed according to the structural transformation method corresponding to the difference type of the difference subtree structure. For example, if the difference type of the difference subtree structure is a semantic structure implementation difference, a subtree structure implemented by other graph query languages specified in the standard universal syntax tree is added under the parent node of the difference subtree structure. If the difference type of the difference subtree structure is a structural implementation difference, the difference subtree structure is converted into a unified subtree structure specified in the standard universal syntax tree.
[0114] Fig. 10A and Fig. 10B An example schematic diagram of difference tree structure conversion according to an embodiment of the present specification is shown.
[0115] exist Fig. 10A In the example, the difference type of the difference subtree structure is the difference in semantic structure implementation, that is, there is a subtree structure P1 with a difference in semantic structure implementation in the abstract syntax tree. In this case, the general syntax tree also has a subtree structure P2 implemented by other graph query languages listed in parallel under the parent node of the subtree structure P1. Therefore, in the abstract syntax tree, the subtree structure P2 implemented by other graph query languages is added under the parent node, thereby achieving structural consistency of the general syntax trees under different graph query languages.
[0116] exist Fig. 10B In the example, the difference type of the difference subtree structure is the difference in grammatical structure, that is, different grammatical expressions for the same semantics. In this case, the nodes Expression, OrExpression, XorExpression and AndExpression are compressed into the node BAnd. In other examples, the unified processing of the grammatical structure can also be achieved according to other predetermined rules. For example, in some embodiments, the grammatical expressions of different graph query languages can be unified into the grammatical expression of a certain graph query language. For example, Figure 8 The differences in the grammatical structure implementation shown in are unified into a grammatical structure implemented based on the GQL language, that is, a grammatical structure guided by a "where clause".
[0117] Fig.11 An example schematic diagram showing a general syntax tree according to an embodiment of the present specification, and Fig.12 An example schematic diagram of a graph logic execution plan according to an embodiment of the present specification is shown.
[0118] After obtaining the graph logic execution plan as above, the generated graph logic execution plan can also be optimized. For example, the graph logic execution plan can be optimized through a series of optimization algorithms and rules based on the logical and physical characteristics of the graph query task. The goal of graph logic execution plan optimization is to reduce the execution cost of the graph query task as much as possible, such as reducing I / O access, reducing the amount of calculation, and optimizing the order of operations, thereby improving the performance and efficiency of the graph query.
[0119] In some embodiments, since the graph logic execution plan is independent of the graph query language implementation of the graph query statement, a pluggable execution plan optimizer can be used to implement the plan optimization of the graph logic execution plan. In the pluggable execution plan optimizer, the execution plan optimization rules can be designed and specified at will without considering the compatibility with the graph logic execution plan.
[0120] Fig.13 FIG. 1 shows an example schematic diagram of an optimized graph logic execution plan according to an embodiment of the present specification. Fig.13 In the example shown, a sub-plan of a graph logic execution plan of non-determined length can be matched, for example, Filter->ExpandAll+->AllNodesScan. After matching the above pattern, taking RBO Optimizer as an example, the graph logic execution plan can be directly adjusted according to the optimization rules, for example, n4 is prioritized as the query starting point.
[0121] The above-mentioned graph logic execution plan generation scheme is used to generate a graph logic execution plan composed of graph logic operators for the graph query statement. Since the graph logic operator is used to describe the minimum processing logic execution unit of the graph query task corresponding to the graph query statement, it is independent of the specific graph query language implementation of the graph query statement, so the same graph logic execution plan can be obtained for graph query statements implemented by different graph query statements, thereby achieving the graph query language compatibility of the graph logic execution plan generation scheme.
[0122] By utilizing the above-mentioned graph logic execution plan generation scheme, the convertible subtree structure is searched out through tree traversal and the graph logic conversion is performed immediately after the convertible subtree structure is found, so as to improve the generation efficiency of the graph logic execution plan.
[0123] By utilizing the above-mentioned graph logic execution plan generation scheme, by defining the convertible subtree structure as including the largest subtree structure that can independently complete the graph logic conversion, the subtree structure processing capacity of a graph logic conversion can be increased, thereby reducing the number of graph logic conversions, and further improving the generation efficiency of the graph logic execution plan.
[0124] By using the above-mentioned graph logic execution plan generation scheme, the abstract syntax tree is converted into a general syntax tree, and the syntax tree is converted to a graph logic execution plan based on the general syntax tree. Since the generation of the general syntax tree to the graph logic execution plan can be implemented in a unified generation method, and the conversion process from the abstract syntax tree to the general syntax tree is simple, the complexity of the graph logic execution plan generation process when facing a variety of graph query statements implemented in different graph query languages can be reduced.
[0125] Fig.14 An example flow chart of a data processing method 1400 according to an embodiment of the present specification is shown.
[0126] like Fig.14 As shown, at 1410, an abstract syntax tree of the graph query statement is generated.
[0127] At 1420, a graph logic conversion based on a graph logic operator is performed on the abstract syntax tree to obtain a graph logic execution plan of the graph query statement, and the obtained graph logic execution plan includes a graph logic operator set with a tree structure. The generation process of the graph logic execution plan can refer to the graph logic execution plan generation process described above.
[0128] At 1430 , data processing corresponding to the graph query statement is performed according to the graph logic execution plan.
[0129] For a graph database, the data processing tasks corresponding to a graph query statement may include, for example, performing operations such as "add", "delete", "modify", and "check" on the graph data stored in the graph database. Except for the "add" operation, other operations require finding the object to be operated on. Objects in a graph database may include graph data edges, graph data vertices, and paths containing graph data edges and graph data vertices.
[0130] In some embodiments, since graph query statements implemented by different graph query languages can obtain graph logic execution plans in the same form of expression, the graph logic execution plan can be considered to be a unified intermediate representation of the graph query statement, and can be used to convert between graph query statements written in different graph query languages. For example, after there are graph query statements written based on the GQL language, a graph logic execution plan can be generated using graph query statements written based on the GQL language. Subsequently, a graph query statement written based on the CYPHER (OpenCypher) language is derived based on the graph logic execution plan, thereby realizing the conversion of graph query statements between different graph query languages.
[0131] Fig.15 FIG. 1 shows an example block diagram of a graph logic execution plan generating device 1500 according to an embodiment of the present specification. Fig.15 As shown, the graph logic execution plan generating apparatus 1500 includes an abstract syntax tree generator 1510 , a syntax tree converter 1520 , a graph logic converter 1530 , and an execution plan optimizer 1540 .
[0132] The abstract syntax tree generator 1510 is configured to generate an abstract syntax tree of a graph query statement. The operation of the abstract syntax tree generator 1510 may refer to the above reference. Figure 1 The operation of 110 is described.
[0133] The syntax tree converter 1520 is configured to convert the abstract syntax tree into a general syntax tree, and the obtained general syntax tree has a unified description structure for different graph query language implementations of the same semantic graph query statement. The operation of the syntax tree converter 1520 can refer to the above reference Fig. 9 Describes the operation.
[0134] The graph logic converter 1530 is configured to perform a graph logic conversion based on a graph logic operator on the general syntax tree to generate a graph logic execution plan for the graph query statement. The generated graph logic execution plan includes a graph logic operator set having a tree structure. The operation of the graph logic converter 1530 can refer to the above reference. Figure 5-Figure 7 Describes the operation.
[0135] The execution plan optimizer 1540 is configured to optimize the graph logic execution plan.
[0136] Fig.16 FIG. 1 shows an example block diagram of a syntax tree converter 1600 according to an embodiment of the present specification. Fig.16 As shown, the syntax tree converter 1600 includes a difference tree structure determination module 1610 and a difference tree structure conversion module 1620 .
[0137] The difference tree structure determination module 1610 is configured to determine the difference subtree structure where the graph query language implementation difference exists from the abstract syntax tree. The operation of the difference tree structure determination module 1610 can refer to the above reference. Fig. 9 The operation described in 910.
[0138] The difference tree structure conversion module 1620 is configured to perform structure conversion on the difference sub-tree structure according to a structure conversion mode corresponding to a difference type of the difference sub-tree structure.
[0139] In some embodiments, the graph query language implementation differences may include semantic structure implementation differences and grammatical structure implementation differences. In response to the difference type of the difference subtree structure being a semantic structure implementation difference, the difference tree structure conversion module adds a subtree structure of other graph query language implementations specified in the standard universal syntax tree under the parent node of the difference subtree structure. In response to the difference type of the difference subtree structure being a grammatical structure implementation difference, the difference tree structure conversion module converts the difference subtree structure into a unified subtree structure specified in the standard universal syntax tree.
[0140] Fig.17 FIG. 1 shows an example block diagram of a graph logic converter 1700 according to an embodiment of the present specification. Fig.17 As shown, the graph logic converter 1700 includes a tree structure segmentation module 1710 and a graph logic conversion module 1720 .
[0141] The tree structure segmentation module 1710 is configured to segment the abstract syntax tree into a plurality of convertible subtree structures according to the node structure and node semantics of the abstract syntax tree. The segmented convertible subtree structures include subtree structures that can independently complete graph logic transformation and have a graph logic transformation mode. The graph logic transformation mode includes graph logic operator transformation and graph logic operator execution order relation transformation. The operation of the tree structure segmentation module 1710 can be referred to Figure 5 The operation described in 510.
[0142] The graph logic conversion module 1720 is configured to perform graph logic conversion on the convertible subtree structure according to the graph logic conversion method of the convertible subtree structure. The operation of the graph logic conversion module 1720 can refer to the above reference Figure 5 The operation of 520 is described.
[0143] In some embodiments, the tree structure segmentation module 1710 can search for multiple convertible subtree structures from the abstract syntax tree in a tree traversal manner according to the node structure and node semantics of the abstract syntax tree. In some embodiments, once the tree structure segmentation module searches for a convertible subtree structure, the graph logic conversion module 1720 performs a graph logic conversion on the searched convertible subtree structure.
[0144] It should be noted that, in some embodiments, the graph logic execution plan generating apparatus 1500 may also not include the syntax tree converter 1520 and / or the execution plan optimizer 1540. In the case where the syntax tree converter 1520 is not included, the graph logic converter 1530 performs a graph logic conversion based on a graph logic operator on the abstract syntax tree to generate a graph logic execution plan for the graph query statement.
[0145] Fig.18 FIG. 1 shows an exemplary block diagram of a data processing device 1800 according to an embodiment of the present specification. Fig.18 As shown, the data processing device 1800 includes an abstract syntax tree generator 1810 , a graph logic converter 1820 , and a plan executor 1830 .
[0146] The abstract syntax tree generator 1810 is configured to generate an abstract syntax tree of a graph query statement.
[0147] The graph logic converter 1820 is configured to perform graph logic conversion based on graph logic operators on the abstract syntax tree to obtain a graph logic execution plan for the graph query statement. The obtained graph logic execution plan includes a set of graph logic operators organized into a tree structure.
[0148] The plan executor 1830 is configured to execute data processing corresponding to the graph query statement according to the graph logic execution plan.
[0149] As above Figures 1 to 18 , a graph logic execution plan generation method, a graph logic execution plan generation device, a data processing method and a data processing device according to an embodiment of this specification are described. The above-mentioned graph logic execution plan generation device and data processing device can be implemented by hardware, or by software or a combination of hardware and software.
[0150] Fig.19 FIG. 1 shows an example schematic diagram of a graph logic execution plan generating device 1900 implemented based on a computer system according to an embodiment of the present specification. Fig.19 As shown, the graph logic execution plan generating apparatus 1900 may include at least one processor 1910, a memory (e.g., a non-volatile memory) 1920, a memory 1930, and a communication interface 1940, and the at least one processor 1910, the memory 1920, the memory 1930, and the communication interface 1940 are connected together via a bus 1960. At least one processor 1910 executes at least one computer-readable instruction stored or encoded in the memory (i.e., the above-mentioned element implemented in the form of software).
[0151] In one embodiment, computer executable instructions are stored in a memory, which, when executed, cause at least one processor 1910 to: generate an abstract syntax tree for a graph query statement; and perform a graph logic transformation based on graph logic operators on the abstract syntax tree to obtain a graph logic execution plan for the graph query statement, wherein the graph logic execution plan includes a set of graph logic operators organized into a tree structure.
[0152] It should be understood that the computer executable instructions stored in the memory, when executed, cause at least one processor 1910 to perform the above combined operations in various embodiments of the present specification. Figure 1-Figure 13 and Figure 15-17 Describes the various operations and functions.
[0153] Fig. 20 FIG. 2 shows an example schematic diagram of a data processing device 2000 implemented based on a computer system according to an embodiment of the present specification. Fig. 20 As shown, the data processing device 2000 may include at least one processor 2010, a memory (e.g., a non-volatile memory) 2020, a memory 2030, and a communication interface 2040, and the at least one processor 2010, the memory 2020, the memory 2030, and the communication interface 2040 are connected together via a bus 2060. At least one processor 2010 executes at least one computer-readable instruction stored or encoded in the memory (i.e., the above-mentioned element implemented in the form of software).
[0154] In one embodiment, computer executable instructions are stored in a memory, which, when executed, cause at least one processor 2010 to: generate an abstract syntax tree for a graph query statement; perform a graph logic transformation based on graph logic operators on the abstract syntax tree to obtain a graph logic execution plan for the graph query statement, the graph logic execution plan comprising a set of graph logic operators having a tree structure; and perform data processing corresponding to the graph query statement according to the graph logic execution plan.
[0155] It should be understood that the computer executable instructions stored in the memory, when executed, cause at least one processor 2010 to perform the above combined operations in various embodiments of the present specification. Fig.14 and Fig.18 Describes the various operations and functions.
[0156] According to one embodiment, a program product such as a machine-readable medium (e.g., a non-transitory machine-readable medium) is provided. The machine-readable medium may have instructions (i.e., the above-mentioned elements implemented in the form of software), which, when executed by a machine, causes the machine to perform the above-mentioned combination of various embodiments of this specification. Figure 1-Figure 18 Specifically, a system or device equipped with a readable storage medium may be provided, on which a software program code implementing the functions of any of the above-mentioned embodiments is stored, and a computer or processor of the system or device reads and executes the instructions stored in the readable storage medium.
[0157] In this case, the program code itself read from the machine-readable medium can realize the function of any one of the above-mentioned embodiments, and thus the machine-readable code and the machine-readable storage medium storing the machine-readable code constitute a part of the present invention.
[0158] Examples of readable storage media include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD-RW), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, the program code may be downloaded from a server computer or a cloud via a communication network.
[0159] According to one embodiment, a computer program product is provided. The computer program product includes a computer program. When the computer program is executed by a processor, the processor performs the above combination of the various embodiments of this specification. Figure 1-Figure 18 Describes the various operations and functions.
[0160] Those skilled in the art should understand that the various embodiments disclosed above can be modified and altered in various ways without departing from the essence of the invention. Therefore, the protection scope of the present invention should be defined by the appended claims.
[0161] It should be noted that not all steps and units in the above-mentioned processes and system structure diagrams are necessary, and some steps or units can be ignored according to actual needs. The execution order of each step is not fixed and can be determined as needed. The device structure described in the above-mentioned embodiments can be a physical structure or a logical structure, that is, some units may be implemented by the same physical entity, or some units may be implemented by multiple physical entities, or some components in multiple independent devices may be implemented together.
[0162] In the above embodiments, the hardware unit or module can be realized by mechanical or electrical means. For example, a hardware unit, module or processor can include permanent dedicated circuit or logic (such as special processor, FPGA or ASIC) to complete the corresponding operation. The hardware unit or processor can also include programmable logic or circuit (such as general-purpose processor or other programmable processor), which can be temporarily set by software to complete the corresponding operation. Specific implementation (mechanical method or dedicated permanent circuit or temporary circuit) can be determined based on cost and time consideration.
[0163] The specific embodiments described above in conjunction with the accompanying drawings describe exemplary embodiments, but do not represent all embodiments that can be implemented or fall within the scope of protection of the claims. The term "exemplary" used throughout this specification means "used as an example, instance, or illustration" and does not mean "preferred" or "having advantages" over other embodiments. For the purpose of providing an understanding of the described technology, the specific embodiments include specific details. However, these technologies can be implemented without these specific details. In some instances, in order to avoid obscuring the concepts of the described embodiments, well-known structures and devices are shown in block diagram form.
[0164] The above description of the present disclosure is provided to enable any person of ordinary skill in the art to implement or use the present disclosure. Various modifications to the present disclosure will be apparent to those of ordinary skill in the art, and the general principles defined herein may be applied to other variations without departing from the scope of protection of the present disclosure. Therefore, the present disclosure is not limited to the examples and designs described herein, but is consistent with the widest range of principles and novel features disclosed herein.< / expr> < / expr> < / expr> < / string> < / expr> < / expr>
Claims
1. A method for generating a graph logic execution plan for a graph query statement, comprising: Generate an abstract syntax tree for graph query statements; as well as Performing a graph logic conversion based on a graph logic operator on the abstract syntax tree to obtain a graph logic execution plan of the graph query statement, wherein the graph logic execution plan includes a set of graph logic operators organized into a tree structure, and the graph logic operator is a minimum execution unit for describing a graph query task. The step of performing a graph logic conversion based on a graph logic operator on the abstract syntax tree to obtain a graph logic execution plan of the graph query statement includes: According to the node structure and node semantics of the abstract syntax tree, the abstract syntax tree is divided into a plurality of convertible subtree structures, wherein the convertible subtree structures include subtree structures that can independently complete graph logic conversion and have graph logic conversion modes, wherein the graph logic conversion modes include graph logic operator conversion and graph logic operator execution order relation conversion; and Performing a graph logic conversion on the convertible subtree structure according to a graph logic conversion method of the convertible subtree structure to obtain a graph logic execution plan of the graph query statement, Among them, the graph logic operator conversion is used to indicate the conversion of the convertible subtree structure into a graph logic operator or a combination of graph logic operators connected in sequence according to the execution order, and the graph logic operator execution order relationship conversion is used to indicate the conversion of the convertible subtree structure into the execution order relationship between the graph logic operators in the subtree structure that has been previously converted.
2. The method of claim 1, wherein: According to the node structure and node semantics of the abstract syntax tree, dividing the abstract syntax tree into a plurality of convertible subtree structures comprises: In a tree traversal manner, the multiple convertible subtree structures are searched out from the abstract syntax tree according to the node structure and node semantics of the abstract syntax tree.
3. The method of claim 2, wherein: Once the convertible subtree structure is searched out, the graph logic conversion of the searched convertible subtree structure is performed.
4. The method of claim 1, wherein: The convertible subtree structure includes a maximum subtree structure that can independently complete graph logic conversion.
5. The method of claim 1, further comprising: Converting the abstract syntax tree into a universal syntax tree, wherein the universal syntax tree has a unified description structure for different graph query language implementations of graph query statements with the same semantics, Performing a graph logic conversion based on a graph logic operator on the abstract syntax tree to generate a graph logic execution plan for the graph query statement includes: The universal syntax tree is subjected to a graph logic transformation based on a graph logic operator to generate a graph logic execution plan for the graph query statement.
6. The method of claim 5, wherein: Converting the abstract syntax tree into a general syntax tree comprises: Determining from the abstract syntax tree a difference subtree structure where there are differences in graph query language implementations; and The difference subtree structure is structurally transformed according to the structural transformation mode corresponding to the difference type of the difference subtree structure.
7. The method of claim 6, wherein: The graph query statement implementation differences include semantic structure implementation differences and grammatical structure implementation differences. According to the conversion mode corresponding to the difference type of the difference subtree structure, the structural conversion of the difference subtree structure includes: In response to the difference type of the difference subtree structure being a semantic structure implementation difference, adding a subtree structure implemented by other graph query languages specified in a standard universal syntax tree under a parent node of the difference subtree structure; In response to the difference type of the difference subtree structure being a syntax structure implementation difference, the difference subtree structure is converted into a unified subtree structure specified in the standard universal syntax tree.
8. The method of claim 1, further comprising: Optimize the generated graph logic execution plan.
9. The method of claim 8, wherein: Plan optimization for the graph logic execution plan is implemented via a pluggable execution plan optimizer.
10. A data processing method, comprising: Generate an abstract syntax tree for graph query statements; Performing a graph logic conversion based on a graph logic operator on the abstract syntax tree to obtain a graph logic execution plan of the graph query statement, wherein the graph logic execution plan includes a set of graph logic operators organized into a tree structure, and the graph logic operator is a minimum execution unit for describing a graph query task; as well as Execute data processing corresponding to the graph query statement according to the graph logic execution plan, The step of performing a graph logic conversion based on a graph logic operator on the abstract syntax tree to obtain a graph logic execution plan of the graph query statement includes: According to the node structure and node semantics of the abstract syntax tree, the abstract syntax tree is divided into a plurality of convertible subtree structures, wherein the convertible subtree structures include subtree structures that can independently complete graph logic conversion and have graph logic conversion modes, wherein the graph logic conversion modes include graph logic operator conversion and graph logic operator execution order relation conversion; and Performing a graph logic conversion on the convertible subtree structure according to a graph logic conversion method of the convertible subtree structure to obtain a graph logic execution plan of the graph query statement, Among them, the graph logic operator conversion is used to indicate the conversion of the convertible subtree structure into a graph logic operator or a combination of graph logic operators connected in sequence according to the execution order, and the graph logic operator execution order relationship conversion is used to indicate the conversion of the convertible subtree structure into the execution order relationship between the graph logic operators in the subtree structure that has been previously converted.
11. A device for generating a graph logic execution plan for a graph query statement, comprising: Abstract syntax tree generator, which generates the abstract syntax tree of graph query statements; as well as A graph logic converter performs a graph logic conversion based on a graph logic operator on the abstract syntax tree to generate a graph logic execution plan for the graph query statement, wherein the graph logic execution plan includes a set of graph logic operators organized into a tree structure, and the graph logic operator is a minimum execution unit for describing a graph query task. Wherein, the graph logic converter comprises: a tree structure segmentation module, which segments the abstract syntax tree into a plurality of convertible subtree structures according to the node structure and node semantics of the abstract syntax tree, wherein the convertible subtree structures include subtree structures that can independently complete graph logic conversion and have graph logic conversion modes, wherein the graph logic conversion modes include graph logic operator conversion and graph logic operator execution order relation conversion; and A graph logic conversion module performs graph logic conversion on the convertible subtree structure according to the graph logic conversion method of the convertible subtree structure. Among them, the graph logic operator conversion is used to indicate the conversion of the convertible subtree structure into a graph logic operator or a combination of graph logic operators connected in sequence according to the execution order, and the graph logic operator execution order relationship conversion is used to indicate the conversion of the convertible subtree structure into the execution order relationship between the graph logic operators in the subtree structure that has been previously converted.
12. The device of claim 11, wherein: The tree structure segmentation module searches for the multiple convertible subtree structures from the abstract syntax tree in a tree traversal manner according to the node structure and node semantics of the abstract syntax tree.
13. The apparatus of claim 11, further comprising: A syntax tree converter converts the abstract syntax tree into a general syntax tree, wherein the general syntax tree has a unified description structure for different graph query language implementations of graph query statements with the same semantics, The graph logic converter performs graph logic conversion based on graph logic operators on the general syntax tree to generate a graph logic execution plan for the graph query statement.
14. The device of claim 13, wherein: The syntax tree converter comprises: a difference tree structure determination module, which determines, from the abstract syntax tree, a difference subtree structure in which a graph query language implementation difference exists; and The difference tree structure conversion module performs structure conversion on the difference subtree structure according to a structure conversion mode corresponding to a difference type of the difference subtree structure.
15. The device of claim 14, wherein: The graph query statement implementation differences include semantic structure implementation differences and grammatical structure implementation differences. In response to the difference type of the difference subtree structure being a semantic structure implementation difference, the difference tree structure conversion module adds a subtree structure implemented by other graph query languages specified in a standard universal syntax tree under a parent node of the difference subtree structure; In response to the difference type of the difference subtree structure being a syntax structure implementation difference, the difference tree structure conversion module converts the difference subtree structure into a unified subtree structure specified in the standard universal syntax tree.
16. A data processing device, comprising: Abstract syntax tree generator, which generates the abstract syntax tree of graph query statements; A graph logic converter performs a graph logic conversion based on a graph logic operator on the abstract syntax tree to obtain a graph logic execution plan of the graph query statement, wherein the graph logic execution plan includes a set of graph logic operators organized into a tree structure, and the graph logic operator is a minimum execution unit for describing a graph query task; as well as A plan executor executes data processing corresponding to the graph query statement according to the graph logic execution plan, Wherein, the graph logic converter comprises: a tree structure segmentation module, which segments the abstract syntax tree into a plurality of convertible subtree structures according to the node structure and node semantics of the abstract syntax tree, wherein the convertible subtree structures include subtree structures that can independently complete graph logic conversion and have graph logic conversion modes, wherein the graph logic conversion modes include graph logic operator conversion and graph logic operator execution order relation conversion; and A graph logic conversion module performs graph logic conversion on the convertible subtree structure according to the graph logic conversion method of the convertible subtree structure. Among them, the graph logic operator conversion is used to indicate the conversion of the convertible subtree structure into a graph logic operator or a combination of graph logic operators connected in sequence according to the execution order, and the graph logic operator execution order relationship conversion is used to indicate the conversion of the convertible subtree structure into the execution order relationship between the graph logic operators in the subtree structure that has been previously converted.
17. A device for generating a graph logic execution plan for a graph query statement, comprising: at least one processor; a memory coupled to the at least one processor; as well as A computer program stored in the memory, wherein the at least one processor executes the computer program to implement the method for generating a graph logic execution plan for a graph query statement as described in any one of claims 1 to 9.
18. A data processing device, comprising: at least one processor; a memory coupled to the at least one processor; as well as The computer program stored in the memory, and the at least one processor executes the computer program to implement the data processing method according to claim 10.
Citation Information
Patent Citations
Mixed query processing method and device based on big data
CN111221852A
Graph database execution plan generation and scheduling method and system, device and medium
CN113918160A
Analyzing method of abstract syntax tree and computer program product
CN114443041A
Data processing method and device, readable storage medium and electronic equipment
CN115982416A
Data analysis method and device, computer equipment and storage medium
CN116795859A
