Implementation method and system of path pattern expression in distributed graph database

By using breadth-first traversal in a distributed graph database to retrieve and merge path data tables, the problem of high network overhead is solved, and data query performance is improved.

CN116244302BActive Publication Date: 2025-12-23VESOFT INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211544910.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-02
Publication Date
2025-12-23
Estimated Expiration
2042-12-02

AI Technical Summary

Technical Problem

In distributed graph databases, the implementation of path pattern expressions suffers from high network overhead, leading to a decrease in query performance.

Method used

Using a breadth-first traversal approach, the first path data table and the second path data table that satisfy the path pattern are obtained from the distributed graph database through the path pattern sub-plan, and then merged into a new data table through the path pattern expression sub-plan.

Benefits of technology

This significantly improves the data query performance of path pattern expressions in distributed graph databases, reduces the number of network accesses, and increases query efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116244302B_ABST
    Figure CN116244302B_ABST
Patent Text Reader

Abstract

The application relates to a method and system for implementing a path pattern expression in a distributed graph database, wherein the method comprises: executing a summary application operator, wherein the summary application operator comprises a path pattern subplan and a path pattern expression subplan; that is, by using the path pattern subplan, first path data tables and second path data tables satisfying a path pattern are respectively acquired from the distributed graph database in a breadth-first traversal manner; and then by using the path pattern expression subplan, the first path data tables and the second path data tables are combined to obtain new data tables. By the application, the problem that network overhead is large in the implementation of a path pattern expression in a distributed graph database is solved, and data of a path pattern expression is acquired in a breadth-first manner, so that the data query performance is greatly improved in a graph database of a distributed architecture.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of graph database, and particularly relates to a method and system for implementing path pattern expression in distributed graph database. BACKGROUND

[0002] With the rise of retail, finance, e-commerce, Internet and Internet of Things industries, the scale of interactive and stored data grows exponentially. As a graph database based on a large-scale relationship network, it has gradually been applied to related industries.

[0003] Open Cypher is developed based on the query language Cypher of the graph database Neo4j, and is mainly used for storing and retrieving data in a graph database. It provides a common language required for querying graph data. Cypher is one of the most widely used graph query languages in the industry, and the arrival of Open Cypher can make the graph processing analysis tool grow faster. In Open Cypher, there is a concept of path pattern expression, for example: `match(v:player)return(v)-[:like]->()`, wherein the expression `(v)-[:like]->()` is a path pattern expression, and its semantic meaning is to iterate the current table and evaluate the entire path pattern expression, and put the path data satisfying the path pattern into a list as the final value of the expression.

[0004] Currently, the method for implementing path pattern expression in a single machine graph database is to iterate the current table, perform a depth-first graph traversal each time to take out path data satisfying the path pattern expression from the storage, and add the path data into a list. However, this method will cause the following problems in the implementation of a distributed graph database: when the depth-first traversal starts from a starting point to obtain an adjacent edge, a network access will be generated each time, and when the expansion times of the path pattern expression are large, a large network access overhead will be caused.

[0005] Currently, there is no effective solution to the problem of large network overhead in the implementation of path pattern expression in a distributed graph database in the related art. SUMMARY

[0006] Embodiments of the present application provide a method and system for implementing path pattern expression in a distributed graph database, to at least solve the problem of large network overhead in the implementation of path pattern expression in a distributed graph database in the related art.

[0007] In a first aspect, embodiments of the present application provide a method for implementing a path pattern expression in a distributed graph database, the method comprising:

[0008] executing a summary application operator, wherein the summary application operator comprises a path pattern sub-plan and a path pattern expression sub-plan;

[0009] obtaining a first path data table and a second path data table satisfying the path pattern from the distributed graph database respectively through the path pattern sub-plan;

[0010] merging the first path data table and the second path data table to obtain a new data table through the path pattern expression sub-plan.

[0011] In some embodiments, obtaining the first path data table and the second path data table satisfying the path pattern from the distributed graph database respectively comprises:

[0012] obtaining the first path data table and the second path data table satisfying the path pattern from the distributed graph database respectively in a breadth-first traversal manner.

[0013] In some embodiments, merging the first path data table and the second path data table to obtain a new data table comprises:

[0014] iteratively obtaining a current row of the first path data table and obtaining a corresponding row from the second path data table, wherein the corresponding row has a same symbol value as the current row;

[0015] connecting the current row and the corresponding row into a new row, and repeating the iteratively obtaining and the connecting to obtain a new data table.

[0016] In some embodiments, iteratively obtaining a current row of the first path data table and obtaining a corresponding row from the second path data table comprises:

[0017] iteratively obtaining a current row of the first path data table, and determining whether the current row of the first path data table is obtained;

[0018] if the current row of the first path data table is obtained, then iteratively obtaining each row of the second path data table to obtain a corresponding row having a same symbol value as the current row;

[0019] if the current row of the first path data table is not obtained, then ending subsequent steps.

[0020] In some embodiments, the distributed graph database is a distributed graph database of edge-cut architecture.

[0021] In a second aspect, the embodiments of the present application provide a system for implementing a path pattern expression in a distributed graph database, the system comprising a first execution module, a second execution module and a third execution module;

[0022] The first execution module is configured to execute a summary application operator, wherein the summary application operator comprises a path pattern sub-plan and a path pattern expression sub-plan.

[0023] The second execution module is configured to obtain a first path data table and a second path data table satisfying the path pattern from the distributed graph database respectively through the path pattern sub-plan.

[0024] The third execution module is configured to merge the first path data table and the second path data table through the path pattern expression sub-plan to obtain a new data table.

[0025] In some embodiments, the second execution module is configured to obtain the first path data table and the second path data table satisfying the path pattern from the distributed graph database respectively in a breadth-first traversal manner.

[0026] In some embodiments, the third execution module is configured to iteratively obtain a current row of the first path data table and obtain a corresponding row from the second path data table, wherein the corresponding row has a same symbol value as the current row; and connect the current row and the corresponding row into a new row, and repeat the iterative obtaining and the connecting to obtain the new data table.

[0027] In some embodiments, the third execution module is configured to iteratively obtain a current row of the first path data table, and determine whether the current row of the first path data table is obtained; if the current row of the first path data table is obtained, iteratively obtain each row in the second path data table to obtain a corresponding row having a same symbol value as the current row; and if the current row of the first path data table is not obtained, end subsequent steps.

[0028] In some embodiments, the distributed graph database is a distributed graph database of an edge-cut architecture.

[0029] Compared with the related art, the embodiment of the present application provides an implementation method and system of path pattern expression in a distributed graph database, wherein the method is performed by executing a summary application operator, wherein the summary application operator comprises a path pattern sub-plan and a path pattern expression sub-plan; that is, by using the path pattern sub-plan, first path data table and second path data table satisfying the path pattern are respectively acquired from the distributed graph database in a breadth-first traversal manner; and then by using the path pattern expression sub-plan, the first path data table and the second path data table are merged to obtain a new data table, so that the problem of large network overhead in the implementation of the path pattern expression in the distributed graph database is solved, and the data of the path pattern expression is acquired in a breadth-first manner, which greatly improves the data query performance in the graph database of the distributed architecture. BRIEF DESCRIPTION OF DRAWINGS

[0030] The drawings described herein are used to provide further understanding of the present application, and form a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application, and do not constitute an improper limitation on the present application. In the drawings:

[0031] Figure 1 is an example schematic diagram of depth-first traversal;

[0032] Figure 2 is an example schematic diagram of breadth-first traversal;

[0033] Figure 3 is a step flowchart of implementing path pattern expression in a distributed graph database according to an embodiment of the present application;

[0034] Figure 4 is a structure schematic diagram of executing a summary application operator according to an embodiment of the present application;

[0035] Figure 5 is a flowchart of a path pattern expression sub-plan according to an embodiment of the present application;

[0036] Figure 6 is a structure block diagram of implementing path pattern expression in a distributed graph database according to an embodiment of the present application;

[0037] Figure 7 is an internal structure schematic diagram of an electronic device according to an embodiment of the present application.

[0038] BRIEF DESCRIPTION OF DRAWINGS: 61, first execution module; 62, second execution module; 63, third execution module. DETAILED DESCRIPTION

[0039] In order to make the objects, technical solutions and advantages of the present application clearer, the present application will be described and illustrated below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and should not be used to limit the present application. Based on the embodiments provided by the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort belong to the scope of the present application.

[0040] Obviously, the accompanying drawings in the following description are only some examples or embodiments of the present application, and for those of ordinary skill in the art, the present application can also be applied to other similar scenarios without creative effort based on the accompanying drawings. In addition, it can be understood that although the efforts made in the development process can be complex and lengthy, for those of ordinary skill in the art related to the content disclosed in the present application, some design, manufacture or production changes based on the technical content disclosed in the present application are only routine technical means, and should not be understood as insufficient disclosure of the content disclosed in the present application.

[0041] In the present application, "embodiment" means that the specific features, structures or characteristics described in conjunction with the embodiment can be included in at least one embodiment of the present application. The phrase appears at various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment to other embodiments. It is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in the present application can be combined with other embodiments without conflict.

[0042] Unless otherwise defined, technical terms and scientific terms used in the present application shall have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. The terms "a", "an", "one", "this", and the like, as used in the present application, do not denote a limitation of quantity, and can be construed to mean either the singular or the plural. The terms "including", "containing", "having", and the like, as used in the present application, are intended to be construed open-ended, i.e., to mean including, without limitation, the stated elements or steps. The terms "connected", "coupled", and the like, as used in the present application, are intended to be construed in an inclusive sense, i.e., to mean either a direct connection between two elements or an indirect connection through one or more additional elements. The term "multiple" means two or more. The term "and / or" describes associated objects, i.e., there can be three instances where the objects exist separately, in which case "A and / or B" means A, B, or A and B. The character " / " generally means an "or" relationship between the associated objects. The terms "first", "second", "third", and the like, merely identify classes of elements, and do not limit the number of elements in each class.

[0043] The inventors have found that in a single-machine graph database, path pattern expressions are generally acquired using a depth-first traversal method to obtain data that conforms to a path pattern

[0044] It should be noted that the depth-first traversal (DFS) is a search method that finds a path and does not stop searching, Figure 1 is an example schematic diagram of depth-first traversal, as shown in Figure 1 The traversal starts from the starting node 1, searches along a path of the starting node 1 without stopping, and when it is found that the path cannot be followed, it backtracks to the last explored node. If the last node has branches that have not been explored, it continues to explore. If the last node has no branches that have not been explored, it continues to backtrack to the node before the last node.

[0045] As can be seen, if depth-first traversal is also used in a distributed graph database, due to the characteristics of the distributed storage architecture and the data model of edge partitioning, each backtracking acquisition will generate a network access. When there are N rows of input, for a path pattern expression that needs to be expanded by M steps, a total of N*M network accesses will be generated.

[0046] Therefore, the application adopts breadth-first query, and for implementation of the path pattern expression, data satisfying the path pattern is all queried and spliced into a path, and then RollUpApply calculation is performed on the front table. Figure 2 is an example schematic diagram of breadth-first traversal, as Figure 2 shown, breadth-first traversal (BFS) is to explore several points adjacent to the starting node 1 first, then to explore points slightly farther from the starting point (one layer apart), and then to explore points farther from the starting point (two layers apart), and to explore outward layer by layer, which requires recording which points are explored in the last layer, so as to find points in the next layer. For the path pattern expression requiring M-step expansion, data of the path pattern expression is acquired by the breadth-first manner, only M times of network access is required; in the distributed architecture of the graph database, the query performance is greatly improved.

[0047] The embodiment of the application provides a method for implementing a path pattern expression in a distributed graph database, Figure 3 is a step flowchart for implementing the path pattern expression in the distributed graph database according to the embodiment of the application, as Figure 3 shown, the method comprises the following steps:

[0048] In step S302, a RollUpApply operator is executed, wherein the RollUpApply operator comprises a path pattern subplan and a path pattern expression subplan.

[0049] Specifically, Figure 4 is a structural schematic diagram of the RollUpApply operator according to the embodiment of the application, as Figure 4 shown, the RollUpApply operator (the RollUpApply operator is executed) is an operator having two subnodes, the left subplan is a path pattern part (the path pattern subplan) of a match statement, and the right subplan is a path pattern expression part (the path pattern expression subplan).

[0050] In step S304, first path data table and second path data table satisfying the path pattern are respectively acquired from the distributed graph database by the path pattern subplan.

[0051] Specifically, the first path data table and the second path data table satisfying the path pattern are respectively acquired from the distributed graph database by the path pattern subplan in a breadth-first traversal manner.

[0052] It should be noted that the distributed graph database in the embodiments of the present application is preferably a distributed graph database of edge-cut architecture.

[0053] In step S306, the first path data table and the second path data table are merged by the path pattern expression plan to obtain a new data table.

[0054] Specifically, the current row of the first path data table is iteratively obtained by the path pattern expression plan, and a corresponding row is obtained from the second path data table, wherein the corresponding row has the same symbol value as the current row; the current row and the corresponding row are connected into a new row, and the iterative obtaining and connecting are repeated to obtain the new data table.

[0055] Preferably, Figure 5 is a flowchart of the path pattern expression plan according to the embodiments of the present application, as Figure 5 shown, the sub-plan specifically includes the following steps:

[0056] Step one, iteratively obtaining the current row of the first path data table, and performing step two;

[0057] Step two, determining whether the current row of the first path data table is obtained, and performing step three or step seven;

[0058] Step three, if the current row is obtained, iteratively obtaining each row in the second path data table, and performing step four;

[0059] Step four, determining whether there is a corresponding row in the second path data table; the corresponding row has the same symbol value as the current row of the first path data table, and performing step five or step six;

[0060] Step five, if there is, the path data in the corresponding row of the second path data table is put into a list;

[0061] and is merged with the current row of the first path data table to finally obtain a new data table;

[0062] Step six, if there is not, returning to step one;

[0063] Step seven, if step one is not obtained, ending.

[0064] Through steps S302 to S306 in the embodiments of the present application, the problem of large network overhead in the implementation of the path pattern expression in the distributed graph database is solved, and the breadth-first mode is used to obtain the data of the path pattern expression, which greatly improves the data query performance in the distributed architecture graph database.

[0065] It is noted that the steps shown in the above flow or the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from here.

[0066] The embodiment of the present application provides an implementation system of a path pattern expression in a distributed graph database, Figure 6 is a structural block diagram for implementing the path pattern expression in the distributed graph database according to the embodiment of the present application, as Figure 6 shown, the system comprises a first execution module 61, a second execution module 62 and a third execution module 63.

[0067] The first execution module 61 is used for executing a summary application operator, wherein the summary application operator comprises a path pattern subplan and a path pattern expression subplan.

[0068] The second execution module 62 is used for acquiring a first path data table and a second path data table satisfying a path pattern from the distributed graph database respectively through the path pattern subplan.

[0069] The third execution module 63 is used for merging the first path data table and the second path data table to obtain a new data table through the path pattern expression subplan.

[0070] Through the first execution module 61, the second execution module 62 and the third execution module 63 in the embodiment of the present application, the problem that the implementation of the path pattern expression in the distributed graph database has a large network overhead is solved, and the data of the path pattern expression is acquired in a breadth-first manner, so that the data query performance is greatly improved in the graph database of the distributed architecture.

[0071] In some embodiments, the second execution module 62 is configured to acquire the first path data table and the second path data table satisfying the path pattern from the distributed graph database respectively in a breadth-first traversal manner.

[0072] In some embodiments, the third execution module 63 is configured to iteratively acquire a current row of the first path data table, and acquire a corresponding row from the second path data table, wherein the corresponding row has a same symbol value as the current row; and connect the current row and the corresponding row into a new row, and repeatedly iteratively acquire and connect to obtain the new data table.

[0073] In some embodiments, the third execution module 63 is configured to iteratively acquire a current row of the first path data table, and judge whether the current row of the first path data table is acquired; if the current row of the first path data table is acquired, iteratively acquire each row in the second path data table to acquire a corresponding row having a same symbol value as the current row; and if the current row of the first path data table is not acquired, end subsequent steps.

[0074] In some embodiments, the distributed graph database is a distributed graph database of edge-cut architecture.

[0075] It should be noted that the above-mentioned various modules can be functional modules or program modules, which can be implemented by software or hardware. For the modules implemented by hardware, the above-mentioned various modules can be located in the same processor; or the above-mentioned various modules can also be located in different processors in any combination.

[0076] The embodiment also provides an electronic device including a memory and a processor, the memory storing a computer program, and the processor being configured to execute the computer program to perform the steps in any of the above method embodiments.

[0077] Optionally, the electronic device can further include a transmission device and an input / output device, wherein the transmission device is connected with the processor, and the input / output device is connected with the processor.

[0078] It should be noted that the specific examples in the embodiment can refer to the examples described in the above embodiments and optional implementation manners, which will not be described here again.

[0079] In addition, in combination with the implementation method of the path pattern expression in the distributed graph database in the above embodiments, the embodiment of the application can provide a storage medium for implementation. The storage medium stores a computer program; the computer program is executed by a processor to implement any of the implementation methods of the path pattern expression in the distributed graph database in the above embodiments.

[0080] In one embodiment, a computer device is provided, which can be a terminal. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The network interface of the computer device is used to communicate with external terminals through network connection. The computer program is executed by the processor to implement an implementation method of a path pattern expression in a distributed graph database. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer overlaid on the display screen, or a key, trackball or touchpad arranged on the shell of the computer device, or an external keyboard, touchpad or mouse, etc.

[0081] In one embodiment, Figure 7 is a schematic diagram of the internal structure of an electronic device according to an embodiment of the present application, as Figure 7 indicated, an electronic device, which can be a server, is provided, and a schematic diagram of the internal structure thereof can be as Figure 7 indicated. The electronic device includes a processor, a network interface, an internal memory, and a non-volatile memory connected through an internal bus, wherein the non-volatile memory stores an operating system, a computer program, and a database. The processor is configured to provide computing and control capabilities, the network interface is configured to communicate with an external terminal through a network connection, the internal memory is configured to provide an environment for the operating system and the computer program to run, the computer program is configured to be executed by the processor to implement a method for implementing a path pattern expression in a distributed graph database, and the database is configured to store data.

[0082] Those skilled in the art can understand that Figure 7 the structure shown in the above embodiment is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the electronic device to which the scheme of the present application is applied. Specifically, the electronic device can include more or fewer components than those shown in the diagram, or combine certain components, or have a different arrangement of components.

[0083] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer readable storage medium. When the computer program is executed, it can include the processes of the above-mentioned embodiments. Any reference to memory, storage, database, or other medium used in the embodiments provided by the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0084] Those skilled in the art should understand that each technical feature of the above-described embodiments can be combined arbitrarily, and for the sake of brevity, each technical feature of the above-described embodiments is not described in all possible combinations, however, as long as the combinations of the technical features do not exist, it should be considered that it is within the scope of the description.

[0085] The above-described embodiments only express several implementation manners of the present application, the description is more specific and detailed, but it should not be understood as a limitation on the patent scope of the application. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are within the scope of protection of the present application. Therefore, the patent protection scope of the present application should be subject to the appended claims.

Claims

1. A method for implementing path pattern expressions in a distributed graph database, characterized in that, The method comprises: executing a summary application operator, wherein the summary application operator comprises a path pattern subplan and a path pattern expression subplan; obtaining, by the path pattern subplan, a first path data table and a second path data table satisfying the path pattern from a distributed graph database in a breadth-first traversal manner, wherein the distributed graph database is a distributed graph database of an edge-cut architecture; obtaining, by the path pattern expression subplan, a current row of the first path data table and a corresponding row from the second path data table iteratively, wherein the corresponding row has a same symbol value as the current row; and connecting the current row and the corresponding row into a new row, and repeating the iterative obtaining and the connecting to obtain a new data table.

2. The method of claim 1, wherein, The iterative obtaining of the current row of the first path data table and the obtaining of the corresponding row from the second path data table comprise: iteratively obtaining the current row of the first path data table, and determining whether the current row of the first path data table is obtained; if the current row of the first path data table is obtained, iteratively obtaining each row in the second path data table, and obtaining the corresponding row having the same symbol value as the current row; if the current row of the first path data table is not obtained, ending subsequent steps.

3. A system for implementing path pattern expressions in a distributed graph database, the system comprising: The system comprises a first execution module, a second execution module, and a third execution module; the first execution module is configured to execute a summary application operator, wherein the summary application operator comprises a path pattern subplan and a path pattern expression subplan; the second execution module is configured to obtain, by the path pattern subplan, a first path data table and a second path data table satisfying the path pattern from a distributed graph database in a breadth-first traversal manner, wherein the distributed graph database is a distributed graph database of an edge-cut architecture; the third execution module is configured to obtain, by the path pattern expression subplan, a current row of the first path data table and a corresponding row from the second path data table iteratively, wherein the corresponding row has a same symbol value as the current row; and connect the current row and the corresponding row into a new row, and repeat the iterative obtaining and the connecting to obtain a new data table.

4. The system of claim 3, wherein, The third execution module is configured to iteratively obtain the current row of the first path data table, and determine whether the current row of the first path data table is obtained; if the current row of the first path data table is obtained, iteratively obtain each row in the second path data table, and obtain the corresponding row having the same symbol value as the current row; and if the current row of the first path data table is not obtained, end subsequent steps.