Ogre, Clojure wrapper for Gremlin

208 views
Skip to first unread message

Zack Maril

unread,
Mar 12, 2013, 3:09:52 PM3/12/13
to gremli...@googlegroups.com
Today, I'm releasing Ogre, a wrapper for Gremlin in Clojure. 
Ogre is the culmination of the last few months of me using Titan and Gremlin. I've had an API in mind for a while now and I've spent the past few days fleshing it all out. Ogre is very much inspired by my work developing Hermes[0] and what I've learned reading through the source for Titanium[1]. My short term goal is to provide an idiomatic and well tested Clojure library for Gremlin that can be used with Hermes or Titanium. The plan is to port over all of the tests from Gremlin for Ogre. There are some very raw parts to Ogre still, but it's already shaping up to do some really cool stuff. I'll end with an example query that should already work:

(q/query example-user
         (q/<-> :friends-with)
         (q/<-> :friends-with)
         (q/except [example-user])
         (q/has :age > 20)
         (q/dedup)
         (q/property :name)
         (q/transform #(.toUpperCase %))
         (q/into-set))

This should return all of the names (in upper case) of the friends of the friends of the example user who are over 20 years of age. 
-Zack

Marko Rodriguez

unread,
Mar 12, 2013, 3:17:42 PM3/12/13
to gremli...@googlegroups.com
Hi Zach,

First, thanks.

Second:

1. Is this a "wrapper" to Gremlin, or are you creating GremlinClosurePipeline and thus, creating a Gremlin dialect?
- e.g. what Gremlin/Groovy is.
2. Is this general enough so its not tied to Titan but instead to Blueprints only?
3. Check out Pacer whereby it uses Pipes, but not Gremlin.

Thanks,
Marko.
--
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 Klishin

unread,
Mar 12, 2013, 3:17:49 PM3/12/13
to gremli...@googlegroups.com

2013/3/12 Zack Maril <thewi...@gmail.com>

Today, I'm releasing Ogre, a wrapper for Gremlin in Clojure. 

Great job, Zack!

Do you think it will be possible to use Orge in future versions of Titanium? I'd be very happy
to not reinvent this wheel :)

Thanks,
--
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

Zack Maril

unread,
Mar 12, 2013, 3:32:07 PM3/12/13
to gremli...@googlegroups.com
@Marko The easy answer is that Ogre provides a DSL for creating gremlin pipes. It only relies on com.tinkerpop.gremlin/gremlin-java and wraps that directly. So, it should let you use it with any Blueprints graph. It's more like clj-gremlin than Gremlin/Groovy. 

@MK Thanks! This should be usable from within Titanium. I used the gremlin example from the Titanium test for the first pass to get things running. Ogre only relies on tinkerpop.gremlin/gremlin-java so it should work. I'll probably start ripping parts that I like out of the Titanium implementation of gremlin to encourage you to use Ogre.
-Zack

Zack Maril

unread,
Mar 12, 2013, 3:36:26 PM3/12/13
to gremli...@googlegroups.com
Also, I've seen pacer before, but I never really understood what it actually does or is for.
-Zack

Marko Rodriguez

unread,
Mar 12, 2013, 3:40:41 PM3/12/13
to gremli...@googlegroups.com
@Marko The easy answer is that Ogre provides a DSL for creating gremlin pipes. It only relies on com.tinkerpop.gremlin/gremlin-java and wraps that directly. So, it should let you use it with any Blueprints graph. It's more like clj-gremlin than Gremlin/Groovy. 

Perfect. Yea, Gremlin-Groovy simply wraps Gremlin-Java. That is how we intend Gremlin JVM variations to be built. I'm glad Ogre is the same.

Re: Pacer --- its like Gremlin-Groovy but JRuby. In fact, Derrick, the dude who wrote it enlightened me to dynamic languages and said: "Bro, you need to drop the ANTLR hell hole you are going down and just use a dynamic JVM language." Thus, Gremlin 0.7+. 


Thanks,
Marko.


Michael Klishin

unread,
Mar 12, 2013, 3:44:38 PM3/12/13
to gremli...@googlegroups.com

2013/3/12 Zack Maril <thewi...@gmail.com>

@MK Thanks! This should be usable from within Titanium. I used the gremlin example from the Titanium test for the first pass to get things running. Ogre only relies on tinkerpop.gremlin/gremlin-java so it should work. I'll probably start ripping parts that I like out of the Titanium implementation of gremlin to encourage you to use Ogre.

Gotcha.

Titanium development is on hold as we are waiting for the 0.3 release but I'd be happy to migrate to Orge
before that. Let me know when you think Orge is ready (or what I can help extract to it from Titanium).

Zack Maril

unread,
Mar 13, 2013, 3:50:28 AM3/13/13
to gremli...@googlegroups.com
@MK I'd say within a week or so I'll have at least 75% of the tests from gremlin ported over. I've got all of the transform tests ported over now and I'm starting the filter steps presently. By the time you read this, Ogre will probably already have test coverage for everything the Titanium implementation has right now. 


The main conceptual hurdle is finding a good way to work with side-effects from within Clojure. How to do that well isn't entirely clear to me yet.
-Zack

Zack Maril

unread,
Mar 13, 2013, 8:03:07 AM3/13/13
to gremli...@googlegroups.com
Well, I spent the morning finishing the rest of the library out. The only thing left is to make a decision about what to do with side effect pipes (tree, groupCount, groupBy, sideEffect, store, table and aggregate). I'm thinking of just saying that if you call any side effect method, an appropriate data structure will supplied and then cap will be immediately applied, executing the pipeline and returning the "side effect". 

@Marko is there any really good reason why Ogre shouldn't do the above?

Another option is saying that you have to pass in an empty atom in you've previously defined. That would be ideal, but I'm not sure that's entirely possible to do. It would mean passing a function in for the state of each side effect which seems hard.
-Zack

Marko Rodriguez

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

> Well, I spent the morning finishing the rest of the library out. The only thing left is to make a decision about what to do with side effect pipes (tree, groupCount, groupBy, sideEffect, store, table and aggregate). I'm thinking of just saying that if you call any side effect method, an appropriate data structure will supplied and then cap will be immediately applied, executing the pipeline and returning the "side effect".
>
> @Marko is there any really good reason why Ogre shouldn't do the above?

There are times when you want to loop over a portion of your pipeline, and in doing so, keep updating a sideEffect (e.g. counting the number of traversers that have flowed through a vertex).

g.v(1).out.groupCount(m).loop(2){it.loops < 3}

However, realize that Faunus does basically what you say -- once you hit a sideEffect, it locks the pipeline and emits the cap. Sideeffects are semantically hard to deal with, though useful in many respects.

HTH,
Marko.

Zack Maril

unread,
Mar 15, 2013, 5:26:10 PM3/15/13
to gremli...@googlegroups.com
That makes sense. For now, in the interest of getting Ogre out and visible, I'm punting and only focusing on side-effects that return immediately. I want to write the easy documentation first and then loop back and take a crack at explaining how to manage mutable state for Gremlin from within Clojure.
-Zack 
Reply all
Reply to author
Forward
0 new messages