I'm interested in extending the Graph for Scala to support Datomic persistence. Has anyone tried this? I'm a seasoned Java developer, and recent grad of Odersky's Scala course. I know I'll be in way over my head if I attempt it.Joe
Thank you for elaborating on my question, Joe. Looking at Datomic basics I realized that you can persist a graph by defining references in your Datomic schema. Is that the way you’d go?
What kind of integration do you envision? In a loose integration, you could call toDatomic that would persist the graph and fromDatomic loading your graph by means of a Datomic query. A tight integration would mean a specific implementation that would react to any method call in a Datomic-specific way for instance by utilizing the Datomic cache…it's a good idea to start with a loosely-coupled preview which will prove to be an easy task. You probably will have seen that JSON export/import and Dot export, both separate modules within Graph for Scala, follow this strategy.
Later on, you may also want to examine the ‘constrained’ module which falls into the tightly-coupled category. It is a good example for how to override behaviour at specific points by referring to extended configuration parameters. While the configuration parameter of a constrained graph contains its constraint, graphs reflecting persistent data will have a configuration parameter providing the database connection, schema description and alike.
As an aside, if you have specific restrictions on the types of connecting nodes and their cardinalities, as it will be the case with Datomic schemas, these restrictions could potentially be managed by a graph constraint in the sense of the constrained module.
Thanks for the tip, Stefan. I stumbled across TInkerpop and Blueprints while investigating. I'll have to give a closer look at the Datomic code. I didn't know they had made it beyond investigation with Datomic.
Joe
On Sun, Nov 18, 2012 at 6:21 AM, Stefan Ollinger <Stefan....@gmx.de> wrote:
Hi,
there is Blueprints, which is basically a Graph API with implementations for several graph databases. Currently they have support for Neo4j [1], SAIL [2] and also (not official) for Datomic [3]. Maybe it would be an option to use their API.
Regards,
Stefan
[1] https://github.com/tinkerpop/blueprints/wiki/Neo4j-Implementation
[2] https://github.com/tinkerpop/blueprints/wiki/Sail-Implementation
[3] https://github.com/datablend/blueprints/tree/master/blueprints-datomic-graph
Hi Joe,
Thanks for creating the graph-datomic repository. My comments/ideas:
val schemaStr = …
Why would you want to describe the Datomic schema by means of a String? I’d opt for a type-safe alternative. Also, analyzing a string at run-time is expensive. How do you plan to map between Scala types and Datomic entries in detail?
val graphSchema = Graph.schema…
Graph companion objects don’t have schema factory methods, like they don’t have JSON-descriptor methods either. Same is valid for Edge, Node etc. This would also contradict loosely coupling.
assert(library.toDatomic(schema).toString === facts)
We won’t be
able to check for equality on a toString basis unless the ordering is defined. Either
we use Graph methods like toSortedString that ensure right ordering or we
compare results with the expected results by equals. I prefer the last.
As for the schema factory methods, I arrived at this approach because I wanted something like your predefined edge descriptors. Any hints on how to better approach this are welcomed.
How do you like the package name I used? I know it's only a minor detail, but I later began to think perhaps "scalax.collection.db.datomic" may be preferable because of its shorter length.
How can we communicate on assembla? I've not seen a way to do that yet.
In the meantime, can you give me some pointers on how your json library is able to extract the fields and values from the scala objects? I need some way to convert a Scala object into a map of property names to values.