How doe the "." notations in Query & GremlinPipeline work in Java

132 views
Skip to first unread message

pShah

unread,
May 17, 2012, 10:21:58 AM5/17/12
to gremli...@googlegroups.com
Hi,
  My primary background is Database programming.  I have done some C# as well and I thought the "." notation used where extension methods.

  But I couldn't understand from the source code of "blueprints" how this works?

  Can someone expalin it using the "Query.java" as the example and how the Edge/Vertex knows what appropriate method goes after the "."

Thanks

Marko Rodriguez

unread,
May 17, 2012, 11:35:47 AM5/17/12
to gremli...@googlegroups.com
Hi,

Using that notation to invoke a method which simply returns the object again is called "the fluent style." (I believe that is the generally accepted term). It is possible to do this in most languages.

Thus, when you do:

GremlinPipeline.out()

You are taking the GremlinPipeline and adding an OutPipe to it. The return of out() is the GremlinPipeline with the new OutPipe on it. As such, you can continuously chain methods.

GremlinPipeline.out().has().in().property()....

Likewise for objects like Blueprints' Query.

I hope that is clear,
Marko.

pShah

unread,
May 17, 2012, 11:40:53 AM5/17/12
to gremli...@googlegroups.com
It does help.  I just have to look at the code more carefully to get a better understanding.

It primarily confuses me becuas the "TinkerVertex.java" class has "query" as a method but not the "has", so how does the Vertex instance know that it can use "has"

Marko Rodriguez

unread,
May 17, 2012, 4:45:50 PM5/17/12
to gremli...@googlegroups.com
Study the code. 

Marko.

pShah

unread,
May 17, 2012, 5:08:38 PM5/17/12
to gremli...@googlegroups.com
That's the plan.

Marko Rodriguez

unread,
May 17, 2012, 5:25:52 PM5/17/12
to gremli...@googlegroups.com
Cool. :).

Marko.

Alexandre Vallette

unread,
Jul 29, 2013, 12:42:37 PM7/29/13
to gremli...@googlegroups.com
sorry for my stupid question but once you get the pipeline list like:
com.tinkerpop.gremlin.java.GremlinPipeline[Nothing,com.tinkerpop.blueprints.Edge] = [StartPipe, InEdgesPipe(parent)]

how do you evaluate it?
I'm confused because in gremlin this evaluation is automatic

Viktoras Veitas

unread,
Jul 30, 2013, 4:33:17 AM7/30/13
to gremli...@googlegroups.com
Sometimes I apply .toList() method:
http://www.tinkerpop.com/docs/javadocs/gremlin/2.3.0/com/tinkerpop/gremlin/java/GremlinPipeline.html#toList%28%29

Viktoras

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages