文档

Gremlin兼容性

更新时间:

图数据库GDB支持TinkerPop Gremlin查询语言。对于TinkerPop Gremlin查询语言,图数据库GDB Gremlin与TinkerPop Gremlin在实现细节上存在差异。本文主要介绍图数据库GDB对于TinkerPop Gremlin查询语言的兼容性。

版本兼容

  • 图数据库GDB Gremlin兼容TinkerPop Gremlin 3.3.x以及3.4.x版本。

  • 与图数据库GDB服务端进行交互时,使用GraphSON格式。

    说明

    GraphSON是Gremlin的标准格式,使用JSON格式表示点、边和属性。

DSL使用限制

图数据库GDB Gremlin在DSL的使用规则上与TinkerPop的差异如下:

  • 所有的DSL必须以内置的变量g开头,该变量等同于TinkerPop中的Graph.traversal()

  • 不支持对于查询策略的控制,所有查询优化由图数据库GDB内置自动执行。

  • 点和边的ID为字符串类型,可以由您指定。如果您没有指定,则自动生成UUID作为点或边的ID。

  • 图数据库GDB的属性图模型中,目前支持Single、Set两种模式,即TinkerPop中的

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

  • 图数据库GDB属性值的类型当前仅支持简单类型(包括数字、字符串和布尔型,即Java编程语言中的byte、char、short、int、long、float、double、boolean和String);不支持复杂类型(例如日期)。

Groovy限制

图数据库GDB Gremlin不支持Groovy语言的相关特性,包括:

  • Groovy风格的Lambda表达式和内嵌函数调用,例如map.findAll{it.value>3}

  • 数学表达式,例如1+1

  • 系统调用,例如System.currentTimeMillis()

事务的支持

图数据库GDB Gremlin默认支持事务,具体如下:

  • 不支持ThreadedTransaction(即跨线程,由用户自己控制开始和提交的方式),而是采用内置的Sesionless方式的事务。一个DSL内部所有的操作认为在一个事务内部。

  • 如果DSL内部含有更新类型的Step(Mutation类别),则认为该事务是一个读写事务,反之认为是一个只读事务。

  • 一个DSL从开始的时候,自动开启一个事务,在结束的时候,按运行情况自动提交或回滚。

  • 事务隔离的级别为Read-Committed。

  • 数据导入拆分为按行的一组单条事务,事务(各数据行)之间无关联。

对TinkerPop Gremlin的Step接口支持情况

说明
  • 主要不支持的接口主要为以下几类:

    • 用到了GraphComputer类的OLAP接口。

    • Explain和Profiling类型的接口。

    • 其他非增、删、查、改类型的辅助接口。

  • 下表中支持代表支持,不支持代表不支持。

Step接口

是否支持

备注

connectedComponent()

不支持GraphComputer

io(String)

-

pageRank()

不支持GraphComputer

pageRank(double)

不支持GraphComputer

peerPressure()

不支持GraphComputer

profile()

-

profile(String)

-

program(VertexProgram<?>)

不支持GraphComputer

shortestPath()

不支持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…)

仅支持Cardinality.single

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)

-

图数据库GDB Gremlin支持的特性

说明

下表中特性的返回内容与TinkerPop的Graph.features()返回内容相同。

分类

特性

是否支持

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

  • 本页导读 (1)
文档反馈