Gremlin-Scala: 2.2.0 ready

607 views
Skip to first unread message

Michael Pollmeier

unread,
Jan 5, 2013, 11:35:37 PM1/5/13
to gremli...@googlegroups.com
For anyone using Gremlin-Scala: I've just bumped my fork to Gremlin 2.2.0: https://github.com/mpollmeier/tinkubator
I've also taken this opportunity to upgrade to Scala 2.10.0.
If any of you depends on a different version of Scala you can simply change the scala.version in the pom.xml.

Cheers
Michael

Stephen Mallette

unread,
Jan 6, 2013, 6:33:02 AM1/6/13
to gremli...@googlegroups.com
michael, thank for the update on gremlin-scala.

best regards,

stephen
> --
>
>

Marko A. Rodriguez

unread,
Jan 6, 2013, 2:32:44 PM1/6/13
to gremli...@googlegroups.com
Hey Michael,

Have you thought of taking Gremlin-Scala as its own repo and not as a fork of the Tinkubator? This way we can remove it from the Tinkubator and you can be the lead maintainer of the repository ?

Thoughts?,
Marko.

http://markorodriguez.com
> --
>
>

Michael Pollmeier

unread,
Jan 7, 2013, 12:40:43 AM1/7/13
to gremli...@googlegroups.com
Can do, no problem. Do you remember who started the Project, maybe we should ask him/her first? I don't want to just anything over without even asking...

Apart from that, are you happy for me to go ahead cutting out the files (thereby removing the git history) and putting it onto my github account? Or should we rather have it on tinkerpop's account and grant me rights for that project / add me as a member?
I don't mind either way.

Cheers
Michael

Marko A. Rodriguez

unread,
Jan 7, 2013, 10:50:07 AM1/7/13
to gremli...@googlegroups.com
Hi Michael,


> Can do, no problem. Do you remember who started the Project, maybe we should ask him/her first? I don't want to just anything over without even asking…

His name is Zach Cox and he is on this mailing list. He is watching us right now...

> Apart from that, are you happy for me to go ahead cutting out the files (thereby removing the git history) and putting it onto my github account? Or should we rather have it on tinkerpop's account and grant me rights for that project / add me as a member?

I would do this:
1. Take the project and push it to your repo.
2. Since it was originally BSD, make the license anything you want, but:
- give credit to Zach Cox
- give credit to TinkerPop
.. in your README or NOTICE
3. Organize it as you please (if you want a little logo, I can make you one).
4. Then we promote your repo and off it goes!

Marko.

Michael Pollmeier

unread,
Jan 8, 2013, 2:51:10 AM1/8/13
to gremli...@googlegroups.com
Sounds cool, will do. If you have an idea for a logo please go ahead and make one. The other tinkerpop logos are really awesome so I'd be happy to have one of those ;)

Michael Pollmeier

unread,
Jan 9, 2013, 4:22:08 AM1/9/13
to gremli...@googlegroups.com
There we go: https://github.com/mpollmeier/gremlin-scala
Let me know if you want to see any changes to the readme. I'll add some sample usage and a quick how-to get started later.

Marko A. Rodriguez

unread,
Jan 9, 2013, 2:09:52 PM1/9/13
to gremli...@googlegroups.com
Hi Michael,

There we go: https://github.com/mpollmeier/gremlin-scala
Let me know if you want to see any changes to the readme. I'll add some sample usage and a quick how-to get started later.

Great. As promised, please see the attached Gremlin-Scala logo.

Next, here are some random assortment of thoughts:
1. In your README, show a code snippet of what Gremlin-Scala looks like.
- something basic so people go: "ah… I get it."
2. Make a wikipage that has a two column Gremlin-Groovy vs. Gremlin-Scala that shows how the syntax varies between the two.
3. You could advertise that this works for:
- OrientDB, DEX, Neo4j, InfiniteGraph, Neo4j, etc. blah blah so people go "huh, thats cool."

Finally, looks great and thanks. Gremlin-Scala is very cool and has been just sitting in the Tinkubator all lonely. Thank you for bringing it back to life.

…when you have the logo all set up, I'll tweet the project.

Good luck Michael,
Marko.




On Tuesday, 8 January 2013 20:51:10 UTC+13, Michael Pollmeier wrote:
Sounds cool, will do. If you have an idea for a logo please go ahead and make one. The other tinkerpop logos are really awesome so I'd be happy to have one of those ;)

On Tuesday, 8 January 2013 04:50:07 UTC+13, Marko A. Rodriguez wrote:
Hi Michael,


> Can do, no problem. Do you remember who started the Project, maybe we should ask him/her first? I don't want to just anything over without even asking…

His name is Zach Cox and he is on this mailing list. He is watching us right now...

> Apart from that, are you happy for me to go ahead cutting out the files (thereby removing the git history) and putting it onto my github account? Or should we rather have it on tinkerpop's account and grant me rights for that project / add me as a member?

I would do this:
        1. Take the project and push it to your repo.
        2. Since it was originally BSD, make the license anything you want, but:
                - give credit to Zach Cox
                - give credit to TinkerPop
                .. in your README or NOTICE
        3. Organize it as you please (if you want a little logo, I can make you one).
        4. Then we promote your repo and off it goes!

Marko.

--
 
 



Michael Pollmeier

unread,
Jan 22, 2013, 3:39:16 AM1/22/13
to gremli...@googlegroups.com
Thanks Erik, I'll add something like that on the weekend.
Cheers, Michael

On Tuesday, 22 January 2013 04:03:18 UTC+13, eriks...@gmail.com wrote:
Hi all,

I just stumbled onto Gremlin and its Scala flavour, and the recommendations under 1 and 2 are exactly what I was looking for. I'm new to Gremlin, so it would be great to know what I can use it with, which dependencies to put in my Maven/SBT build and what a Hello World would look like. I can't wait to fiddle around with it!

Cheers,
Erik

Erik Post

unread,
Jan 22, 2013, 12:02:37 PM1/22/13
to gremli...@googlegroups.com
Hi Michael,

Thanks, I'm a lot further along now. I had a bit of trouble figuring out what to do initially because of problems with the Gremlin REPL. When evaluating the initial addImports in Console.scala, it choked on some of the Java imports containing a "static " prefix. However, since exceptions were being swallowed, the imports step simply failed. Consequently, most of the stuff I entered beyond that point didn't give me any output. Manually importing some of the required stuff helped, but I still couldn't get the automatic imports to work because:

1) I got a 'class broken' error when importing TransactionalGraph$Conclusion.
2) The REPL keeps crashing when doing imports, for some reason.

I'm using Scala version 2.10.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_06).
--
 
 

Michael Pollmeier

unread,
Jan 28, 2013, 3:07:46 AM1/28/13
to gremli...@googlegroups.com, er...@shinsetsu.nl
I've just updated the readme and put together some simple use cases to start with. It's on the readme aswell as an executable ScalaTest specification (SampleUsageTest.scala). Let me know your thoughts!
https://github.com/mpollmeier/gremlin-scala

PS: the Console seems to be broken, will have a look when I find a minute.

Alfredo Serafini

unread,
Jan 29, 2013, 11:18:49 AM1/29/13
to gremli...@googlegroups.com, er...@shinsetsu.nl
great work! 
can't wait to have time for do some experiment/test :-)

Alfredo

eriks...@gmail.com

unread,
Jan 29, 2013, 3:57:07 PM1/29/13
to gremli...@googlegroups.com, er...@shinsetsu.nl
Hi Michael,

Looks great, and I've already spotted a few bits in your updated readme that I'd overlooked, so thanks! I've added some stuff to my own fork btw, such as an SBT build. [1] Maybe it would be a good idea to have it cross-build for multiple scala versions and publish the artifacts with -scala_2.x suffixes for compatibility?

I've also created some IndexedGraph pimps, as well as a loop syntax that allows you to say:

   g.v(1).loopWith(_.out)(_.loops < 3).property("name")

I'm not sure if this is in line with what gremlin is all about, but I thought it was convenient. BTW, by splitting up the parameter list, the compiler will infer the LoopBundle => Boolean types, which is quite nice I think. I'll try to upload cleaned up versions and tests of those things later this week.

Cheers,
Erik

[1] https://github.com/epost/gremlin-scala/tree/sbt

Michael Pollmeier

unread,
Jan 30, 2013, 5:30:23 AM1/30/13
to gremli...@googlegroups.com, er...@shinsetsu.nl
Hi Erik,

your sbt build sounds cool, can I just grab your sbt project files or do I need anything else? You can send me a pull request aswell, if you like.
I didn't bother with older scala versions because most Scala projects seem to be up to date with the latest pretty quickly. I'm basically waiting until anyone asks for it ;)

Your loop example looks like what's in the Gremlin wiki, however my use cases are slightly different, so not sure if that's `what gremlin is about`.
There's certainly a lot we can do to make Gremlin more Scala-esque, e.g. using Scala's types and getting rid of all those type casts.

Cheers
Michael

PS: I'm going to be travelling for a few days, so don't expect much progress this weekend - it's summer down here in New Zealand ;)

Michael Pollmeier

unread,
Feb 11, 2013, 3:09:46 AM2/11/13
to gremli...@googlegroups.com
The console should work now - I've also updated the readme.
Cheers
Michael

Stephen Mallette

unread,
Feb 11, 2013, 8:17:37 AM2/11/13
to gremli...@googlegroups.com
Michael, thanks for the update. I just played with the console a
little bit...works great.

I was wondering if you'd given any thought to provide a JSR-223 Script
Engine implementation for gremlin-scala. If gremlin-scala had that
capability it could be easily dropped into Rexster and served as a
gremlin flavor. Frank Panetta is working on one for gremlin-js and
even in the early stage that he's in with it, I was able to drop his
jar into Rexster's path and start issuing gremlin-js flavored gremlin
to Rexster.

What do you think?

Thanks,

Stephen
> --
> 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.
>
>

Michael Pollmeier

unread,
Feb 12, 2013, 3:04:01 AM2/12/13
to gremli...@googlegroups.com
Thanks for testing, Stephen!

JSR-223 is currently not part of the main Scala library (https://issues.scala-lang.org/browse/SI-874), however there's a project here that could help: http://code.google.com/p/scalascriptengine/
I don't know much about JSR-223, can you tell me what that jar should look like and how I can give it a try with Rexster? I use Rexster for a pet project, so you can assume some basic knowledge there ;)

Stephen Mallette

unread,
Feb 12, 2013, 8:18:11 AM2/12/13
to gremli...@googlegroups.com
I don't think it takes much to get this working, but that's easy for
me to say. :) Check out the gremlin-groovy script engine:

https://github.com/tinkerpop/gremlin/tree/master/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/jsr223

and gremlin-js script engine:

https://github.com/entrendipity/gremlin-js/blob/master/src/main/java/com/entrendipity/gremlin/javascript/jsr223/

At a high level, you simply implement ScriptEngine and
ScriptEngineFactory from the jsr223 spec (gremlin-groovy is a little
different in that the ScriptEngine extends from GroovyScriptEngineImpl
and maps to jsr223 but I think the concept isn't so different). Make
sure that you include this:

https://github.com/tinkerpop/gremlin/blob/master/gremlin-groovy/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory
https://github.com/entrendipity/gremlin-js/blob/master/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory

so that the ServiceLoader can find your ScriptEngineFactory
implementation. For Rexster compatibility, make sure you prefix your
engine name with "gremlin-". In other words, your engine name should
be called "gremlin-scala". Build the jar with maven, copy/paste to
the REXSTER_HOME/ext directory and edit rexster.xml to include
"gremlin-scala" here:

https://github.com/tinkerpop/rexster/blob/master/rexster-server/rexster.xml#L49

basically:

<script-engines>gremlin-groovy,gremlin-scala</script-engines>

Then test by opening Rexster Console and do:

?l

that's a lower-case "L", to list the gremlin languages available. you
should see groovy and scala as languages. you can then switch between
the two with:

?scala
?groovy

what's really cool is that the bindings from either language session
are shared, so when you define "g" in groovy, then switch to scala,
"g" is still available to you. I tried it out with gremlin-js.
here's what my session looked like:

rexster[groovy]> ?javascript
rexster[javascript]> g = rexster.getGraph("tinkergraph")
==>mocktinkertransactionalgraph[vertices:6 edges:6
directory:data/graph-example-1]
rexster[javascript]> d = new
com.entrendipity.gremlin.javascript.GremlinJSPipeline(g)
rexster[javascript]> d.V()
==>v[3]
==>v[2]
==>v[1]
==>v[6]
==>v[5]
==>v[4]
rexster[javascript]> d.V().out().groupCount().cap()
==>{v[3]=3, v[2]=1, v[5]=1, v[4]=1}
rexster[javascript]> ?groovy
rexster[groovy]> g.V.out.groupCount().cap
==>{v[3]=3, v[2]=1, v[5]=1, v[4]=1}

again, gremlin-js is a work in progress and Frank and I were just
testing things out to make sure the concepts were sound. Frank is
looking to cut the verbosity in the language and simplifying a bit,
but at least it shows the idea works.

Please let me know if you have any other questions. Thanks again!

Stephen

On Tue, Feb 12, 2013 at 3:04 AM, Michael Pollmeier

Michael Pollmeier

unread,
Feb 28, 2013, 2:57:43 AM2/28/13
to gremli...@googlegroups.com
The dependency for gremlin-groovy was missing - should work fine now.
Let me know how you get on!

On 28/02/13 00:33, pram...@gmail.com wrote:
> Hi Michael,
> Can you provide instructions on how we can use OrientDB with gremlin-scala?
>
> I got the following error when I tested.
>
> gremlin> val g = new OrientGraph("memory:demo")
> ScriptEngineManager providers.next(): javax.script.ScriptEngineFactory:
> Provider
> com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngineFactory not
> found
> ==>orientgraph[memory:demo]
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Gremlin-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/gremlin-users/p-bwn67E8OE/unsubscribe?hl=en.
> To unsubscribe from this group and all its topics, send an email to

pram...@gmail.com

unread,
Feb 28, 2013, 8:17:32 PM2/28/13
to gremli...@googlegroups.com
Hi Michael,
Thank you for the update. It is working now. 
I have trouble with graph update operations. For example I'm not able to create an edge as shown below. It is also not clear how I can add new properties.

The sample usage mainly shows how to access the graph, can you please include some examples on graph creation as well?

gremlin> val g = new TinkerGraph()
==>tinkergraph[vertices:0 edges:0]
gremlin> val v1 = g.addVertex("1")
==>v[1]
gremlin> val v2 = g.addVertex("2")
==>v[2]
gremlin> val e = g.addEdge(v1, v2, "edge")
gremlin>

- Padhu

Michael Pollmeier

unread,
Mar 1, 2013, 8:23:25 PM3/1/13
to gremli...@googlegroups.com
Hi Padhu,

you were pretty close... I've added some convenience methods for
Gremlin-Scala to create edges and vertices without having to specify the
IDs. From the updated readme:

# create a new graph with two vertices and an edge between them
val g = new TinkerGraph()
val v1 = graph.addV()
val v2 = graph.addV()
graph.addE(v1, v2, "label")

I personally find it easier to explore Gremlin with IDE-Support, a good
starting point might be the executable SampleUsageTest.

Cheers
Michael

pram...@gmail.com

unread,
Mar 8, 2013, 6:11:17 AM3/8/13
to gremli...@googlegroups.com
Super. That worked great.
Speaking of IDE, It would be nice if I can use gremlin-scala within scala IDE to utilize code completion. Not quite sure how to do that. Please let me know whether this is possible now.

Marko Rodriguez

unread,
Mar 8, 2013, 9:12:12 AM3/8/13
to gremli...@googlegroups.com
Hi,

In Gremlin/Groovy I just make a:

src/main/groovy/com/my/project/MyClass

I then:

static {
Gremlin.load()
}

And then my class is Gremlin-ified with code completion/etc.

For Gremlin-Scala, I suspect its even easier as its not a dynamic language and thus, you don't need Gremlin.load(), just import the classes you need and go.

src/main/scala/com/my/project/MyClass

Marko.
On Mar 8, 2013, at 4:11 AM, pram...@gmail.com wrote:

Super. That worked great.
Speaking of IDE, It would be nice if I can use gremlin-scala within scala IDE to utilize code completion. Not quite sure how to do that. Please let me know whether this is possible now.


--
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.

Michael Pollmeier

unread,
Mar 8, 2013, 4:54:07 PM3/8/13
to gremli...@googlegroups.com
I just use the Eclipse Scala IDE with the m2e plugin (because
Gremlin-Scala is a maven project). But you could just add Gremlin-Scala
as a dependency to any other project you have in your IDE and get code
completion..

Cheers
Michael

pram...@gmail.com

unread,
Mar 10, 2013, 8:03:03 AM3/10/13
to gremli...@googlegroups.com
You are right, I'm  able to use Scala worksheet plugin for Eclipse and get console like output and have the benefits of IDE.

Here is an example worksheet with output:

import com.tinkerpop.gremlin.scala._
import com.tinkerpop.blueprints.impls.tg.TinkerGraphFactory

object gremlin {
    val graph  = TinkerGraphFactory.createTinkerGraph
                //> graph  : com.tinkerpop.blueprints.impls.tg.TinkerGraph = tinkergraph[vertices:6 edges:6]
      val marko = graph.v(1)  //> marko  : com.tinkerpop.blueprints.Vertex = v[1]
      marko("name")            //> res0: Object = marko
      marko("age")              //> res1: Object = 29
}

pram...@gmail.com

unread,
Mar 10, 2013, 11:21:05 AM3/10/13
to gremli...@googlegroups.com
This is what I had to do to get the name property of all the vertices of g. 
Is there a better way?

  g.V.map.toList.asScala.map(_.asScala("name"))   //> res3: scala.collection.mutable.Buffer[Object] = ArrayBuffer(lop, vadas, marko, peter, ripple, josh)

Michael Pollmeier

unread,
Mar 11, 2013, 4:49:40 AM3/11/13
to gremli...@googlegroups.com
g.V.property("name")

I've added this to the readme and the SampleUsageTest.scala

pram...@gmail.com

unread,
Mar 16, 2013, 5:14:12 PM3/16/13
to gremli...@googlegroups.com
Thanks Michael that worked.
It looks like just few more barriers to cross, for final nirvana. The helpful graph loaders are missing. Do you have plans to add them in Scala?

g.loadGraphML("../gremlin/data/graph-example-1.xml") // loadGraphML is not a member of TinkerGraph

Unfortunately static loading Gremlin.groovy like Marko suggested does not help. Examining the com.tinkerpop.gremlin.groovy.loaders.GraphLoader.class file in the gremlin-groovy-2.2.0.jar showed that it is raw Groovy code and not the compiled Java class. I think that would work only inside a Groovy development environment.

import com.tinkerpop.gremlin.groovy._
object gremlinTest {
  Gremlin.load()
}

 That makes me wonder about the long term usefulness of Groovy ecosystem. It seems the Groovy code can not be easily utilized by Java as Scala code.

Michael Pollmeier

unread,
May 26, 2013, 4:36:41 AM5/26/13
to gremli...@googlegroups.com, Stephen Mallette
Hey Stephen,

I just spent a good part of my weekend trying to get the jsr223 to work
- turns out it's not that easy ;( I haven't given up yet, but it's not
looking good so far.

The main problem is that there's no existing ScriptEngine for Scala that
support jsr223. For groovy and javascript it's easy as they can just use
what's already there.

The closest I found was the ScalaScriptEngine project, which
deliberately decided not to support jsr223 because it's old and rusty
[1]. I took the challenge and tried to implement it. And I got really
close: I can generate the script and get the results back, then hand in
these results into the next script and work with them etc.

But the final detail just hit me: I'd like to allow the user to use it
in any of these ways:
1)"test"
2)a = "test"
3)val a = "test"
4)val a = { some command with = assignment }
5){ some command with = assignment }

The problem is that when write that dummy script file I have to parse
the line myself. If there is a '=' in the command, then it could either
be part of the command I want to run, or the assignment to the variable
in the repl. For illustration, this is an excerpt of the dummy script
file I generate and run. I call the result function:
class Script(vals: mutable.Map[String, Any]) extends ScalaScript {
val a = vals("a").asInstanceOf[Int]
val b = vals("b").asInstanceOf[String]
def result = { some command with = assignment }
}

The only option I see is to not allow any assignments (only options 1
and 5) and instead tell the user under which name the result is available:
scala> "test"
res0: String = test

Another candidate is Apache Sling's implementation. I've started to rip
it out of the greater project but it hasn't been updated since 2011 and
I had some trouble getting it to work. But that's going to be my next
attempt.

Best regards
Michael

[1]
https://groups.google.com/forum/?fromgroups#!topic/scala-user/IYo1UTefKUk

Stephen Mallette

unread,
May 28, 2013, 8:11:13 AM5/28/13
to gremli...@googlegroups.com
Michael, thanks for the update.  I was hoping the ScalaScriptEngine would work out, but did not know it was not compliant with JSR-223.  I'm not sure of the performance impact, but would it make sense to wrap the ScalaScriptEngine in your own implementation of the JSR-223 classes?  Perhaps that is a possible path to follow.

Stephen



For more options, visit https://groups.google.com/groups/opt_out.



--
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-users+unsubscribe@googlegroups.com.

Michael Pollmeier

unread,
May 30, 2013, 5:05:06 AM5/30/13
to gremli...@googlegroups.com
Hi Stephen,

the implementation of the JSR interfaces is not the problem, I've in
fact done that as the first step towards understanding the it. Using (or
wrapping) the ScalaScriptEngine is the hard bit, and as I described I
got pretty far, but run into some blockers.

Best regards
Michael
> https://groups.google.com/__forum/?fromgroups#!topic/__scala-user/IYo1UTefKUk
> <https://groups.google.com/forum/?fromgroups#!topic/scala-user/IYo1UTefKUk>
>
> On 13/02/13 02:18, Stephen Mallette wrote:
>
> I don't think it takes much to get this working, but that's easy for
> me to say. :) Check out the gremlin-groovy script engine:
>
> https://github.com/tinkerpop/__gremlin/tree/master/gremlin-__groovy/src/main/java/com/__tinkerpop/gremlin/groovy/__jsr223
> https://github.com/__entrendipity/gremlin-js/blob/__master/src/main/java/com/__entrendipity/gremlin/__javascript/jsr223/
> <https://github.com/entrendipity/gremlin-js/blob/master/src/main/java/com/entrendipity/gremlin/javascript/jsr223/>
>
> At a high level, you simply implement ScriptEngine and
> ScriptEngineFactory from the jsr223 spec (gremlin-groovy is a little
> different in that the ScriptEngine extends from
> GroovyScriptEngineImpl
> and maps to jsr223 but I think the concept isn't so different).
> Make
> sure that you include this:
>
> https://github.com/tinkerpop/__gremlin/blob/master/gremlin-__groovy/src/main/resources/__META-INF/services/javax.__script.ScriptEngineFactory
> <https://github.com/tinkerpop/gremlin/blob/master/gremlin-groovy/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory>
> https://github.com/__entrendipity/gremlin-js/blob/__master/src/main/resources/__META-INF/services/javax.__script.ScriptEngineFactory
> <https://github.com/entrendipity/gremlin-js/blob/master/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory>
>
> so that the ServiceLoader can find your ScriptEngineFactory
> implementation. For Rexster compatibility, make sure you prefix
> your
> engine name with "gremlin-". In other words, your engine name
> should
> be called "gremlin-scala". Build the jar with maven, copy/paste to
> the REXSTER_HOME/ext directory and edit rexster.xml to include
> "gremlin-scala" here:
>
> https://github.com/tinkerpop/__rexster/blob/master/rexster-__server/rexster.xml#L49
> <https://github.com/tinkerpop/rexster/blob/master/rexster-server/rexster.xml#L49>
>
> basically:
>
> <script-engines>gremlin-__groovy,gremlin-scala</script-__engines>
>
> Then test by opening Rexster Console and do:
>
> ?l
>
> that's a lower-case "L", to list the gremlin languages
> available. you
> should see groovy and scala as languages. you can then switch
> between
> the two with:
>
> ?scala
> ?groovy
>
> what's really cool is that the bindings from either language session
> are shared, so when you define "g" in groovy, then switch to scala,
> "g" is still available to you. I tried it out with gremlin-js.
> here's what my session looked like:
>
> rexster[groovy]> ?javascript
> rexster[javascript]> g = rexster.getGraph("tinkergraph"__)
> ==>__mocktinkertransactionalgraph[__vertices:6 edges:6
> directory:data/graph-example-__1]
> rexster[javascript]> d = new
> com.entrendipity.gremlin.__javascript.GremlinJSPipeline(__g)
> rexster[javascript]> d.V()
> ==>v[3]
> ==>v[2]
> ==>v[1]
> ==>v[6]
> ==>v[5]
> ==>v[4]
> rexster[javascript]> d.V().out().groupCount().cap()
> ==>{v[3]=3, v[2]=1, v[5]=1, v[4]=1}
> rexster[javascript]> ?groovy
> rexster[groovy]> g.V.out.groupCount().cap
> ==>{v[3]=3, v[2]=1, v[5]=1, v[4]=1}
>
> again, gremlin-js is a work in progress and Frank and I were just
> testing things out to make sure the concepts were sound. Frank is
> looking to cut the verbosity in the language and simplifying a bit,
> but at least it shows the idea works.
>
> Please let me know if you have any other questions. Thanks again!
>
> Stephen
>
> On Tue, Feb 12, 2013 at 3:04 AM, Michael Pollmeier
> <michael.pollmeier@googlemail.__com
> <mailto:michael....@googlemail.com>> wrote:
>
> Thanks for testing, Stephen!
>
> JSR-223 is currently not part of the main Scala library
> (https://issues.scala-lang.__org/browse/SI-874
> <https://issues.scala-lang.org/browse/SI-874>), however
> there's a project
> here that could help:
> http://code.google.com/p/__scalascriptengine/
> <mailto:michael....@googlemail.com>> wrote:
>
> The console should work now - I've also updated the
> readme.
> Cheers
> Michael
>
> On Sunday, 6 January 2013 17:35:37 UTC+13, Michael
> Pollmeier wrote:
>
>
> For anyone using Gremlin-Scala: I've just bumped
> my fork to Gremlin
> 2.2.0:
> https://github.com/mpollmeier/__tinkubator
> <https://github.com/mpollmeier/tinkubator>
> I've also taken this opportunity to upgrade to
> Scala 2.10.0.
> If any of you depends on a different version of
> Scala you can simply
> change the scala.version in the pom.xml.
>
> Cheers
> Michael
>
>
> --
> 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
> <mailto:gremlin-user...@googlegroups.com>.
> For more options, visit
> https://groups.google.com/__groups/opt_out
> <https://groups.google.com/groups/opt_out>.
>
>
>
> --
> 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-users+unsubscribe@__googlegroups.com
> <mailto:gremlin-users%2Bunsu...@googlegroups.com>.
> For more options, visit
> https://groups.google.com/__groups/opt_out
> <https://groups.google.com/groups/opt_out>.
>
>
>
>
> --
> 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-users+unsubscribe@__googlegroups.com
> <mailto:gremlin-users%2Bunsu...@googlegroups.com>.
> For more options, visit https://groups.google.com/__groups/opt_out
> <https://groups.google.com/groups/opt_out>.
>
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Gremlin-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/gremlin-users/p-bwn67E8OE/unsubscribe?hl=en.
> To unsubscribe from this group and all its topics, send an email to

Antonio VonG

unread,
May 31, 2013, 7:11:29 AM5/31/13
to gremli...@googlegroups.com
Michael,

Any news on the JSR-223 front?

Regards,
Antonio

On Sunday, January 6, 2013 12:35:37 PM UTC+8, Michael Pollmeier wrote:
For anyone using Gremlin-Scala: I've just bumped my fork to Gremlin 2.2.0: https://github.com/mpollmeier/tinkubator

Michael Pollmeier

unread,
May 31, 2013, 6:43:17 PM5/31/13
to gremli...@googlegroups.com
Hi Antonio,

my mail from May 26 on this thread is my latest update.

Cheers
Michael

Jakub Liska

unread,
Apr 15, 2014, 7:04:53 AM4/15/14
to gremli...@googlegroups.com
Hey Michael,

I just tried gremlin-scala and it works like a charm, I was just wondering, have you thought about @GremlinScala annotation for Tinkerpop Frames ? It seems to me that gremlin-scala is mature enough to be part of the tinkerpop gremlin stack so that Frames could contain @GremlinScala annotation. Adding such a support from outside Frames would be complicated though. Are there any plans on incorporating gremlin-scala into tinkerpop gremlin ? 

Michael Pollmeier

unread,
Apr 16, 2014, 2:22:58 AM4/16/14
to gremli...@googlegroups.com
Hi Jakub,

thanks for your feedback and I'm glad it works for you. I'm currently
focusing on Tinkerpop3 and I managed to get some really valueable things
done, including full type safety.

You can now (with Gremlin-Scala3) do a query like:
g.v(1).outE.label.path.toList

The returning list is not simply a List[Any] (i.e. List<Object> in java
land), but a List[Vertex :: Edge :: String], so it's all statically typed.

There's also many more checks at compile time now, e.g. the following
does NOT compile: g.v(1).outE.outE
That will make Gremlin-Scala much more useful than it has been so far.

You can have a sneak preview on the tinkerpop3 branch if you fancy. The
build might be broken though as Marko and Stephen iterate quite a lot on
the underlying libraries.


According to https://github.com/tinkerpop/tinkerpop3/wiki Frames will no
longer be part of tinkerpop anymore. Let's first see where it is going,
and then we can think about adding it to Frames.

Cheers
Michael
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Gremlin-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/gremlin-users/p-bwn67E8OE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> gremlin-user...@googlegroups.com
> <mailto:gremlin-user...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Jakub Liska

unread,
Apr 17, 2014, 3:25:44 PM4/17/14
to gremli...@googlegroups.com
Hi Michael,

thanks for info, I'm about to start a 3 months long project with titan and tinkerpop2 stack which basically means that right after I'm done I'll have to migrate it to tinkerpop3 which is a little unfortunate. I won't use Frames, hopefully there won't be any breaking changes that might cause a major pain to migrate. Jakub

Jakub Liska

unread,
Apr 20, 2014, 4:27:47 PM4/20/14
to gremli...@googlegroups.com
Michael there is one problem with gremlin-scala though, getting vertex property works only if one specifies return type parameter :

gremlin> g.v(4).getProperty[String]("city")
res10: String = aixas
==> aixas
gremlin> g.v(4).property[String]("city")
res12: Option[String] = Some(aixas)
==> Some(aixas)

otherwise :

gremlin> g.v(4).property("city")        
res14: Option[Nothing] = None
==> None
g.v(4).getProperty("city")
java.lang.ClassCastException: java.lang.String cannot be cast to scala.runtime.Nothing$

I don't know why, but the pattern matching in ScalaElement#property method always matches None if you don't specify the generic parameter as I said :

  def property[A: ClassTag](name: String): Option[A] = {
    val value: A = element.getProperty(name)
    value match {
      case value: A ⇒ Option(value)
      case other    ⇒ None
    }
  }

This is pretty nasty behavior cause it may lead to a lot of hidden bugs. wdyt ?

I'm using gremlin-scala HEAD, scala 2.11.0 and java 1.7.0_51

Michael Pollmeier

unread,
Apr 20, 2014, 7:44:41 PM4/20/14
to gremli...@googlegroups.com
Hi Jakub,

this behaviour is kind-of intended if you specified the `wrong` type.
E.g. if you try `someVertex.property[String]("some integer")` the return
is None, because the property is an integer. Does that make sense?

However I do see your point that it's easy to `forget` to define a type
parameter (esp. as it's not enforced by the compiler) and end up with
the type `Nothing`, and then run into this ugly ClassCastException.

It looks like we can enforce a type parameter always to be specified. I
like the third answer on this thread (NotNothing type class based on
Miles Sabin's solution):
http://stackoverflow.com/questions/4403906/is-it-possible-in-scala-to-force-the-caller-to-specify-a-type-parameter-for-a-po

It would mean that you have to specify a type parameter (which can by
`Any` if you're unsure of the actual type) for property (and maybe even
getProperty).
What's your thoughts?

Thanks for starting this discussion btw, it's very important to think
these things through properly!
Michael

Jakub Liska

unread,
Apr 20, 2014, 8:28:30 PM4/20/14
to gremli...@googlegroups.com
Hi Michael, I made a pull request https://github.com/mpollmeier/gremlin-scala/pull/20 that deals with it using compile time warning. Jakub
Reply all
Reply to author
Forward
0 new messages