1
votes

I wish to extract all the edges and vertices that are attached to a specific list and who they follow and copy them to either neo4j directly or by creating a graphson or a kryo file of the data.

Something similar to this:

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

I basically want every vertices and edge in a separate database or file to query in isolation.

What is my best approach approach?

I did the following but can't seem to export as json or kryo only 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

1 Answers

1
votes

When you generate a subgraph from one graph and try to push to another you might end up with serialization problems because the new graph might not know how to deal with the data within the first graph. That is the case you are having here, specifically with the RelationIdentifier which is the unique id in Titan.

So to state that in the context of your work, you have a TinkerGraph that has Titan RelationIdentifier in it and when you go to write that to gryo, the serialization process fails because TinkerGraph doesn't have knowledge of the Titan serializers.

You can work around this problem by giving gryo the Titan serializers. Do something like:

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

That's one way to do it. You could also build the GryoWriter up from scratch for even more control over different options and settings.