gremlin-scala step by step example

932 views
Skip to first unread message

Marco F.

unread,
Dec 2, 2014, 10:07:26 AM12/2/14
to gremli...@googlegroups.com
Hi, I'm trying to start off a little sample project using Titan with Scala.

It's kinda hard to understand how to use gremlin-scala. GitHub README does not look very updated.

I would just like to:
- build up a graph
- "store" it into hadoop (I'll use the hadoop-es configuration, if possible)
- play with it a little

Where do I begin?

Michael Pollmeier

unread,
Dec 3, 2014, 2:26:27 PM12/3/14
to gremli...@googlegroups.com
If you're just starting with Gremlin I would recommend to use the Tinkerpop3 implementation (as mentioned in the readme).
Here's an examples project, currently only for Neo4j, that gives you an idea: https://github.com/mpollmeier/gremlin-scala-examples

I haven't used Titan with Tinkerpop3 yet - if you have a similar example for titan I'd be grateful to include it in the examples.

Marco F.

unread,
Dec 4, 2014, 4:07:26 AM12/4/14
to gremli...@googlegroups.com
Ok great!

I'm trying to start off with something like this: https://gist.github.com/mfirry/6324d81fba240c50a924

And already I have some issues since apparently HadoopGraph does not support adding vertices.

I'm also wondering if I should just use TitanGraph instead.

One more thing: using gremlin-scala, how does one pass configuration for storage and index systems?

Daniel Kuppitz

unread,
Dec 4, 2014, 12:18:12 PM12/4/14
to gremli...@googlegroups.com
Use TitanGraph to build a graph and do standard OLTP queries. HadoopGraph is mainly used for analytical jobs (OLAP). However, note that none of the current Titan releases is compatible with TP3, you would need to use the 0.9 snapshot.

Cheers,
Daniel


--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/c5009bc8-b637-4b71-a8bb-a45371fd5e1f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Pollmeier

unread,
Dec 4, 2014, 6:52:03 PM12/4/14
to gremli...@googlegroups.com
Re passing configuration to storage/index system:
It depends on the graph you use - however that should be independent of
GremlinScala. GremlinScala is just a wrapper on top of the graph that
allows you to write your traversal in a more scala-esque way, plus some
more benefits like type safe label steps.

The examples project contains a neo4j example with indexes - that would
be a good starting point.

If you have something working with TitanGraph (and/or HadoopGraph)
please let me know - and/or create a pull request for the examples
project so that everybody can benefit.
https://github.com/mpollmeier/gremlin-scala-examples

Thank you!

Marco F.

unread,
Dec 9, 2014, 9:27:01 AM12/9/14
to gremli...@googlegroups.com
Hi again,
thanks for both answers.

Yes, Michael I'm trying to have a working example using Titan (that's my main goal). You'll hear from me about it as soon as I manage.

I understand GremlinScala is "just" (more than enough!) a wrapper of the traversal part of gremlin, but everywhere I look while reading about Titan pushes you into doing every little bit inside gremlin cli, which is what I'm mimicking.

Just to give some context. I want to use Titan on Hbase and ES. That's my starting point.

for now I have something like this:

  val conf = new BaseConfiguration()
  conf.setProperty("storage.backend", "hbase")
  ... some more configuration here...
  conf.setProperty("storage.directory", "/tmp/titangraph")

  val g = TitanFactory.open(conf)

which throws java.lang.NoClassDefFoundError: org/apache/hadoop/hbase/TableNotEnabledException

following step would have been

  val graph = new ScalaGraph(g)

I might have to wait until Titan gets closer to TP3.

Thanks again.

-m

Michael Pollmeier

unread,
Dec 10, 2014, 4:13:04 AM12/10/14
to gremli...@googlegroups.com
I guess you run the above from a standard sbt project? Can you share that here please?
Looks like you're just missing some dependencies...
This might help you get the dependencies sorted: https://github.com/jrudolph/sbt-dependency-graph

Marco F.

unread,
Dec 11, 2014, 8:59:18 AM12/11/14
to gremli...@googlegroups.com
Sure. I started off by cloning https://github.com/mpollmeier/gremlin-scala-examples.git

And worked my Titan example that looks like: https://github.com/mfirry/gremlin-scala-titan-example

Bear in mind that it's not working and it's a working-in-progress thing.

I'll actually put it off Github soon as I get your feedback.

Thanks a lot!

-m

Jacek Laskowski

unread,
Dec 11, 2014, 3:38:28 PM12/11/14
to gremli...@googlegroups.com
Hi Marco,

I spent the whole day to get it up and running and think I did manage to have a working setup with the recent versions - Titan 0.9.0-M1 + GremlinScala 3.0.0.M6a (and specs2 2.4.15).


Since I'm pretty new to the entire graph database world I've just followed the many scattered-around examples and seemed to get lucky as the single test in the project works fine :)

Jacek

Michael Pollmeier

unread,
Dec 12, 2014, 3:02:41 AM12/12/14
to gremli...@googlegroups.com
Hi Jacek,

Good work, can I steal that and integrate it in gremlin-scala-examples?
Alternatively I could give you commit rights on that project and we can
evolve it in one central place.

Thoughts?
Michael

Michael Pollmeier

unread,
Dec 12, 2014, 3:03:45 AM12/12/14
to gremli...@googlegroups.com
Btw nice start Marco, but as you said that version doesn't actually
compile. Thanks for your effort!

Marco F.

unread,
Dec 12, 2014, 3:22:54 AM12/12/14
to gremli...@googlegroups.com
Thanks so much!

Marco F.

unread,
Dec 12, 2014, 3:23:57 AM12/12/14
to gremli...@googlegroups.com
Michael, I told you I couldn't make it work. That was my whole point of posting here :)

I'll have a look at Jacek's stuff and let you guys know.

Thanks!

Marco F.

unread,
Dec 12, 2014, 3:30:29 AM12/12/14
to gremli...@googlegroups.com
Jacek, I get funny errors when running sbt test.
Have a look: http://pastie.org/private/4yail08l2twf11vwmtvw

Michael Pollmeier

unread,
Dec 12, 2014, 4:09:32 AM12/12/14
to gremli...@googlegroups.com
Looks like you are not using Java 8.
Please check as per the instructions in
https://github.com/mpollmeier/gremlin-scala-examples

Marco F.

unread,
Dec 12, 2014, 4:21:34 AM12/12/14
to gremli...@googlegroups.com
You're right. For some reason my "alternative" installation for Java 8 on Ubuntu did not stick after rebooting.
Thanks again.

Marco F.

unread,
Dec 12, 2014, 5:14:31 AM12/12/14
to gremli...@googlegroups.com
Ok.
Using titan "0.9.0-M1" made my example work.

I'll fix it and make pretty and let you guys know.

Cheers!

Jacek Laskowski

unread,
Dec 12, 2014, 6:52:06 AM12/12/14
to gremli...@googlegroups.com
Hi Michael,

Sure! We can work it out together! I'd be delighted working with you (as I've got so much to learn re gremlim-scala/titan and hope you could cut the time needed enormously). Thanks!

Jacek

Michael Pollmeier

unread,
Dec 13, 2014, 2:50:34 AM12/13/14
to gremli...@googlegroups.com
Hi Jacek,

I just added you as a collaborator to
https://github.com/mpollmeier/gremlin-scala-examples
Just add your titan example project and feel free to update the readme ;)

Cheers
Michael

Marco F.

unread,
Dec 18, 2014, 11:15:45 AM12/18/14
to gremli...@googlegroups.com
I've given this a little try and will continue on this: check this out https://github.com/whiplash/gremlin-scala-examples/blob/master/titan/src/main/scala/Example.scala
Reply all
Reply to author
Forward
0 new messages