Gremlin兼容性
圖數(shù)據(jù)庫(kù)GDB支持TinkerPop Gremlin查詢語言。對(duì)于TinkerPop Gremlin查詢語言,圖數(shù)據(jù)庫(kù)GDB Gremlin與TinkerPop Gremlin在實(shí)現(xiàn)細(xì)節(jié)上存在差異。本文主要介紹圖數(shù)據(jù)庫(kù)GDB對(duì)于TinkerPop Gremlin查詢語言的兼容性。
版本兼容
圖數(shù)據(jù)庫(kù)GDB Gremlin兼容TinkerPop Gremlin 3.3.x以及3.4.x版本。
與圖數(shù)據(jù)庫(kù)GDB服務(wù)端進(jìn)行交互時(shí),使用GraphSON格式。
說明GraphSON是Gremlin的標(biāo)準(zhǔn)格式,使用JSON格式表示點(diǎn)、邊和屬性。
DSL使用限制
圖數(shù)據(jù)庫(kù)GDB Gremlin在DSL的使用規(guī)則上與TinkerPop的差異如下:
所有的DSL必須以內(nèi)置的變量g開頭,該變量等同于TinkerPop中的
Graph.traversal()
。不支持對(duì)于查詢策略的控制,所有查詢優(yōu)化由圖數(shù)據(jù)庫(kù)GDB內(nèi)置自動(dòng)執(zhí)行。
點(diǎn)和邊的ID為字符串類型,可以由您指定。如果您沒有指定,則自動(dòng)生成UUID作為點(diǎn)或邊的ID。
圖數(shù)據(jù)庫(kù)GDB的屬性圖模型中,目前支持Single、Set兩種模式,即TinkerPop中的
org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality.single; org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality.set
圖數(shù)據(jù)庫(kù)GDB屬性值的類型當(dāng)前僅支持簡(jiǎn)單類型(包括數(shù)字、字符串和布爾型,即Java編程語言中的byte、char、short、int、long、float、double、boolean和String);不支持復(fù)雜類型(例如日期)。
Groovy限制
圖數(shù)據(jù)庫(kù)GDB Gremlin不支持Groovy語言的相關(guān)特性,包括:
Groovy風(fēng)格的Lambda表達(dá)式和內(nèi)嵌函數(shù)調(diào)用,例如
map.findAll{it.value>3}
。數(shù)學(xué)表達(dá)式,例如
1+1
。系統(tǒng)調(diào)用,例如
System.currentTimeMillis()
。
事務(wù)的支持
圖數(shù)據(jù)庫(kù)GDB Gremlin默認(rèn)支持事務(wù),具體如下:
不支持ThreadedTransaction(即跨線程,由用戶自己控制開始和提交的方式),而是采用內(nèi)置的Sesionless方式的事務(wù)。一個(gè)DSL內(nèi)部所有的操作認(rèn)為在一個(gè)事務(wù)內(nèi)部。
如果DSL內(nèi)部含有更新類型的Step(Mutation類別),則認(rèn)為該事務(wù)是一個(gè)讀寫事務(wù),反之認(rèn)為是一個(gè)只讀事務(wù)。
一個(gè)DSL從開始的時(shí)候,自動(dòng)開啟一個(gè)事務(wù),在結(jié)束的時(shí)候,按運(yùn)行情況自動(dòng)提交或回滾。
事務(wù)隔離的級(jí)別為Read-Committed。
數(shù)據(jù)導(dǎo)入拆分為按行的一組單條事務(wù),事務(wù)(各數(shù)據(jù)行)之間無關(guān)聯(lián)。
對(duì)TinkerPop Gremlin的Step接口支持情況
主要不支持的接口主要為以下幾類:
用到了GraphComputer類的OLAP接口。
Explain和Profiling類型的接口。
其他非增、刪、查、改類型的輔助接口。
下表中代表支持,代表不支持。
Step接口 |
是否支持 |
備注 |
---|---|---|
|
不支持 |
|
|
- |
|
|
不支持 |
|
|
不支持 |
|
|
不支持 |
|
|
- |
|
|
- |
|
|
不支持 |
|
|
不支持 |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
僅支持 |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
|
|
- |
圖數(shù)據(jù)庫(kù)GDB Gremlin支持的特性
下表中特性的返回內(nèi)容與TinkerPop的Graph.features()返回內(nèi)容相同。
分類 |
特性 |
是否支持 |
---|---|---|
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 |