Skip to content

Commit

Permalink
Added automatic save config for TinkerGraph
Browse files Browse the repository at this point in the history
This closes #77
  • Loading branch information
spmallette committed Feb 14, 2024
1 parent 644dddc commit c650c45
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions book/Section-Moving-Beyond.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,41 @@ try {
}
----

It's worth adding that with TinkerGraph there is a second way to save your data that
allows it to happen a bit more automatically. If you configure your TinkerGraph at
startup to include a 'graphLocation' and 'graphFormat', TinkerGraph will
automatically save the graph on a call to the 'close'. Earlier, the graph was created
with the following code:

[source,java]
----
// Create a new (empty) TinkerGraph
TinkerGraph tg = TinkerGraph.open();
----

The 'open' method has the option to accept a 'Configuration' object. In that
configuration we would add those two settings.

[source,java]
----
// Create a new (empty) TinkerGraph with a configuration
Configuration conf = new BaseConfiguration();
conf.setProperty("gremlin.tinkergraph.graphLocation", "mygraph.xml");
conf.setProperty("gremlin.tinkergraph.graphLocation", "graphml");
TinkerGraph tg = TinkerGraph.open(configuration);
...
// call close() to save as GraphML to a file called mygraph.xml
try {
tg.close();
} catch (Exception ex) {
System.out.println("Graph failed to save");
}
----

NOTE: 'Configuration' refers to the Apache Configuration library.

[[groovyapp]]
Working with TinkerGraph from a Groovy application
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down

0 comments on commit c650c45

Please sign in to comment.