[go: up one dir, main page]

CN116303763A - Distributed graph database incremental graph partitioning method and system based on vertex degree - Google Patents

Distributed graph database incremental graph partitioning method and system based on vertex degree Download PDF

Info

Publication number
CN116303763A
CN116303763A CN202310060074.3A CN202310060074A CN116303763A CN 116303763 A CN116303763 A CN 116303763A CN 202310060074 A CN202310060074 A CN 202310060074A CN 116303763 A CN116303763 A CN 116303763A
Authority
CN
China
Prior art keywords
vertex
server
stored
graph
edges
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310060074.3A
Other languages
Chinese (zh)
Inventor
陈佳祺
庄永真
罗进开
万志远
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang University ZJU
Original Assignee
Zhejiang University ZJU
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang University ZJU filed Critical Zhejiang University ZJU
Priority to CN202310060074.3A priority Critical patent/CN116303763A/en
Publication of CN116303763A publication Critical patent/CN116303763A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • G06F16/278Data partitioning, e.g. horizontal or vertical partitioning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2308Concurrency control
    • G06F16/2315Optimistic concurrency control
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • G06F16/273Asynchronous replication or reconciliation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a distributed graph database incremental graph dividing method and system based on vertex degrees. By tracking the change of the degree of the vertex of the graph, the high-order vertex and the connected edges thereof are rapidly divided, and the online partition decision of each transaction is made in real time while a single OLTP operation is serviced. As clients initiate requests to the graph database, the invention adjusts partitions incrementally in multiple stages according to the increase of related graph information (change of vertex degree), and is mainly divided into three steps: hash partitioning phase, vertex repartitioning phase, edge repartitioning phase. The method is suitable for the OLTP load, continuously updates the local data of the graph, and responds to graph queries of a plurality of clients. The distributed server can be provided with excellent load balancing through smaller system overhead, so that better data locality is realized; thereby increasing the parallelism of access and the throughput of the graph database.

Description

一种基于顶点度的分布式图数据库增量图划分方法及系统A method and system for incremental graph division of distributed graph database based on vertex degree

技术领域technical field

本发明属于分布式图数据库领域,尤其涉及一种基于顶点度的分布式图数据库增量图划分方法及系统。The invention belongs to the field of distributed graph databases, in particular to a method and system for dividing incremental graphs of distributed graph databases based on vertex degrees.

背景技术Background technique

分布式图数据库会同时收到来自多个客户端的查询,不恰当的增量图分区方法会导致集群中部分服务器负载过高以及整体事务处理速度降低。分布式图数据库必须迅速处理事务,因此其图划分算法需要能够快速进行在线决策。分布式图数据库的分区算法在工作时,常常无法全部掌握全局与局部图结构,只能基于很小一部分的图信息进行分区计算。除此之外,在现实的图数据库中,常常会存储一种非常稀疏的图数据,这种图数据存在大量低度数节点,但是同时又有部分节点拥有大量的连通边,如果将这些顶点划分到同一服务器中,会大大降低从这些顶点开始的图遍历速度,故而降低图数据库的吞吐量。The distributed graph database will receive queries from multiple clients at the same time, and an inappropriate incremental graph partitioning method will lead to excessive load on some servers in the cluster and slow down the overall transaction processing speed. A distributed graph database must process transactions quickly, so its graph partitioning algorithm needs to be able to make fast online decisions. When the partitioning algorithm of the distributed graph database is working, it is often impossible to fully grasp the global and local graph structures, and can only perform partitioning calculations based on a small part of the graph information. In addition, in real graph databases, a very sparse graph data is often stored. There are a large number of low-degree nodes in this graph data, but at the same time, some nodes have a large number of connected edges. If these vertices are divided into To the same server, it will greatly reduce the graph traversal speed starting from these vertices, thus reducing the throughput of the graph database.

现有的增量图划分技术分为点划分和边划分。点划分将图的顶点集合划分为若干部分,因此图中的边可能因为两个顶点被划分在不同的子图中而成为割边,割边集大小会直接影响分布式算法的通信代价,典型的点划分算法如LDG算法、Fennel算法等。边划分则是将图的边集合划分为若干部分,因此,当一个顶点的邻边被划分在不同的子图中时,这个点会在多个图分区中存在而成为割点,割点集的大小也会影响分布式算法的通信代价,典型的边划分算法如Grid算法、Greedy算法等。Existing incremental graph partitioning techniques are divided into point partitioning and edge partitioning. Vertex division divides the vertex set of the graph into several parts, so the edges in the graph may become cut edges because the two vertices are divided into different subgraphs. The size of the cut edge set will directly affect the communication cost of the distributed algorithm. Typical The point division algorithm such as LDG algorithm, Fennel algorithm and so on. Edge division is to divide the edge set of the graph into several parts. Therefore, when the adjacent edges of a vertex are divided into different subgraphs, this point will exist in multiple graph partitions and become a cut point. The cut point set The size of will also affect the communication cost of distributed algorithms, typical edge partitioning algorithms such as Grid algorithm, Greedy algorithm, etc.

现有的增量图划分方法并不适用于上述提到分布式图数据库的特性。上述图划分算法只能基于大量的图信息进行划分,并且决策速度很慢。除此之外,现有的图划分顶点并不会对顶点进行重新划分,在分布式图数据库中,随着图结构的不断变化,原来的分区可能会不再适用于现在的图。现有的增量图分区算法并不能够在资源消耗很少、不显著降低图数据库吞吐量的情况下针对上述提到的稀疏的图数据进行恰当划分。The existing incremental graph partitioning methods are not suitable for the above-mentioned characteristics of distributed graph databases. The above graph partitioning algorithm can only be partitioned based on a large amount of graph information, and the decision-making speed is very slow. In addition, the existing graph division vertices do not re-divide the vertices. In a distributed graph database, as the graph structure changes, the original partition may no longer be applicable to the current graph. Existing incremental graph partitioning algorithms cannot properly partition the above-mentioned sparse graph data without resource consumption and significantly reducing the throughput of the graph database.

现有的分布式图数据库如Nebula Graph或是JanusGraph等,都是通过简单的哈希算法来对图数据进行分区,虽然能够在一定程度上实现负载均衡,但缺乏对割集大小的优化。即:这种分区算法并不能够控制服务器之间的通信代价。Existing distributed graph databases, such as Nebula Graph or JanusGraph, use a simple hash algorithm to partition graph data. Although load balancing can be achieved to a certain extent, they lack optimization of the cut set size. That is: this partitioning algorithm cannot control the communication cost between servers.

综上所述,在分布式图数据库领域,并不存在一种能够为OLTP事务提供服务的高性能在线图划分方法。To sum up, in the field of distributed graph databases, there is no high-performance online graph partitioning method that can serve OLTP transactions.

发明内容Contents of the invention

本发明的目的在于针对现有技术的不足,提供一种基于顶点度的分布式图数据库增量图划分方法及系统。在许多情况下,分布式图数据库会收到来自多个客户端的高度并发请求,超高的工作负载要求分布式图数据库能够为应用程序提供高质量的服务。随着OLTP操作的执行,即顶点和边的插入,顶点度数可能会发生很大的变化。当一个大度数顶点v被不恰当的图分区方法划分后,从v开始进行图遍历或查询操作时,会消耗大量时间加载v的连接边,这会降低事务处理的速度,故而降低图数据库的吞吐量。该方法可以及时响应顶点度的动态变化,提高访问高度顶点的并行,提高数据局部性,形成更加平衡的分区。The object of the present invention is to provide a method and system for incremental graph division of a distributed graph database based on the vertex degree to address the deficiencies of the prior art. In many cases, distributed graph databases will receive highly concurrent requests from multiple clients, and ultra-high workloads require distributed graph databases to be able to provide high-quality services for applications. As OLTP operations are performed, i.e., insertion of vertices and edges, the degree of vertices can vary greatly. When a large-degree vertex v is partitioned by an inappropriate graph partitioning method, when the graph traversal or query operation starts from v, it will consume a lot of time to load the connection edges of v, which will reduce the speed of transaction processing, thus reducing the graph database. throughput. This method can respond to the dynamic change of vertex degree in time, improve the parallelism of accessing height vertices, improve data locality, and form more balanced partitions.

本发明的目的是通过以下技术方案来实现的:一种基于顶点度的分布式图数据库增量图划分方法,该方法包括如下步骤:The purpose of the present invention is achieved through the following technical solutions: a method for dividing incremental graphs of distributed graph databases based on vertex degrees, the method comprising the steps of:

S1、对图数据库中的计数器初始化,将内存中维护的计数器初始化为0,所述计数器用于记录图数据库每个分区中顶点的状态以及部署了存储服务的服务器中分区的状态,包括顶点的位置、顶点当前的分割状态以及顶点在当前服务器和其他部署存储服务的服务器上连接边的数量;S1. Initialize the counters in the graph database, initialize the counters maintained in the memory to 0, and the counters are used to record the state of the vertices in each partition of the graph database and the state of the partitions in the server where the storage service is deployed, including the state of the vertices The position, the current split state of the vertex, and the number of connected edges of the vertex on the current server and other servers where the storage service is deployed;

S2、哈希划分,通过哈希函数得到当前数据图中的顶点id的哈希值,以及所有插入顶点id的哈希值,对服务器总数的值取模,将顶点及其连接边进行哈希划分,同时更新服务器上存储的计数器;S2. Hash division, obtain the hash value of the vertex id in the current data graph through the hash function, and the hash values of all inserted vertex ids, take the modulus of the total number of servers, and hash the vertices and their connected edges partition while updating the counters stored on the server;

S3、顶点重新划分,随着OLTP事务的执行,以下步骤所有的顶点以及相关数据都进行异步移动和更新;当某一顶点v连接边的数量超过阈值ThresholdR时,评估将v从当前服务器移动到其他服务器的收益,并将v移动到收益最大的服务器;更新服务器上存储的计数器;S3. Vertex re-division. With the execution of OLTP transactions, all vertices and related data in the following steps are moved and updated asynchronously; when the number of edges connected to a vertex v exceeds the threshold ThresholdR, the evaluation will move v from the current server to other servers' gains, and move v to the server with the greatest gain; update the counter stored on the server;

S4、边重新划分,当某一顶点v在存储引擎中存储的连接边的数量超过阈值ThresholdE时,在不移动顶点v的情况下,重新分配这些连接边的位置,将顶点v的出边及其目标顶点分割到同一服务器,并将顶点v的入边及其源顶点分割到同一服务器;更新服务器上存储的计数器。S4, edge re-division, when the number of connection edges stored in a certain vertex v in the storage engine exceeds the threshold ThresholdE, without moving the vertex v, redistribute the positions of these connection edges, and the outgoing edges and Its target vertex is split to the same server, and the incoming edge of vertex v and its source vertex are split to the same server; the counter stored on the server is updated.

进一步地,所述步骤S1中计数器包括:Further, the counter in the step S1 includes:

在当前存储顶点v的服务器上,通过计数器split(v)的值1或0表示顶点v的边是否已经被分割过;On the server that currently stores the vertex v, the value 1 or 0 of the counter split(v) indicates whether the edge of the vertex v has been split;

在最初或当前存储顶点v的服务器上,通过计数器location(v)表示v的准确位置;On the server where the vertex v is originally or currently stored, the exact location of v is indicated by the counter location(v);

顶点v最多会拥有四个计数器,用于记录顶点连接边的信息:Vertex v will have up to four counters, which are used to record the information of the connected edges of the vertex:

计数器acto(v)用来表示v出边集中目标顶点和v存储在同一服务器上的边的数量,acto(v)只存储在实际存储v的机器上;The counter acto(v) is used to indicate the number of edges of the target vertex and v stored on the same server in the outgoing edge set of v, and acto(v) is only stored on the machine that actually stores v;

计数器acti(v)用来表示v入边集中源顶点和v存储在同一服务器上的边的数量,acti(v)只存储在实际存储v的服务器上;The counter acti(v) is used to indicate the number of edges in v’s incoming edge set where the source vertices and v are stored on the same server, and acti(v) is only stored on the server that actually stores v;

计数器poto(v)用来表示v出边集中目标顶点和v不存储在同一服务器上的边的数量,poto(v)只存储在存储v的邻居顶点的服务器上;The counter poto(v) is used to indicate the number of edges in v’s outgoing edge set where the target vertex and v are not stored on the same server, and poto(v) is only stored on the server that stores v’s neighbor vertices;

计数器poti(v)用来表示v入边集中源顶点和v不存储在同一个服务器上的边的数量,poti(v)只存储在存储v的邻居顶点的服务器上。The counter poti(v) is used to indicate the number of edges in v’s incoming edge set where the source vertex and v are not stored on the same server, and poti(v) is only stored on the server that stores v’s neighbor vertices.

在每台服务器上,通过计数器size表示服务器上存储的分区的顶点和边总数的和。On each server, the sum of the total number of vertices and edges for the partitions stored on the server is represented by the counter size.

进一步地,所述S2中更新存储的计数器步骤如下:Further, the steps of updating the stored counter in S2 are as follows:

在当前存储顶点v的服务器上,通过计算插入边e的目标顶点u的哈希值以及当前服务器存储的location(u),可以确定插入边e的目标顶点u和v是否在存储在同一服务器中。On the server currently storing vertex v, by calculating the hash value of the target vertex u of the inserted edge e and the location(u) stored in the current server, it can be determined whether the target vertex u and v of the inserted edge e are stored in the same server .

如果u和v在同一服务器上,则acto(v)的值增加1;If u and v are on the same server, the value of acto(v) is increased by 1;

如果u和v不在同一服务器上,则poti(u)的值增加1;If u and v are not on the same server, the value of poti(u) is increased by 1;

同理,在存储顶点u的服务器上,计数器也会进行相应的更新。Similarly, on the server storing vertex u, the counter will be updated accordingly.

进一步地,所述步骤S3中顶点重新划分的具体步骤如下:Further, the specific steps of re-dividing the vertices in the step S3 are as follows:

首先评估将v从当前服务器Snow移动到其他服务器Si的收益

Figure BDA0004061098200000038
并将v移动到profit最大的服务器,即目标服务器,表示为Starget,收益profit评估公式如下:First evaluate the benefit of moving v from the current server S now to some other server Si
Figure BDA0004061098200000038
And move v to the server with the largest profit, that is, the target server, denoted as S target , and the profit evaluation formula is as follows:

Figure BDA0004061098200000031
Figure BDA0004061098200000031

其中,

Figure BDA0004061098200000032
为移动后v出边集中目标顶点和v不存储在同一服务器上的边的数量,/>
Figure BDA0004061098200000033
为移动后v入边集中源顶点和v不存储在同一个服务器上的边的数量,
Figure BDA0004061098200000034
为当前服务器v出边集中目标顶点和v存储在同一服务器上的边的数量,
Figure BDA0004061098200000035
为当前服务器v入边集中源顶点和v存储在同一服务器上的边的数量,/>
Figure BDA0004061098200000036
Figure BDA0004061098200000037
分别为移动后服务器和当前服务器中存储的分区的顶点和边总数的和。in,
Figure BDA0004061098200000032
is the number of edges where the target vertex and v are not stored on the same server in the set of v outbound edges after the move, />
Figure BDA0004061098200000033
is the number of edges whose source vertices and v are not stored in the same server in v's inbound edge set after moving,
Figure BDA0004061098200000034
For the current server v, the number of edges in the target vertex and v stored on the same server,
Figure BDA0004061098200000035
For the current server v, the number of edges in the pool of source vertices and v stored on the same server, />
Figure BDA0004061098200000036
and
Figure BDA0004061098200000037
are the sum of the total number of vertices and edges of the partitions stored in the moved server and the current server, respectively.

进一步地,所述步骤S3中更新服务器上存储的计数器步骤如下:Further, the step of updating the counter stored on the server in the step S3 is as follows:

在完成顶点v的重新划分之后,需要更新顶点v以及v的邻居顶点在内存中维护的计数器的值:After completing the re-division of vertex v, it is necessary to update the value of the counter maintained in memory by vertex v and v's neighbor vertices:

将location(v)从当前服务器Snow移动到目标服务器StargetMove location(v) from the current server S now to the target server S target ;

当前服务器Snow的size值减少1,目标服务器Starget的size值增加1;The size value of the current server S now is reduced by 1, and the size value of the target server S target is increased by 1;

在原始服务器中,poto(v)将更新为acto(v)的值,poti(v)的值将更新为acti(v)的值;在目标服务器中,acto(v)的值将更新为poto(v)的值,acti(v)的值将更新为poti(v)的值;In the original server, poto(v) will be updated to the value of acto(v), and the value of poti(v) will be updated to the value of acti(v); in the target server, the value of acto(v) will be updated to poto (v), the value of acti(v) will be updated to the value of poti(v);

对原始服务器中存储的v的邻居顶点来说,v入边集每条边的源顶点vi,acto(vi)减少1;v出边集每条边的目标顶点vj,acti(vj)减少1;For the neighbor vertices of v stored in the original server, the source vertex v i and acto(v i ) of each edge in v’s incoming edge set are reduced by 1; the target vertex v j of each edge in v’s outgoing edge set, acti(v j ) decrease by 1;

对目标服务器中存储的邻居顶点来说,v入边集每条边的源顶点vk,acto(vk)增加1;v出边集每条边的目标顶点vs,acti(vs)增加1。For the neighbor vertices stored in the target server, the source vertex v k of each edge in the v incoming edge set, acto(v k ) increases by 1; the target vertex v s of each edge in the v outgoing edge set, acti(v s ) increase by 1.

进一步地,所述步骤S4中更新计数器操作为:清空顶点v的所有边计数器,更新split(v),确保顶点v不会再重新分配,更新location(v)。Further, the operation of updating the counter in step S4 is: clear all edge counters of vertex v, update split(v), ensure that vertex v will not be redistributed, and update location(v).

进一步地,所述步骤S3和S4中,更新内存中的计数器后,在当前事务中,将该顶点添加到挂起的顶点重新划分队列中。在当前事务完成之后,立刻停止处理与该顶点有关的请求,拒绝发起该请求的客户端,并和客户端同步该顶点状态。客户端同步状态后,再次向正确的服务器发起请求。Further, in the steps S3 and S4, after updating the counter in the memory, in the current transaction, add the vertex to the pending vertex repartition queue. After the current transaction is completed, immediately stop processing the request related to the vertex, reject the client that initiated the request, and synchronize the state of the vertex with the client. After the client synchronizes the state, it initiates a request to the correct server again.

根据说明书的另一方面,提供了一种基于顶点度的分布式图数据库增量图划分系统,该系统为一种图数据库,分为三个服务模块,分别是计算服务模块、存储服务模块以及元数据服务模块;According to another aspect of the description, a distributed graph database incremental graph partition system based on vertex degree is provided. The system is a graph database and is divided into three service modules, namely, a computing service module, a storage service module and metadata service module;

计算服务模块中包括若干查询引擎,用于对客户端发起的查询请求进行解析,并执行OLTP事务;The computing service module includes several query engines, which are used to analyze the query requests initiated by the client and execute OLTP transactions;

存储服务模块中包括若干存储引擎,所述每个存储引擎中分为多个图分区;用于保存每个顶点的出边集合和入边集合;The storage service module includes several storage engines, and each storage engine is divided into multiple graph partitions; it is used to save the outgoing edge set and incoming edge set of each vertex;

元数据服务模块中包括若干元数据服务引擎,所述元数据服务引擎包括元数据管理器、分区管理器和其他运维管理器;所述元数据服务引擎得到发生变动的顶点或边,执行计数器初始化、哈希划分、顶点重新划分和边重新划分。The metadata service module includes several metadata service engines, and the metadata service engine includes a metadata manager, a partition manager and other operation and maintenance managers; the metadata service engine obtains the changed vertices or edges, and executes the counter Initialization, hash partitioning, vertex repartitioning, and edge repartitioning.

本发明的优点及有益效果是:Advantage of the present invention and beneficial effect are:

提出一种适用于分布式图数据库、能够快速响应图顶点度数变化的增量图划分方法。分布式图数据库是一般只对图的一小部分进行增、删、改、查操作。这些操作通常由多个客户端并发发出,并且需要立即完成。通过着重划分高阶顶点及其邻边的位置,该算法不需要获得全图的信息即可确定新到来顶点或边的位置。This paper proposes an incremental graph partitioning method suitable for distributed graph databases that can quickly respond to changes in the degree of graph vertices. Distributed graph databases generally only perform addition, deletion, modification, and query operations on a small part of the graph. These operations are often issued concurrently by multiple clients and need to complete immediately. By emphasizing the location of high-order vertices and their adjacent edges, the algorithm does not need to obtain the information of the whole graph to determine the location of new vertices or edges.

能够在有限的资源下快速划分新的顶点和边。随着图中顶点连通性的增加,只需要占用很少的内存,本发明就能够快速在每个OLTP事务中进行快速的在线决策,重新划分顶点和边的位置。Ability to quickly partition new vertices and edges with limited resources. With the increase of vertex connectivity in the graph, only a small amount of memory is required, and the present invention can quickly perform fast online decision-making in each OLTP transaction, and re-divide the positions of vertices and edges.

分区结果能够很好地服务于OLTP操作。通过让客户端和服务器共享相同的信息,大部分的顶点能够实现单跳访问。本发明提供的方法能够提高数据本地性,实现服务器负载均衡,增加客户端访问图中高阶顶点的能力。本发明只需要使用很小的开销,就能够大大提高图数据库的查询性能。Partition results can serve OLTP operations well. By having the client and server share the same information, most vertices can be accessed with a single hop. The method provided by the invention can improve data locality, realize server load balancing, and increase the client's ability to access high-order vertices in the graph. The present invention can greatly improve the query performance of the graph database only by using a small overhead.

实现一个拥有更高吞吐量、并发访问能力等性能的图数据库。通过在现有的图数据库中实现本发明的方法,使用恰当的分区方法,能够大大提高图数据库的吞吐量和并发。Realize a graph database with higher throughput and concurrent access capabilities. By implementing the method of the present invention in an existing graph database and using an appropriate partition method, the throughput and concurrency of the graph database can be greatly improved.

附图说明Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图做简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动前提下,还可以根据这些附图获得其他附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention. Those skilled in the art can also obtain other drawings based on these drawings without creative work.

图1为本发明系统的架构图;Fig. 1 is the architectural diagram of the system of the present invention;

图2为本发明实施例中默认划分阶段的示意图;FIG. 2 is a schematic diagram of a default division stage in an embodiment of the present invention;

图3为本发明实施例中顶点重新划分阶段的示意图;FIG. 3 is a schematic diagram of a vertex re-division stage in an embodiment of the present invention;

图4为本发明实施例中边重新划分阶段的示意图。Fig. 4 is a schematic diagram of an edge re-partitioning stage in an embodiment of the present invention.

具体实施方式Detailed ways

为使本发明的上述目的、特征和优点能够更加明显易懂,下面结合附图对本发明的具体实施方式做详细的说明。In order to make the above objects, features and advantages of the present invention more comprehensible, specific implementations of the present invention will be described in detail below in conjunction with the accompanying drawings.

在下面的描述中阐述了很多具体细节以便于充分理解本发明,但是本发明还可以采用其他不同于在此描述的其它方式来实施,本领域技术人员可以在不违背本发明内涵的情况下做类似推广,因此本发明不受下面公开的具体实施例的限制。In the following description, a lot of specific details are set forth in order to fully understand the present invention, but the present invention can also be implemented in other ways different from those described here, and those skilled in the art can do it without departing from the meaning of the present invention. By analogy, the present invention is therefore not limited to the specific examples disclosed below.

本发明提供一种基于顶点度的分布式图数据库增量图划分方法,该方法包括如下步骤:The present invention provides a method for dividing an incremental graph of a distributed graph database based on vertex degree, and the method includes the following steps:

(1)计数器初始化。在内存中维护一系列计数器来明确每个分区中顶点的状态以及服务器中分区的状态,将所有计数器的值初始化为0。(1) Counter initialization. Maintain a series of counters in memory to determine the state of the vertices in each partition and the state of the partitions in the server, and initialize all counters to 0.

(1.1)在当前存储顶点v的服务器上,通过split(v)表示顶点v的边是否已经被分割过;(1.1) On the server currently storing vertex v, use split(v) to indicate whether the edge of vertex v has been split;

(1.2)在最初或当前存储顶点v的服务器上,通过location(v)表示v的准确位置;(1.2) On the server that initially or currently stores the vertex v, the exact location of v is represented by location(v);

(1.3)计数器acto(v)用来表示v出边集中目标顶点和v存储在同一服务器上的边的数量,acto(v)只存储在实际存储v的机器上;(1.3) The counter acto(v) is used to indicate the number of edges of the target vertex and v stored on the same server in the outbound edge set of v, and acto(v) is only stored on the machine that actually stores v;

计数器acti(v)用来表示v入边集中源顶点和v存储在同一服务器上的边的数量,acti(v)只存储在实际存储v的服务器上;The counter acti(v) is used to indicate the number of edges in v’s incoming edge set where the source vertices and v are stored on the same server, and acti(v) is only stored on the server that actually stores v;

计数器poto(v)用来表示v出边集中目标顶点和v不存储在同一服务器上的边的数量,poto(v)只存储在存储v的邻居顶点的服务器上;The counter poto(v) is used to indicate the number of edges in v’s outgoing edge set where the target vertex and v are not stored on the same server, and poto(v) is only stored on the server that stores v’s neighbor vertices;

计数器poti(v)用来表示v入边集中源顶点和v不存储在同一个服务器上的边的数量,poti(v)只存储在存储v的邻居顶点的服务器上。The counter poti(v) is used to indicate the number of edges in v’s incoming edge set where the source vertex and v are not stored on the same server, and poti(v) is only stored on the server that stores v’s neighbor vertices.

在每台服务器上,通过计数器size表示服务器上存储的分区的顶点和边总数的和。On each server, the sum of the total number of vertices and edges for the partitions stored on the server is represented by the counter size.

(2)哈希划分阶段。通过哈希函数得到当前数据图中的顶点id的哈希值,以及所有插入顶点id的哈希值,对服务器总数的值取模,将顶点及其连接边进行哈希划分,同时更新服务器上存储的计数器;以客户端发起插入边请求、成功插入边e(顶点v->顶点u)为例:(2) Hash division stage. Obtain the hash value of the vertex id in the current data graph through the hash function, as well as the hash value of all inserted vertex ids, take the modulus of the total number of servers, divide the vertices and their connected edges by hash, and update the server at the same time Stored counter; take the client to initiate an edge insertion request and successfully insert an edge e (vertex v->vertex u) as an example:

(2.1)在当前存储顶点v的服务器上,通过计算u的哈希值以及当前服务器存储的location(u),可以确定e的目标顶点u是否在存储在同一服务器中。(2.1) On the server currently storing vertex v, by calculating the hash value of u and the location(u) stored in the current server, it can be determined whether the target vertex u of e is stored in the same server.

a)如果u在同一服务器上,则acto(v)的值增加1;a) If u is on the same server, the value of acto(v) is increased by 1;

b)如果u不在同一服务器上,则poti(u)的值增加1。b) If u is not on the same server, increment the value of poti(u) by 1.

(2.2)同理,在存储顶点u的服务器上,计数器也会进行相应的更新。(2.2) Similarly, on the server storing vertex u, the counter will be updated accordingly.

(3)顶点重新划分阶段。随着客户端发起图查询请求以及OLTP事务的执行,当某一顶点v连接边的数量超过预设阈值ThresholdR时,对该顶点的位置进行重新划分,同时更新服务器上存储的计数器。(3) Vertex redivision stage. As the client initiates a graph query request and executes OLTP transactions, when the number of connected edges of a certain vertex v exceeds the preset threshold ThresholdR, the position of the vertex is re-divided, and the counter stored on the server is updated at the same time.

(3.1)首先评估将v从当前服务器Snow移动到其他服务器Si的收益

Figure BDA0004061098200000061
并将v移动到/>
Figure BDA0004061098200000062
最大的服务器,即目标服务器,表示为Starget,收益/>
Figure BDA0004061098200000063
评估公式如下:(3.1) First evaluate the benefit of moving v from the current server S now to another server S i
Figure BDA0004061098200000061
and move v to />
Figure BDA0004061098200000062
The largest server, namely the target server, denoted as S target , yields />
Figure BDA0004061098200000063
The evaluation formula is as follows:

Figure BDA0004061098200000064
Figure BDA0004061098200000064

其中,

Figure BDA0004061098200000065
为移动后v出边集中目标顶点和v不存储在同一服务器上的边的数量,/>
Figure BDA0004061098200000066
为移动后v入边集中源顶点和v不存储在同一个服务器上的边的数量,
Figure BDA0004061098200000067
为当前服务器v出边集中目标顶点和v存储在同一服务器上的边的数量,
Figure BDA0004061098200000068
为当前服务器v入边集中源顶点和v存储在同一服务器上的边的数量,/>
Figure BDA0004061098200000069
Figure BDA00040610982000000610
分别为移动后服务器和当前服务器中存储的分区的顶点和边总数的和。in,
Figure BDA0004061098200000065
is the number of edges where the target vertex and v are not stored on the same server in the set of v outbound edges after the move, />
Figure BDA0004061098200000066
is the number of edges whose source vertices and v are not stored in the same server in v's inbound edge set after moving,
Figure BDA0004061098200000067
For the current server v, the number of edges in the target vertex and v stored on the same server,
Figure BDA0004061098200000068
For the current server v, the number of edges in the pool of source vertices and v stored on the same server, />
Figure BDA0004061098200000069
and
Figure BDA00040610982000000610
are the sum of the total number of vertices and edges of the partitions stored in the moved server and the current server, respectively.

(3.2)在完成顶点v的重新划分之后,需要更新顶点v以及v的邻居顶点在内存中维护的计数器的值:(3.2) After completing the re-division of vertex v, it is necessary to update the value of the counter maintained in memory by vertex v and v's neighbor vertices:

将location(v)从当前服务器Snow移动到目标服务器StargetMove location(v) from the current server S now to the target server S target ;

当前服务器Snow的size值减少1,目标服务器Starget的size值增加1。The size value of the current server Snow is decreased by 1, and the size value of the target server S target is increased by 1.

在原始服务器中,poto(v)将更新为acto(v)的值,poti(v)的值将更新为acti(v)的值;在目标服务器中,acto(v)的值将更新为poto(v)的值,acti(v)的值将更新为poti(v)的值。In the original server, poto(v) will be updated to the value of acto(v), and the value of poti(v) will be updated to the value of acti(v); in the target server, the value of acto(v) will be updated to poto (v), the value of acti(v) will be updated to the value of poti(v).

对原始服务器中存储的v的邻居顶点来说,v入边集每条边的源顶点vi,acto(vi)减少1;v出边集每条边的目标顶点vj,acti(vj)减少1。For the neighbor vertices of v stored in the original server, the source vertex v i and acto(v i ) of each edge in v’s incoming edge set are reduced by 1; the target vertex v j of each edge in v’s outgoing edge set, acti(v j ) Decrease by 1.

对目标服务器中存储的邻居顶点来说,v入边集每条边的源顶点vk,acto(vk)增加1;v出边集每条边的目标顶点vs,acti(vs)增加1。For the neighbor vertices stored in the target server, the source vertex v k of each edge in the v incoming edge set, acto(v k ) increases by 1; the target vertex v s of each edge in the v outgoing edge set, acti(v s ) increase by 1.

(4)边重新划分阶段。当某一顶点v连接边的数量超过预设阈值ThresholdE时,对顶点v的边进行重新划分(不移动顶点v),并更新内存中维护的计数器。(4) Edge re-division stage. When the number of connected edges of a certain vertex v exceeds the preset threshold ThresholdE, the edges of the vertex v are re-divided (the vertex v is not moved), and the counter maintained in the memory is updated.

(4.1)将顶点v的出边及其目标顶点分割到同一服务器;(4.1) Split the outgoing edge of vertex v and its target vertex to the same server;

(4.2)将顶点v的入边及其源顶点分割到同一服务器;(4.2) Split the incoming edge of vertex v and its source vertex to the same server;

(4.3)清空顶点v的所有边计数器,更新split(v),确保顶点v不会再经历重新分配阶段;(4.3) Clear all edge counters of vertex v, update split(v), and ensure that vertex v will not go through the reallocation phase again;

(4.4)更新location(v)。(4.4) Update location(v).

(5)在上述(3)(4)步骤中,为了避免阻塞OLTP操作,所有的顶点以及相关数据都是异步移动的。(5) In the above steps (3) and (4), in order to avoid blocking OLTP operations, all vertices and related data are moved asynchronously.

(5.1)在(3)阶段,确定顶点移动的目标服务器、更新内存中的计数器后,讲该顶点添加到挂起的顶点重新划分队列中,停止提供关于该顶点的服务,拒绝发起该请求的客户端,并和客户端同步该顶点状态。(5.1) In stage (3), after determining the target server for vertex movement and updating the counter in the memory, add the vertex to the pending vertex repartition queue, stop providing services about the vertex, and reject the requester client, and synchronize the vertex state with the client.

(5.2)在(4)阶段,在更新内存中的计数器后,将该顶点的连接边添加到挂起的边重新划分队列中,停止提供关于不存储在本地的边的服务,拒绝发起该请求的客户端,并和客户端同步该顶点及其连接边状态。(5.2) In stage (4), after updating the counter in memory, add the connected edges of this vertex to the pending edge repartition queue, stop providing services about edges that are not stored locally, and refuse to initiate the request , and synchronize the state of the vertex and its connected edges with the client.

如图1所示,本发明实施例提供的一种基于顶点度的分布式图数据库增量图划分系统。分布式图数据库服务端分为三个服务模块,分别是计算服务模块、存储服务模块以及元数据服务模块。As shown in FIG. 1 , an embodiment of the present invention provides a distributed graph database incremental graph partitioning system based on vertex degree. The distributed graph database server is divided into three service modules, namely computing service module, storage service module and metadata service module.

计算服务模块中包括若干查询引擎,用于对客户端发起的查询请求进行解析,并执行OLTP事务;The computing service module includes several query engines, which are used to analyze the query requests initiated by the client and execute OLTP transactions;

存储服务模块中包括若干存储引擎,所述每个存储引擎中分为多个图分区;由于图数据库支持双向遍历,因此存储引擎应该保存每个顶点的出边集合和入边集合。The storage service module includes several storage engines, and each storage engine is divided into multiple graph partitions; since the graph database supports bidirectional traversal, the storage engine should save the outgoing edge set and incoming edge set of each vertex.

元数据服务模块中包括若干元数据服务引擎,所述元数据服务引擎包括元数据管理器、分区管理器和其他运维管理器;所述元数据服务引擎得到发生变动的顶点或边,执行计数器初始化、哈希划分、顶点重新划分和边重新划分。The metadata service module includes several metadata service engines, and the metadata service engine includes a metadata manager, a partition manager and other operation and maintenance managers; the metadata service engine obtains the changed vertices or edges, and executes the counter Initialization, hash partitioning, vertex repartitioning, and edge repartitioning.

本实施例将以一个样例方式,对上述一种基于顶点度的分布式图数据库增量图划分方法进行进一步的说明。In this embodiment, an example will be used to further illustrate the above-mentioned incremental graph division method of a distributed graph database based on vertex degree.

本实施例假设预设的顶点重新划分阶段阈值ThresholdR为6,边重新划分阶段的阈值ThresholdE为7。In this embodiment, it is assumed that the threshold ThresholdR of the vertex re-division stage is 6, and the threshold ThresholdE of the edge re-division stage is 7.

顶点重新划分阶段的阈值ThresholdR和边重新划分阶段的阈值ThresholdE均可以通过实验得到。在与实际应用场景数据相似的多个数据集中,用不同的阈值构建图,统计每个阈值对应的切边率和重新划分的顶点或边的数量作为代价,选择代价最小的值作为实际应用中的阈值。The threshold ThresholdR of the vertex re-division stage and the threshold ThresholdE of the edge re-division stage can be obtained through experiments. In multiple data sets similar to the actual application scene data, use different thresholds to construct graphs, count the edge cutting rate corresponding to each threshold and the number of re-divided vertices or edges as the cost, and select the value with the smallest cost as the actual application. threshold.

假设本样例集群拥有三台服务器。此时客户端发来连续的插入请求,插入完成后的图如图2所示。在初始默认划分阶段,对每个顶点计算哈希值后对3取模,被划分为3个分区。图2中的实线顶点表示该顶点存储在本地服务器中,虚线顶点表示该顶点没有存储在本地服务器中。为了实现图数据库的双向遍历,每条边会存储两次,如边(v->x)在服务器1中存储为顶点v的出边,在服务器2中存储为顶点x的入边,因此服务器1的size为8,服务器2的size为6,服务器3的size为4。Assume that this sample cluster has three servers. At this time, the client sends continuous insert requests, and the figure after the insert is completed is shown in Figure 2. In the initial default division stage, after calculating the hash value for each vertex, it is divided into 3 partitions by modulo 3. The solid line vertex in FIG. 2 indicates that the vertex is stored in the local server, and the dotted line vertex indicates that the vertex is not stored in the local server. In order to realize the two-way traversal of the graph database, each edge will be stored twice. For example, the edge (v->x) is stored as the outgoing edge of vertex v in server 1, and is stored as the incoming edge of vertex x in server 2. Therefore, the server The size of 1 is 8, the size of server 2 is 6, and the size of server 3 is 4.

在服务器1中,只有边(v->y)是表示了实际的连接边,因此acto(v)=1,acti(y)=1,其他的边都只是潜在的连接关系,即存储在另外两台服务器上,poti(x)=1,poto(z)=1,poto(u)=1,poti(s)=1,poti(w)=1。在服务器2和服务器3中,并没有存储顶点v,只保存了顶点v的一个索引。In server 1, only the side (v->y) represents the actual connection side, so acto(v)=1, acti(y)=1, and other sides are only potential connection relationships, that is, stored in another On the two servers, poti(x)=1, poti(z)=1, poti(u)=1, poti(s)=1, poti(w)=1. In server 2 and server 3, vertex v is not stored, only an index of vertex v is saved.

此时服务器1中顶点v的度数为6,已经到达顶点重新划分的阈值。计算服务器2的profit值为2*(2+1)-2*(1+0)+(6-8)=2,服务器3的profit值为2*(1+1)-2*(1+0)+(4-8)=-2,因此顶点v会从服务器1重新划分到服务器2,进行顶点重划分后的划分图以及服务器中存储的计数器值如图3所示,服务器1中acti(y)=0,size=7;服务器2中acto(v)=2,acti(v)=0,acto(u)=1,acti(s)=0,acti(x)=1,size=7;服务器3中poto(v)=1,poti(v)=1,size=4。At this time, the degree of vertex v in server 1 is 6, which has reached the threshold for vertex re-division. Calculate the profit value of server 2 as 2*(2+1)-2*(1+0)+(6-8)=2, and the profit value of server 3 as 2*(1+1)-2*(1+ 0)+(4-8)=-2, so the vertex v will be re-divided from server 1 to server 2, and the partition map after vertex re-division and the counter value stored in the server are shown in Figure 3. In server 1, acti (y)=0, size=7; in server 2, acto(v)=2, acti(v)=0, acto(u)=1, acti(s)=0, acti(x)=1, size= 7; poto(v)=1, poti(v)=1, size=4 in server 3.

客户端再次发送插入边(v->t)的请求,事务执行结束后,此时服务器1中顶点v的度数为7,已经到达边重新划分的阈值。如图4所示,分割前,图分区存储引擎1中存储的顶点v的入边集合为(u,z),出边集合为(s,t,w,y,x)。此时所有的边都存储在服务器1上,分割后,它们将根据各自目标顶点和源顶点的位置在所有三个服务器上分配,服务器存储引擎中存储的内容为:图分区存储引擎1中存储的顶点v的入边集合为(),出边集合为(t,y),图分区存储引擎2中存储的顶点v的入边集合为(u),出边集合为(s,x),图分区存储引擎3中存储的顶点v的入边集合为(x),出边集合为(w)。The client sends a request to insert an edge (v->t) again. After the transaction is executed, the degree of vertex v in server 1 is 7, which has reached the threshold for edge re-division. As shown in Fig. 4, before splitting, the incoming edge set of the vertex v stored in the graph partition storage engine 1 is (u, z), and the outgoing edge set is (s, t, w, y, x). At this time, all edges are stored on server 1. After splitting, they will be distributed on all three servers according to the positions of their respective target vertices and source vertices. The content stored in the server storage engine is: stored in graph partition storage engine 1 The set of incoming edges of vertex v is (), the set of outgoing edges is (t, y), the set of incoming edges of vertex v stored in graph partition storage engine 2 is (u), and the set of outgoing edges is (s, x), The incoming edge set of the vertex v stored in the graph partition storage engine 3 is (x), and the outgoing edge set is (w).

分别适用当前常见的图划分算法Fennel、Hash和本发明中基于顶点度的分布式图数据库增量图划分方法进行测试。下表1为本发明和其余传统图划分方法的多项性能对比,测试中使用的图中顶点的数量为百万级,边的数量为千万级。The current common graph partitioning algorithms Fennel, Hash and the incremental graph partitioning method of the distributed graph database based on the vertex degree in the present invention are respectively applied for testing. The following table 1 shows the multiple performance comparisons between the present invention and other traditional graph division methods. The number of vertices in the graph used in the test is on the order of millions, and the number of edges is on the order of tens of millions.

表1本发明方法和Fennel、Hash性能对比Table 1 method of the present invention and Fennel, Hash performance contrast

Figure BDA0004061098200000081
Figure BDA0004061098200000081

Figure BDA0004061098200000091
Figure BDA0004061098200000091

通过上表可得到,本发明实施例提供的方法所需要的图遍历(四步)时间小于Fennel和Hash,且切边率也小于Fennel和Hash两种方法。It can be seen from the above table that the graph traversal (four steps) time required by the method provided by the embodiment of the present invention is shorter than that of Fennel and Hash, and the edge cutting rate is also smaller than that of the two methods of Fennel and Hash.

以上所述仅为本说明书一个或多个实施例的较佳实施例而已,并不用以限制本说明书一个或多个实施例,凡在本说明书一个或多个实施例的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本说明书一个或多个实施例保护的范围之内。The above descriptions are only preferred embodiments of one or more embodiments of this specification, and are not intended to limit one or more embodiments of this specification. Within the spirit and principles of one or more embodiments of this specification, Any modification, equivalent replacement, improvement, etc. should be included in the scope of protection of one or more embodiments of this specification.

Claims (9)

1.一种基于顶点度的分布式图数据库增量图划分方法,其特征在于,该方法包括如下步骤:1. A distributed graph database incremental graph division method based on vertex degree, it is characterized in that, the method comprises the steps: S1、对图数据库中的计数器初始化,将内存中维护的计数器初始化为0,所述计数器用于记录图数据库每个分区中顶点的状态以及部署了存储服务的服务器中分区的状态,包括顶点的位置、顶点当前的分割状态以及顶点在当前服务器和其他部署存储服务的服务器上连接边的数量;S1. Initialize the counters in the graph database, initialize the counters maintained in the memory to 0, and the counters are used to record the state of the vertices in each partition of the graph database and the state of the partitions in the server where the storage service is deployed, including the state of the vertices The position, the current split state of the vertex, and the number of connected edges of the vertex on the current server and other servers where the storage service is deployed; S2、哈希划分,通过哈希函数得到当前数据图中的顶点id的哈希值,以及所有插入顶点id的哈希值,对服务器总数的值取模,将顶点及其连接边进行哈希划分,同时更新服务器上存储的计数器;S2. Hash division, obtain the hash value of the vertex id in the current data graph through the hash function, and the hash values of all inserted vertex ids, take the modulus of the total number of servers, and hash the vertices and their connected edges partition while updating the counters stored on the server; S3、顶点重新划分,随着OLTP事务的执行,以下步骤所有的顶点以及相关数据都进行异步移动和更新;当某一顶点v连接边的数量超过阈值ThresholdR时,评估将v从当前服务器移动到其他服务器的收益,并将v移动到收益最大的服务器;更新服务器上存储的计数器;S3. Vertex re-division. With the execution of OLTP transactions, all vertices and related data in the following steps are moved and updated asynchronously; when the number of edges connected to a vertex v exceeds the threshold ThresholdR, the evaluation will move v from the current server to other servers' gains, and move v to the server with the greatest gain; update the counter stored on the server; S4、边重新划分,当某一顶点v在存储引擎中存储的连接边的数量超过阈值ThresholdE时,在不移动顶点v的情况下,重新分配这些连接边的位置,将顶点v的出边及其目标顶点分割到同一服务器,并将顶点v的入边及其源顶点分割到同一服务器;更新服务器上存储的计数器。S4, edge re-division, when the number of connection edges stored in a certain vertex v in the storage engine exceeds the threshold ThresholdE, without moving the vertex v, redistribute the positions of these connection edges, and the outgoing edges and Its target vertex is split to the same server, and the incoming edge of vertex v and its source vertex are split to the same server; the counter stored on the server is updated. 2.根据权利要求1所述的基于顶点度的分布式图数据库增量图划分方法,其特征在于,所述S1中计数器包括:2. the distributed graph database incremental graph division method based on vertex degree according to claim 1, is characterized in that, counter comprises in the described S1: 在当前存储顶点v的服务器上,通过计数器split(v)的值1或0表示顶点v的边是否已经被分割过;On the server that currently stores the vertex v, the value 1 or 0 of the counter split(v) indicates whether the edge of the vertex v has been split; 在最初或当前存储顶点v的服务器上,通过计数器location(v)表示v的准确位置;On the server where the vertex v is originally or currently stored, the exact location of v is indicated by the counter location(v); 顶点v最多会拥有以下四个计数器,用于记录顶点连接边的信息:Vertex v will have at most the following four counters, which are used to record the information of the connected edges of the vertex: 计数器acto(v)用来表示v出边集中目标顶点和v存储在同一服务器上的边的数量,acto(v)只存储在实际存储v的服务器上;The counter acto(v) is used to indicate the number of edges of the target vertex and v stored on the same server in the outgoing edge set of v, and acto(v) is only stored on the server that actually stores v; 计数器acti(v)用来表示v入边集中源顶点和v存储在同一服务器上的边的数量,acti(v)只存储在实际存储v的服务器上;The counter acti(v) is used to indicate the number of edges in v’s incoming edge set where the source vertices and v are stored on the same server, and acti(v) is only stored on the server that actually stores v; 计数器poto(v)用来表示v出边集中目标顶点和v不存储在同一服务器上的边的数量,poto(v)只存储在存储v的邻居顶点的服务器上;The counter poto(v) is used to indicate the number of edges in v’s outgoing edge set where the target vertex and v are not stored on the same server, and poto(v) is only stored on the server that stores v’s neighbor vertices; 计数器poti(v)用来表示v入边集中源顶点和v不存储在同一个服务器上的边的数量,The counter poti(v) is used to indicate the number of edges in v’s incoming edge set where the source vertices and v are not stored on the same server, (v)只存储在存储v的邻居顶点的服务器上;(v) is stored only on servers that store v's neighbor vertices; 在每台服务器上,通过计数器size表示服务器上存储的分区的顶点和边总数的和。On each server, the sum of the total number of vertices and edges for the partitions stored on the server is represented by the counter size. 3.根据权利要求2所述的基于顶点度的分布式图数据库增量图划分方法,其特征在于,所述S2中更新存储的计数器步骤如下:3. the method for dividing the incremental graph of distributed graph database based on vertex degree according to claim 2, is characterized in that, the counter step of updating storage among the described S2 is as follows: 在当前存储顶点v的服务器上,通过计算插入边e的目标顶点u的哈希值以及当前服务器存储的location(u),能够确定插入边e的目标顶点u和v是否在存储在同一服务器中;On the server currently storing vertex v, by calculating the hash value of the target vertex u of the inserted edge e and the location(u) stored in the current server, it can be determined whether the target vertex u and v of the inserted edge e are stored in the same server ; 如果u和v在同一服务器上,则acto(v)的值增加1;If u and v are on the same server, the value of acto(v) is increased by 1; 如果u和v不在同一服务器上,则poti(u)的值增加1;If u and v are not on the same server, the value of poti(u) is increased by 1; 同理,在存储顶点u的服务器上,计数器也会进行相应的更新。Similarly, on the server storing vertex u, the counter will be updated accordingly. 4.根据权利要求1所述的基于顶点度的分布式图数据库增量图划分方法,其特征在于,所述S3中顶点重新划分的具体步骤如下:4. the method for dividing the incremental graph of distributed graph database based on vertex degree according to claim 1, is characterized in that, the specific steps of re-dividing the vertex in the described S3 are as follows: 评估将v从当前服务器Snow移动到其他服务器Si的收益
Figure FDA0004061098190000021
并将v移动到收益profit最大的服务器,即目标服务器,表示为Starget,收益profit评估公式如下:
Evaluate the payoff of moving v from the current server S now to some other server S i
Figure FDA0004061098190000021
And move v to the server with the largest profit profit, that is, the target server, denoted as S target , and the profit evaluation formula is as follows:
Figure FDA0004061098190000022
Figure FDA0004061098190000022
其中,
Figure FDA0004061098190000023
为移动后v出边集中目标顶点和v不存储在同一服务器上的边的数量,
Figure FDA0004061098190000024
为移动后v入边集中源顶点和v不存储在同一个服务器上的边的数量,
Figure FDA0004061098190000025
为当前服务器v出边集中目标顶点和v存储在同一服务器上的边的数量,
Figure FDA0004061098190000026
为当前服务器v入边集中源顶点和v存储在同一服务器上的边的数量,/>
Figure FDA0004061098190000027
Figure FDA0004061098190000028
分别为移动后服务器和当前服务器中存储的分区的顶点和边总数的和。
in,
Figure FDA0004061098190000023
is the number of edges where the target vertex and v are not stored on the same server in the outbound edge set of v after the move,
Figure FDA0004061098190000024
is the number of edges whose source vertices and v are not stored in the same server in v's inbound edge set after moving,
Figure FDA0004061098190000025
For the current server v, the number of edges in the target vertex and v stored on the same server,
Figure FDA0004061098190000026
For the current server v, the number of edges in the pool of source vertices and v stored on the same server, />
Figure FDA0004061098190000027
and
Figure FDA0004061098190000028
are the sum of the total number of vertices and edges of the partitions stored in the moved server and the current server, respectively.
5.根据权利要求4所述的基于顶点度的分布式图数据库增量图划分方法,其特征在于,所述S3中更新服务器上存储的计数器步骤如下:5. the method for dividing the incremental graph of distributed graph database based on vertex degree according to claim 4, is characterized in that, in the described S3, the counter step stored on the update server is as follows: 在完成顶点v的重新划分之后,需要更新顶点v以及v的邻居顶点在内存中维护的计数器的值:After completing the re-division of vertex v, it is necessary to update the value of the counter maintained in memory by vertex v and v's neighbor vertices: 将location(v)从当前服务器Snow移动到目标服务器StargetMove location(v) from the current server S now to the target server S target ; 当前服务器Snow的size值减少1,目标服务器Starget的size值增加1;The size value of the current server S now is reduced by 1, and the size value of the target server S target is increased by 1; 在原始服务器中,poto(v)的值将更新为acto(v)的值,poti(v)的值将更新为acti(v)的值;在目标服务器中,acto(v)的值将更新为poto(v)的值,acti(v)的值将更新为poti(v)的值;In the original server, the value of poto(v) will be updated to the value of acto(v), and the value of poti(v) will be updated to the value of acti(v); in the target server, the value of acto(v) will be updated is the value of poto(v), the value of acti(v) will be updated to the value of poti(v); 对原始服务器中存储的v的邻居顶点来说,v入边集每条边的源顶点vi对应的acto(vi)减少1;v出边集每条边的目标顶点vj对应的acti(vj)减少1;For the neighbor vertices of v stored in the original server, the acto(v i ) corresponding to the source vertex v i of each edge set of v is reduced by 1; the acti corresponding to the target vertex v j of each edge set of v (v j ) decreases by 1; 对目标服务器中存储的v的邻居顶点来说,v入边集每条边的源顶点vk对应的acto(vk)增加1;v出边集每条边的目标顶点vs对应的acti(vs)增加1。For the neighbor vertices of v stored in the target server, the acto(v k ) corresponding to the source vertex v k of each edge set of v is increased by 1; the acti corresponding to the target vertex vs s of each edge set of v (v s ) is incremented by 1. 6.根据权利要求2所述的基于顶点度的分布式图数据库增量图划分方法,其特征在于,所述S4中更新计数器操作为:清空顶点v的所有边计数器,更新split(v),确保顶点v不会再重新分配,更新location(v)。6. the incremental graph division method of distributed graph database based on vertex degree according to claim 2, it is characterized in that, update counter operation among the described S4: clear all edge counters of vertex v, update split(v), To ensure that vertex v will not be reallocated again, update location(v). 7.根据权利要求1所述的基于顶点度的分布式图数据库增量图划分方法,其特征在于,所述S3,确定顶点移动的目标服务器、更新内存中的计数器后,在当前OLTP事务中,将该顶点添加到挂起的顶点重新划分队列中;在当前事务完成之后,立刻停止处理与该顶点有关的请求,拒绝发起该请求的客户端,并和客户端同步该顶点状态;客户端同步状态后,再次向正确的服务器发起请求。7. The incremental graph division method of distributed graph database based on vertex degree according to claim 1, characterized in that, said S3, after determining the target server of vertex movement and updating the counter in the memory, in the current OLTP transaction , add the vertex to the pending vertex repartition queue; after the current transaction is completed, immediately stop processing the request related to the vertex, reject the client that initiated the request, and synchronize the state of the vertex with the client; the client After the state is synchronized, make a request to the correct server again. 8.根据权利要求1所述的基于顶点度的分布式图数据库增量图划分方法,其特征在于,所述步骤S4中,在更新内存中的计数器后,在当前事务中,将该顶点的连接边添加到挂起的边重新划分队列中;在当前事务完成之后,立刻停止处理关于不存储在本地的边的请求,拒绝发起该请求的客户端,并和客户端同步该顶点及其连接边状态;客户端同步状态后,再次向正确的服务器发起请求。8. The incremental graph division method of distributed graph database based on vertex degree according to claim 1, characterized in that, in the step S4, after updating the counter in the memory, in the current transaction, the vertex's The connection edge is added to the pending edge repartition queue; immediately after the current transaction is completed, stop processing requests for edges that are not stored locally, reject the client that initiated the request, and synchronize the vertex and its connections with the client Edge state; after the client synchronizes the state, it initiates a request to the correct server again. 9.一种用于实现权利要求1-8任一项所述方法的系统,其特征在于,该系统为一种图数据库,分为三个服务模块,分别是计算服务模块、存储服务模块以及元数据服务模块;9. A system for implementing the method according to any one of claims 1-8, characterized in that the system is a graph database, which is divided into three service modules, namely, a computing service module, a storage service module, and a metadata service module; 所述计算服务模块中包括若干查询引擎,用于对客户端发起的查询请求进行解析,并执行OLTP事务;The calculation service module includes several query engines, which are used to analyze the query requests initiated by the client and execute OLTP transactions; 所述存储服务模块中包括若干存储引擎,每个存储引擎中存储多个图分区,用于保存每个顶点的出边集合和入边集合;The storage service module includes several storage engines, and each storage engine stores a plurality of graph partitions for storing the outgoing edge set and incoming edge set of each vertex; 所述元数据服务模块中包括若干元数据服务引擎,所述元数据服务引擎包括元数据管理器、分区管理器和运维管理器;所述元数据服务引擎用于得到发生变动的顶点或边,执行计数器初始化、哈希划分、顶点重新划分和边重新划分。The metadata service module includes several metadata service engines, and the metadata service engine includes a metadata manager, a partition manager and an operation and maintenance manager; the metadata service engine is used to obtain the changed vertices or edges , performs counter initialization, hash partitioning, vertex repartitioning, and edge repartitioning.
CN202310060074.3A 2023-01-18 2023-01-18 Distributed graph database incremental graph partitioning method and system based on vertex degree Pending CN116303763A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310060074.3A CN116303763A (en) 2023-01-18 2023-01-18 Distributed graph database incremental graph partitioning method and system based on vertex degree

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310060074.3A CN116303763A (en) 2023-01-18 2023-01-18 Distributed graph database incremental graph partitioning method and system based on vertex degree

Publications (1)

Publication Number Publication Date
CN116303763A true CN116303763A (en) 2023-06-23

Family

ID=86812182

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310060074.3A Pending CN116303763A (en) 2023-01-18 2023-01-18 Distributed graph database incremental graph partitioning method and system based on vertex degree

Country Status (1)

Country Link
CN (1) CN116303763A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117556095A (en) * 2024-01-11 2024-02-13 腾讯科技(深圳)有限公司 Graph data segmentation method, device, computer equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117556095A (en) * 2024-01-11 2024-02-13 腾讯科技(深圳)有限公司 Graph data segmentation method, device, computer equipment and storage medium
CN117556095B (en) * 2024-01-11 2024-04-09 腾讯科技(深圳)有限公司 Graph data segmentation method, device, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
US12169507B2 (en) Database compaction in distributed data system
Serafini et al. Clay: Fine-grained adaptive partitioning for general database schemas
US10019294B2 (en) Method of achieving intra-machine workload balance for distributed graph-processing systems
CN106777351B (en) ART Tree-Based Distributed System Graph Storage Computing System and Its Method
US10445344B2 (en) Load balancing for large in-memory databases
US20190384845A1 (en) Using computing resources to perform database queries according to a dynamically determined query size
CN108600321A (en) A kind of diagram data storage method and system based on distributed memory cloud
Dai et al. IOGP: An incremental online graph partitioning algorithm for distributed graph databases
US20150370647A1 (en) Directed backup for massively parallel processing databases
CN104111936A (en) Method and system for querying data
US11176088B2 (en) Dynamic server pool data segmentation using dynamic ordinal partition key without locks
CN105975345A (en) Video frame data dynamic equilibrium memory management method based on distributed memory
CN116303763A (en) Distributed graph database incremental graph partitioning method and system based on vertex degree
KR102054068B1 (en) Partitioning method and partitioning device for real-time distributed storage of graph stream
CN107506388A (en) A kind of iterative data balancing optimization method towards Spark parallel computation frames
Liroz-Gistau et al. Dynamic workload-based partitioning algorithms for continuously growing databases
US10657126B2 (en) Meta-join and meta-group-by indexes for big data
Sakouhi et al. Hammer lightweight graph partitioner based on graph data volumes
Li et al. A partition model and strategy based on the Stoer–Wagner algorithm for SaaS multi-tenant data
Ge et al. Cinhba: A secondary index with hotscore caching policy on key-value data store
Li Dynamic load balancing method for urban surveillance video big data storage based on HDFS
Govindaraju et al. Big data processing: Scalability with extreme single-node performance
WO2024119980A1 (en) Data analysis method and related device
Shi et al. PECC: parallel expansion based on clustering coefficient for efficient graph partitioning
CN117874297A (en) Partition management method of distributed KV

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination