Method and device for realizing concurrent import of graph database data based on dependency tree

By building a point-edge dependency tree and monitoring point type import status, concurrent import of the graph database is achieved, which solves the problems of slow import speed and inconsistent data in traditional methods, and improves import efficiency and consistency.

CN118820535AInactive Publication Date: 2024-10-22杭州悦数科技有限公司

Patent Information

Application Number
CN202411303167.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-19
Publication Date
2024-10-22
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The traditional method of sequentially executing the import of nodes and edges in a graph database results in a slow import speed, and concurrent import can easily lead to import errors if the dependencies between nodes and edges are not properly handled.

Method used

By constructing a point-edge dependency tree that contains point-edge dependencies, the import status of point types is monitored and recorded to determine whether all edge types depend on point types. After the point types have been imported, the import tasks of edge types are executed concurrently to ensure data consistency. sex.

Benefits of technology

Significantly improves import efficiency, ensures data consistency, avoids the risk of import failure, and enhances system flexibility and scalability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118820535A_ABST
    Figure CN118820535A_ABST
Patent Text Reader

Abstract

The invention discloses a method and a device for realizing concurrent import of graph database data based on a dependency tree, relates to the technical field of big data processing and graph databases, and solves the problem of low import speed caused by sequential execution of import of nodes and edges in the prior art. The method comprises the following steps: constructing a point-edge dependency tree containing a point-edge dependency relationship, monitoring and recording an import state of a point type, and concurrently executing an import task of the point type and an import task of an edge type in a first state, according to the point-edge dependency tree and the importing state of the point type, judging whether all the point types on which the edge type depends are completely imported or not, and if the judgment result is yes, enabling the corresponding edge type to enter the first state, according to the method, the data consistency is ensured in a mode of constructing the point-edge dependency tree, meanwhile, the concurrency of data importing is improved, and the data importing efficiency is improved. And thus, the data importing speed is increased.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of big data processing and graph database technology, and in particular to a method and device for implementing concurrent import of graph database data based on a dependency tree. Background Art

[0002] With the widespread application of graph data in social networks, recommendation systems, knowledge graphs and other fields, efficiently importing large amounts of graph data into graph databases has become a critical task. Traditional methods often import nodes and edges sequentially, which limits the import speed. Although concurrent import can improve efficiency, it can easily lead to import errors if the dependencies between nodes and edges are not properly handled. For example, when an edge is imported, its associated node does not yet exist in the database, and the edge import will fail. Therefore, how to achieve efficient concurrent import of graph data while ensuring data consistency has become a problem that needs to be solved urgently. Summary of the invention

[0003] The purpose of this application is to overcome the problem of slow import speed caused by sequential execution of node and edge import in the prior art, and to provide a method and device for concurrent import of graph database data based on a dependency tree.

[0004] In a first aspect, a method for concurrently importing graph database data based on a dependency tree is provided, comprising: Build a vertex-edge dependency tree containing vertex-edge dependency relationships; Monitor and record the import status of point types; The import task of the point type is executed concurrently with the import task of the edge type in the first state, wherein it is determined whether all point types that the edge type depends on have been imported based on the point-edge dependency tree and the import state of the point type; if the judgment result is yes, the corresponding edge type enters the first state.

[0005] In some possible implementations, building a vertex-edge dependency tree including vertex-edge dependency relationships includes: Analyze metadata information of the graph database, wherein the metadata information includes edge types and source and target types of the edges; A dependency tree is established according to the metadata information, wherein the dependency tree includes the node types that each edge type depends on.

[0006] In some possible implementations, the import status of the point type is monitored and recorded, including: Before importing data, obtain the point types included in the import task and set the import status of all point types to incomplete; Real-time tracking of whether the data of each point type is successfully imported; If the point type data is successfully imported, the import status of the corresponding point type will be changed to completed.

[0007] In some possible implementations, the import status of the point type is maintained via a Map structure, wherein the key represents the point type and the value represents the import status of the point type.

[0008] In some possible implementations, the import task of an edge type is automatically started within a specified time after the edge type enters the first state.

[0009] In some possible implementations, the method also includes: verifying the data before importing and recording the data that fails the verification; during the data import process, if the batch data import fails, splitting the batch data into single data and re-importing them; if the import of a single data fails, recording the single data that failed to be imported and the reason for the import failure.

[0010] In a second aspect, a device for concurrently importing graph database data based on a dependency tree is provided, comprising: A construction module is used to construct a vertex-edge dependency tree containing vertex-edge dependency relationships; Monitoring module, used to monitor and record the import status of point types; An import module is used to concurrently execute the import task of the point type and the import task of the edge type in the first state, wherein, according to the point-edge dependency tree and the import state of the point type, it is judged whether all the point types that the edge type depends on have been imported. If the judgment result is yes, the corresponding edge type enters the first state.

[0011] In a third aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute the method described in the first aspect.

[0012] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable medium stores a program code for execution by a device, wherein the program code includes steps for executing the method in any one of the implementations of the first aspect described above.

[0013] In a fifth aspect, an electronic device is provided, comprising a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements a method as in any one of the implementations in the first aspect above.

[0014] This application has the following beneficial effects: 1. Significantly improve import efficiency: Through the concurrent import mechanism, this application can effectively reduce the total time consumed in data import, especially when processing large-scale graph data sets, the performance improvement is particularly obvious.

[0015] 2. Ensure data consistency: The introduction of the dependency tree and the dynamic status monitoring mechanism ensure the existence of dependent nodes before edge data is imported, avoiding the risk of data inconsistency and import failure.

[0016] 3. Enhance system flexibility and scalability: The solution of this application is flexibly designed and can easily adapt to changes in different graph database structures and import requirements, making it easier to expand to more complex graph data processing scenarios in the future. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The drawings constituting a part of the present application are used to provide a further understanding 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.

[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0019] Figure 1 It is a flowchart of a method for implementing concurrent import of graph database data based on a dependency tree according to Example 1 of the present application; Figure 2 This is an example diagram of the dependency relationship between the vertex type and the edge type in the method for implementing concurrent import of graph database data based on the dependency tree in Example 1 of the present application; Figure 3 It is a structural block diagram of an apparatus for implementing concurrent import of graph database data based on a dependency tree according to Embodiment 2 of the present application; Figure 4 It is a schematic diagram of the internal structure of the electronic device of Example 5 of the present application.

[0020] Reference numerals: 100, construction module; 200, monitoring module; 300, import module. DETAILED DESCRIPTION

[0021] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0022] Example 1

[0023] Embodiment 1 of the present application involves a method for concurrently importing graph database data based on a dependency tree, comprising: constructing a point-edge dependency tree including point-edge dependency relationships; monitoring and recording the import status of point types; concurrently executing the import task of the point type and the import task of the edge type in a first state, wherein, based on the point-edge dependency tree and the import status of the point type, it is determined whether all point types that the edge type depends on have been imported. If the judgment result is yes, the corresponding edge type enters the first state. This method greatly improves the speed of data import through a concurrent import mechanism, and at the same time, through the dependency tree and the monitoring of the import status of the point type data, effectively ensures the existence of the point type data on which the edge type data depends before the import, thereby effectively avoiding data inconsistency and the risk of data import failure due to incomplete import of the point type data on which the edge type data depends.

[0024] Specifically, Figure 1 A flowchart of a method for implementing concurrent import of graph database data based on a dependency tree in Embodiment 1 of the present application is shown, including: S100, constructing a point-edge dependency tree including point-edge dependency relationships; First, by analyzing the metadata information of the graph database (the metadata information includes the edge type and the source and target node types of the edge), a node-edge dependency model, namely the node-edge dependency tree, is established. The node-edge dependency tree clearly shows the node type that each edge type depends on, providing a basis for subsequent concurrent imports.

[0025] The construction of the point-edge dependency tree is obtained by querying metadata information in the graph database. It is necessary to execute query statements for querying edge types, source point types, and target point types in the graph database and parse the statement execution results into a dependency tree with a Map structure.

[0026] Query all edge types under the specified graph database name graphName, and parse the edge type name, source point type name, and target point type name from the edge type pattern. For example, if the queried edge type pattern is (person)-[friend]->(person), the dependency tree structure constructed for the friend edge type is friend->(person,person). The business meaning is that the edge type friend depends on the source point type person and the target point type person.

[0027] For example, the implementation code for building a vertex-edge dependency tree is as follows: / / Get all edge types and the source and target types of the edges in the specified graph database, and use a Map data structure to store this information. The key of the Map is the edge type, and the value of the Map is a tuple, which represents the source and target types of the edge type in the key.

[0028] def getEdgeDependencies(graphName: String): Map[String, (String,String)] = { val edges = new mutable.HashMap[String, (String, String)] / / Construct a graph database query statement to query edge types and edge source and target types val getEdgesPattern = "call describe_graph(\"" + graphName + "\")return graph_type_name next call describe_graph_type(graph_type_name) filterentity_type=\"Edge\" return type_pattern" val result = execute(getEdgesPattern) / / Parse the query results while (result._1.hasNext) { val edgeTypePattern = result._1.next().get(0).asString() var srcNodeType: String = null var dstNodeType: String = null var edgeType : String = null / / Match the edge type name, source point type name, and target point type name from the edge type pattern of the query result val edgeDirectionPattern = """\((.*?)\)-\[(.*?)\]->\((.*?)\)""" val regexWithEdgeDirection = edgeDirectionPattern.r val regexWithoutEdgeDirection = edgeUnDirectionPattern.r if (edgeTypePattern.matches(edgeDirectionPattern)) { edgeTypePattern match { case regexWithEdgeDirection(start, edge, end) => srcNodeType = start edgeType = edge dstNodeType = end } } else { throw new RuntimeException("can not parse the edge typepattern.") } / / Construct Map structure edges += (edgeType ->(srcNodeType, dstNodeType)) } edges.toMap } S200, monitoring and recording the import status of the point type; In this embodiment, a point type import status map is maintained to track in real time whether the data of each node type has been successfully imported. Before importing, the point types included in the current import task are obtained, and the import status of all point types is set to unfinished. During the import process, whenever the data of a certain point type is imported, its import status is marked as completed. This mechanism is the key to realizing timely import of edge type data.

[0029] The point type import status is maintained using a Map structure, where the key represents the point type and the value represents the import status of the point type. The import status is identified by a Boolean variable, i.e. person->false indicates that the point type person has not been imported yet. Once the point type person is imported, the value corresponding to person in the Map structure will be updated to true.

[0030] For example, the implementation code for monitoring the import status of point types is as follows: private def getNodeTypeStatus(sourceConfigs: List[DataSourceConfigEntry]): mutable.HashMap[String, Boolean]= { val nodeImportFinish = new mutable.HashMap[String, Boolean]() sourceConfigs.foreach(config =>{ config.schemaConfigs.par.foreach { case nodeConfig: NodeConfig =>nodeImportFinish +=(nodeConfig.name ->false) case _ => } }) nodeImportFinish } S300, executing the import task of the point type concurrently with the import task of the edge type in the first state, wherein, judging whether all point types that the edge type depends on have been imported according to the point-edge dependency tree and the import state of the point type, if the judgment result is yes, the corresponding edge type enters the first state; It should be noted that during the import process, for each edge type included in the import task, first check whether all the node types it depends on have completed the import. This check is based on the point-edge dependency tree and point type import status mapping constructed in step S100 and step S200. If the import of the point type data on which the edge type depends is not completed, the import task of the edge enters the waiting state; once all the dependent source point types and target point types of the edge type have completed the import, the edge type will enter the first state, which means that the import task of the edge type data is ready for execution. The import task of the edge type data will be automatically started within the specified time (for example: within 5 seconds, 7 seconds, 10 seconds, etc.), and all executable point type and edge type import tasks will be executed concurrently, thereby making full use of system resources and accelerating the entire data import process.

[0031] like Figure 2As shown in the figure, the import task includes 4 types of points (A, B, C, D) and 4 types of edges (E_Edge_E, A_Edge_B, B_Edge_C, D_Edge_D). The point type that edge type E_Edge_E depends on is not in the current task. In this case, the import of this edge is not subject to dependency constraints and can be imported directly. Edge type A_Edge_B depends on point type A and point type B. Only when the import of point tasks of type A and type B is completed, can the import of type A_Edge_B begin. Edge type B_Edge_C depends on point type B and point type C. Only when the import of point tasks of type B and type C is completed, can the import of type B_Edge_C begin. Edge type D_Edge_D depends on point type D. Only when the import of point tasks of type D is completed, can the import of type D_Edge_D begin.

[0032] At the beginning of the import task, the data import of point types A, B, C, D and edge type E_Edge_E can be executed concurrently. Once the point type on which the edge type depends is imported, the data import of the corresponding edge type can be started. For example, only when the point tasks of point types B and C are all imported, can the edge type B_Edge_C be imported. The concurrent import mechanism can effectively reduce the total time consumed in data import, especially when processing large-scale graph data sets. The performance improvement is particularly obvious. At the same time, the introduction of the point-edge dependency tree and the dynamic status monitoring mechanism ensure the existence of the dependent point type data before the edge type data is imported, avoiding the risk of data inconsistency and import failure.

[0033] In order to flexibly perform error handling and logging, this embodiment also integrates error handling logic and logging functions to ensure that any exceptions encountered during the concurrent import process can be properly recorded and handled, thereby ensuring the robustness of data import.

[0034] Specifically, data will be verified before importing. The verification content includes whether the data used as the primary key of the point cannot be empty, whether the data type of the primary key data meets the data type requirements in the Schema set by the library, etc. These non-compliant data will be recorded separately as dirty data, for example: recorded in the dirty / directory. When importing data in batches, if the import fails, the batch data will be split into single data and re-imported. This logic can minimize the amount of failed data and avoid the failure of the entire batch data due to a problem with one piece of data in the batch data. Finally, the data that still fails when importing a single data will be recorded separately as failed import data, for example: recorded in the failed / directory, and the reason for the import failure will be output in the log to facilitate users to adjust the data.

[0035] Example 2

[0036] like Figure 3 As shown, a device for implementing concurrent import of graph database data based on a dependency tree according to Embodiment 2 of the present application includes: A construction module 100 is used to construct a point-edge dependency tree including point-edge dependency relationships; Monitoring module 200, used to monitor and record the import status of point types; The import module 300 is used to concurrently execute the import task of the point type and the import task of the edge type in the first state, wherein, according to the point-edge dependency tree and the import state of the point type, it is judged whether all the point types that the edge type depends on have been imported. If the judgment result is yes, the corresponding edge type enters the first state.

[0037] It should be noted that other specific implementations of the device for implementing concurrent import of graph database data based on the dependency tree in this embodiment can be found in the specific implementations of the method for implementing concurrent import of graph database data based on the dependency tree mentioned above. To avoid redundancy, they will not be repeated here.

[0038] Example 3

[0039] A computer program product involved in Example 3 of the present application is used to store a computer program. When the computer program runs on a computer, the method in any one of the implementation modes in Example 1 of the present application is implemented.

[0040] Example 4

[0041] A computer-readable storage medium according to Embodiment 4 of the present application, wherein the computer-readable storage medium stores a program code for execution by a device, wherein the program code includes steps for executing a method in any one of the implementations in Embodiment 1 of the present application; Among them, the computer-readable storage medium can be a read-only memory (ROM), a static storage device, a dynamic storage device or a random access memory (RAM); the computer-readable storage medium can store program code, and when the program stored in the computer-readable storage medium is executed by the processor, the processor is used to execute the steps of the method in any one of the implementation methods in Example 1 of the present application.

[0042] Example 5

[0043] like Figure 4As shown, an electronic device involved in Embodiment 5 of the present application includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor, and when the program or instruction is executed by the processor, a method in any one of the implementations in Embodiment 1 of the present application is implemented; Among them, the processor can adopt a general-purpose central processing unit (CPU), a microprocessor, an application specific integrated circuit (ASIC), a graphics processing unit (GPU) or one or more integrated circuits to execute relevant programs to implement the method in any one of the implementation methods in Example 1 of the present application.

[0044] The processor may also be an integrated circuit electronic device with signal processing capability. In the implementation process, each step of the method in any implementation of Embodiment 1 of the present application may be completed by an integrated logic circuit of hardware in the processor or by instructions in software form.

[0045] The above-mentioned processor may also be a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed by a hardware decoding processor, or may be executed by a combination of hardware and software modules in a decoding processor. The software module may be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor reads the information in the memory, and completes the functions required to be performed by the unit included in the data processing device of the embodiment of the present application in combination with its hardware, or executes the method in any one of the implementation modes in the embodiment 1 of the present application.

[0046] The above are only preferred specific implementations of the present application; however, the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical solution and its improved ideas of the present application within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.

Claims

1. A method for concurrently importing graph database data based on a dependency tree, characterized in that: include: Build a vertex-edge dependency tree containing vertex-edge dependency relationships; Monitor and record the import status of point types; The import task of the point type is executed concurrently with the import task of the edge type in the first state, wherein it is determined whether all point types that the edge type depends on have been imported based on the point-edge dependency tree and the import state of the point type; if the judgment result is yes, the corresponding edge type enters the first state.

2. The method for concurrently importing graph database data based on dependency tree according to claim 1 is characterized in that: Build a vertex-edge dependency tree containing vertex-edge dependencies, including: Analyze metadata information of the graph database, wherein the metadata information includes edge types and source and target types of the edges; A dependency tree is established according to the metadata information, wherein the dependency tree includes the node types that each edge type depends on.

3. The method for concurrently importing graph database data based on dependency tree according to claim 1 is characterized in that: Monitor and record the import status of point types, including: Before importing data, obtain the point types included in the import task and set the import status of all point types to incomplete; Real-time tracking of whether the data of each point type is successfully imported; If the point type data is successfully imported, the import status of the corresponding point type will be changed to completed.

4. The method for concurrently importing graph database data based on dependency tree according to claim 3 is characterized in that: The import status of the point type is maintained through a Map structure, wherein the key represents the point type and the value represents the import status of the point type.

5. The method for concurrently importing graph database data based on dependency tree according to claim 1 is characterized in that: The import task of an edge type is automatically started within a specified time after the edge type enters the first state.

6. The method for concurrently importing graph database data based on dependency tree according to claim 1 is characterized in that: Also includes: Before data import, the data is verified and the data that fails the verification is recorded. During the data import process, if the batch data import fails, the batch data is split into single data and re-imported. If the import of a single data fails, the single data that failed to be imported and the reason for the import failure are recorded.

7. A device for concurrently importing graph database data based on a dependency tree, characterized in that: include: The construction module is used to construct a vertex-edge dependency tree containing vertex-edge dependency relationships; Monitoring module, used to monitor and record the import status of point types; An import module is used to concurrently execute the import task of the point type and the import task of the edge type in the first state, wherein, according to the point-edge dependency tree and the import state of the point type, it is judged whether all the point types that the edge type depends on have been imported. If the judgment result is yes, the corresponding edge type enters the first state.

8. A computer program product, characterized in that The computer program product stores computer instructions, and when the computer instructions are executed by a processor, the method according to any one of claims 1 to 6 is implemented.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program code for execution by a device, wherein the program code includes steps for executing the method according to any one of claims 1 to 6.

10. An electronic device, characterized in that: The electronic device comprises a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction implements the method as claimed in any one of claims 1 to 6 when executed by the processor.

Citation Information

Patent Citations

  • Graph data storage method, device, equipment and readable storage medium

    CN111694834A

  • Data importing method and device of graph database, storage medium and electronic equipment

    CN113468275A

  • Graph database data importing method and system, electronic equipment and medium

    CN116992065A

  • Graph data importing method, electronic equipment and graph data importing system

    CN118568142A

Cited By

  • GQL graph database data importing method and device

    CN119577018A