Gremlin compatibility

Updated at:

Graph Database (GDB) supports the TinkerPop Gremlin query language. This topic describes how the GDB Gremlin implementation is compatible with TinkerPop Gremlin and where it differs.

Version compatibility

  • GDB Gremlin is compatible with TinkerPop Gremlin versions 3.3.x and 3.4.x.

  • Interaction with the GDB server uses the GraphSON format.

    Note

    GraphSON is the standard format for Gremlin. It uses the JSON format to represent vertices, edges, and properties.

Limits on DSL

The rules for using the domain-specific language (DSL) in GDB Gremlin differ from those in TinkerPop in the following ways:

  • All DSL queries must start with the built-in variable g. This variable is equivalent to Graph.traversal() in TinkerPop.

  • You cannot control query strategies. GDB automatically performs all query optimizations.

  • The IDs for vertices and edges are strings. You can specify the IDs. If you do not specify an ID, a universally unique identifier (UUID) is automatically generated for the vertex or edge.

  • The property graph model in GDB supports two cardinality modes: Single and Set. These modes correspond to the following in TinkerPop:

    org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality.single; org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality.set

  • GDB property values support only simple data types, such as numbers, strings, and Booleans. In Java, these data types correspond to byte, char, short, int, long, float, double, boolean, and String. Complex types, such as dates, are not supported.

Limits on Apache Groovy

GDB Gremlin does not support the following features of the Groovy language:

  • Groovy-style Lambda expressions and embedded function calls, such as map.findAll{it.value>3}.

  • Mathematical expressions, such as 1+1.

  • System calls, such as System.currentTimeMillis().

Support for transactions

GDB Gremlin supports transactions by default, as follows:

  • GDB Gremlin does not support ThreadedTransaction, which is a cross-thread transaction that you must manually start and commit. Instead, GDB Gremlin uses built-in sessionless transactions. All operations within a single DSL query are considered part of one transaction.

  • If a DSL query contains a mutation step, it is treated as a read-write transaction. Otherwise, it is treated as a read-only transaction.

  • A transaction is automatically started when a DSL query begins. The transaction is automatically committed or rolled back based on the execution result when the query ends.

  • The transaction isolation level is READ-COMMITTED.

  • The data is imported to GDB by row. Each row represents a single transaction. Transactions or rows are independent of each other.

Support for TinkerPop Gremlin Step interfaces

Note
  • The main unsupported interfaces are in the following categories:

    • It utilizes the OLAP interface of the GraphComputer class.

    • Explain and Profiling interfaces.

    • Other auxiliary interfaces that are not used for creating, retrieving, updating, or deleting data.

  • In the table below, Supported indicates supported, and Not supported indicates not supported.

Step interface

Supported

Remarks

connectedComponent()

Does not support GraphComputer

io(String)

-

pageRank()

Does not support GraphComputer

pageRank(double)

Does not support GraphComputer

peerPressure()

Does not support GraphComputer

profile()

-

profile(String)

-

program(VertexProgram<?>)

Does not support GraphComputer

shortestPath()

Does not support GraphComputer

subgraph(String)

-

tx()

-

withBulk(boolean)

-

withComputer()

-

withComputer(Class<? extends GraphComputer>)

-

withComputer(Computer)

-

withoutStrategies(Class<? extends TraversalStrategy>…)

-

withPath()

-

withRemote(Configuration)

-

withRemote(RemoteConnection)

-

withRemote(String)

-

write()

-

addE(String)

-

addE(Traversal<?, String>)

-

addV()

-

addV(String)

-

addV(Traversal<?, String>)

-

aggregate(String)

-

and(Traversal<?, ?>…)

-

as(String, String…)

-

barrier()

-

barrier(Consumer>)

-

barrier(int)

-

both(String…)

-

bothE(String…)

-

bothV()

-

branch(Function,M>

-

branch(Traversal<?, M>)

-

by()

-

by(Comparator)

-

by(Function, Comparator)

-

by(Function)

-

by(Order)

-

by(String)

-

by(String, Comparator)

-

by(T)

-

by(Traversal<?, ?>)

-

by(Traversal<?, ?>, Comparator)

-

cap(String, String…)

-

choose(Function)

-

choose(Predicate, Traversal<?, E2>)

-

choose(Predicate, Traversal<?, E2>, Traversal<?, E2>)

-

choose(Traversal<?, ?>, Traversal<?, E2>)

-

choose(Traversal<?, ?>, Traversal<?, E2>, Traversal<?, E2>)

-

choose(Traversal<?, M>)

-

coalesce(Traversal<?, E2>…)

-

coin(double)

-

constant(E2)

-

count()

-

count(Scope)

-

cyclicPath()

-

dedup(Scope, String…)

-

dedup(String…)

-

drop()

-

E(Object…)

-

emit()

-

emit(Predicate>)

-

emit(Traversal<?, ?>)

-

filter(Predicate>)

-

filter(Traversal<?, ?>)

-

flatMap(Function, Iterator>)

-

flatMap(Traversal<?, E2>)

-

fold()

-

fold(E2, BiFunction)

-

from(String)

-

from(Traversal<?, Vertex>)

-

from(Vertex)

-

group()

-

group(String)

-

groupCount()

-

groupCount(String)

-

has(String)

-

has(String, Object)

-

has(String, P<?>)

-

has(String, String, Object)

-

has(String, String, P<?>)

-

has(String, Traversal<?, ?>)

-

has(T, Object)

-

has(T, P<?>)

-

has(T, Traversal<?, ?>)

-

hasId(Object, Object…)

-

hasId(P)

-

hasKey(P)

-

hasKey(String, String…)

-

hasLabel(P)

-

hasLabel(String, String…)

-

hasNot(String)

-

hasValue(Object, Object…)

-

hasValue(P)

-

id()

-

identity()

-

in(String…)

-

index()

-

inE(String…)

-

inject(E…)

-

inV()

-

is(Object)

-

is(P)

-

iterate()

-

key()

-

label()

-

limit(long)

-

limit(Scope, long)

-

local(Traversal<?, E2>)

-

loops()

-

loops(String)

-

map(Function, E2>)

-

map(Traversal<?, E2>)

-

match(Traversal<?, ?>…)

-

math(String)

-

max()

-

max(Scope)

-

mean()

-

mean(Scope)

-

min()

-

min(Scope)

-

not(Traversal<?, ?>)

-

option(M, Traversal<?, E2>)

-

option(Traversal<?, E2>)

-

optional(Traversal<?, E2>)

-

or(Traversal<?, ?>…)

-

order()

-

order(Scope)

-

otherV()

-

out(String…)

-

outE(String…)

-

outV()

-

path()

-

project(String, String…)

-

properties(String…)

-

property(Object, Object, Object…)

-

property(Cardinality, Object, Object, Object…)

Only Cardinality.single is supported.

propertyMap(String…)

-

range(long, long)

-

range(Scope, long, long)

-

read()

-

repeat(String, Traversal<?, E>)

-

repeat(Traversal<?, E>)

-

sack()

-

sack(BiFunction)

-

sample(int)

-

sample(Scope, int)

-

select(Column)

-

select(Pop, String)

-

select(Pop, String, String, String…)

-

select(Pop, Traversal)

-

select(String)

-

select(String, String, String…)

-

select(Traversal)

-

sideEffect(Consumer>)

-

sideEffect(Traversal<?, ?>)

-

simplePath()

-

skip(long)

-

skip(Scope, long)

-

store(String)

-

sum()

-

sum(Scope)

-

tail()

-

tail(long)

-

tail(Scope)

-

tail(Scope, long)

-

timeLimit(long)

-

times(int)

-

to(Direction, String…)

-

to(String)

-

to(Traversal<?, Vertex>)

-

to(Vertex)

-

toE(Direction, String…)

-

toV(Direction)

-

tree()

-

tree(String)

-

unfold()

-

union(Traversal<?, E2>…)

-

until(Predicate>)

-

until(Traversal<?, ?>)

-

V(Object…)

-

value()

-

valueMap(boolean, String…)

-

valueMap(String…)

-

values(String…)

-

where(P)

-

where(String, P)

-

where(Traversal<?, ?>)

-

with(String)

-

with(String, Object)

-

withSack(A)

-

withSack(A, BinaryOperator)

-

withSack(A, UnaryOperator)

-

withSack(A, UnaryOperator<A>, BinaryOperator<A>)

-

withSack(Supplier<A>)

-

withSack(Supplier,BinaryOperator)

-

withSack(Supplier,UnaryOperator)

-

withSack(Supplier,UnaryOperator,BinaryOperator)

-

withSideEffect(String, A)

-

withSideEffect(String, A, BinaryOperator)

-

withSideEffect(String,Supplier)

-

withSideEffect(String,Supplier, BinaryOperator)

-

Features supported by GDB Gremlin

Note

The feature information in the following table is the same as the content that is returned by the Graph.features() call in TinkerPop.

Category

Feature

Supported

Graph

ThreadedTransactions

Computer

Transactions

Persistence

ConcurrentAccess

Variable

SerializableValues

UniformListValues

BooleanArrayValues

DoubleArrayValues

IntegerArrayValues

StringArrayValues

MapValues

MixedListValues

ByteArrayValues

FloatArrayValues

LongArrayValues

Variables

BooleanValues

ByteValues

DoubleValues

FloatValues

IntegerValues

LongValues

StringValues

Vertex

MetaProperties

DuplicateMultiProperties

MultiProperties

NumericIds

UuidIds

CustomIds

AnyIds

AddVertices

RemoveVertices

UserSuppliedIds

AddProperty

RemoveProperty

StringIds

Vertex Property

UserSuppliedIds

NumericIds

UuidIds

CustomIds

AnyIds

SerializableValues

UniformListValues

BooleanArrayValues

DoubleArrayValues

IntegerArrayValues

StringArrayValues

MapValues

MixedListValues

ByteArrayValues

FloatArrayValues

LongArrayValues

AddProperty

RemoveProperty

StringIds

Properties

BooleanValues

ByteValues

DoubleValues

FloatValues

IntegerValues

LongValues

StringValues

Edge

NumericIds

UuidIds

CustomIds

AnyIds

AddEdges

RemoveEdges

UserSuppliedIds

AddProperty

RemoveProperty

StringIds

Edge Property

SerializableValues

UniformListValues

BooleanArrayValues

DoubleArrayValues

IntegerArrayValues

StringArrayValues

MapValues

MixedListValues

ByteArrayValues

FloatArrayValues

LongArrayValues

Properties

BooleanValues

ByteValues

DoubleValues

FloatValues

IntegerValues

LongValues

StringValues