Search
Follow Us

Follow nosqldatabases on Twitter Follow nosqldatabases on Facebook Follow nosqldatabases on Google Buzz Follow nosqldatabases on LinkedIn Follow nosqldatabases on FeedBurner NoSQL presentations on slideshare

Sponsors

Become a sponsor of NoSQLDatabases.com. Contact us to find out how.

Featured Jobs

 

Follow On Facebook
Recent NoSQL News

Advertisments

Entries in DSL (1)

Monday
Aug232010

Gremlin: A Graph-Based Programming Language

In this presentation, Marko Rodriguez, discusses Gremlin, a graph programming language.

What is Gremlin?

Gremlin is a Turing-complete, graph-based programming language developed for key/value-pair multi-relational graphs called property graphs. Gremlin makes extensive use of XPath 1.0 to support complex graph traversals. Connectors exist to various graph databases and frameworks. This language has application in the areas of graph query, analysis, and manipulation.

There are several interesting facts about Gremlin. First, Gremlin is JSR-223 compliant which allows the language itself to be embedded in Java applications, much like Jython, JRuby or Groovy code fragments can. In addition, Gremlin is considered a DSL (domain specific language) and NOT an API. Gremlin is designed to work with several different types of graph databases via Blueprints.

Two important things that Gremlin provides:

  1. Gremlin provides a means to elegantly map single-relational graph analysis algorithms over to the multi-relational graph domain
  2. Gremlin provides an elegant way to do automated reasoning in multi-relational graphs using path expressions

Gremlin works with a type of graph called a property graph. A property graph has the following properties:

  • Vertices and edges are labeled with unique identifiers
  • Edges are directed, labeled, and can form loops
  • Multiple edges of the same label can exist for the same vertex pair
  • Vertices and edges can have any number of key/value pair properties/attributes

So as an example of a typical Gremlin expression you have the following:

./outE[@label=‘knows’]/inV[matches(@name,‘va.{3}’) and @age > 21]/@name

Here is how this expression would be evaluated:

  1. Get the current object(s)
  2. outE[@label=‘knows’]: Get the outgoing edges of the current object(s), where their labels equal ‘knows’
  3. inV[matches(@name,‘va.{3}’) and @age > 21]: Get the incoming vertices of those ‘knows’ edges, where the names of those vertices are 5 characters long, start with ‘va’, and whose age is greater than 21
  4. @name: get the name of those particular incoming vertices

The language is simple, easy to understand and very concise. Marko dives into several other examples of expressions, as well as, language specifics like types, expressions and variables.

If you are planning on working with graph databases, take a look at Gremlin.