Created
December 10, 2011 02:11
-
-
Save espeed/1454298 to your computer and use it in GitHub Desktop.
Scoped Groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_indexed_vertex(data,index_name,keys) { | |
manager = g.getRawGraph().index() | |
index = manager.forNodes(index_name) | |
g.setMaxBufferSize(0) | |
g.startTransaction() | |
vertex = g.getRawGraph().createNode() | |
for (entry in data.entrySet()) { | |
if (entry.value == null) continue; | |
vertex.setProperty(entry.key,entry.value) | |
if (keys == null || keys.contains(entry.key)) | |
index.add(vertex,entry.key,entry.value) | |
} | |
g.stopTransaction(TransactionalGraph.Conclusion.SUCCESS) | |
return vertex | |
} | |
return create_indexed_vertex(data,index_name,keys) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment