Created
April 30, 2013 03:35
-
-
Save espeed/5486461 to your computer and use it in GitHub Desktop.
Convert vertex IDs to vertices in Gremlin
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
| // If you use an external search engine to return a list of vertex IDs, | |
| // a common pattern in Gremlin for starting with Vertex IDs has been to | |
| // convert the IDs to vertices and use the IdentityPipe to start the pipeline... | |
| // See IdentityPipe https://github.com/tinkerpop/gremlin/wiki/Gremlin-Steps | |
| start = [1,2,3,4].collect{ g.v(it) } | |
| start._().filter{it.isActive} | |
| // ...or as a one liner... | |
| [1,2,3,4].collect{ g.v(it) }._().filter{it.isActive} | |
| // Now this is what g.v(ids) is doing under the hood... | |
| // https://github.com/tinkerpop/gremlin/blob/master/gremlin-groovy/src/main/groovy/com/tinkerpop/gremlin/groovy/loaders/GraphLoader.groovy#L48 | |
| g.v(ids).filter{it.isActive} // easiest way now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment