A data processing method, device, readable storage medium and electronic equipment
By performing semantic analysis on the filtering conditions of the objects to be queried in the query statement of the graph database, target nodes and child nodes are generated, which solves the problem of the lack of a unified query language in graph databases and realizes efficient cross-language data processing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
- Filing Date
- 2023-01-29
- Publication Date
- 2026-04-21
AI Technical Summary
The lack of a unified query language standard in existing technologies leads to inefficiency and inaccurate results when graph databases process different types of query statements.
By performing semantic analysis on the filtering conditions of the objects to be queried in the query statement, target nodes and child nodes are generated, and database operations are determined based on these nodes to execute the query task in order to improve processing efficiency.
Even when receiving queries of different languages, the database operation can still be accurately determined, improving data processing efficiency and result accuracy.
Smart Images

Figure CN115982416B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of computer technology, and in particular to a data processing method, apparatus, readable storage medium, and electronic device. Background Technology
[0002] Currently, with the development of Internet technology and people's increasing attention to their own privacy data, graph databases are being used more and more in people's lives. However, there is still no unified query language standard when processing data in graph databases.
[0003] Based on this, this specification provides a data processing method. Summary of the Invention
[0004] This specification provides a data processing method, apparatus, readable storage medium, and electronic device to partially solve the aforementioned problems existing in the prior art.
[0005] The following technical solution is adopted in this specification:
[0006] This specification provides a data processing method applied to a graph database, comprising:
[0007] Based on the received query statement, determine each query object in the query statement and the filtering conditions for each query object, wherein the query object includes at least one of graph data vertices and graph data edges in the graph database;
[0008] For each object to be queried, a target node corresponding to the object to be queried is generated, and semantic analysis is performed on the filtering conditions of the object to be queried to determine the semantic query conditions. Then, the child nodes of the target node are determined according to the determined semantic query conditions.
[0009] Based on the child nodes of each target node, determine the database operations that the graph database needs to perform corresponding to each target node;
[0010] Based on the database operations, execute the data processing task corresponding to the query statement, and return the execution result according to the query statement.
[0011] This specification provides a data processing apparatus for use in graph databases, including:
[0012] The semantic determination module is used to determine each query object and the filtering conditions of each query object in the received query statement, wherein the query object includes at least one of graph data vertices and graph data edges in the graph database.
[0013] The node determination module is used to generate a target node corresponding to each query object, perform semantic analysis on the filtering conditions of the query object to determine the semantic query conditions, and determine the child nodes of the target node according to the determined semantic query conditions.
[0014] The operation determination module is used to determine, based on the child nodes of each target node, the database operations that the graph database needs to perform corresponding to each target node.
[0015] The processing module is used to execute the data processing task corresponding to the query statement according to the database operations, and return the execution result according to the query statement.
[0016] This specification provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described data processing method.
[0017] This specification provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the above-described data processing method.
[0018] The above-mentioned technical solutions adopted in this specification can achieve the following beneficial effects:
[0019] Upon receiving a query statement, the system identifies the objects to be queried contained within the query statement and determines the corresponding filtering conditions for each object. Semantic analysis is then performed on these filtering conditions to determine semantic query conditions. This generates the target nodes and child nodes corresponding to each object. Based on these target nodes and their child nodes, the system determines the database operations to be performed by the graph database. Finally, the system executes the data processing task corresponding to the query statement based on the determined database operations and returns the execution results.
[0020] This method extracts the filtering conditions for each queried object from the query statement and performs semantic analysis on these conditions to determine semantic query conditions that can accommodate the semantics of multiple query statements, thereby accurately determining the database operation. Even when receiving query statements corresponding to different types of query languages, it can determine the execution result for each query statement, improving data processing efficiency. Attached Figure Description
[0021] The accompanying drawings, which are included to provide a further understanding of this specification and form part of this specification, illustrate exemplary embodiments and their descriptions, serving to explain this specification and do not constitute an undue limitation thereof.
[0022] In the picture:
[0023] Figure 1 A flowchart illustrating the data processing method provided in this specification;
[0024] Figure 2 This is a structural diagram of the target node and its corresponding child nodes provided in this specification;
[0025] Figure 3 This is a schematic diagram of the semantic tree framework provided in this specification;
[0026] Figure 4 A flowchart illustrating the data processing method provided in this specification;
[0027] Figure 5 This is a schematic diagram of the data processing device provided in this specification;
[0028] Figure 6 The corresponding information provided in this specification Figure 1 A schematic diagram of an electronic device. Detailed Implementation
[0029] To make the objectives, technical solutions, and advantages of this specification clearer, the technical solutions of this specification will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this specification, and not all of them. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this specification.
[0030] The technical solutions provided in the various embodiments of this specification are described in detail below with reference to the accompanying drawings.
[0031] In recent years, with the gradual maturation of graph computing technology and the development of internet technology, graph databases have been increasingly applied in various fields of people's lives, such as finance, healthcare, and security. Graph databases are a type of non-relational graph database. Compared to relational databases, graph databases differ significantly in data storage, querying, and data structure because they require query statements to access data within the graph database.
[0032] Because graph databases are a relatively recent development, there is currently no unified standard query language for querying data within them. In other words, there is no universal query language for querying data in graph databases. This has led to a wide variety of query languages being used. To ensure query efficiency and accuracy for each type of query language, the graph database is typically modified based on the syntax characteristics of that query language. This allows the graph database to execute and obtain accurate results when it receives a query of that type.
[0033] However, there are differences between various types of query languages. While their corresponding syntaxes share some commonalities, they also have differences. This means that the graph database modified based on the aforementioned syntax features cannot support data processing for other types of query statements, or the results obtained when querying data based on other types of query statements are not accurate enough.
[0034] Therefore, there is an urgent need for a data processing method that can process any type of query statement received and obtain accurate results. Based on this, this specification provides a new data processing method.
[0035] Figure 1 This is a flowchart illustrating the data processing method provided in this specification, which specifically includes the following steps:
[0036] S100: Based on the received query statement, determine each object to be queried in the query statement and the filtering conditions for each object to be queried, wherein the object to be queried includes at least one of graph data vertices and graph data edges in the graph database.
[0037] When querying a graph database based on a query statement, the following situation may occur: the type of query statement supported by the graph database is designated as the specified type. Upon receiving a query statement, the database determines the corresponding query language type. Then, it determines the conversion rules between query statements of the specified query language type and query statements of the designated type. Based on these rules, the database translates the received query statement into a query statement of the designated type. Finally, the translation result is processed to obtain the processing result, which serves as the processing result of the received query statement.
[0038] However, similarly, based on the aforementioned content, there are commonalities and differences between the syntaxes corresponding to different types of query languages. This leads to a certain loss of descriptive information when a query statement of one query language type is translated into another query language type, resulting in lower accuracy of the execution results when data is processed based on the translated query statement.
[0039] In contrast to the above, this specification provides a new data processing method: after receiving a query statement, the method determines the objects to be queried contained in the query statement, determines the filtering conditions corresponding to each object to be queried based on the query statement, performs semantic analysis on the filtering conditions to determine semantic query conditions, thereby generating target nodes and child nodes corresponding to each object to be queried, and determines the database operations to be performed by the graph database based on each target node and its child nodes. Finally, the method executes the data processing task corresponding to the query statement according to the determined database operations and returns the execution results.
[0040] This solution extracts the filtering conditions for each queried object from the query statement and performs semantic analysis on these conditions to determine semantic query conditions that can accommodate the semantics of multiple query statements. This allows for the precise determination of the database operations to be performed on each query. Even when receiving query statements corresponding to different types of query languages, the solution can determine the execution result for each query statement, thus improving data processing efficiency.
[0041] Based on the brief description of the data processing method provided in this specification, this method can be applied in graph databases, where the graph database queries and processes its stored data based on received query statements. It can also be applied in servers, where the server determines the corresponding database operation based on the received query statement, sends the semantic tree to the graph database, executes the determined database operation, and returns the execution result to the server. For ease of description, the following explanation uses a graph database as an example to illustrate the data processing method provided in this specification.
[0042] Specifically, this graph database can receive query statements sent by other devices. These other devices can be electronic devices such as servers, terminals, and smart devices. The type of electronic device corresponding to the sender of the query statement can be configured as needed; this specification does not impose any restrictions on this.
[0043] For any database, executing a query statement involves performing operations such as "create," "delete," "update," and "query" on the data stored in the database. Except for the "create" operation, all other operations require locating the object to be manipulated. For the "create" operation, if a new object needs to be added, the location allocated to the object needs to be found; if a specific attribute of an object needs to be added, the object itself needs to be located. Therefore, query statements often include the object to be queried and the filtering conditions for that object.
[0044] In this context, objects can be data stored in a database. Taking a key-value database as an example, objects in a key-value database can be keys, values, or key-value pairs themselves. In a graph database, objects can be graph edges, graph vertices, paths containing graph edges and vertices, etc.
[0045] Therefore, upon receiving a query statement, the graph database can determine the query objects and their corresponding filter conditions based on the preset query objects and the query statement itself. This allows subsequent steps to be executed based on the determined query objects and their respective filter conditions.
[0046] Of course, the graph database can also predefine that the objects to be queried can only contain the starting point of the graph data or the edge of the graph data. The specific objects to be queried that can be included in the query statement can be set as needed, and this manual does not impose any restrictions on this.
[0047] Taking the graph query statement Match(n:Object{name:"oc"}) as an example, match() means search, n represents vertex data, and Object is the type. Therefore, the graph database can determine the query object corresponding to the above graph query statement as a graph data vertex based on the preset type of the query object and the query statement. Furthermore, the execution operation corresponding to this query statement is "search," and the filtering condition for this graph data vertex can be "Object{name:"oc"}". S102: For each query object, generate the target node corresponding to that query object, perform semantic analysis on the filtering conditions of the query object to determine the semantic query conditions, and determine the child nodes of the target node based on each determined semantic query condition.
[0048] In one or more embodiments provided in this specification, as described above, the core idea of the data processing method provided in this specification is as follows: after determining the filtering conditions corresponding to each query object, semantic analysis is performed on each filtering condition to obtain semantic query conditions that can be used to represent the semantics corresponding to various query language types. Subsequently, data processing tasks corresponding to the query statement can be executed based on these semantic query conditions, ensuring data processing efficiency.
[0049] For a given query object, there are often multiple filtering conditions. If the query object is described directly using the filtering conditions, it may not be able to properly represent the query object. If the query object is described directly using semantic query conditions, then when determining the corresponding database operation based on the semantic filtering conditions, it may be necessary to perform syntax conversion or to first break down the semantic filtering conditions before the database operation for the query object can be determined.
[0050] Based on this, the graph database can generate a target node corresponding to each queried object. This target node can be used solely to represent the queried object.
[0051] Then, the graph database can perform semantic analysis on the filtering conditions of the object to be queried to obtain semantic query conditions.
[0052] Taking the graph query `Match(n:Object{name:"oc"})` as an example, `match()` indicates a search, `n` represents the vertex data, and `Object` is the type. Assuming the filter condition for the graph data vertices is "Object{name:"oc"}", semantic analysis of this filter condition can be performed to determine the semantics of the query: searching for graph data vertices with the name "oc" and type "Object". Therefore, the semantic filter condition for the graph data vertices is: name "oc", type "Object".
[0053] Finally, the graph database can determine the child nodes of the target node based on the determined semantic query conditions. That is, each semantic query condition is represented as a child node of the target node. Based on the determined child nodes, the queried object can be accurately represented. When determining the database operations to be performed on the graph data based on the child nodes, since each child node corresponds to a type of filtering condition, the graph database does not need to further split the semantic query conditions. For example... Figure 2 As shown.
[0054] Figure 2 This diagram illustrates the structure of the target node and its corresponding child nodes provided in this specification. Taking the graph query statement `Match(n:Object{name:"oc"})` as an example, the diagram identifies the query object as a graph data vertex. The semantic filtering condition for this graph data vertex is: name "oc", type "Object". Then, based on this semantic filtering condition, the child nodes of the target node corresponding to the graph data vertex are determined.
[0055] It should be noted that the above filtering conditions, semantic query conditions, and... Figure 2The structure described is merely illustrative; the filtering conditions can also be represented in a tree structure, the semantic query conditions can also be represented in the form of an expression, and the structure between the target node and its child nodes can also be in the form of a binary tree, ternary tree, or multi-way tree. The specific forms of the filtering conditions and semantic query conditions, as well as the structure between the target node and its child nodes, can be set as needed, and this specification does not impose any limitations on them.
[0056] S104: Based on the child nodes of each target node, determine the database operations that the graph database needs to perform corresponding to each target node.
[0057] In one or more embodiments provided in this specification, typically, a graph database can determine the database operation corresponding to a query statement based on the query statement, and then execute the determined graph database operation to complete the data processing task corresponding to the query statement. Based on this, the graph database can determine the database operation.
[0058] Specifically, a graph database is a database that uses a graphical model for querying, identifying and storing data through nodes, edges, and attributes. The graph vertices in this specification are the nodes in the graph database. Taking as an example the nodes in the graph database being discrete ID types such as products, users, product owners, and product attributes, this specification allows querying of these types of nodes. In other words, the graph database can pre-store graph vertices and their corresponding attribute information. Following the same logic, the graph database can also currently store graph edges and their corresponding attribute information.
[0059] Therefore, the graph database can determine the type of each query object based on the target node of that query object.
[0060] Then, based on the child nodes of the target node and the type of the object to be queried, the graph database can determine the database operations to be performed when querying the object. The graph database can then execute the determined database operations.
[0061] Taking a graph data vertex as an example, the graph database can determine that the type of the object to be queried is a graph data vertex based on the target node corresponding to the object. The database can then determine how to query the object from the pre-stored graph data vertices and their attribute information. Assuming the semantic filtering conditions for the child nodes of the target node are: name "oc" and type "Object", the database can determine the corresponding database operation as follows: from the pre-stored graph data vertices and their attribute information, query the graph data vertices named "oc" according to their node names; then, from the graph data vertices named "oc", query according to their type to find graph data vertices of type "Object" with the name "oc".
[0062] Of course, the above database operation can also take the form of n→name→oc→type→Object, where n represents the type of the object to be queried as a graph data vertex, name represents searching by name, oc represents the name of the object to be queried, type represents searching by type, and Object represents the type of the object to be queried. Therefore, the above expression can be used to characterize each database operation corresponding to the object to be queried.
[0063] It should be noted that the order of operations performed by the graph database described above is for illustrative purposes only. The specific execution order of each operation can be set as needed, and this manual does not impose any restrictions on it.
[0064] S106: Execute the data processing task corresponding to the query statement according to the database operations, and return the execution result according to the query statement.
[0065] In one or more embodiments provided in this specification, after determining the database operation, the graph database can execute each database operation to perform the data processing task corresponding to the query statement.
[0066] Specifically, the graph database can directly execute the database operations determined in step S104 to determine the object to be queried.
[0067] Then, since the query statements corresponding to "add," "delete," and "update" operations, in addition to the "query" operation, also require data processing during execution, the graph database also needs to determine the database operations for processing each queried object based on the processing method corresponding to each queried object in the query statement, and process each queried object according to the determined database operations.
[0068] Furthermore, since query statements corresponding to "create," "delete," and "update" operations, in addition to "query," will more or less modify the data in the graph database during execution, the graph database can also update the data based on the processing results after the data processing is complete.
[0069] Finally, after the data processing task is completed, the graph database can determine the execution result and return the result according to each query statement to complete the execution process corresponding to the query statement.
[0070] Of course, the process of determining and executing the database operations for each queried object based on the query statement in the above-mentioned graph database can also be executed in step S104. That is, after determining the database operations required for each queried object, the database operations for each queried object are determined according to the query statement, and the database operations corresponding to each queried object are updated to determine the database operations that include not only the query process but also the processing process. How and when these database operations are determined can be set as needed, and this specification does not impose any restrictions on this.
[0071] based on Figure 1 The data processing method shown involves, upon receiving a query statement, determining the objects to be queried contained in the query statement, determining the filtering conditions corresponding to each object to be queried based on the query statement, performing semantic analysis on the filtering conditions to determine semantic query conditions, thereby generating target nodes and child nodes corresponding to each object to be queried, and determining the database operations to be performed on the graph database based on each target node and its child nodes. Finally, the data processing task corresponding to the query statement is executed according to the determined database operations, and the execution result is returned.
[0072] This method extracts the filtering conditions for each queried object from the query statement and performs semantic analysis on these conditions to determine semantic query conditions that can accommodate the semantics of multiple query statements. This allows for the accurate determination of the database operation corresponding to the query statement. Even when receiving query statements corresponding to different types of query languages, the method can determine the execution result for each query statement, thus improving data processing efficiency.
[0073] Furthermore, the graph database in this specification needs to execute query statements corresponding to various types of query languages. In other words, the graph database accommodates various types of query languages. Since the syntax of different query languages differs, the graph database needs to perform semantic analysis on the filtering conditions. The basis of this semantic analysis is that the graph database can determine each query object and its filtering conditions. When the query language syntax differs, the graph database needs to determine the query object based on the syntax type of the received query statement. Therefore, in step S100, the graph database needs to determine the syntax information corresponding to the query statement.
[0074] Specifically, this graph database can receive query statements and determine the corresponding query language type. Taking the query statements Match(n:Object{name:"oc"}) and Match(n:Object where n.name="oc") as examples, the graph database can receive these query statements and determine that the query language corresponding to Match(n:Object{name:"oc"}) is OpenCypher query language, and the query language corresponding to Match(n:Object where n.name="oc") is Gremlin query language. Both OpenCypher and Gremlin query languages are types of graph query languages.
[0075] Secondly, the graph database can determine the syntax information corresponding to the query statement based on the query language type. This syntax information can be the sentence structure corresponding to the "add," "delete," "modify," and "query" operations in the query statement, or how information such as name and type is represented, or how the type of the object to be queried is represented as predefined. The specific content of the syntax information can be set as needed, and this manual does not impose any restrictions on it.
[0076] Taking the query statement Match(n:Object{name:"oc"}) as an example, the graph database can determine the syntax information corresponding to the OpenCypher query language, which is used as the syntax information for the query statement Match(n:Object{name:"oc"}).
[0077] Then, the graph database can determine the objects to be queried in the query statement and the descriptive information for each object to be queried based on the determined syntax information.
[0078] Taking the query statement Match(n:Object{name:"oc"}) as an example, the graph database can determine from the syntax information of the query statement that the object to be queried is n, which represents the point data; that is, the object to be queried is a vertex of the graph data. Simultaneously, the graph database can determine the description information of the object to be queried as Object{name:"oc"}.
[0079] Finally, for each query object, the graph database can determine the filtering conditions based on its description. Specifically, the graph database can directly use the description as the filtering condition, or it can analyze the determined description and use the analysis result as the filtering condition. For example, it can determine the abstract syntax tree (AST) of the query object based on its description, and then use the determined AST as the filtering condition.
[0080] Furthermore, since the object to be queried may contain at least one of graph data vertices and graph data edges, and the filtering conditions for graph data vertices and graph data edges in the query statement often differ, the graph database can perform semantic analysis on graph data starting points and graph data edges separately in step S102.
[0081] Specifically, when querying graph data vertices, the corresponding filter conditions typically include three categories: name, type, and description. The name is the name of the graph data vertex, the type is the type of the graph data vertex, and the description is the specific description of the graph data vertex contained in the query object. For example, the name of the graph data vertex is A, the type of the graph data vertex is object, and the description of the graph data vertex is a string with a length greater than 2, etc. Of course, the specific types and number of filter conditions corresponding to the graph data vertex can be set as needed, and this manual does not impose any restrictions on this.
[0082] Therefore, when it is determined that the object to be queried contains graph data vertices, the graph database can determine the name, type, and description of the object to be queried based on the semantic query conditions of the graph data vertices. Then, the graph database can determine the name node, type node, and description node based on the name, type, and description of the object to be queried, and use the determined name node, type node, and description node as child nodes of the target node of the object to be queried.
[0083] Of course, since the type and number of filtering conditions included in the query statement are determined by the device sending the query statement, the query statement can determine at least one semantic query condition and at least one child node when determining the semantic query conditions of graph data vertices and determining the child nodes of the target node based on the semantic query conditions. The specific number of semantic query conditions and child nodes can be set as needed, and this specification does not impose any restrictions on this.
[0084] It should be noted that the above graph data vertices include at least one of the graph data start point and the graph data end point.
[0085] Generally, when querying graph edges, the corresponding filter conditions typically include four categories: name, type, direction, and description. The name refers to the edge's name, the type to its type, the direction to its direction, and the description to the specific details of the edge within the query object. For example, the edge's name might be "B," its type "object," and its direction "left to right," with the description condition "carrying the C identifier," etc. Of course, the specific types and number of filter conditions for each edge can be set as needed; this manual does not impose any restrictions on this.
[0086] Therefore, when it is determined that the object to be queried contains graph data edges, the graph database can determine the name, type, direction, and description of the object to be queried based on the semantic query conditions of the graph data edges. Then, based on the name, type, direction, and description of the object to be queried, the graph database can determine the name node, type node, direction node, and description node, and use the determined name node, type node, direction node, and description node as child nodes of the target node of the object to be queried.
[0087] Similarly, since the type and number of filtering conditions included in the query statement are determined by the device sending the query statement, the query statement can determine at least one semantic query condition and at least one child node when determining the semantic query conditions of graph data edges and determining the child nodes of the target node based on the semantic query conditions. The specific number of semantic query conditions and child nodes can be set as needed, and this specification does not impose any restrictions on this.
[0088] Furthermore, since a database can process multiple queries simultaneously, to avoid the situation where the database processes a query operation for object B in query A as a query operation for object D in query C, a semantic tree can also be used in this specification to represent the target nodes of each queried object and the child nodes of each target node. For example... Figure 3 As shown.
[0089] Figure 3This is a schematic diagram of the semantic tree structure provided in this specification. In the diagram, the query statement contains two query objects, query object 1 and query object 2. For query object 1, the corresponding child nodes are leaf node 1 and leaf node 2. For query object 2, the corresponding child nodes are leaf node 3, leaf node 4 and leaf node 5.
[0090] It should be noted that, Figure 3 This is merely an exemplary description of the semantic tree framework. The specific structure corresponding to this semantic tree framework can be set as needed, and this specification does not impose any restrictions on it.
[0091] In one or more embodiments provided in this specification, it is relatively easy to determine the execution plan corresponding to the graph database based on the semantic tree used to guarantee the query statement in the graph database. Therefore, when determining the target node corresponding to each queried object and the child nodes corresponding to each target node, the graph database can directly determine the semantic tree. The graph database can represent each target node and its child nodes corresponding to the same query statement using a semantic tree, avoiding the aforementioned execution errors and ensuring the accuracy of data processing.
[0092] In addition, since the target node of the query object can usually be an intermediate node of the semantic tree, and the target node can be a leaf node of the semantic tree, when determining the semantic tree, the graph database can determine the subtree of the target node corresponding to each query object, and then construct the semantic tree according to the subtrees corresponding to each query object.
[0093] Specifically, a graph database can determine the subtree of the target node corresponding to a graph vertex based on the vertex name query condition, the vertex type query condition, and the vertex description query condition.
[0094] Meanwhile, the graph database can determine the subtree of the target node corresponding to the graph data edge based on the query conditions of the graph data edge name, the graph data edge type, the graph data edge direction, and the graph data edge description.
[0095] Finally, based on the subtrees corresponding to each identified object to be queried, a semantic tree corresponding to the query statement is generated.
[0096] Furthermore, the query statement can also include a description of the query results. That is, after determining the query results, the graph database can filter the results based on the corresponding filter conditions and process the filtered results as the final query results. Therefore, the graph database can also determine database operations based on the filter conditions corresponding to the query results.
[0097] Specifically, this graph database can determine the filtering conditions for query results from the query statement. For example, the query result is a string type, or the query result has a value greater than 7, etc.
[0098] Secondly, the graph database can determine the target node corresponding to the query result and perform semantic analysis on the filtering conditions of the query result to obtain the semantic query conditions corresponding to the query result.
[0099] Then, the graph database can determine the result constraint nodes based on the determined semantic query conditions, which will serve as child nodes of the target node corresponding to the query result.
[0100] Finally, the graph database can update the database operations that need to be performed based on the target node and result constraint node corresponding to the query result. That is, the database operations corresponding to the query result are added to the original database operations.
[0101] Of course, the graph database can also update the semantic tree corresponding to the query statement based on the target node and result constraints. Then, based on the updated semantic tree, the database operations that the graph database needs to perform are redefined.
[0102] Furthermore, when generating the semantic tree, this graph database can arrange the subtrees of the target nodes corresponding to each queried node to generate the semantic tree. Alternatively, the query order for each queried object can be pre-set in the graph database, such as querying the graph start point first, then the graph edges, and finally the graph end point. Then, according to the query order corresponding to each queried object, the subtrees are arranged in the query order to determine the semantic tree corresponding to the query statement.
[0103] by Figure 2 Taking query object 1 and query object 2 as an example, if the query order of query object 2 is higher than that of query object 1, then the upper-level branch can be set as the branch of query object 2, and the branch corresponding to query object 1 can be set as the lower-level branch. Alternatively, the branch corresponding to query object 1 can be set as a part of the branch of query object 2.
[0104] The specific method for obtaining the semantic tree corresponding to the graph database can be configured as needed, and this manual does not impose any restrictions on it.
[0105] Furthermore, as mentioned earlier, after determining the semantic tree corresponding to the query statement, the graph database can query the data stored in the graph database itself based on the determined semantic tree, so as to achieve accurate processing based on the semantic tree.
[0106] Based on this, after determining the semantic tree corresponding to the query statement, the graph database can execute the data processing task corresponding to the query statement according to the semantic tree.
[0107] Therefore, the graph database can execute the data processing task corresponding to the query statement based on the semantic tree of the query statement. This data processing task can be a task involving operations such as "add, delete, modify, and query" on the data stored in the graph database.
[0108] Furthermore, for the database itself, its corresponding database operations can include both logical execution plans and physical execution plans. The logical execution plan describes which data the graph database needs to perform database operations on, while the physical execution plan describes how the graph database needs to perform database operations on the data it stores.
[0109] Therefore, the graph database can determine the logical execution plan of the query statement based on the types of the objects to be queried contained in the semantic tree of the query statement, and then determine the physical execution plan based on the child nodes of the target nodes of each object to be queried and the above logical execution plan.
[0110] The logical execution plan contains descriptions of all the steps required to execute the query statement; in other words, it includes a structure diagram for executing the query statement. The physical execution plan contains descriptions of the specific execution order of each step in the query statement, the data types of the executed data, and so on; in other words, it includes a flowchart for executing the query statement.
[0111] Assuming the query object is a graph data vertex, and the semantic filtering conditions for the child nodes of the target node of the query object are: name "oc" and type "Object", then the logical execution plan for this graph database can be determined as follows: Determine the graph data vertices from the graph data vertices and their corresponding attribute information. The physical execution plan is as follows: From the graph data vertices and their corresponding attribute information, search for each graph data vertex named "oc" by name; then, from the graph data vertices named "oc", query by type to retrieve the graph data vertices of type "Object" with the name "oc".
[0112] Furthermore, the graph database stores the vertices and their attribute information, as well as the edges and their attribute information, in tabular form. Specifically, the graph database can store the vertices and their attribute information in vertex tables and the edges and their attribute information in relational tables. The attribute information of the vertices includes at least one of the following: vertex name, type, and description. The attribute information of the edges includes at least one of the following: vertex name, type, direction, and description.
[0113] Therefore, when determining database operations, the graph database can, for each queried object, determine the target table to be queried from the vertex table and relation table based on the target node corresponding to that queried object. Then, based on the child nodes corresponding to the target node, it determines the database operations that the graph database needs to perform when querying that queried object.
[0114] It should be noted that the attribute information of the object to be queried can correspond to the semantic query conditions mentioned above. Therefore, when performing semantic analysis on the filtering conditions for the object to be queried, the graph database can perform semantic analysis on the filtering conditions based on the preset attributes of the object to be queried, and determine the semantic query results. The specific types corresponding to the preset attribute information of the object to be queried can be set as needed, and this manual does not impose any restrictions on this.
[0115] Furthermore, after the data processing task corresponding to the query statement is completed, the graph database can return the execution result based on the query statement. This execution result can be either "execution successful," "execution failed," or simply the query result itself. The specific type of the execution result and how it is determined can be configured as needed; this manual does not impose any restrictions on this.
[0116] It should be noted that, in the process of determining the physical execution plan based on the logical execution plan, the graph database described above can determine the database operations that need to be performed on the graph data based on the logical execution plan and the child nodes of the target node of the object to be queried. The determined database operations are then sorted to obtain the optimal sort, and the optimally sorted operations are used as the physical execution plan. This optimal sort is the one with the lowest required computational resources or time complexity among all sorts. The specific method for determining the physical execution plan can be set as needed, and this specification does not impose any restrictions on it.
[0117] Furthermore, in query statements, the description of query results usually includes not only filtering conditions, but also aggregation conditions, sorting conditions, and other conditions to describe the query results.
[0118] Therefore, the graph database can determine the aggregation and sorting conditions corresponding to the query results from the query statement.
[0119] The aggregation condition can describe how the query results are aggregated, such as summing all query results, determining the total number of query results, selecting the maximum value among the query results, etc. The sorting condition can determine the attribute corresponding to each query result, select a certain attribute to sort the query results, and output the sorted result. For example, assuming the query result is "people," the sorting condition could be to sort the query results in descending order of age. Of course, the specific content of the aggregation condition and the sorting condition can be set as needed, and this manual does not impose any restrictions on this.
[0120] The graph database can then determine the result aggregation node of the query result based on the aggregation conditions of the query result, and determine the result sorting node of the query result based on the sorting conditions of the query result.
[0121] Finally, after determining the above-mentioned result aggregation node and result sorting node, the graph database can update the semantic tree corresponding to the query statement based on the result aggregation node, result sorting node, and the previously determined result filtering node.
[0122] Of course, the query statement can also include a first filter condition to indicate whether the query result can be nullable. After determining the query result, the graph database can determine the first filter condition in the query statement and judge whether the execution result matches the first filter condition. If they match, the graph database can return the execution result. If they do not match, the graph database can return a prompt message indicating that the query statement execution failed.
[0123] Of course, the first filtering condition used to indicate whether the query result can be empty can also be used to constrain graph vertices and edges. If any query result for a graph vertex or edge does not match the first filtering condition, a message indicating that the query statement failed is returned based on the query statement. The specific data type carried in the query statement and how information is returned based on the query result can be set as needed; this specification does not impose any restrictions on this.
[0124] It should be noted that when the object to be queried is the query result, the description of the query result in the query statement includes at least one of the following: filtering conditions, aggregation conditions, and sorting conditions. The specific conditions used to describe the query result can be set as needed, and this manual does not impose any restrictions on this.
[0125] Following the same approach, this specification also provides a structural diagram of a semantic tree framework, such as... Figure 4As shown.
[0126] Figure 4 This is a schematic diagram of the semantic tree structure provided in this specification. In the diagram, the graph database determines the subtrees of the target nodes for the graph data vertices, the target nodes for the graph data edges, the target nodes for the graph data endpoints, and the target nodes for the query results. The graph database can then concatenate these determined subtrees to obtain, as shown below. Figure 4 The semantic tree shown is an example of a query result. The result constraint node, result aggregation node, and result sorting node are child nodes of the target node in the query results.
[0127] Of course, in the semantic tree framework described above, the graph data start point, graph data edge, and graph data end point can all be child nodes corresponding to the query object, or they can be child nodes corresponding to the query statement together with the query object. The specific results of this semantic tree framework can be set as needed, and this manual does not impose any restrictions on this.
[0128] Following the same line of thought, this specification also provides a data processing device, such as... Figure 5 As shown.
[0129] Figure 5 This specification provides a data processing apparatus for use in graph databases, comprising:
[0130] The semantic determination module 200 is used to determine each query object and the filtering conditions of each query object in the received query statement, wherein the query object includes at least one of graph data vertices and graph data edges in the graph database.
[0131] The node determination module 202 is used to generate a target node corresponding to each query object, perform semantic analysis on the filtering conditions of the query object to determine the semantic query conditions, and determine the child nodes of the target node according to the determined semantic query conditions.
[0132] The operation determination module 204 is used to determine, based on the child nodes of each target node, the database operations that the graph database needs to perform corresponding to each target node.
[0133] The processing module 206 is used to execute the data processing task corresponding to the query statement according to the database operations, and return the execution result according to the query statement.
[0134] Optionally, the semantic determination module 200 is configured to receive a query statement, determine the syntax information corresponding to the query statement, determine each query object in the query statement and the description information of each query object based on the syntax information, and use the description information of each query object as a filtering condition for each query object.
[0135] Optionally, the object to be queried includes at least graph data vertices, and the graph data vertices include at least one of graph data start point and graph data end point. The node determination module 202 is used to perform semantic analysis on the filtering conditions of the graph data vertices to determine the name, type and description of the object to be queried.
[0136] Based on the name, type, and description of the object to be queried, determine the name node, type node, and description node, which will serve as child nodes of the target node corresponding to the object to be queried.
[0137] Optionally, the object to be queried contains at least graph data edges. The node determination module 202 is used to perform semantic analysis on the filtering conditions of the graph data edges to determine the name, type, direction and description of the object to be queried. Based on the name, type, direction and description of the object to be queried, the name node, type node, direction node and description node are determined as child nodes of the target node corresponding to the object to be queried.
[0138] Optionally, the query statement further includes filtering conditions for the query results. The operation determination module 204 is used to determine the filtering conditions corresponding to the query results from the query statement, determine the target node corresponding to the query results, perform semantic analysis on the filtering conditions of the query results to obtain the semantic query conditions corresponding to the query results, and determine the result constraint node as a child node of the target node corresponding to the query results based on the determined semantic query conditions. Based on the target node corresponding to the query results and the result constraint node, the database operations to be performed on the graph database are updated.
[0139] Optionally, the graph database stores a vertex table and a relation table. The vertex table stores the attribute information of each vertex in the graph data, and the relation table stores the attribute information of each edge in the graph data. The operation determination module 204 is used to determine, for each query object, the target table to be queried from the vertex table and the relation table based on the target node corresponding to the query object, and to determine the database operation to be executed sequentially when the graph database queries the query object based on the child nodes corresponding to the target node.
[0140] Optionally, the query statement includes filtering conditions for the query results. The filtering conditions include a first filtering condition used to indicate whether the query results can be empty. The processing module 206 is used to determine the filtering conditions for the query results in the query statement, and to determine whether the execution result matches the first filtering condition in the filtering conditions. If yes, the execution result is returned; if no, a prompt message indicating that the query statement failed to execute is returned.
[0141] This specification also provides a computer-readable storage medium storing a computer program that can be used to execute the above-described... Figure 1 The provided data processing methods.
[0142] This instruction manual also provides Figure 6 The diagram shows the schematic structure of the electronic device. As described in section 6, at the hardware level, this electronic device includes a processor, an internal bus, a network interface, memory, and non-volatile memory, and may also include other hardware required for the business operations. The processor reads the corresponding computer program from the non-volatile memory into memory and then runs it to achieve the above-mentioned functions. Figure 1 The data processing method described herein. Of course, in addition to software implementation, this specification does not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. In other words, the execution subject of the following processing flow is not limited to individual logic units, but can also be hardware or logic devices.
[0143] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the methodology). However, with technological advancements, many methodological improvements today can be considered direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved methodology into the hardware circuit. Therefore, it cannot be said that a methodological improvement cannot be implemented using hardware physical modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. Designers can program and "integrate" a digital system onto a PLD themselves, without needing chip manufacturers to design and manufacture dedicated integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly implemented using "logic compiler" software. Similar to the software compiler used in program development, the original code before compilation must be written in a specific programming language, called a Hardware Description Language (HDL). There are many HDLs, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should understand that by simply performing some logic programming on the method flow using one of these hardware description languages and programming it into an integrated circuit, the hardware circuit implementing the logical method flow can be easily obtained.
[0144] The controller can be implemented in any suitable manner. For example, it can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicon Labs C8051F320. A memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also recognize that, in addition to implementing the controller in purely computer-readable program code form, the same functionality can be achieved by logically programming the method steps to make the controller take the form of logic gates, switches, ASICs, programmable logic controllers, and embedded microcontrollers. Therefore, such a controller can be considered a hardware component, and the means included therein for implementing various functions can also be considered as structures within the hardware component. Alternatively, the means for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.
[0145] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.
[0146] For ease of description, the above devices are described in terms of function, divided into various units. Of course, in implementing this specification, the functions of each unit can be implemented in one or more software and / or hardware.
[0147] Those skilled in the art will understand that embodiments of this specification can be provided as methods, systems, or computer program products. Therefore, this specification may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this specification may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0148] This specification is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this specification. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create a machine for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0149] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0150] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0151] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0152] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0153] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage 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 technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0154] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0155] Those skilled in the art will understand that the embodiments of this specification can be provided as methods, systems, or computer program products. Therefore, this specification may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this specification may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0156] This specification can be described in the general context of computer-executable instructions that are executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a specific task or implement a specific abstract data type. This specification can also be practiced in distributed computing environments, where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0157] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0158] The above description is merely an embodiment of this specification and is not intended to limit this specification. Various modifications and variations can be made to this specification by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification should be included within the scope of the claims of this specification.
Claims
1. A data processing method applied to a graph database, the method comprising: Based on the received query statement, determine each query object in the query statement and the filtering conditions for each query object, wherein the query object includes at least one of graph data vertices and graph data edges in the graph database; For each object to be queried, a target node corresponding to the object to be queried is generated, and semantic analysis is performed on the filtering conditions of the object to be queried to determine the semantic query conditions. Then, the child nodes of the target node are determined according to the determined semantic query conditions. Based on the child nodes of each target node, determine the database operations that the graph database needs to perform corresponding to each target node; Based on the database operations, execute the data processing task corresponding to the query statement, and return the execution result according to the query statement.
2. The method as described in claim 1, wherein determining each object to be queried in the received query statement and the filtering conditions for each object to be queried specifically includes: Receive a query statement and determine the syntax information corresponding to the query statement; Based on the grammatical information, determine each object to be queried in the query statement, as well as the descriptive information for each object to be queried; For each object to be queried, the filtering conditions are determined based on the description information of the object to be queried.
3. The method as described in claim 1, wherein the object to be queried at least includes graph data vertices, and the graph data vertices include at least one of graph data start point and graph data end point; The process involves performing semantic analysis on the filtering conditions for the target object to determine the semantic query conditions, and then determining the child nodes of the target node based on each determined semantic query condition. Specifically, this includes: Semantic analysis is performed on the filtering conditions of the graph data vertices to determine at least one of the name, type, and description of the object to be queried; Based on at least one of the name, type, and description of the object to be queried, determine at least one of the name node, type node, and description node as a child node of the target node corresponding to the object to be queried.
4. The method as described in claim 1, wherein the object to be queried contains at least graph data edges; The process involves performing semantic analysis on the filtering conditions for the target object to determine the semantic query conditions, and then determining the child nodes of the target node based on each determined semantic query condition. Specifically, this includes: Semantic analysis is performed on the filtering conditions of the graph data edges to determine at least one of the name, type, direction, and description of the object to be queried; Based on at least one of the name, type, direction, and description of the object to be queried, determine at least one of the name node, type node, direction node, and description node as a child node of the target node corresponding to the object to be queried.
5. The method as described in claim 1, wherein the query statement further includes filtering conditions for the query results; The method further includes: From the query statement, determine the filtering conditions corresponding to the query results; The target node corresponding to the query result is determined, and the filtering conditions of the query result are semantically analyzed to obtain the semantic query conditions corresponding to the query result. Based on the determined semantic query conditions, the result constraint node is determined as the child node of the target node corresponding to the query result. Based on the target node corresponding to the query result and the result constraint node, update each database operation that needs to be performed on the graph database.
6. The method as described in claim 1, wherein the graph database stores a vertex table and a relation table, the vertex table stores attribute information of each graph data vertex, and the relation table stores attribute information of each graph data edge; Based on the target node corresponding to each queried object and the child node corresponding to each target node, the database operations to be performed by the graph database for each target node are determined, specifically including: For each object to be queried, based on the target node corresponding to the object to be queried, the target table to be queried for the object to be queried is determined from the vertex table and the relationship table; Based on the child nodes corresponding to the target node, determine the database operations to be performed on the target table.
7. The method as described in claim 1, wherein the query statement includes filtering conditions for the query results, and the filtering conditions include a first filtering condition for characterizing whether the query results can be empty; The execution result will be returned according to the query statement, specifically including: Determine the filtering conditions for the query results in the query statement; Determine whether the execution result matches the first filtering condition in the filtering criteria; If so, return the execution result; If not, return a message indicating that the query statement failed to execute.
8. A data processing apparatus applied to a graph database, the graph database containing graph data vertices and graph data edges, the apparatus comprising: The semantic determination module is used to determine each query object and the filtering conditions of each query object in the received query statement, wherein the query object includes at least one of graph data vertices and graph data edges in the graph database. The node determination module is used to generate a target node corresponding to each query object, perform semantic analysis on the filtering conditions of the query object to determine the semantic query conditions, and determine the child nodes of the target node according to the determined semantic query conditions. The operation determination module is used to determine, based on the child nodes of each target node, the database operations that the graph database needs to perform corresponding to each target node; The processing module is used to execute the data processing task corresponding to the query statement according to the database operations, and return the execution result according to the query statement.
9. A computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described in any one of claims 1 to 7.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method described in any one of claims 1 to 7.
Citation Information
Patent Citations
Semantic processing method and system
CN110276080A