Skip to content

Instantly share code, notes, and snippets.

@espeed
Created September 4, 2011 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save espeed/1193693 to your computer and use it in GitHub Desktop.
Save espeed/1193693 to your computer and use it in GitHub Desktop.
Jython AbstractPipeClosure Example
# Jython AbstractPipeClosure Example
# by James Thornton, http://jamesthornton.com
from com.tinkerpop.pipes.util import FluentPipeline
from com.tinkerpop.pipes import AbstractPipeClosure
from com.tinkerpop.blueprints.pgm.impls.tg import TinkerGraphFactory
class StartsWithJ(AbstractPipeClosure):
def compute(self,objects):
return objects[0].startswith("j")
starts_with_j = StartsWithJ()
pipe = FluentPipeline()
g = TinkerGraphFactory.createTinkerGraph()
results = pipe.start(g.getVertex(1)).out("knows").property("name").filter(starts_with_j).back(2).out("created")
for vertex in results:
print vertex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment