An operation method for a graph database and related devices
By storing and managing nodes, edges and their attributes in the graph database independently, and prohibiting operations when nodes or edges are locked, the conflict problems caused by multiple people's simultaneous operations are solved, and the performance of the graph database is improved.
Patent Information
- Application Number
- CN202411680248.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-21
- Publication Date
- 2025-07-29
- Estimated Expiration
- 2044-11-21
AI Technical Summary
In the graph database, conflicts and confusion are easily caused when multiple people operate on the same node or edge and its attributes at the same time, resulting in performance degradation.
The nodes, edges and their attributes in the graph database are stored and managed independently, and operations are prohibited when the nodes or edges are locked. All attributes of nodes or edges are also prohibited when they are locked. By obtaining user operation statements, the object to be operated is parsed and the locking process is performed.
It avoids conflicts and confusion when multiple people operate simultaneously, and allows multiple users to operate on different attributes of the same node or edge at the same time, improving the performance of the graph database.
Smart Images

Figure CN119166648B_ABST
Abstract
Description
Technical Field
[0001] One or more embodiments of this specification relate to the field of database technology, and in particular, to an operation method for a graph database and related devices. Background Art
[0002] A graph database is a database system specifically designed for storing and querying graph data. Graph data mainly includes nodes, edges, and properties of nodes and edges. Among them, nodes represent entities, edges represent relationships between entities, and properties are usually key-value pairs attached to nodes or edges to describe the characteristics of nodes or edges.
[0003] In many cases, there are often situations where multiple people operate on the same node or edge and its properties in a graph database simultaneously. For example, user A is deleting a node X in the graph database, while user B wants to modify a property of the node X. There is a conflict between the two. If the operation of user A is submitted first, then the operation of user B will error because the node X cannot be found in the graph database, seriously affecting the user experience and reducing the database performance. Summary of the Invention
[0004] In view of this, one or more embodiments of this specification provide an operation method for a graph database and related devices.
[0005] In a first aspect, this specification provides an operation method for a graph database, where the graph database includes nodes, edges, and properties of the nodes and edges; among them, when the node or edge is locked, operating on the node or edge, and all properties of the node or edge is prohibited, and when any property among all properties of the node or edge is locked, operating on the property and the node or edge is prohibited; the method includes:
[0006] Obtain an operation statement initiated by a user for the graph database;
[0007] Parse the operation statement, and determine an object to be operated on according to the parsing result; where the object to be operated on includes any one of a target node, a target edge, a target property of the target node, and a target property of the target edge;
[0008] Determine whether the object to be operated on has been prohibited from being operated on. If not, perform a locking process on the object to be operated on, and after the locking is completed, execute several operations included in the operation statement on the object to be operated on.
[0009] Second aspect, this specification provides an operating device for a graph database, where the graph database includes nodes and edges, and attributes of the nodes and edges; wherein, when a node or an edge is locked, operating on the node or the edge, and all attributes of the node or the edge is prohibited, and when any one of all attributes of the node or the edge is locked, operating on this attribute, and the node or the edge is prohibited; the device includes:
[0010] An obtaining unit, configured to obtain an operation statement initiated by a user for the graph database;
[0011] A determining unit, configured to parse the operation statement and determine an object to be operated according to the parsing result; wherein, the object to be operated includes any one of a target node, a target edge, a target attribute of a target node, and a target attribute of a target edge;
[0012] An operation execution unit, configured to determine whether the object to be operated has been prohibited from being operated. If not, perform a locking process on the object to be operated, and after the locking is completed, execute several operations included in the operation statement on the object to be operated.
[0013] Correspondingly, this specification also provides a computing device, including: a memory and a processor; a computer program / instructions that can be run by the processor is stored on the memory; when the processor runs the computer program / instructions, it executes the operation method for the graph database described in the first aspect above.
[0014] Correspondingly, this specification also provides a computer-readable storage medium, on which a computer program / instructions is stored. When the computer program / instructions is run by a processor, it executes the operation method for the graph database described in the first aspect above.
[0015] Correspondingly, this specification also provides a computer program product, the computer program product includes computer program / instructions. When the computer program / instructions is executed by a processor, it executes the operation method for the graph database described in the first aspect above.
[0016] In summary, in the present application, nodes, edges, attributes of nodes, and attributes of edges in the graph database can all be locked individually. Moreover, when a node or an edge is locked, operations on that node or edge, as well as all attributes of that node or edge, are prohibited. When any one of the attributes of all attributes of a node or an edge is locked, operations on that attribute, as well as that node or edge, are prohibited. Based on this, when the graph database receives an operation statement initiated by a user, it can first determine whether the object to be operated on in the operation statement is prohibited from being operated on. If it is not prohibited from being operated on, then the object to be operated on can be locked and the corresponding operation can be executed to prohibit other users from operating on the object to be operated on simultaneously. In this way, conflicts and chaos situations generated when multiple people operate on the same node or edge and their attributes in the graph database at the same time are avoided. Moreover, since each attribute of a node or an edge can be locked individually, multiple different users are allowed to operate on different attributes of the same node or edge simultaneously, reducing the situation of multi-user blocking and improving the performance of the graph database. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 is a schematic diagram of a system architecture provided by an exemplary embodiment;
[0018] Figure 2 is a schematic flowchart of an operation method for a graph database provided by an exemplary embodiment;
[0019] Figure 3 is a schematic flowchart of a process for multiple people to edit a graph model provided by an exemplary embodiment;
[0020] Figure 4 is a schematic diagram of the structure of an operation device for a graph database provided by an exemplary embodiment;
[0021] Figure 5 is a schematic diagram of the structure of a computing device provided by an exemplary embodiment. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0022] Here, the exemplary embodiments will be described in detail, and the examples are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with one or more embodiments of this specification. On the contrary, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.
[0023] It should be noted that: In other embodiments, the steps of the corresponding method are not necessarily executed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may also be combined into a single step for description in other embodiments.
[0024] It should be noted that the "multiple" referred to in this application means two or more.
[0025] In addition, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data that have been authorized by the user or fully authorized by all parties. And the collection, use, and processing of relevant data need to comply with relevant laws, regulations, and standards of relevant countries and regions, and corresponding operation entrances are provided for users to choose to authorize or reject.
[0026] As mentioned above, in many cases, there are often situations where multiple people operate on the same node or edge and its attributes in the graph database simultaneously. For example, user A is deleting a node X in the graph database, while user B wants to modify an attribute of the node X. There is a conflict between the two. If the operation of user A is submitted first, then the operation of user B will be in error because the node X cannot be found in the graph database, seriously affecting the user experience and reducing the database performance.
[0027] In addition, it should be noted that in a conventional graph database, nodes, edges, and their attributes are usually managed uniformly because they together constitute the complete structure of the graph data. This unified management method simplifies the data model and makes querying and operation more intuitive and efficient. For example, all attributes of a node are stored in the same data row of a data table. Based on this, in some possible implementation manners, in order to avoid conflicts generated when different users operate on the same node or edge and its attributes simultaneously, the node or edge and its attributes can be locked uniformly. For example, the above-mentioned user A can first lock the node X and its attributes uniformly (such as using a row-level lock to lock the data row where the node X and its attributes are located), thereby prohibiting other users from operating on the node X and its attributes.
[0028] However, nodes and edges usually have multiple attributes, and different users may also want to operate on different attributes of the same node respectively. There is no conflict between the two and they can be carried out simultaneously. If the node and its attributes are directly locked uniformly at this time, it will instead cause user congestion and reduce the database performance.
[0029] Based on this, this specification provides a technical solution that allows nodes, edges, node attributes, and edge attributes in a graph database to be locked separately. Moreover, when a node or an edge is locked, operations on that node or edge, as well as all attributes of that node or edge, are prohibited. When any one of all attributes of that node or edge is locked, operations on that attribute, as well as that node or edge, are prohibited. Based on this, when the graph database receives an operation statement initiated by a user, it can first determine whether the object to be operated on in the operation statement is prohibited from being operated on. If it is not prohibited from being operated on, it can lock the object to be operated on and execute several operations included in the operation statement to prohibit other users from operating on the object to be operated on simultaneously. In this way, conflicts and chaos situations generated when multiple people operate on the same node or edge and their attributes in the graph database at the same time are avoided. Moreover, since each attribute of a node or an edge can be locked separately, multiple different users are allowed to operate on different attributes of the same node or edge simultaneously, reducing the situation of multi-user blocking and improving the performance of the graph database.
[0030] Please refer to Figure 1 , Figure 1 which is a schematic diagram of a system architecture provided by an exemplary embodiment. One or more embodiments provided in this specification can be specifically implemented in the Figure 1 system architecture shown or a similar system architecture. As Figure 1 shown, the system architecture can include a computing device 100 and a computing device 200. Among them, a graph database server is installed in the computing device 100, and a graph database client is installed in the computing device 200.
[0031] In an illustrated embodiment, the graph database client in the computing device 200 can provide a visualization interface related to the graph database. A graph model of the graph database can be displayed in the visualization interface. Among them, the graph model is the basis of the graph database, and the nodes, edges, and attributes of the nodes and edges in the graph database are defined in the graph model.
[0032] In an illustrated embodiment, the nodes and edges defined in the graph model, as well as the attributes of the nodes and edges, can be stored and managed separately and independently, that is, the nodes and edges are stored in one location and managed independently, and the attributes of the nodes and edges are stored in another location and managed independently. For example, a node exists in one data row, and multiple attributes of the node are stored in multiple other data rows. The same applies to the node and its attributes.
[0033] Alternatively, in one illustrated embodiment, nodes, edges, attributes of nodes, and attributes of edges can all be stored and managed separately and independently, that is, nodes are stored in one location and managed independently, edges are stored in another location and managed independently, attributes of nodes are stored in another location and managed independently, and attributes of edges are also stored in another location and managed independently. This specification does not make specific limitations on this.
[0034] In this way, nodes, edges, attributes of nodes, and attributes of edges in the graph database can all be locked separately. And, to prevent operation conflicts, when a node or an edge is locked, operations on that node or edge, and all attributes of that node or edge can be prohibited. When any one of all attributes of a node or an edge is locked, operations on that attribute, and that node or edge can be prohibited.
[0035] In one illustrated embodiment, a user can perform editing operations on the graph model displayed in the visual interface provided by the graph database client through an input device (such as a mouse, a keyboard, or a touch screen, etc.) provided by the computing device 200. Specifically, it can be editing operations on nodes, edges, attributes of nodes, or attributes of edges defined in the graph model.
[0036] Exemplarily, the editing operation on the graph model can be deleting a node or an edge defined in the graph model, or modifying the originally defined node type, or adding a new attribute to a node or an edge, or modifying the data type of an existing attribute, etc. This specification does not make specific limitations on this.
[0037] Furthermore, the graph database client in the computing device 200 can generate a corresponding operation statement in response to an editing operation on the graph model input by the user, and send the operation statement to the graph database server (i.e., the graph engine) in the computing device 100. In one illustrated embodiment, the operation statement can be a Data Definition Language (DDL) statement. This specification does not make specific limitations on this.
[0038] Correspondingly, the graph database server in the computing device 100 can obtain the operation statement sent by the graph database client. Then, the graph database server can parse the operation statement and determine the object to be operated according to the parsing result. Among them, the object to be operated can be any one of the target nodes, target edges, target attributes of target nodes, and target attributes of target edges among several nodes, edges, and their attributes defined in the graph model. It should be noted that the target attribute of a target node refers to one of several attributes of the target node. Similarly, the target attribute of a target edge refers to one of several attributes of the target edge. The two target attributes are not the same.
[0039] Further, the graph database server can determine whether the object to be operated on has been prohibited from being operated on. If the object to be operated on has been prohibited from being operated on, the current operation cannot be executed; if the object to be operated on has not been prohibited from being operated on, the graph database server can lock the object to be operated on, and after the locking is completed, perform a number of operations included in the operation statement on the object to be operated on. For specific reference, Figure 2 please refer to the description in the corresponding embodiment, which will not be elaborated here.
[0040] In this way, by separately storing and managing the nodes and edges in the graph database, as well as the attributes of the nodes and edges independently, the nodes and edges can be locked separately, and each attribute of the nodes and edges can also be locked separately. In this way, not only is it possible to avoid the conflicts and chaos that occur when multiple people operate on the same node or edge and its attributes in the graph database at the same time, but also because each attribute can be locked separately, it is thus allowed that multiple different users can operate on different attributes of the same node or edge at the same time, reducing the situation of multi-user blocking and improving the performance of the graph database.
[0041] In an illustrated embodiment, Figure 1 the illustrated computing device 100 can be a server with the above functions, or a server cluster composed of multiple servers; the computing device 200 can be a smart wearable device, a smart phone, a tablet computer, a laptop computer, a desktop computer, etc. with the above functions. This specification does not make specific limitations on this.
[0042] It should be understood that Figure 1 the illustrated system architecture is only for exemplary illustration. In some possible embodiments, the system architecture may further include other devices. For example, it may further include multiple computing devices 200 used by other multiple users, etc. This specification does not make specific limitations on this.
[0043] Please refer to Figure 2 , Figure 2 which is a schematic flowchart of an operation method for a graph database provided by an exemplary embodiment. This method can be applied to Figure 1 the illustrated system architecture, and specifically can be applied to Figure 1 the graph database server in the illustrated system architecture. The graph database includes nodes and edges, as well as the attributes of the nodes and edges; among them, the nodes and edges, as well as the attributes of the nodes and edges are stored and managed independently. As Figure 2 shown, this method can specifically include the following steps S201 - step S203.
[0044] Step S201: Obtain an operation statement initiated by a user for the graph database. The graph database contains nodes, edges, and attributes of nodes and edges. Among them, when a node or an edge is locked, operations on the node or the edge, and all attributes of the node or the edge are prohibited. When any one of the attributes of all attributes of a node or an edge is locked, operations on the attribute and the node or the edge are prohibited.
[0045] In an illustrated embodiment, as described above, the graph database server can obtain an operation statement initiated by a user through the graph database client, specifically an operation statement for the graph model in the graph database. For details, reference can be made to the description in the corresponding embodiment above, and details will not be elaborated here. Figure 1 Corresponding to the description in the embodiment, details will not be elaborated here.
[0046] As described above, nodes, edges, and attributes of nodes and edges are defined in the graph model. Moreover, nodes, edges, and attributes of nodes and edges are stored and managed independently, and can be locked separately. And when a node or an edge is locked, operations on the node or the edge, and all attributes of the node or the edge are prohibited. When any one of the attributes of all attributes of a node or an edge is locked, operations on the attribute and the node or the edge are prohibited.
[0047] In an illustrated embodiment, nodes and edges can be stored in a first data table, and attributes of nodes and edges can be stored in a second data table. Or, in an illustrated embodiment, nodes can be stored in a first data table, edges can be stored in a second data table, attributes of nodes can be stored in a third data table, and attributes of edges can be stored in a fourth data table. This specification does not make specific limitations in this regard.
[0048] It should be noted that the above-mentioned first data table, second data table, third data table, and fourth data table can be different data tables, or different partitions of the same data table. This specification does not make specific limitations in this regard.
[0049] Specifically, the graph model can include metadata of nodes and edges, and metadata of attributes of nodes and edges. These metadata constitute the definitions of nodes, edges, and their attributes. Among them, the fact that nodes, edges, and attributes of nodes and edges are stored and managed independently can mean that the metadata of nodes and edges, and the metadata of attributes of nodes and edges are stored and managed independently. Correspondingly, the fact that nodes and edges are stored in the first data table can mean that the metadata of nodes and edges are stored in the first data table, and the metadata of different nodes and edges can be located in different data rows of the first data table. Correspondingly, the fact that attributes of nodes and edges are stored in the second data table can mean that the metadata of attributes of nodes and edges are stored in the second data table, and the metadata of different attributes of nodes and edges can be located in different data rows of the second data table.
[0050] Correspondingly, when a node or an edge is locked, operating on the node or the edge and all attributes thereof may mean that when the data row where the metadata of the node or the edge is located is locked, operating on the data row where the node or the edge is located and the data rows where all attributes thereof are located is prohibited. Correspondingly, when any one of all attributes of a node or an edge is locked, operating on the attribute and the node or the edge may mean that when the data row where the metadata of any one of all attributes of the node or the edge is located is locked, operating on the data row where the metadata of the attribute is located and the data row where the metadata of the node or the edge is located is prohibited.
[0051] In an illustrated embodiment, the metadata of a node may include a node type (type), such as a company node, an employee node, a user node, or a commodity node, and so on.
[0052] In an illustrated embodiment, the metadata of an edge may include an edge type, the start type of the edge (such as the above user node or commodity node, etc.) and the end type (such as the above user node or commodity node, etc.).
[0053] In an illustrated embodiment, the metadata of the attributes of a node may include an attribute type (or an attribute name), such as types like name, position, and length of service, etc., and may also include the data type of the attribute value. For example, the data type of a name may be a string type (string), the data type of a position may also be string, and the data type of the length of service may be an integer type, such as Integer or long, etc. This specification does not make specific limitations thereto.
[0054] In an illustrated embodiment, the metadata of the attributes of an edge may include an attribute type, such as types like superior-subordinate relationship, friend relationship, purchase relationship, and relationship start time, etc., and may also include the data type of the attribute value. For example, the data types of the superior-subordinate relationship, friend relationship, and purchase relationship may be boolean (boole), and the data type of the relationship start time may be a date (date), etc. This specification does not make specific limitations thereto.
[0055] Exemplarily, a code example of a graph model may be as follows:
[0056] "node":
[0057] [{
[0058] "typeName":"person"
[0059] "properties":{
[0060] "name":"string"
[0061] }
[0062] }]
[0063] "edge":
[0064] [{
[0065] "type":"edge1"
[0066] "src_type":"person"
[0067] "dst_type":"person"
[0068] "properties":{
[0069] "friends": boolean
[0070] }
[0071] }]
[0072] As shown above, the graph model defines a node type of person, a node attribute type of name, and a string attribute value. The edge type is edge1, the source type (src_type) of the edge is person, the destination type (dst_type) of the edge is also person, and the attribute type of the edge is friend relationship, and the attribute value of this attribute type is boolean.
[0073] In one illustrated embodiment, assuming that node and edge metadata are stored in a first data table, and node and edge attribute metadata are stored in a second data table, the node "person" can be stored in a row in the first data table, and the attribute "name": "string" can be stored in a row in the second data table and associated with the node "person." Similarly, the edge "edge1" can be stored in a row in the first data table, and the attribute "friend": boolean can be stored in a row in the second data table and associated with the edge "edge1."
[0074] Step S201 , parsing the operation statement, and determining the object to be operated on the operation statement according to the parsing result; wherein the object to be operated on includes any one of a target node, a target edge, a target attribute of a target node, and a target attribute of a target edge.
[0075] Further, the graph database server can parse the obtained operation statements and determine the objects to be operated on according to the parsing results. Among them, the objects to be operated on may be any one of the target nodes, target edges, target attributes of the target nodes, and target attributes of the target edges defined in the graph model. This specification does not make specific limitations in this regard. Or, in some possible implementation manners, the objects to be operated on may also be any combination of the target nodes, target edges, target attributes of the target nodes, and target attributes of the target edges, and may also be multiple target nodes, multiple target edges, or multiple target attributes of the target nodes, or may be multiple target attributes of the target edges, etc. This specification does not make specific limitations in this regard.
[0076] Step S203: Determine whether the object to be operated on has been prohibited from being operated. If not, perform a locking process on the object to be operated on, and after the locking is completed, perform several operations included in the operation statement on the object to be operated on.
[0077] Further, after determining the object to be operated on, the graph database server can further determine whether the object to be operated on has been prohibited from being operated. In an illustrated implementation manner, if the object to be operated on has been prohibited from being operated, the current operation cannot be executed. In an illustrated implementation manner, if the object to be operated on has not been prohibited from being operated, the graph database server can perform a locking process on the object to be operated on, and after the locking is completed, perform several operations included in the operation statement on the object to be operated on. Further, after the several operations are completed, the graph database server can perform a release process on the lock of the object to be operated on.
[0078] In an illustrated implementation manner, assume that the object to be operated on is a target node. When the graph database server determines whether the object to be operated on has been prohibited from being operated and, if not, performs a locking process on the object to be operated on, it may specifically include: determining whether the target node has been locked; if the target node has not been locked, further determining whether several attributes of the target node have been locked; if several attributes (or all attributes) of the target node have not been locked, it can be determined that the target node has not been prohibited from being operated, and then a locking process can be performed on the target node to prohibit other users from performing operations on the target node and all attributes of the target node.
[0079] Further, after the locking is completed, the graph database server can perform several operations included in the operation statement on the target node, such as deleting the target node, or modifying the node type of the target node, etc. This specification does not make specific limitations in this regard.
[0080] Further, after several operations included in the operation statement are completed, the graph database server can release the lock on the target node so that other users can perform operations subsequently.
[0081] In an illustrated embodiment, assuming that the object to be operated on is a target edge, when the graph database server determines whether the object to be operated on has been prohibited from being operated on, and if not, when performing a locking process on the object to be operated on, it may specifically include: determining whether the target edge has been locked; if the target edge has not been locked, further determining whether several attributes of the target edge have been locked; if several attributes (or all attributes) of the target edge have not been locked, it can be determined that the target edge has not been prohibited from being operated on, and then the target edge can be locked to prohibit other users from performing operations on the target edge and all attributes of the target edge.
[0082] Further, after locking is completed, the graph database server can perform several operations included in the operation statement on the target edge, such as modifying the edge type of the target edge, modifying the start type of the target edge, or modifying the end type of the target edge, etc. This specification does not make specific limitations in this regard.
[0083] Further, after several operations included in the operation statement are completed, the graph database server can release the lock on the target edge so that other users can perform operations subsequently.
[0084] In an illustrated embodiment, assuming that the object to be operated on is a target attribute of a target node, when the graph database server determines whether the object to be operated on has been prohibited from being operated on, and if not, when performing a locking process on the object to be operated on, it may specifically include: determining whether the target node has been locked; if the target node has not been locked, further determining whether the target attribute of the target node has been locked; if the target attribute of the target node has not been locked, it can be determined that the target attribute of the target node has not been prohibited from being operated on, and then the target attribute of the target node can be locked to prohibit other users from performing operations on the target node and the target attribute of the target node.
[0085] Further, after locking is completed, the graph database server can perform several operations included in the operation statement on the target attribute of the target node, such as deleting the target attribute, adding the target attribute, or modifying the data type of the attribute value of the target attribute, etc. This specification does not make specific limitations in this regard.
[0086] Further, after several operations included in the operation statement are completed, the graph database server can release the lock on the target attribute of the target node so that other users can perform operations subsequently.
[0087] In an illustrated embodiment, assuming that the object to be operated on is the target attribute of the target edge, when the graph database server determines whether the object to be operated on has been prohibited from being operated on, if not, when performing a locking process on the object to be operated on, it may specifically include: determining whether the target edge has been locked; if the target edge has not been locked, further determining whether the target attribute of the target edge has been locked; if the target attribute of the target edge has not been locked, it may be determined that the target attribute of the target edge has not been prohibited from being operated on, and then a locking process may be performed on the target attribute of the target edge to prohibit other users from performing operations on the target edge and the target attribute of the target edge.
[0088] Further, after the locking is completed, the graph database server may perform several operations included in the operation statement on the target attribute of the target edge, such as deleting the target attribute, adding the target attribute, or modifying the data type of the attribute value of the target attribute, etc., and this specification does not make specific limitations on this.
[0089] Further, after the several operations included in the operation statement are completed, the graph database server may perform a release process on the lock of the target attribute of the target edge so that other users can perform operations subsequently.
[0090] It should be noted that this specification does not make special limitations on the specific implementation manner of the locking process. In an illustrated embodiment, the graph database server may adopt a row-level lock when performing the locking process.
[0091] In an illustrated embodiment, assuming that the nodes and edges defined in the graph model are stored in a first data table, and the metadata of the target node or the target edge is located in the corresponding first data row in the first data table, when the above graph database server determines whether the target node or the target edge has been locked, it may specifically include: determining whether the first data row where the metadata of the target node or the target edge is located has been locked.
[0092] It should be noted that the first data row described in the embodiments of this specification is used to refer to the data row where the target node or the target edge is located, and does not specifically refer to a fixed data row.
[0093] In an illustrated embodiment, assuming that the metadata of the attributes of the nodes and edges defined in the graph model is stored in a second data table, and the metadata of several attributes of the target node or the target edge is stored in several corresponding data rows in the second data table, when the graph database server determines whether several attributes of the target node or the target edge have been locked, it may specifically include: determining whether the several data rows where the metadata of several attributes of the target node or the target edge is located have been locked.
[0094] In an illustrated embodiment, assuming that the metadata of the target attribute of the target node or target edge is stored in the corresponding second data row of the second data table, when determining whether the target attribute of the target node or target edge has been locked, the graph database server may specifically include: determining whether the second data row where the metadata of the target attribute of the target node or target edge is located has been locked.
[0095] It should be noted that the second data row described in the embodiments of this specification is used to refer to the data row where the target attribute of the target node or target edge is located, and does not specifically refer to a fixed data row.
[0096] Correspondingly, when the graph database server performs a locking process on the target node or target edge, it may specifically include: performing a locking process on the first data row where the metadata of the target node or target edge is located. Further, after the locking is completed, several operations included in the above operation statement may be executed on the metadata of the target node or target edge recorded in the first data row. Further, after the operation is completed, the lock on the first data row may be released.
[0097] Correspondingly, when the graph database server performs a locking process on the target attribute of the target node or target edge, it may specifically include: performing a locking process on the second data row where the metadata of the target attribute of the target node or target edge is located. Further, after the locking is completed, several operations included in the above operation statement may be executed on the metadata of the target attribute of the target node or target edge recorded in the second data row. Further, after the operation is completed, the lock on the second data row may be released.
[0098] In an illustrated embodiment, after the locking is completed, the graph database server may also notify other users that the current object to be operated on has been locked, and send the updated version of the current graph model to other users, etc., which are not specifically limited in this specification.
[0099] Exemplarily, please refer to Figure 3 , Figure 3 is a schematic flowchart of a process for multiple users to edit a graph model provided by an exemplary embodiment. As Figure 3 shown, several nodes and edges and their attributes are defined in the graph model, and the graph model is split into two parts, one part is the nodes and edges, and the other part is the attributes of the nodes and edges. That is to say, the nodes and edges in the graph model, as well as the attributes of the nodes and edges, are stored and managed independently. Specifically, as As shown in the figure, the graph model includes: node x, two attributes of node x (x1: long and x2: string respectively), node y, two attributes of node y (y1: long and y2: string respectively), edge z, and two attributes of edge z (z1: boole and z2: string).
[0100] As shown, the graph model can be output and displayed to the user in a visual interface so that the user can edit and modify any node, edge, and their attributes in the graph model.
[0101] As shown, when user A edits the graph model and wants to modify node x in the graph model, specifically, a new attribute x3: long is added to node x. As shown, after the graph database server receives the operation statement initiated by user A for this graph model, it can determine the object to be operated on as the attribute x3: long of node x by parsing the operation statement. Further, after the graph database server determines that the current node x is not locked and the attribute x3: long is not locked either, the graph database server can lock the attribute x3: long to successfully add the attribute x3: long. In addition, other users can also receive the new version of the graph model with the added attribute x3: long sent by the graph database server.
[0102] As shown, when user B edits the graph model and also wants to modify node x in the graph model, specifically, the data type of the attribute x1: long of node x is changed from long to string. As shown, after the graph database server receives the operation statement initiated by user B for this graph model, it can determine the object to be operated on as the attribute x1: long of node x by parsing the operation statement. Further, after the graph database server determines that the current node x is not locked and the attribute x1: long is not locked either, the graph database server can lock the attribute x1: long and change its data type to string. In addition, other users can also receive the new version of the graph model containing the modified attribute x1: string sent by the graph database server.
[0103] As shown, after the operations of user A and user B are submitted, that is, after the above modifications are officially written to the disk, the attributes of node x in the graph model can include: x1: string, x2: string, x3: long.
[0104] As As shown, when user C edits the graph model and wants to modify node y in the graph model, specifically, a new attribute y3: long is added to node y. As shown, after the graph database server receives the operation statement for this graph model initiated by user C, it can determine the object to be operated on as the attribute y3: long of node y by parsing the operation statement. Further, after the graph database server determines that the current node y is not locked and the attribute y3: long is not locked either, the graph database server can perform a locking process on the attribute y3: long to successfully add the attribute y3: long. In addition, other users can also receive the new version of the graph model with the added attribute y3: long sent by the graph database server.
[0105] As shown, after the operation of user C is submitted, that is, after the above modification is officially written to the disk, the attributes of node y in the graph model can include: y1: long, y2: string, y3: long.
[0106] In this way, by storing and managing the nodes and edges in the graph model, as well as the attributes of the nodes and edges separately and independently, the present application enables the nodes and edges, as well as the attributes of the nodes and edges, to be locked individually, which allows users A, B, and C shown to edit the graph model simultaneously. They can not only edit nodes x and y simultaneously, but also edit different attributes (x1 and x3) of node x simultaneously, and there are no conflicts between them, meeting the usage requirements of users and greatly improving the performance of the graph database.
[0107] Corresponding to the implementation of the above method flow, the embodiments of this specification also provide an operation device for a graph database. Please refer to , which is a schematic structural diagram of an operation device for a graph database provided by an exemplary embodiment. The device 40 can be applied to the system architecture shown, and specifically can be applied to the graph database server in the system architecture shown; the graph database contains nodes and edges, as well as the attributes of the nodes and edges; among them, when a node or an edge is locked, operating on the node or the edge, as well as all the attributes of the node or the edge, is prohibited, and when any one of all the attributes of a node or an edge is locked, operating on the attribute, as well as the node or the edge, is prohibited. As shown, the device 40 includes:
[0108] An acquisition unit 401, configured to acquire an operation statement initiated by a user for the graph database;
[0109] A determination unit 402, configured to parse the operation statement and determine an object to be operated on according to the parsing result; wherein, the object to be operated on includes any one of a target node, a target edge, a target attribute of the target node, and a target attribute of the target edge.
[0110] An operation execution unit 403, configured to determine whether the object to be operated on has been prohibited from being operated on. If not, perform a locking process on the object to be operated on, and after the locking is completed, execute a number of operations included in the operation statement on the object to be operated on.
[0111] In an illustrated embodiment, the apparatus 40 further includes a lock release unit 404, configured to:
[0112] After the number of operations is executed, perform a release process on the lock of the object to be operated on.
[0113] In an illustrated embodiment, the object to be operated on is the target node or the target edge; the operation execution unit 403 is specifically configured to:
[0114] Determine whether the target node or the target edge has been locked.
[0115] If the target node or the target edge has not been locked, further determine whether all attributes of the target node or the target edge have been locked.
[0116] If all attributes of the target node or the target edge have not been locked, determine that the target node or the target edge has not been prohibited from being operated on, and perform a locking process on the target node or the target edge.
[0117] In an illustrated embodiment, the object to be operated on is a target attribute of the target node or the target edge; the operation execution unit 403 is specifically configured to:
[0118] Determine whether the target node or the target edge has been locked.
[0119] If the target node or the target edge has not been locked, further determine whether the target attribute of the target node or the target edge has been locked.
[0120] If the target attribute of the target node or the target edge has not been locked, determine that the target attribute of the target node or the target edge has not been prohibited from being operated on, and perform a locking process on the target attribute of the target node or the target edge.
[0121] In an illustrated embodiment, metadata of the nodes and edges, as well as metadata of attributes of the nodes and edges, are defined in the graph model of the graph database; wherein, the metadata of the nodes and edges, and the metadata of the attributes of the nodes and edges are stored and managed independently.
[0122] In an illustrated embodiment, the metadata of the nodes includes node types, and the metadata of the edges includes edge types, start types of the edges, and end types of the edges; the metadata of the attributes includes attribute types and data types of attribute values.
[0123] In an illustrated embodiment, the metadata of the nodes and edges is stored in a first data table, and the metadata of the target node or the target edge is located in a corresponding first data row in the first data table;
[0124] The operation execution unit 403 is specifically configured to:
[0125] Lock the first data row where the metadata of the target node or the target edge is located;
[0126] Execute a number of operations included in the operation statement on the metadata of the target node or the target edge.
[0127] In an illustrated embodiment, the metadata of the attributes of the nodes and edges is stored in a second data table, and the metadata of the target attribute of the target node or the target edge is located in a corresponding second data row in the second data table;
[0128] The operation execution unit 403 is specifically configured to:
[0129] Lock the second data row where the metadata of the target attribute of the target node or the target edge is located;
[0130] Execute a number of operations included in the operation statement on the metadata of the target attribute of the target node or the target edge.
[0131] In an illustrated embodiment, the operation statement is an operation statement for the graph model generated by the client of the graph database in response to an editing operation on the graph model displayed in the visualization interface provided by the client.
[0132] The acquisition unit 401 is specifically configured to: receive the operation statement for the graph model sent by the client.
[0133] In an illustrated embodiment, the operation statement is a DDL statement.
[0134] The implementation process of the functions and roles of each unit in the above-mentioned device 40 can be specifically referred to the description of the above-mentioned embodiments, and will not be elaborated here. It should be understood that the above-mentioned device 40 can be implemented by software, or by hardware or a combination of software and hardware. Taking software implementation as an example, as a device in a logical sense, it is formed by the processor (CPU) of the device where it is located reading the corresponding computer program instructions into the memory and running them. From a hardware perspective, in addition to the CPU and the memory, the device where the above-mentioned device is located usually also includes other hardware such as chips for wireless signal transceiver, and / or other hardware such as boards for implementing network communication functions.
[0135] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical modules, that is, they may be located in one place, or may be distributed to multiple network modules. Some or all of the units or modules can be selected according to actual needs to achieve the purpose of the solution in this specification. A person of ordinary skill in the art can understand and implement it without creative work.
[0136] The devices, units, and modules illustrated in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, and the specific form of the computer can be a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver device, a game console, a tablet computer, a wearable device, a vehicle-mounted computer, or a combination of any several of these devices.
[0137] Corresponding to the above method embodiments, the embodiments of this specification also provide a computing device. Please refer to , which is a schematic structural diagram of a computing device provided by an exemplary embodiment. The computing device shown can be the computing device 100 equipped with a graph database server in the system architecture shown in the figure. The graph database contains nodes and edges, and the attributes of nodes and edges. Among them, when a node or an edge is locked, operating on the node or the edge, and all the attributes of the node or the edge are prohibited. When any one of the attributes of all the attributes of a node or an edge is locked, operating on the attribute, and the node or the edge are prohibited. As As shown, the computing device includes a processor 1001 and a memory 1002, and may further include an input device 1004 (such as a keyboard, etc.) and an output device 1005 (such as a display, etc.). The processor 1001, the memory 1002, the input device 1004, and the output device 1005 may be connected via a bus or other means. As shown, the memory 1002 includes a computer-readable storage medium 1003, and the computer-readable storage medium 1003 stores a computer program that can be run by the processor 1001. The processor 1001 may be a CPU, a microprocessor, or an integrated circuit for controlling the execution of the above method embodiments. When the processor 1001 runs the stored computer program, it can execute each step of the operation method for the graph database in the embodiments of this specification, including: obtaining an operation statement initiated by a user for the graph database; parsing the operation statement, and determining an object to be operated according to the parsing result; wherein, the object to be operated includes any one of a target node, a target edge, a target attribute of the target node, and a target attribute of the target edge; determining whether the object to be operated has been prohibited from being operated, and if not, performing a locking process on the object to be operated, and after the locking is completed, performing several operations included in the operation statement on the object to be operated, and so on.
[0138] For a detailed description of each step of the above operation method for the graph database, please refer to the previous content, and details will not be repeated here.
[0139] Corresponding to the above method embodiments, an embodiment of this specification further provides a computer-readable storage medium, on which a computer program is stored, and when these computer programs are run by a processor, they execute each step of the operation method for the graph database in the embodiments of this specification. For details, please refer to the description of the above embodiments, and details will not be repeated here.
[0140] The above are only the preferred embodiments of this specification, and are not intended to limit this specification. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of this specification shall be included within the scope of protection of this specification.
[0141] In a typical configuration, a terminal device includes one or more CPUs, an input / output interface, a network interface, and a memory.
[0142] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM), and / or non-volatile memory in the form of, for example, read-only memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
[0143] A computer-readable medium includes both permanent and non-permanent, removable and non-removable media and can implement information storage by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data.
[0144] 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, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transitory medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media such as modulated data signals and carrier waves.
[0145] It should also be noted that the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, article or apparatus comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or apparatus. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or apparatus comprising the element.
[0146] Those skilled in the art should understand that the embodiments of this specification can be provided as a method, system or computer program product. Therefore, the embodiments of this specification can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the embodiments of this specification can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) containing computer-usable program code.
Claims
1. An operation method for a graph database, characterized in that, The graph database contains nodes and edges, as well as attributes of the nodes and edges; wherein, when a node or an edge is locked, operating on the node or the edge, as well as all attributes of the node or the edge is prohibited, and when any one of all attributes of the node or the edge is locked, operating on that attribute, as well as the node or the edge is prohibited; The method includes: Obtain an operation statement initiated by a user for the graph database; Parse the operation statement and determine an object to be operated on according to the parsing result; wherein, the object to be operated on includes any one of a target node, a target edge, a target attribute of the target node, and a target attribute of the target edge; Determine whether the object to be operated on has been prohibited from being operated on. If not, perform a locking process on the object to be operated on, and after the locking is completed, execute several operations included in the operation statement on the object to be operated on.
2. The method according to claim 1, wherein The method further includes: After the several operations are executed, perform a release process on the lock of the object to be operated on.
3. The method according to claim 1, wherein The object to be operated on is the target node or the target edge; The determining whether the object to be operated on has been prohibited from being operated on. If not, performing a locking process on the object to be operated on includes: Determine whether the target node or the target edge has been locked; If the target node or the target edge has not been locked, further determine whether all attributes of the target node or the target edge have been locked; If all attributes of the target node or the target edge have not been locked, determine that the target node or the target edge has not been prohibited from being operated on, and perform a locking process on the target node or the target edge.
4. The method according to claim 3, wherein The object to be operated on is the target attribute of the target node or the target edge; The determining whether the object to be operated on has been prohibited from being operated on. If not, performing a locking process on the object to be operated on includes: Determine whether the target node or the target edge has been locked; If the target node or the target edge has not been locked, further determine whether the target attribute of the target node or the target edge has been locked; If the target attribute of the target node or the target edge has not been locked, determine that the target attribute of the target node or the target edge has not been prohibited from being operated on, and perform a locking process on the target attribute of the target node or the target edge.
5. The method according to claim 4, characterized in that, In the graph model of the graph database, metadata of the nodes and edges, as well as metadata of the attributes of the nodes and edges are defined; wherein, the metadata of the nodes and edges, as well as the metadata of the attributes of the nodes and edges are stored and managed independently.
6. The method according to claim 5, characterized in that The metadata of the nodes includes node types, and the metadata of the edges includes edge types, starting point types and ending point types of the edges; The metadata of the attributes includes attribute types and data types of attribute values.
7. The method according to claim 5, characterized in that, The metadata of the nodes and edges is stored in a first data table, and the metadata of the target node or the target edge is located in a corresponding first data row in the first data table; The performing a locking process on the target node or the target edge includes: Performing a locking process on the first data row where the metadata of the target node or the target edge is located; Performing several operations included in the operation statement on the object to be operated on includes: Performing several operations included in the operation statement on the metadata of the target node or the target edge.
8. The method according to claim 5, wherein The metadata of the attributes of the node and the edge is stored in a second data table, and the metadata of the target attribute of the target node or the target edge is located in the corresponding second data row in the second data table; The locking process for the target attribute of the target node or the target edge includes: Performing a locking process on the second data row where the metadata of the target attribute of the target node or the target edge is located; Performing several operations included in the operation statement on the object to be operated on includes: Performing several operations included in the operation statement on the metadata of the target attribute of the target node or the target edge.
9. The method according to claim 5, characterized in that, The operation statement is generated by the client of the graph database in response to an editing operation on the graph model displayed in the visualization interface provided by the client for user input. Obtaining the operation statement initiated by the user for the graph database includes: receiving the operation statement for the graph model sent by the client.
10. The method according to any one of claims 1-9, characterized in that, The operation statement is a DDL statement.
11. An operating device for a graph database, characterized in that, The graph database includes nodes and edges, and attributes of the nodes and edges; wherein, when a node or an edge is locked, operating on the node or the edge, and all attributes of the node or the edge is prohibited, and when any one of all attributes of the node or the edge is locked, operating on the attribute and the node or the edge is prohibited; The apparatus includes: An obtaining unit for obtaining the operation statement initiated by the user for the graph database; A determining unit for parsing the operation statement and determining the object to be operated on according to the parsing result; wherein, the object to be operated on includes any one of a target node, a target edge, a target attribute of the target node, and a target attribute of the target edge; An operation execution unit for determining whether the object to be operated on has been prohibited from being operated on, and if not, performing a locking process on the object to be operated on, and after the locking is completed, performing several operations included in the operation statement on the object to be operated on.
12. A computing device, characterized in that, Including: A memory and a processor; The memory stores computer programs / instructions that can be run by the processor; When the processor runs the computer programs / instructions, it executes the method according to any one of claims 1-10.
13. A computer-readable storage medium, characterized in that, It stores computer programs / instructions thereon, and when the computer programs / instructions are executed by the processor, the method according to any one of claims 1-10 is implemented.
14. A computer program product, characterized in that, The computer program product includes computer programs / instructions, and when the computer programs / instructions are executed by the processor, the method according to any one of claims 1-10 is implemented.
Citation Information
Patent Citations
Method and device for processing data in tree structure, equipment and storage medium
CN112306991A
Graph data writing method and device
CN113672636A