Is there any tool to convert data from hive or sql directly into a graphml file

248 views
Skip to first unread message

张国彬

unread,
Sep 20, 2019, 9:11:06 AM9/20/19
to Gremlin-users
Is there any tool to convert data from hive or sql directly into a graphml file? How do you generate a graphml file?

Stephen Mallette

unread,
Sep 20, 2019, 9:34:25 AM9/20/19
to gremli...@googlegroups.com
> Is there any tool to convert data from hive or sql directly into a graphml file? How do you generate a graphml file? 

I'm not aware of any conversion tool like that. 

> How do you generate a graphml file?

You can generate one from a TinkerPop-enabled graph with io() step:


g.io("graph.xml").write().iterate() 

If you're asking how to generate one from a relational database or other data source then you probably just have to write some code to generate an XML file according to the GraphML standard:



On Fri, Sep 20, 2019 at 9:11 AM 张国彬 <gbzha...@gmail.com> wrote:
Is there any tool to convert data from hive or sql directly into a graphml file? How do you generate a graphml file?

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/57d1d27f-ab9e-4723-8f02-92c5e9b48abf%40googlegroups.com.

张国彬

unread,
Sep 22, 2019, 10:15:57 PM9/22/19
to Gremlin-users
thanks,i want to know how to convert data to TinkerPop from a relational database or other data source ,only by writing code to generate an XML file or other file like json?

在 2019年9月20日星期五 UTC+8下午9:34:25,Stephen Mallette写道:
> Is there any tool to convert data from hive or sql directly into a graphml file? How do you generate a graphml file? 

I'm not aware of any conversion tool like that. 

> How do you generate a graphml file?

You can generate one from a TinkerPop-enabled graph with io() step:


g.io("graph.xml").write().iterate() 

If you're asking how to generate one from a relational database or other data source then you probably just have to write some code to generate an XML file according to the GraphML standard:



On Fri, Sep 20, 2019 at 9:11 AM 张国彬 <gbzha...@gmail.com> wrote:
Is there any tool to convert data from hive or sql directly into a graphml file? How do you generate a graphml file?

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremli...@googlegroups.com.

Stephen Mallette

unread,
Sep 23, 2019, 6:21:16 AM9/23/19
to gremli...@googlegroups.com
If you have a relational database that you want to convert to a graph you would typically just write a Gremlin script to do that conversion and then execute it Gremlin Console. The script approach will work fine for "medium" size graphs (i.e. millions of edges or low tens of millions of edges). As an example, consider the simple csv-to-graph example in the Getting Started tutorial:


Instead of reading from a file, just establish a JDBC connection and issue SQL statements to collect the data you wish to convert then use Gremlin to write the data to the graph.

If you have billions of edges then you will probably need to parallelize your load somehow (e.g. gremlin-spark. custom loading scripts that are multi-threaded, etc) so that it finishes in some reasonable period of time.

To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/5e3058cc-9789-4dca-80a8-db9fe758953e%40googlegroups.com.

张国彬

unread,
Sep 23, 2019, 7:23:47 AM9/23/19
to Gremlin-users
thanks very much!

在 2019年9月23日星期一 UTC+8下午6:21:16,Stephen Mallette写道:

张国彬

unread,
Sep 23, 2019, 10:45:25 PM9/23/19
to Gremlin-users
I write a Gremlin script to do that conversion,and excute the script in the gremlin  Execution Mode  or Interactive Mode,but where the data is saved when the script is run over? just saved in the Program memory(RAM)?,in the data file directory,i did not find the data file in any type like xm,kryo or json format,how to persistence the gremlin script excution result ,so i can use it directly next time,thanks for your reply.

Persistencep


在 2019年9月23日星期一 UTC+8下午6:21:16,Stephen Mallette写道:
If you have a relational database that you want to convert to a graph you would typically just write a Gremlin script to do that conversion and then execute it Gremlin Console. The script approach will work fine for "medium" size graphs (i.e. millions of edges or low tens of millions of edges). As an example, consider the simple csv-to-graph example in the Getting Started tutorial:

Stephen Mallette

unread,
Sep 24, 2019, 6:38:56 AM9/24/19
to gremli...@googlegroups.com
You have to choose a TinkerPop graph instance to store your data. That example in the tutorial uses TinkerGraph which is an in-memory graph. You can persist an in-memory snapshot of that by doing:

g.io('file.graphml').write().iterate()


If you want something that flushes transactions to disk then you need to choose something else:





To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/bc6fec13-5e77-452f-a9ca-738aca851e53%40googlegroups.com.

Wolfgang Fahl

unread,
Sep 24, 2019, 1:32:25 PM9/24/19
to Gremlin-users
Reply all
Reply to author
Forward
0 new messages