2015-10-31 42 views
1

我希望提取附加到特定列表的所有邊和頂點以及他們關注的人,並將它們直接複製到neo4j或通過創建數據的graphson或kryo文件。Titan - > Neo4j Gremlin子圖

事情與此類似:

g.V().has("sublist_id", 14).in('ON').out('FOLLOWS') 

我基本上要在一個單獨的數據庫或文件中的每個頂點和邊緣隔離查詢。

我最好的方法是什麼?

我做了以下,但似乎無法導出爲json或kryo只graphml。

gremlin> subGraph = g.V().has('sublist_id', 14).in('ON').outE('FOLLOWS').subgraph('subGraph').cap('subGraph').next() 
==>tinkergraph[vertices:3438716 edges:14090945] 


gremlin> subGraph.io(IoCore.gryo()).writeGraph("/data/test.kryo") 
Class is not registered: com.thinkaurelius.titan.graphdb.relations.RelationIdentifier 
Note: To register this class use: kryo.register(com.thinkaurelius.titan.graphdb.relations.RelationIdentifier.class); 
Display stack trace? 


gremlin> subGraph.io(IoCore.graphson()).writeGraph("/data/test.json"); 
(was java.lang.IllegalStateException) (through reference chain: com.thinkaurelius.titan.graphdb.relations.RelationIdentifier["inVertexId"]) 
Display stack trace? [yN] 

回答

1

當您生成從一個圖的子圖,並嘗試推到另一個則可能是序列化的問題結束了,因爲新的圖形可能不知道如何處理的第一張圖中的數據。這就是你在這裏遇到的情況,特別是在Titan中的唯一ID RelationIdentifier

所以要指出,在您的工作中,你有泰坦RelationIdentifier在裏面,當你去寫,要gryo,序列化過程中,因爲TinkerGraph沒有泰坦序列化的知識未能通過TinkerGraph 。

你可以通過給予gryo泰坦串行器來解決這個問題。做類似:

gryo = GryoIo.build().registry(TitanIoRegistry.INSTANCE).graph(subGraph).create() 
gryo.writeGraph("/data/test.kryo") 

這是一種方法。您還可以從頭開始構建GryoWriter,以便更好地控制不同的選項和設置。

相關問題