Query methods, devices, and electronic equipment for real-time graph databases

By constructing a graph in a graph database and using a key-value database to store and update nodes and their second-degree neighbor relationships, the problem of low query efficiency in real-time graph databases is solved, enabling rapid graph updates and real-time queries, while reducing computational resource consumption and hardware costs.

CN116340579BActive Publication Date: 2026-04-17中国邮政储蓄银行股份有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
中国邮政储蓄银行股份有限公司
Filing Date
2023-03-16
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

Existing real-time graph databases have low query efficiency, making it difficult to achieve millisecond-level real-time updates and queries, and their high computational resource consumption leads to increased hardware costs.

Method used

By constructing a graph database, generating operation instructions, and using a key-value database to store and update graph data, nodes and their second-degree neighbor relationships are updated in real time, enabling fast queries.

Benefits of technology

It improves the real-time query efficiency of graph databases, reduces computing resource consumption, reduces hardware costs, and enables fast reading and real-time querying of graphs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116340579B_ABST
    Figure CN116340579B_ABST
Patent Text Reader

Abstract

This application provides a query method, apparatus, and electronic device for a real-time graph database. The method includes: constructing a graph database atlas based on the real-time graph database, the graph database atlas including multiple nodes; generating operation instructions based on the graph database atlas; and updating graph data in a key-value database and the graph data in the real-time graph database in real time, so that the key-value database is invoked for querying according to the operation instructions, and query results are generated. The key-value database stores each node and its corresponding neighbor relationships within two degrees of separation. A two-degree neighbor relationship is used to represent the existence of a node between two nodes, and there is a connection between all nodes. The neighbor relationship is the relationship between neighbor nodes within two degrees of separation. This achieves fast graph database updates and real-time querying during updates, thereby solving the problem of low search efficiency in existing real-time graph databases.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of database technology, and more specifically, to a query method, apparatus, computer-readable storage medium, and electronic device for a real-time graph database. Background Technology

[0002] As a representative of NoSQL databases, graph databases and graph technologies have been widely applied in information systems and services based on relational analysis and computation due to their significant advantages in relational storage, querying, and graph derivation algorithms. Graph databases and graph technologies are based on the concepts of nodes and edges, construct graphs based on the relationships between nodes and edges, and execute relational queries and a series of derivation algorithms.

[0003] Due to the relatively complex data structure of graph data and the high computational demands of graph query and derivation algorithms, the update and query speed of graph databases has always been a focal point in the field. Currently, there are many statistical dimensions for evaluating the update and query speed of graph databases. In practice, "real-time performance" is often used to summarize the query performance of graph databases. Graph databases with update and query performance in the millisecond range are generally referred to as "real-time graph databases." Based on the performance requirements of real-time features, ranked from lowest to highest, the basic concepts included in "real-time performance" are shown in Table 1.

[0004] Table 1. Conceptual table of database real-time performance indicators

[0005]

[0006] Currently, with the increasing demands for real-time data from various business needs, improving the performance of graph databases in real-time graph updates and real-time queries during updates has become a consensus among graph database vendors and a key challenge in technological iteration. At present, most graph database products support access to real-time data, but due to limitations in their own performance and computing resources, they generally have problems supporting real-time graph updates and real-time queries during updates: First, most graph databases can only achieve offline batch updates of the graph; second, although some graph databases support real-time graph updates, the real-time performance is mostly in the second range, and achieving millisecond-level performance is quite difficult; third, to improve real-time performance, graph databases often require a large amount of computing resources, resulting in high costs for the supporting hardware systems. Summary of the Invention

[0007] The main objective of this application is to provide a query method, apparatus, computer-readable storage medium, and electronic device for real-time graph databases, so as to at least solve the problem of low search efficiency of real-time graph databases in the prior art.

[0008] To achieve the above objectives, according to one aspect of this application, a query method for a real-time graph database is provided. The method includes: constructing a graph database graph based on the real-time graph database, the graph database graph including multiple nodes; generating an operation instruction based on the graph database graph, the operation instruction being used to instruct adjustments to the neighbor relationships between nodes in the graph database graph; and updating graph data in a key-value database and the graph data in the real-time graph database in real time, so that a query is performed on the key-value database according to the operation instruction to generate query results. The key-value database stores each node and its corresponding neighbor relationships within two degrees of separation, the two-degree neighbor relationship representing the existence of a node between two nodes and a connection between the nodes, the neighbor relationship being the relationship between neighbor nodes within two degrees of separation.

[0009] Optionally, querying the Key-value database according to the operation instruction to generate query results includes: when the operation instruction is to add an edge between the first target node and the second target node, querying the Key-value database to generate a first query result, wherein, when the first target node and the second target node are first-degree neighbors or have no neighbor relationship, the first query result is used to indicate that the first target node and the second target node have established a first-degree neighbor relationship, the first-degree neighbor relationship is used to indicate that there are no other nodes between the first target node and the second target node, and there is a connection between the first target node and the second target node; the no-node relationship is used to indicate that there are no other nodes between the first target node and the second target node, and there is no connection between the first target node and the second target node; when the operation instruction is to add an edge between the first target node and the second target node, querying the Key-value database to generate a second query result, wherein, when the first target node and the second target node are second-degree neighbors, the second query result is used to indicate that the first target node and the second target node have established a first-degree neighbor relationship, and the first target node and the second target node each lose one node that is a second-degree neighbor.

[0010] Optionally, querying the Key-value database according to the operation instruction and generating query results includes: when the operation instruction is to add an edge between the first target node and the second target node, querying the Key-value database and generating a third query result, wherein, when the first target node and the second target node are three-degree neighbors or more than three-degree neighbors, the third query result is used to characterize that the first target node and the second target node establish a one-degree neighbor relationship, and the one-degree neighbor relationship is used to characterize that there are no other nodes between the first target node and the second target node, and there is a connection between the first target node and the second target node.

[0011] Optionally, querying the Key-value database according to the operation instruction to generate query results includes: when the operation instruction is to add an edge between the first target node and the second target node, querying the Key-value database to generate a fourth query result, wherein when the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node have no neighbor relationship, the fourth query result is used to indicate that the first target node and the second target node have a second-degree neighbor relationship, and the absence of a neighbor relationship indicates that there are no other nodes between the first target node and the second target node, and there is no connection between the first target node and the second target node; when the operation instruction is to add an edge between the first target node and the second target node, querying the Key-value database to generate a fifth query result, wherein when the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node have a second-degree neighbor relationship or a higher degree of neighbor relationship, the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node have a second-degree neighbor relationship, and the first-degree neighbor node indicates that there are no other nodes between the first target node and the second target node, and there is a connection between the first target node and the second target node.

[0012] Optionally, querying the Key-value database according to the operation instruction to generate query results includes: when the operation instruction is to delete an edge between the first target node and the second target node, querying the Key-value database to generate a sixth query result, wherein, when the first target node and the second target node are first-degree neighbors, the sixth query result is used to characterize that the first target node and the second target node have a no-neighbor relationship, and the no-neighbor relationship is used to characterize that there are no other nodes between the first target node and the second target node, and there is no connection between the first target node and the second target node; when the operation instruction is to delete an edge between the first target node and the second target node, querying the Key-value database to generate a seventh query result, wherein, when the first target node and the second target node are second-degree neighbors, the seventh query result is used to characterize that the first target node and the second target node have a no-neighbor relationship, and the first-degree neighbor node between the first target node and the second target node has a no-neighbor relationship with either the first target node or the second target node.

[0013] Optionally, querying the Key-value database according to the operation instruction and generating query results includes: when the operation instruction is to delete an edge between the first target node and the second target node, querying the Key-value database and generating an eighth query result, wherein, when the first target node's first-degree neighbor node and the second target node's first-degree neighbor node are in a first-degree neighbor relationship, the eighth query result is used to characterize that the first target node's first-degree neighbor node and the second target node's first-degree neighbor node have a no-neighbor relationship, and the no-neighbor relationship is used to characterize that there are no other nodes between the first target node and the second target node, and there is no connection between the first target node and the second target node.

[0014] Optionally, querying the Key-value database according to the operation instruction to generate query results includes: when the operation instruction is to delete an edge between the first target node and the second target node, querying the Key-value database to generate a ninth query result, wherein, if the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node are second-degree neighbors or higher, and an edge is deleted between the first-degree neighbors of the first target node and the first-degree neighbors of the first-degree neighbors of the first target node, then the first target node and the first-degree neighbors of the first-degree neighbors of the first target node establish a no-neighbor relationship; when the operation instruction is to delete an edge between the first target node and the second target node, querying the Key-value database to generate a tenth query result, wherein, if the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node are second-degree neighbors or higher, the tenth query result is used to characterize that it has no impact on the second-degree neighbor relationship of the first target node and has no impact on the second-degree neighbor relationship of the second target node.

[0015] According to another aspect of this application, a query apparatus for a real-time graph database is provided. The apparatus includes a construction unit, a generation unit, and a processing unit. The construction unit is used to construct a graph database map based on the real-time graph database, the graph database map including multiple nodes. The generation unit is used to generate operation instructions based on the graph database map, the operation instructions instructing adjustments to the neighbor relationships between nodes in the graph database map. The processing unit is used to update graph data in a key-value database and the graph data in the real-time graph database in real time, so that the key-value database is invoked for querying according to the operation instructions, generating query results. The key-value database stores each node and its corresponding second-degree neighbor relationships, where the second-degree neighbor relationship represents the existence of a node between two nodes and a connection between the nodes. The neighbor relationship is the relationship between second-degree neighbor nodes.

[0016] According to another aspect of this application, a computer-readable storage medium is provided, the computer-readable storage medium including a stored program, wherein, when the program is executed, it controls the device where the computer-readable storage medium is located to execute any of the aforementioned real-time graph database query methods.

[0017] According to another aspect of this application, an electronic device is provided, the electronic circuit including one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs including a query method for performing any of the aforementioned real-time graph databases.

[0018] By applying the technical solution of this application, a key-value database is used to store, update, and traverse all nodes and their neighbor information in a graph database. When the graph is updated, the values ​​of all nodes (first-degree and second-degree neighbor nodes) are updated in real time, enabling fast graph updates and real-time queries during updates. This solves the problem of low search efficiency in real-time graph databases in the prior art. Attached Figure Description

[0019] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:

[0020] Figure 1 A hardware structure block diagram of a mobile terminal for performing a real-time graph database query method according to an embodiment of this application is shown.

[0021] Figure 2 A flowchart illustrating a real-time graph database query method according to an embodiment of this application is shown.

[0022] Figure 3 A structural block diagram of a real-time graph database query device provided according to an embodiment of this application is shown. Detailed Implementation

[0023] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.

[0024] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0025] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0026] For ease of description, the following explains some of the nouns or terms used in the embodiments of this application:

[0027] Graph database querying: Graph databases store and query data using a graph data structure. Their primary function and characteristic lie in their ability to retrieve data relationships, i.e., graph data querying. Common graph query functions include k-degree neighbor lookup, path lookup, and subgraph lookup. The most commonly used is k-degree neighbor lookup. After the graph is constructed, given any node as the starting point, it queries nodes directly connected to the starting point (denoted as 1-degree neighbors), nodes directly connected to the starting point's first-degree neighbors (denoted as 2-degree neighbors), and a series of nodes that are neighbors of the starting point and its neighbors (queries are repeated k times). This locates all nodes with k-degree neighbor relationships to the starting point. As a fundamental function of graph databases, k-degree neighbor lookup is not only directly applied to locating relationships but also forms the basis for many graph algorithms (such as PageRank, shortest path, and clustering). In practice, the results of high-order neighbor queries often consume a lot of computing resources, and the correlation strength between high-order neighbors and the query starting point will continue to decrease as the query order increases, which has limited significance for actual business. In practice, the dimensions of neighbor query are often limited to within 3 degrees of neighbor.

[0028] One key consideration is the shortest path approach. Due to the inherent characteristics of graph databases, graph queries (especially higher-order graph queries) may involve multiple connecting paths between the starting and target nodes, leading to confusion in the determination of k-degree neighbors. Existing solutions often address this issue by explicitly identifying the shortest path. Specifically, among all paths between the starting and target nodes, the path with the fewest nodes is selected as the shortest path. The shortest path approach is both a determination method and a graph algorithm, and it is crucial for k-degree neighbor queries (especially higher-order queries). It effectively avoids confusion in k-degree neighbor determination and prevents the influence of circular relationships between some nodes on neighbor determination.

[0029] Graph database updates: Graph databases store data using a graph data structure. There are two logics for graph updates: adding (nodes or edges) and deleting (nodes or edges), but the way data is updated differs significantly from traditional relational databases. Currently, regardless of whether a graph database adopts a full update or incremental update strategy, graph updates still have a significant negative impact on the real-time performance of graph databases when dealing with large amounts of data. Based on the aforementioned description of the real-time performance of graph databases, if the goal is set as real-time graph updates (e.g., requiring the graph to be updated within milliseconds in 99% of cases) and real-time queries during updates (e.g., requiring the graph database to support real-time updates while allowing queries with time lags of seconds or milliseconds), most graph databases still meet these requirements to a very low degree.

[0030] Key-value databases, represented by Redis and Berkeley DB, use keys to add, query, or delete data. Their biggest advantage is fast querying, making them suitable for applications where data changes rapidly. Combining this patent's application of graph querying and fast updates, this invention achieves fast graph querying and updates by traversing all nodes (keys) and their neighbors within two degrees of their origin (values).

[0031] As introduced in the background section, with the increasing demands for real-time data from various business needs, improving the performance of graph databases in real-time graph updates and real-time querying during updates has become a consensus among graph database vendors and a key challenge in technological iteration. Currently, most graph database products support access to real-time data, but due to limitations in their own performance and computing resources, they generally have problems supporting real-time graph updates and real-time querying during updates: First, most graph databases can only achieve offline batch updates of the graph; second, although some graph databases support real-time graph updates, the real-time performance is mostly in the second range, and achieving millisecond-level performance is quite difficult; third, in order to improve real-time performance, graph databases often require a large amount of computing resources, resulting in high costs for supporting hardware systems. To solve the problem of low search efficiency in existing real-time graph databases, embodiments of this application provide a query method, apparatus, computer-readable storage medium, and electronic device for real-time graph databases.

[0032] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.

[0033] The methods and embodiments provided in this application can be executed on a mobile terminal, computer terminal, or similar computing device. Taking running on a mobile terminal as an example, Figure 1 This is a hardware structure block diagram of a mobile terminal for a real-time graph database query method according to an embodiment of the present invention. Figure 1As shown, a mobile terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. The mobile terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the mobile terminal described above. For example, the mobile terminal may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.

[0034] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the device information display method in this embodiment of the invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thereby implementing the above-described method. The memory 104 may include high-speed random access memory and non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the mobile terminal via a network. Examples of the aforementioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. The transmission device 106 is used to receive or send data via a network. Specific examples of the aforementioned networks may include wireless networks provided by the mobile terminal's communication provider. In one example, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to communicate with the Internet. In one example, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0035] This embodiment provides a method for querying a real-time graph database that runs on a mobile terminal, computer terminal, or similar computing device. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Also, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0036] Figure 2 This is a flowchart illustrating a real-time graph database query method provided according to an embodiment of this application.

[0037] like Figure 2 As shown, the method includes the following steps:

[0038] Step S201: Construct a graph database graph based on the real-time graph database, wherein the graph database graph includes multiple nodes;

[0039] Specifically, the graph database graph records the neighbor relationships between each node in the graph database;

[0040] Step S202: Based on the graph database graph, generate operation instructions. The operation instructions are used to indicate the adjustment of the neighbor relationships between nodes in the graph database graph.

[0041] Specifically, based on the pre-set operation information of the staff and the above graph database map, operation instructions are generated to facilitate subsequent querying of the key-value database;

[0042] Step S203: Update the graph data in the Key-value database and the graph data in the real-time graph database in real time, so that the Key-value database can be called to perform a query according to the above operation instructions and generate query results. The Key-value database stores each of the above nodes and the neighbor relationships within the second degree of each of the above nodes. The second degree of neighbor relationship is used to represent that there is a above node between two of the above nodes and there is a connection relationship between the above nodes. The neighbor relationship is the relationship between neighbor nodes within the second degree of each other.

[0043] Specifically, because the Key-value database stores the aforementioned nodes and their corresponding second-degree neighbors (i.e., it stores neighbor relationship data), and updates the graph data in both the Key-value database and the aforementioned real-time graph database in real time, calling the Key-value database for lookup is more efficient than existing solutions, while ensuring that the Key-value database and the graph database are updated synchronously.

[0044] As shown in Table 2, the data structure of a key-value database is used to store, update, and traverse all nodes and their neighbors (within second-degree neighbors) of the graph data. The node and its neighbor information is recorded as key values ​​before and after the graph update. If there are multiple neighbors at degree k, the neighbor information is stored in the common built-in data structure of key-value database, list or set. Each graph update case is stored as a specific graph update rule.

[0045] Query Method: Querying nodes within two degrees of separation of a node in the graph database will be transformed from querying the graph database itself to querying a key-value database. For first-degree neighbor nodes, the value of the first-degree neighbor node is located by indexing the key-value database key "first-degree neighbor nodes of a given node"; for second-degree neighbor nodes, the value is located by indexing the key-value database key "first-degree neighbor nodes of a given node"; for nodes within two degrees of separation, the values ​​of both first-degree and second-degree neighbor nodes are located by indexing the key-value database key "first-degree and second-degree neighbor nodes of a given node", and data merging is performed to summarize the nodes within two degrees of separation.

[0046] In terms of the basic states of graph updates, there are two types: addition and deletion. Addition and deletion can be further divided into four categories: adding nodes, adding edges, deleting nodes, and deleting edges. However, when the problem specifically concerns the impact of graph updates on neighbor relationships within degree two, we can see that: deleting a node is equivalent to deleting the relationship (edge) between that node and all its surrounding degree one neighbors; therefore, deleting a node is simply a case of deleting edges. Adding a node requires that the node establish a neighbor relationship with any of its surrounding nodes to affect neighbor queries; therefore, adding a node is also a case of adding edges. Thus, addition and deletion can be simplified to two categories: adding edges and deleting edges.

[0047] In terms of the scale of graph updates, the scale can be enormous (e.g., updating millions of vertices and edges at once). However, for any node (which existed before the graph update) and its second-degree or lower neighbors, the updates of vertices or edges that can affect the neighbor query results of that node must be within its second-degree neighbors. Furthermore, by examining the changes in neighbors of two nodes and their respective first-degree neighbors from before the graph update (mutual first-degree neighbors / mutual second-degree neighbors / no neighbor relationship) to after the update, and then traversing the entire graph according to predetermined rules, all cases of graph updates can be covered. Therefore, the complex vertex-edge relationships in a graph database and the impact of their updates on neighbor queries can be abstracted into the changes in the relationship between two nodes (hereinafter referred to as observation point 1 and observation point 2). By exhaustively enumerating all possible changes, a complete set of corresponding rules can be formed.

[0048] Table 2. Updated Changes to Figure 1

[0049]

[0050] In one embodiment of this application, step S203, which involves querying the Key-value database according to the aforementioned operation instructions and generating query results, includes:

[0051] When the above operation instruction is to add an edge between the first target node and the second target node, the key-value database is called to perform a query and generate a first query result. In the case that the first target node and the second target node are either first-degree neighbors or have no neighbor relationship, the first query result is used to indicate that the first target node and the second target node have a first-degree neighbor relationship. The first-degree neighbor relationship is used to indicate that there are no other nodes between the first target node and the second target node, and there is a connection between the first target node and the second target node. The no-neighbor relationship is used to indicate that there are no other nodes between the first target node and the second target node, and there is no connection between the first target node and the second target node.

[0052] Specifically, since this application only examines the first-degree and second-degree neighbor relationships between observation points during exhaustive search, it does not exclude the possibility that each of the two observation points (i.e., the first target node and the second target node, corresponding to A and B in Table 2, respectively) has other first-degree and second-degree neighbor nodes. These potential neighbor information are represented by {…} in Table 2. The updated key-value data structure of the graph only records the changes in the neighbor relationship between the two observation points. When the above operation instruction is to add an edge between the first target node and the second target node, and the first target node and the second target node have no neighbor relationship, establishing a first-degree neighbor relationship between the two observation points will add one first-degree neighbor to each of the two observation points (Scenario 1); when the above operation instruction is to add an edge between the first target node and the second target node, and the first target node and the second target node have a first-degree neighbor relationship, there is no possibility of adding an edge between the two observation points, and therefore it has no impact on the neighbor node query (Scenario 2).

[0053] When the above operation instruction is to add an edge between the first target node and the second target node, the above key-value database is called to perform a query and generate a second query result. In the case that the first target node and the second target node are second-degree neighbors, the second query result is used to represent that the first target node and the second target node have established a first-degree neighbor relationship. At the same time, the first target node and the second target node each reduce one of the above nodes that are second-degree neighbors.

[0054] Specifically, as shown in Table 3, when the above operation instruction is to add an edge between the first target node and the second target node, and the first target node and the second target node are second-degree neighbors, establishing a first-degree neighbor relationship between the two observation points that already have a second-degree neighbor relationship will add one first-degree neighbor node to each of the two observation points and remove one second-degree neighbor node from each of them (Scenario 3).

[0055] Table 3. Updated Changes for Figure 2

[0056]

[0057] In one embodiment of this application, step S203, which involves querying the Key-value database according to the aforementioned operation instructions and generating query results, includes:

[0058] When the above operation instruction is to add an edge between the first target node and the second target node, the above key-value database is called to perform a query and generate a third query result. Wherein, when the first target node and the second target node are third-degree neighbors or higher, the above third query result is used to indicate that the first target node and the second target node have established a first-degree neighbor relationship. The first-degree neighbor relationship is used to indicate that there are no other nodes between the first target node and the second target node, and there is a connection between the first target node and the second target node.

[0059] Specifically, when the above operation instruction is to add an edge between the first target node and the second target node, and the first target node and the second target node are three-degree neighbors or more than three-degree neighbors, the impact on the query of neighbors within two degrees is relatively certain, that is, the two observation points will add each other as first-degree neighbors (Scenario 4).

[0060] In one embodiment of this application, step S203, which involves querying the Key-value database according to the aforementioned operation instructions and generating query results, includes:

[0061] When the above operation instruction is to add an edge between the first target node and the second target node, the above key-value database is called to perform a query and generate a fourth query result. In the case that the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node have no neighbor relationship, the above fourth query result is used to indicate that the first target node and the second target node have established a second-degree neighbor relationship. The absence of a neighbor relationship is used to indicate that there are no other nodes between the first target node and the second target node, and there is no connection between the first target node and the second target node.

[0062] Specifically, as shown in Table 4, when the above operation instruction is to add an edge between the first target node and the second target node, and the first-degree neighbor nodes of the first target node and the second target node have no neighbor relationship, a second-degree neighbor node will be added to each of the two observation points (Scenario 5). Scenario 5 only considers the increase in the relationship between the first-degree neighbors of the two observation points, and does not consider the k-degree neighbor relationship between the two observation points before the graph update. Table 4 can be regarded as {…} already including the existing k-degree neighbor relationship between A and B. Therefore, even if the two observation points have a k-degree neighbor relationship before the graph update, it has no impact on the change of the second-degree or less neighbor relationship between the observation points after the graph update.

[0063] Table 4. Update Changes to Figure 3

[0064]

[0065] When the above operation instruction is to add an edge between the first target node and the second target node, the above key-value database is called to perform a query and generate a fifth query result. In the case that the first-degree neighbor of the first target node and the first-degree neighbor of the second target node are second-degree neighbors or have a relationship of second-degree neighbor or higher, the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node establish a second-degree neighbor relationship. The first-degree neighbor node is used to indicate that there are no other nodes between the first target node and the second target node, and there is a connection between the first target node and the second target node.

[0066] Specifically, when the above operation instruction is to add an edge between the first target node and the second target node, and the first-degree neighbor of the first target node and the first-degree neighbor of the second target node are first-degree neighbors, there is no possibility of adding an edge between the first-degree neighbors of the two observation points, so it has no impact on the neighbor query (Scenario 6). When the above operation instruction is to add an edge between the first target node and the second target node, and the first-degree neighbor of the first target node and the first-degree neighbor of the second target node are second-degree neighbors or have a neighbor relationship of second degree or higher, the two observation points will add each other's first-degree neighbor nodes as second-degree neighbor nodes (Scenario 7).

[0067] In one embodiment of this application, step S203, which involves querying the Key-value database according to the aforementioned operation instructions and generating query results, includes:

[0068] When the above operation instruction is to delete the edge between the first target node and the second target node, the above key-value database is called to perform a query and generate a sixth query result. In the case that the first target node and the second target node are first-degree neighbors, the sixth query result is used to indicate that the first target node and the second target node have a no-neighbor relationship. The no-neighbor relationship is used to indicate that there are no other nodes between the first target node and the second target node, and there is no connection between the first target node and the second target node.

[0069] Specifically, when the above operation instruction is to delete an edge between the first target node and the second target node, and the first target node and the second target node have no first-degree or second-degree neighbor relationship, no edge can be deleted, and it has no impact on the neighbor node query (Scenario 8); when the above operation instruction is to delete an edge between the first target node and the second target node, and the first target node and the second target node have a first-degree neighbor relationship, one first-degree neighbor node is removed from each of the two observation points (Scenario 9).

[0070] When the above operation instruction is to delete the edge between the first target node and the second target node, the above key-value database is called to perform a query and generate a seventh query result. In the case that the first target node and the second target node are second-degree neighbors, the seventh query result is used to characterize that the first target node and the second target node have a no-neighbor relationship, and the first-degree neighbor node between the first target node and the second target node has a no-neighbor relationship with either the first target node or the second target node.

[0071] Specifically, as shown in Table 5, when the above operation instruction is to delete an edge between the first target node and the second target node, and the first target node and the second target node are second-degree neighbors, regardless of which edge is deleted, one first-degree neighbor and one second-degree neighbor of one observation point will be removed, and one second-degree neighbor of the other observation point will be removed (Scenario 10); when the above operation instruction is to delete an edge between the first target node and the second target node, and the first target node and the second target node are third-degree neighbors or higher, deleting the edge has no impact on the query for neighbor nodes within the second degree (Scenario 11).

[0072] Table 5. Update Changes to Figure 4

[0073]

[0074] In one embodiment of this application, step S203, which involves querying the Key-value database according to the aforementioned operation instructions and generating query results, includes:

[0075] When the above operation instruction is to delete an edge between the first target node and the second target node, the above key-value database is called to perform a query and generate an eighth query result. In the case that the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node are in a first-degree neighbor relationship, the above eighth query result is used to indicate that the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node have a no-neighbor relationship. The no-neighbor relationship is used to indicate that there are no other nodes between the first target node and the second target node, and there is no connection between the first target node and the second target node.

[0076] Specifically, when the above operation instruction is to delete an edge between the first target node and the second target node, and the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node have no neighbor relationship, there is no edge to delete, so it has no impact on the neighbor query (Scenario 12); when the above operation instruction is to delete an edge between the first target node and the second target node, and the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node have a first-degree neighbor relationship, it can be deduced from Scenario 4 that each of the two observation points loses a second-degree neighbor node (Scenario 13).

[0077] In one embodiment of this application, step S203, which involves querying the Key-value database according to the aforementioned operation instructions and generating query results, includes:

[0078] When the above operation instruction is to delete an edge between the first target node and the second target node, the above key-value database is called to perform a query and generate a ninth query result. In this case, if the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node are second-degree neighbors or higher, and the edge between the first-degree neighbor node of the first target node and the first-degree neighbor node of the first target node is deleted, the first target node and the first-degree neighbor node of the first target node establish a no-neighbor relationship.

[0079] When the above operation instruction is to delete an edge between the first target node and the second target node, the above key-value database is called to perform a query and generate a tenth query result. Wherein, if the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node are second-degree neighbors or higher, the above tenth query result is used to indicate that it has no effect on the second-degree neighbor relationship of the first target node and has no effect on the second-degree neighbor relationship of the second target node.

[0080] Specifically, if the above operation instruction is to delete an edge between the first target node and the second target node, and the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node are second-degree neighbors or higher, then if the deleted edge is an edge from the first-degree neighbor of the observation point to its own first-degree neighbor, then the observation point loses a second-degree neighbor; otherwise, it has no effect on the observation point's neighbors within the second degree. However, since this scenario is equivalent to scenario 10, case 2 during traversal, it is no longer considered (scenario 14).

[0081] Through the above embodiments, a key-value database is used to store, update, and traverse all nodes and their neighbor information in a graph database. During graph updates, the values ​​of all nodes (first-degree and second-degree neighbors) are updated in real time, enabling fast graph updates and real-time queries during updates. This solves the problem of low search efficiency in existing real-time graph databases. Considering the characteristics of graph queries, this application focuses on queries of neighbor nodes within second degree (inclusive), with all neighbors determined based on the shortest path. Finally, while some graph databases distinguish between directed and undirected graphs, this does not affect the determination of k-degree neighbors and is not considered in this application.

[0082] This paper focuses on fast querying and updating of neighbor relationships within two degrees of separation in graph databases, based on key-value databases. However, its main drawback is that the scope is limited to the rapid iteration of query results for neighbors within two degrees of separation. This limitation stems from the inherent complexity of graph database structures. Querying neighbors at three degrees and above presents significantly increased complexity in terms of adding and deleting nodes and edges, requiring robust exhaustive methods and logical deduction; therefore, this aspect has not been addressed. Furthermore, the association strength between higher-order neighbors and the query origin decreases with increasing query order, limiting its practical significance. In practice, neighbor query analysis is often limited to neighbors within three degrees of separation. Therefore, the focus on two-degree and one-degree neighbor queries in this paper still holds significant practical value.

[0083] Based on the above context, the rules for context determination and neighbor updates are outlined from the perspective of a key-value database. To more accurately and intuitively describe the rules for graph updates, the following settings are made: The mathematical concept of a "set" is used to summarize all first- or second-degree neighbors of any point. However, in a specific database, this set can be stored in various forms such as lists and tuples. Furthermore, the naming convention for this set is "H-neighbor order-observation point," such as "1-degree neighbors of point A" being represented as "H1A." Other points are named in the same way. The specific traversal rules are shown in Table 6.

[0084] Table 6 Traversal Rules

[0085]

[0086]

[0087]

[0088] This application also provides a query device for a real-time graph database. It should be noted that this query device can be used to execute the query method for real-time graph databases provided in this application. This device is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.

[0089] The following describes the real-time graph database query device provided in the embodiments of this application.

[0090] Figure 3 This is a structural block diagram of a real-time graph database query device provided according to an embodiment of this application. For example... Figure 3As shown, the device includes a construction unit 31, a generation unit 32, and a processing unit 33. The construction unit 31 is used to construct a graph database graph based on a real-time graph database, the graph database graph including multiple nodes. The generation unit 32 is used to generate operation instructions based on the graph database graph, the operation instructions being used to instruct the adjustment of the neighbor relationships between nodes in the graph database graph. The processing unit 33 is used to update the graph data in the key-value database and the graph data in the real-time graph database in real time, so that the key-value database is invoked to perform a query according to the operation instructions, and a query result is generated. The key-value database stores each node and the neighbor relationships within two degrees of separation corresponding to each node. The two-degree neighbor relationship is used to represent that there is a node between two nodes and that there is a connection between each node. The neighbor relationship is the relationship between neighbor nodes within two degrees of separation.

[0091] In the above device, a key-value database is used to store, update, and traverse all nodes and their neighbor information in the graph database. When the graph is updated, the values ​​of all nodes (first-degree and second-degree neighbor nodes) are updated in real time to achieve fast graph reading and real-time querying during the update, thereby solving the problem of low search efficiency of real-time graph databases in the prior art.

[0092] In one embodiment of this application, the processing unit includes a first processing module and a second processing module. The first processing module is used to query the key-value database and generate a first query result when the operation instruction is to add an edge between the first target node and the second target node. In the case where the first target node and the second target node are either first-degree neighbors or have no neighbors, the first query result indicates that the first target node and the second target node have a first-degree neighbor relationship. This first-degree neighbor relationship indicates that there are no other nodes between the first target node and the second target node, and that there is a connection between the first target node and the second target node. The "no node relationship" indicates that there are no other nodes between the first target node and the second target node, and there is no connection between them. The second processing module is used to query the Key-value database and generate a second query result when the operation instruction is to add an edge between the first target node and the second target node. In the case that the first target node and the second target node are second-degree neighbors, the second query result indicates that the first target node and the second target node have established a first-degree neighbor relationship, and the first target node and the second target node each have reduced one node that is a second-degree neighbor.

[0093] In one embodiment of this application, the processing unit further includes a third processing module. The third processing module is used to call the Key-value database to perform a query and generate a third query result when the operation instruction is to add an edge between the first target node and the second target node. In the case that the first target node and the second target node are three-degree neighbors or more than three-degree neighbors, the third query result is used to indicate that the first target node and the second target node have established a one-degree neighbor relationship. The one-degree neighbor relationship is used to indicate that there are no other nodes between the first target node and the second target node, and there is a connection between the first target node and the second target node.

[0094] In one embodiment of this application, the processing unit further includes a fourth processing module and a fifth processing module. The fourth processing module is used to query the key-value database and generate a fourth query result when the operation instruction is to add an edge between the first target node and the second target node. In the case where the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node have no neighbor relationship, the fourth query result indicates that the first target node and the second target node have established a second-degree neighbor relationship. The absence of a neighbor relationship indicates that there are no other nodes between the first target node and the second target node. There is no connection between them; the fifth processing module is used to call the key-value database to query and generate a fifth query result when the above operation instruction is to add an edge between the first target node and the second target node. In the case that the first-degree neighbor of the first target node and the first-degree neighbor of the second target node are second-degree neighbors or have a relationship of second-degree neighbor or higher, the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node establish a second-degree neighbor relationship. The first-degree neighbor node is used to indicate that there are no other nodes between the first target node and the second target node, and there is a connection between the first target node and the second target node.

[0095] In one embodiment of this application, the processing unit further includes a sixth processing module and a seventh processing module. The sixth processing module is used to query the Key-value database and generate a sixth query result when the operation instruction is to delete an edge between the first target node and the second target node. In the case where the first target node and the second target node are first-degree neighbors, the sixth query result indicates that the first target node and the second target node have a no-neighbor relationship, and the no-neighbor relationship indicates that there are no other nodes between the first target node and the second target node, and there is no connection between them. The seventh processing module is used to query the Key-value database and generate a seventh query result when the operation instruction is to delete an edge between the first target node and the second target node. In the case where the first target node and the second target node are second-degree neighbors, the seventh query result indicates that the first target node and the second target node have a no-neighbor relationship, and the first-degree neighbor node between the first target node and the second target node has a no-neighbor relationship with either the first target node or the second target node.

[0096] In one embodiment of this application, the processing unit further includes an eighth processing module. The eighth processing module is used to query the key-value database and generate an eighth query result when the operation instruction is to delete an edge between the first target node and the second target node. In the case that the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node are in a first-degree neighbor relationship, the eighth query result is used to indicate that the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node have a no-neighbor relationship. The no-neighbor relationship is used to indicate that there are no other nodes between the first target node and the second target node, and there is no connection between the first target node and the second target node.

[0097] In one embodiment of this application, the processing unit further includes a ninth processing module and a tenth processing module. The ninth processing module is used to query the Key-value database and generate a ninth query result when the operation instruction is to delete an edge between the first target node and the second target node. Specifically, if the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node are second-degree neighbors or have a higher degree of neighbor relationship, and if an edge is deleted between the first-degree neighbors of the first target node and their respective first-degree neighbors, then the first target node and its respective first-degree neighbors form a no-neighbor relationship. The tenth processing module is used to query the Key-value database and generate a tenth query result when the operation instruction is to delete an edge between the first target node and the second target node. Specifically, if the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node are second-degree neighbors or have a higher degree of neighbor relationship, then the tenth query result indicates that it has no impact on the second-degree neighbor relationship of the first target node and also has no impact on the second-degree neighbor relationship of the second target node.

[0098] The query device for the aforementioned Z-real-time graph database includes a processor and a memory. The aforementioned construction units, generation units, and processing units are all stored as program units in the memory, and the processor executes these program units stored in the memory to achieve the corresponding functions. All of the aforementioned modules reside in the same processor; alternatively, the aforementioned modules may be located in different processors in any combination.

[0099] The processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured, and adjusting kernel parameters can address the low search efficiency of real-time graph databases in existing technologies.

[0100] The memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.

[0101] This invention provides a computer-readable storage medium including a stored program, wherein, when the program is executed, it controls the device where the computer-readable storage medium is located to perform the real-time graph database query method.

[0102] This invention provides a processor for running a program, wherein the program executes the query method for the real-time graph database.

[0103] This invention provides a device including a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it performs at least the following steps: constructing a graph database graph based on a real-time graph database, the graph database graph including multiple nodes; generating operation instructions based on the graph database graph, the operation instructions instructing adjustments to the neighbor relationships between nodes in the graph database graph; and updating graph data in a key-value database and the graph data in the real-time graph database in real-time, so that the key-value database is invoked according to the operation instructions to perform a query and generate query results. The key-value database stores each node and its corresponding second-degree neighbor relationships. The second-degree neighbor relationships represent the existence of a node between two nodes, and the nodes are connected. The neighbor relationships are the relationships between nodes within two degrees of each other. The device described herein can be a server, PC, PAD, mobile phone, etc.

[0104] This application also provides a computer program product, which, when executed on a data processing device, is suitable for executing an initialization program having at least the following method steps: constructing a graph database graph based on a real-time graph database, the graph database graph including multiple nodes; generating operation instructions based on the graph database graph, the operation instructions being used to instruct the adjustment of neighbor relationships between nodes in the graph database graph; updating graph data in a key-value database and the graph data in the real-time graph database in real time, so that the key-value database is invoked to perform a query according to the operation instructions, generating query results, the key-value database storing each of the aforementioned nodes and the neighbor relationships within two degrees of separation corresponding to each of the aforementioned nodes, the two-degree neighbor relationships being used to characterize the existence of a node between two of the aforementioned nodes, and the existence of a connection relationship between the aforementioned nodes, the neighbor relationships being the relationships between neighbor nodes within two degrees of separation.

[0105] This invention provides an electronic device, which includes one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs include a query method for performing any of the above-described real-time graph databases.

[0106] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those described herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.

[0107] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0108] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0109] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0110] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0111] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0112] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0113] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0114] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0115] As can be seen from the above description, the embodiments of this application achieve the following technical effects:

[0116] 1) The real-time graph database query method of this application uses a key-value database to store, update and traverse all nodes and their neighbor information in the graph database. When the graph is updated, the values ​​of all nodes (first-degree and second-degree neighbor nodes) are updated in real time to realize fast graph update and real-time query during the update, thereby solving the problem of low search efficiency of real-time graph databases in the prior art.

[0117] 2) The real-time graph database query device of this application uses a key-value database to store, update and traverse all nodes and their neighbor information in the graph database. When the graph is updated, the value of all nodes (first-degree and second-degree neighbor nodes) is updated in real time to realize fast graph update and real-time query during the update, thereby solving the problem of low search efficiency of real-time graph databases in the prior art.

[0118] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A query method of a real-time graph database, characterized in that, include: Based on the real-time graph database, a graph database graph is constructed, which includes multiple nodes; Based on the graph database graph, an operation instruction is generated, which is used to instruct the adjustment of the neighbor relationships between nodes in the graph database graph. The graph data in the Key-value database and the graph data in the real-time graph database are updated in real time so that the Key-value database can be called to perform a query according to the operation instruction and generate query results. The Key-value database stores each node and the neighbor relationships within the second degree of each node. The second degree of neighbor relationship is used to represent that there is a node between two nodes and there is a connection between each node. The neighbor relationship is the relationship between neighbor nodes within the second degree of each other. The operation instructions are used to query the Key-value database and generate query results, including: When the operation instruction is to add an edge between the first target node and the second target node, the key-value database is invoked to perform a query and generate a first query result. In the case that the first target node and the second target node are either first-degree neighbors or have no neighbor relationship, the first query result is used to indicate that the first target node and the second target node have a first-degree neighbor relationship. The first-degree neighbor relationship indicates that there are no other nodes between the first target node and the second target node, and there is a connection between the first target node and the second target node. The no-neighbor relationship indicates that there are no other nodes between the first target node and the second target node, and there is no connection between the first target node and the second target node. When the operation instruction is to add an edge between the first target node and the second target node, the key-value database is invoked to perform a query and generate a second query result. In the case that the first target node and the second target node are second-degree neighbors, the second query result is used to characterize that the first target node and the second target node have established a first-degree neighbor relationship, and at the same time, the first target node and the second target node each reduce one of the nodes that are second-degree neighbors.

2. The method according to claim 1, characterized in that, The operation instructions are used to query the Key-value database and generate query results, including: If the operation instruction is to add an edge between the first target node and the second target node, the key-value database is invoked to perform a query, generating a third query result. Wherein, if the first target node and the second target node are third-degree neighbors or more than third-degree neighbors, the third query result is used to characterize that the first target node and the second target node form a first-degree neighbor relationship. The first-degree neighbor relationship is used to characterize that there are no other nodes between the first target node and the second target node, and there is a connection between the first target node and the second target node.

3. The method according to claim 1, characterized in that, The operation instructions are used to query the Key-value database and generate query results, including: When the operation instruction is to add an edge between the first target node and the second target node, the key-value database is invoked to perform a query and generate a fourth query result. In the case that the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node have no neighbor relationship, the fourth query result is used to indicate that the first target node and the second target node have established a second-degree neighbor relationship. The absence of a neighbor relationship is used to indicate that there are no other nodes between the first target node and the second target node, and there is no connection between the first target node and the second target node. When the operation instruction is to add an edge between the first target node and the second target node, the key-value database is invoked to perform a query and generate a fifth query result. In the case where the first-degree neighbor of the first target node and the first-degree neighbor of the second target node are second-degree neighbors or have a relationship of more than two degrees, the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node establish a second-degree neighbor relationship. The first-degree neighbor node is used to indicate that there are no other nodes between the first target node and the second target node, and there is a connection relationship between the first target node and the second target node.

4. The method according to claim 1, characterized in that, The operation instructions are used to query the Key-value database and generate query results, including: When the operation instruction is to delete an edge between the first target node and the second target node, the key-value database is invoked to perform a query and generate a sixth query result. In the case that the first target node and the second target node are first-degree neighbors, the sixth query result is used to characterize that the first target node and the second target node have a no-neighbor relationship. The no-neighbor relationship is used to characterize that there are no other nodes between the first target node and the second target node, and there is no connection between the first target node and the second target node. When the operation instruction is to delete an edge between the first target node and the second target node, the key-value database is invoked to perform a query and generate a seventh query result. In the case that the first target node and the second target node are second-degree neighbors, the seventh query result is used to characterize that the first target node and the second target node have a no-neighbor relationship, and the first-degree neighbor node between the first target node and the second target node has a no-neighbor relationship with either the first target node or the second target node.

5. The method according to claim 1, characterized in that, The operation instructions are used to query the Key-value database and generate query results, including: When the operation instruction is to delete an edge between the first target node and the second target node, the key-value database is invoked to perform a query and generate an eighth query result. In the case that the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node are in a first-degree neighbor relationship, the eighth query result is used to characterize that the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node have a no-neighbor relationship. The no-neighbor relationship is used to characterize that there are no other nodes between the first target node and the second target node, and there is no connection between the first target node and the second target node.

6. The method according to claim 1, characterized in that, The operation instructions are used to query the Key-value database and generate query results, including: When the operation instruction is to delete an edge between the first target node and the second target node, the key-value database is invoked to perform a query and generate a ninth query result. In this case, if the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node are second-degree neighbors or higher, and an edge is deleted between the first-degree neighbor node of the first target node and the first-degree neighbor node of the first-degree neighbor node of the first target node, then the first target node and the first-degree neighbor node of the first target node establish a no-neighbor relationship. When the operation instruction is to delete an edge between the first target node and the second target node, the key-value database is invoked to perform a query and generate a tenth query result. In the case that the first-degree neighbor node of the first target node and the first-degree neighbor node of the second target node are second-degree neighbors or higher, the tenth query result is used to indicate that it has no effect on the second-degree neighbor relationship of the first target node and has no effect on the second-degree neighbor relationship of the second target node.

7. A query device for a real-time graph database, characterized in that, include: A construction unit is used to construct a graph database graph based on a real-time graph database, wherein the graph database graph includes multiple nodes; The generation unit is configured to generate operation instructions based on the graph database graph, the operation instructions being used to instruct the adjustment of neighbor relationships between nodes in the graph database graph; The processing unit is used to update the graph data in the Key-value database and the graph data in the real-time graph database in real time, so that the Key-value database is invoked to perform a query according to the operation instruction and generate query results. The Key-value database stores each node and the neighbor relationships within the second degree of each node. The second degree of neighbor relationship is used to represent that there is a node between two nodes and there is a connection relationship between each node. The neighbor relationship is the relationship between neighbor nodes within the second degree of each other. The processing unit includes a first processing module and a second processing module. The first processing module is used to query the Key-value database and generate a first query result when the operation instruction is to add an edge between the first target node and the second target node. In the case that the first target node and the second target node are first-degree neighbors or have no neighbor relationship, the first query result is used to indicate that the first target node and the second target node have a first-degree neighbor relationship. The first-degree neighbor relationship indicates that there are no other nodes between the first target node and the second target node, and there is a connection between the first target node and the second target node. The no-node relationship indicates that there are no other nodes between the first target node and the second target node, and there is no connection between the first target node and the second target node. The second processing module is used to call the Key-value database to perform a query and generate a second query result when the operation instruction is to add an edge between the first target node and the second target node. In the case that the first target node and the second target node are second-degree neighbors, the second query result is used to characterize that the first target node and the second target node have established a first-degree neighbor relationship, and at the same time, the first target node and the second target node each reduce one of the nodes that are second-degree neighbors.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein, when the program is executed, it controls the device on which the computer-readable storage medium is located to perform the query method for the real-time graph database according to any one of claims 1 to 6.

9. An electronic device, characterized in that, include: One or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs including a query method for performing a real-time graph database according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Large-scale social network service-oriented graph data storage and query method

    CN104899156A

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

    CN114443911A