Skip to content

Instantly share code, notes, and snippets.

@rkroll
Created April 12, 2013 20:52
Show Gist options
  • Save rkroll/5375046 to your computer and use it in GitHub Desktop.
Save rkroll/5375046 to your computer and use it in GitHub Desktop.
TitanGraph g = titanGraphService.getSingleton()
In a job:
while(true) {
Vertex vertex = g.addVertex(null);
vertex.setProperty("foo", "bar");
batchCount++;
if(batchCount % 1000 == 0) { g.commit() }
}
Then in a separate (Jersey) class:
TitanGraph g = titanGraphService.getSingleton();
Iterable<Vertex> v = titanGraph.query().vertices()
int count = 0;
while(v.hasNext()) {
count++;
}
The first time you access the jersey class, count will be for example 2000, then on every subsequent request, count will be 2000 (always returns the cached result).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment