简体   繁体   中英

Gremlin: how works IO import with python

I am trying to know what are the functions called from the command g.io('file.json').read().iterate() I see that a 'read' step is put in the step_instructions but I can't found the original function to import the file in to the graph.

This because I want to import a lot of data but without a file, using a python object. I see that io().read() import a big file in a minute and I want to ricreate it but without using a file.

Thanks a lot.

First of all to be clear on the nomenclature, io() is a step, while read() and write() are step modulators and those modulators can only apply to io() step to tell it to read or write respectively. Therefore, as io() currently only works with a string file name consequently you can only read/write from/to files.

If you want to send "a lot of data" with Python, I'd first consider what you mean by that in size. If you're talking millions of vertices and edges, you should first check if the graph database you are using has its own bulk loading tool. If it does, you should use that. You may also consider methods using Gremlin/Spark as described here in the case of JanusGraph. Finally, if you must use pure Gremlin to do your bulk loading, then parameterized traversal with your Python object (I assume a list / dict of some sort) is probably the approach to take. Thisblog post might offer some inspiration in that line of thinking.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM