could someone explain tinkergraph please?

1,400 views
Skip to first unread message

rootsical

unread,
Feb 27, 2013, 2:59:08 PM2/27/13
to gremli...@googlegroups.com
hi.. i have come across tinkergraph and as i like using blueprints/gremlin i was wondering if it is a better graph db to use than, say, neo4j.. however i am not sure if it is the right thing as i don't really get it. could someone explain it in really simple english. in particular could someone explain 'in-memory' - does this mean that the graph data is not stored somewhere on my hard-drive.. if so, that that doesn't seem good for me. i am basically looking at graph dbs in general for a small notes application to help keep me organized.. i will need nodes to hold a fair amount of text, but there won't be millions of nodes! anyhows, any info that augments what i found at https://github.com/tinkerpop/blueprints/wiki/TinkerGraph would be gratefully received. thanks!

Marko Rodriguez

unread,
Feb 27, 2013, 3:08:26 PM2/27/13
to gremli...@googlegroups.com
Hello,


hi.. i have come across tinkergraph and as i like using blueprints/gremlin i was wondering if it is a better graph db to use than, say, neo4j.. however i am not sure if it is the right thing as i don't really get it.

What do you mean "better" ? TinkerGraph is an in-memory graph that is not thread-safe and persists via Java serialization and/or GraphML/etc. file output. Its great if you app is small (< 10 million edges) and single-threaded (at least, single write-threaded). Its extremely fast and good at what it does, but is not a "database" in the classic sense. 

If you are looking at databases, then you should be looking at:

… etc. See all the databases the Blueprints supports.

Good luck,
Marko.


rootsical

unread,
Feb 27, 2013, 7:21:24 PM2/27/13
to gremli...@googlegroups.com
thank you very much for your reply.. sorry, by 'better' i meant at integrating with blueprints/gremlin as it's part of the tinkerpop collection..

unfortunately i am still a bit puzzled about tinkergraph.. maybe i am a bit out of my depth as i don't understand:

- not thread safe
- persists via Java serialization and/or GraphMl etc file output

i am not using the data with anyone else, is that what you mean about thread-safe..? it will be just one app accessing the data at any time.. and it certainly has less than 10 million edges! as for persistence will the data be stored anywhere? as in, when i run my app each time, will the same data i added/deleted from last time be available - and if so, where from?

sorry if i am misunderstanding.. i am just trying to play with graph dbs with a view to helping me organize myself by storing notes/tags as nodes and relationships in a nice little java app.. just to give you an idea of what i am trying to achieve..  thank you for your help..

Marko Rodriguez

unread,
Feb 27, 2013, 7:58:49 PM2/27/13
to gremli...@googlegroups.com
Hi,

> i am not using the data with anyone else, is that what you mean about thread-safe..? it will be just one app accessing the data at any time..

Then TinkerGraph will be great --- and fast.

> and it certainly has less than 10 million edges!

Its all in-memory, so just make sure you allocate enough heap. In principle, your TinkerGraph can go as big as your RAM.

> as for persistence will the data be stored anywhere? as in, when i run my app each time, will the same data i added/deleted from last time be available - and if so, where from?

When you shutdown your app, you simply:

g.saveGraphML('mygraph.graphml')

When you load your app, you simply:

g = new TinkerGraph()
g.loadGraphML('mygraph.graphml')

> sorry if i am misunderstanding.. i am just trying to play with graph dbs with a view to helping me organize myself by storing notes/tags as nodes and relationships in a nice little java app.. just to give you an idea of what i am trying to achieve.. thank you for your help..

If you don't need a "database," don't use a database. Moreover, with TinkerGraph, its free, simple, and you can do with it as you please.

Enjoy,
Marko.

http://thinkaurelius.com

rootsical

unread,
Feb 28, 2013, 8:35:30 AM2/28/13
to gremli...@googlegroups.com
thank you. i understand a lot better now..

rootsical

unread,
Mar 6, 2013, 6:22:00 AM3/6/13
to gremli...@googlegroups.com
ok so i have been playing around with this a bit today but having trouble locating the loadGraphML and saveGraphML methods mentioned above.. is this pseudo-code or maybe i am missing a dependency or class or something.. i am trying to save the graphML file in a 'data' subdirectory of my NotesApp i.e "data/notesApp.graphml" .. should i be using something more akin to what is described at https://github.com/tinkerpop/blueprints/wiki/GraphML-Reader-and-Writer-Library ? if so, what does the InputStream and OutputStream refer to? thank you very much..

Stephen Mallette

unread,
Mar 6, 2013, 6:39:48 AM3/6/13
to gremli...@googlegroups.com
If using Gremlin then you don't need to do anything more than call the
save/loadGraphML method on the graph. If you are using Java then you
need to use overloads on the GraphMLWriter/Reader classes. If you are
using the 2.3.0-SNAPSHOT you should find an overload for the
save/loadGraphML methods that lets you pass just the file path as a
String. If not, then you need to create a FileInput/OutputStream:

http://docs.oracle.com/javase/6/docs/api/java/io/FileOutputStream.html
http://docs.oracle.com/javase/6/docs/api/java/io/FileInputStream.html


Stephen
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

rootsical

unread,
Mar 6, 2013, 6:51:28 AM3/6/13
to gremli...@googlegroups.com
aah yes.. thanks i am indeed trying it with java.. this seems to work..

for the input i did..

        g = new TinkerGraph() ;

        try (InputStream in = new FileInputStream("data/notesApp.graphML")) {
          
               GraphMLReader.inputGraph(g, in);
        } catch (IOException e) {
       
            //handle exception
            System.out.println("there has been an input stream error or some ting");
        }

and for the ouput (when shutting down the graph) i did..

                try (OutputStream out = new FileOutputStream("data/notesApp.graphml")) {
                   
                    GraphMLWriter.outputGraph(graph, out);
                } catch (IOException e) {
               
                    //handle exception
                    System.out.println("there has been a  output stream error or someting");
                }

seems to work! i now have a graphml file! thank you!

rootsical

unread,
Mar 6, 2013, 6:54:06 AM3/6/13
to gremli...@googlegroups.com
sorry i meant

GraphMLWriter.outputGraph(g, out);

as i am referring to my graph as 'g' and not 'graph'...


rootsical

unread,
Mar 6, 2013, 6:56:00 AM3/6/13
to gremli...@googlegroups.com
and this is using Blueprints 2.2.0 ... should have mentioned that..
Reply all
Reply to author
Forward
0 new messages