Hi All, 

I am sorry for my previous email, I made a mistake and chose a wrong mailing 
list (neo4j instead of gremlin mailing list).  

Best Regards,
Wojtek  


Dnia 18 października 2011 9:59 skarab77 <skara...@o2.pl> napisał(a):

> I need a pipe, which returns a set of vertices for an input Vertex (wrapped 
> in User Defined Step). I use blueprints pipes with Neo4j. My current code is:
> 
> import org.junit.Test
> import com.tinkerpop.blueprints.pgm.Graph
> import com.tinkerpop.blueprints.pgm.Vertex
> import com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jVertex
> import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
> import com.tinkerpop.gremlin.Gremlin
> import com.tinkerpop.pipes.AbstractPipe
> import com.tinkerpop.pipes.Pipe
> 
> class MyUDSTest  {
> 
> public static class MyPipe extends  AbstractPipe<Vertex, Iterable<Vertex>> {
> 
>     @Override
>     protected Iterable<Vertex> processNextStart() throws 
> NoSuchElementException {
>             def v =  this.starts.next();
> 
>             def nodes = [v, v, v].iterator; 
> 
>             return new Iterable<Vertex>() {
>             @Override
>             public Iterator<Vertex> iterator() {
>                 return new Iterator<Vertex>() {
>                     @Override
>                     public boolean hasNext() {
>                         return nodes.hasNext();
>                     }
> 
>                     @Override
>                     public Vertex next() {
>                         return new Neo4jVertex(nodes.next(), graph);
>                     }
> 
>                     @Override
>                     public void remove() {
>                         throw new UnsupportedOperationException();
> 
>                     }
>                 };
>             }
>         };
> }
> 
> }
> 
> @Test
> public void testUDS() 
> {           
>     Gremlin.load();
>     Graph g; 
>     Gremlin.defineStep('myPipe',[Vertex,Pipe], { new MyPipe() })
> 
>     g = TinkerGraphFactory.createTinkerGraph()
>     println "$g"
>     def result = [] 
>     g.v(1).myPipe.filter{true} >> result
> 
>     result.each {
>         println "$it"           
>     }   
> 
> }
> 
> }
> 
> However it does not work property in the gremlin expression:
> 
> Gremlin.defineStep('myPipe',[Vertex,Pipe], { new MyPipe() })
>  ...
>  def result = [];    
>  g.v(1).myPipe >> result
> 
> result.each 
> {
>   println it
> }
> 
> prints out: neo4j.MyUDSTest$MyPipe$1@49aacd5f. I would expect that I will get 
> a list of vertices. Could anybody help me with this pipe? 
> 
> 
_______________________________________________
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to