Created
September 4, 2011 23:14
-
-
Save espeed/1193693 to your computer and use it in GitHub Desktop.
Jython AbstractPipeClosure Example
This file contains 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
# 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