-
Notifications
You must be signed in to change notification settings - Fork 274
Partition Implementation
PartitionGraph
is a graph wrapper that partitions the elements (vertices/edges) of a graph into String
named partions. The idea behind PartitionGraph
is presented in the image above where each element is in a single partition (represented by its color). Partitions can be read, written to, and linked by edges that span one or two partitions.
PartitionGraph
is simple to use. There are three primary variables in PartitionGraph
:
-
Partition Key: The property key that denotes a
String
value representing a partition. -
Write Partition: A
String
denoting what partition all future written elements will be in. -
Read Partitions: A
Set<String>
of partitions that can be read from.
The best way to understand PartitionGraph
is via an example.
PartitionGraph graph = new PartitionGraph(rawGraph, "_partition", "a"); // reading and writing is to partition "a"
Vertex v1 = graph.addVertex(null); // v1 has a property of {_partition:"a"}
graph.setWritePartition("b");
Vertex v2 = graph.addVertex(null); // v2 has a property of {_partition:"b"}
graph.getVertices(); // only v1 is in the iterator
graph.addReadPartition("b");
graph.getVertices() // both v1 and v2 are in the iterator
graph.removeReadPartition("a");
graph.removeReadPartition("b");
graph.getVertices(); // no vertices are in the iterator
graph.setWritePartition("c");
Edge e1 = graph.addEdge(null, v1, v2, "knows"); // e1 has a property of {_partition:"c"}
graph.getEdges(); // e1 is in the iterator
By writing elements to particular partitions and then restricting read partions, the developer is able to create multiple graphs within a single address space. Moreover, by supporting references between partitions, it is possible to have merges of those multiple graphs. Finally, there also exists PartitionIndexableGraph
with read partition respective index get()
and count()
methods.