Question

I'm new to graph databases and to Titan. I'm embedding Titan in a Clojure app. When the app starts up, it creates a BerkeleyDB backed Titan store.

I want to know/do 3 things:

  1. Is this database new? If so, create a version node with version 0. Run the migration procedures to bring the "schema" to the newest version.
  2. If not, does it have a version node? If not, throw an exception.
  3. If the database was preexisting and has a version node, run migration procedures to bring the "schema" up to date.

How do I do this in Titan? Is there a best practice for this?

EDIT:

OK, on further review, I think using a hard-coded vertexid makes the most sense. There's a TitanTransaction.containsVertex(long vertexid). Are there any drawbacks to this approach? I guess I don't know how vertexids are allocated and what their reserved ranges are, so this smells dangerous. I'm new to graph DBs, but I think in Neo4j creating a reference node from the root node is recommended. But Titan discourages root node usage because it becomes a supernode. IDK...

Était-ce utile?

La solution

1- I don't know if there is a way to see if the database is new through Titan. You could check to see if the directory where BerkeleyDB will be stored exists before you start Titan.

2/3- Probably your best bet would be a hardcoded vertex with an indexed property "version". Do a look up within the (nearly empty) index on "version" at the start and base your logic on those results.

An aside, you might be interested in Titanium[0]. We're gearing up for a big release in the next week or so that should make it much more useful[1].

[0] http://titanium.clojurewerkz.org/

[1] http://blog.clojurewerkz.org/blog/2013/04/17/whats-going-on-with-titanium/

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top