DBDB.io The Encyclopedia of Database Systems · Est. 2017
Database of Databases

Database Entry

JanusGraph


JanusGraph is a transactional graph DBMS optimized for storing and querying graphs distributed across a multi-machine cluster.

Source Code
https://github.com/JanusGraph/janusgraph[02]
Country of Origin
US
Start Year
2012
Former Name
Titan
Acquired By
Project Type
Open Source
Written in
Java
Supported Languages
Java
Derived From
1010data
Compatible With
Berkeley DB
Operating System
All OS with Java VM
License
Apache v2

Database Entry

JanusGraph


JanusGraph is a transactional graph DBMS optimized for storing and querying graphs distributed across a multi-machine cluster.

History


  • Originally called Titan. It was renamed to JanusGraph in 2015.

Data Model


Query Interface[04]


JanusGraph uses Gremlin graph query language to retrieve data from and modify data in the graph. Gremlin is a functional language whereby traversal operators are chained together to form path-like expressions, expressing query or data modification on graphs.

A Gremlin query is a chain of operations/functions that are evaluated from left to right. A simple example of gremlin language to query the name of Alex's grandson on his genealogy graph is provided below

g.V().has('name', 'Alex').out('father').out('father').values('name')

The query can be read as
g : for the current graph
V : for the vertices in the graph
has('name', 'Alex') : filters the vertices down to those with the "name" property "Alex"
out('father') : traverse outgoing through edges whose type is "father" from "Alex" (Notice here the result can be more than one vertices)
out('father') : traverse outgoing through edges whose type is "father" from "Alex"' son (the result from the last traversal)
values('name') : get the property of "name"

Other more complex examples of Gremlin can be found in
Complete Gremlin Manual

There're two ways to query JanusGraph with Gremlin

  • First one is to use Gremlin Console, Gremlin Console is an interactive shell that is distributed with JanusGraph, by connecting Gremlin Console to JanusGraph Server, users can directly interact with graphs stored in JanusGraph Server using Gremlin.

  • The second one is to embed Gremlin code into your Java Application using JanusGraph Java API as shown below

Traversal t = g.V().has("name", "pluto"); // Define a traversal. // Note the traversal is not executed/iterated yet Vertex pluto = null;
if (t.hasNext()) { // Check if results are available
pluto = g.V().has("name", "pluto").next(); // Get one result
g.V(pluto).drop().iterate(); // Execute a traversal to drop pluto from graph
}
// Note the traversal can be cloned for reuse
Traversal tt = t.asAdmin().clone();
if (tt.hasNext()) {
System.err.println("pluto was not dropped!");
}
List gods = g.V().hasLabel("god").toList(); // Find all the gods

Citations

4 sources
  1. JanusGraph janusgraph.org
  2. GitHub - JanusGraph/janusgraph: JanusGraph: an open-source, distributed graph database · GitHub github.com
  3. https://docs.janusgraph.org/latest janusgraph.org Dead — Check Archive
  4. https://docs.janusgraph.org/latest/gremlin.html janusgraph.org Dead — Check Archive
Revision #17 Last Updated: