[Blueprints] TransactionalGraph, ThreadedTransactionalGraph, and BufferGraph

97 views
Skip to first unread message

Marko Rodriguez

unread,
May 11, 2012, 5:17:00 PM5/11/12
to gremli...@googlegroups.com
Hi,

For TinkerPop 2, we have done some reorganizing of TransactionalGraph. No longer is there a concept of a mutation buffer.


However, there is now a BufferGraph which is a graph wrapper.

Finally, there is a new interface coming to town that allows multiple threads within the same transaction:
As far as we know, Neo4jGraph and OrientGraph will not be able to support this, but for other graph databases (into the future) that can support multiple threads within the same transactions, we have the interface. Matthias can say more on it.

Take care,
Marko.

Matthias Broecheler

unread,
May 13, 2012, 3:29:18 PM5/13/12
to gremli...@googlegroups.com
ThreadedTransactionalGraph extends TransactionalGraph by an additional method that returns a TransactionalGraph identifying a thread-independent transactional object. This is in contrast to TransactionalGraph where transactions are always tied to the thread operating on the graph.
So, what this allows you to do is something like the following.

ThreadedTransactionalGraph g = new ...
TransactionalGraph transaction = g.startThreadTransaction() //we get a transaction object that is independent from the current thread
for (Vertex marko : transaction.getVertices("name","Marko")) {
     Thread particle = new ParticleSwarm(transaction,marko);
     particle.run();
}
//Collect all the results from the individual particles for a particular analysis

This code snippet is just for demonstration purposes and illustrates a scenario, where you want to have multiple particles traverse a graph starting from all the vertices named "Marko" for some sort of analysis and then collect the results. To speed up the analysis, we run each particle in a separate thread. In TransactionalGraph, each of these threads would run in a separate transaction, which is not what we want here (in particular if the particle modifies the graph in any way).

Now, while this is a more "advanced" application of transactions, it will be a very important one in the near future. A lot of graph algorithms are pretty expensive (e.g. extensive traversals) but easily parallelizable. As raw CPU performance won't be increasing much but many more cores will be added, multi-threaded approaches (such as the trivial one outlined above) are the only way to speed up such algorithms. ThreadedTransactionalGraph provides transactional support for multi-threaded algorithms.

Cheers,
Matthias
--
Matthias Broecheler, PhD
http://www.matthiasb.com
E-Mail: m...@matthiasb.com
Reply all
Reply to author
Forward
0 new messages