SchemaViolationException-JanusGraph問題筆記(二)

場景

Gremlin命令行加載Graph of the Gods(官網入門Demo) GraphOfTheGodsFactory.load(graph)shell

問題 E04: 加載示例圖時報錯SchemaViolationException

報錯信息:後端

org.janusgraph.core.SchemaViolationException: Adding this property for key [~T$SchemaName] and value [rtname] violates a uniqueness constraint [SystemIndex#~T$SchemaName]bash

適用於其餘SchemaViolationException(模式衝突)的狀況推定post

分析

指Schema衝突,[rtname]違反了惟一性約束。SchemaName這一屬性是惟一的,添加的值與先前存在的值衝突。 這是因爲先前已經加載過Graph of the Gods,load命令已經執行過,存儲中已存在相同的數據了,再次添加數據形成。學習

解決方案

方案一

不須要執行GraphOfTheGodsFactory.load(graph)語句,直接進行示例查詢。this

gremlin> g = graph.traversal()
==>graphtraversalsource[standardjanusgraph[cql:[127.0.0.1]], standard]
gremlin> saturn = g.V().has('name', 'saturn').next()
==>v[256]
gremlin> g.V(saturn).valueMap()
==>[name:[saturn], age:[10000]]
gremlin> g.V(saturn).in('father').in('father').values('name')
==>hercules
複製代碼

方案二

  • 刪除整個圖【謹慎操做,不可恢復】, 包含 graph、data、schema 等都會被刪除: JanusGraphFactory.drop(graph)

注意: 刪除圖操做以後要關掉從新進gremlin console,從新打開圖再執行load。不然報錯 Could not re-open management log

org.janusgraph.core.JanusGraphException: Could not re-open management logspa

或者:命令行

  • 刪除存儲後端中的數據表,再執行GraphOfTheGodsFactory.load(graph)便可。 HBase中默認的數據表名是「janusgraph

JanusGraph問題與解決系列

JanusGraph學習筆記-問題與解決(一)code

結語

筆記持續更新,歡迎關注。若有幫助,點贊便是鼓勵!cdn

相關文章
相關標籤/搜索