Since last year I have been storing metadata about my photos, and other stuff like the twilight data, in a Redland triple store, backed by the MySQL storage implementation I wrote. I have been writing various PHP scripts for maintaining and querying the various graphs, and I found that there were a few basic tasks I kept implementing, writing the same code over and over again. At one point I finally started factoring them out into a common “library", librdfutil (syntax highlighted version).
Most of the functions are only helpful in a PHP and/or MySQL environment, but a few of them might make it into the core Redland API at some point if other people find them useful and we can persuade Dave Beckett to include them.
The current version of this library is 0.0.1 (this entry will server as the changelog).
librdfutil_mysql_cbd_original_lite: Add the original CBD (without reification) for a node object to a model.
librdfutil_mysql_cbd_lite: Add revised CBD (without reification) for a node object to a model.
librdfutil_strings_to_node: Create a new librdf_node from a set of strings.
librdfutil_stringset_to_statement: Create a new librdf_statement from a set of strings.
librdfutil_tuple_to_statement: Create a new librdf_statement from a database tuple.
librdfutil_model_to_string: Get a serialised representation of a model, in R3X or Turtle syntax.
librdfutil_stream_to_string: Get a serialised representation of a stream of statements, in R3X or Turtle syntax.
librdfutil_node_to_turtle_string: Generate Turtle syntax fragment for node.
librdfutil_node_to_hash: Get a string hash (the MySQL ID) of a node object.
librdfutil_strings_hash: Get a string hash (the MySQL ID) of a node.
A few additional notes:
- The MySQL specific functions, the ones that start with
librdfutil_mysql, require ADODB.
- In case anyone is wondering about the naming of the CBD functions, I expect to implement the full specification(s) at a later date — or perhaps someone else will contribute them…
- At some point, a pretty API overview with usage examples will be created, for easy reference.
Comments, bug reports, and suggestions are as always much appreciated. Thanks to Russell Cloran for initial thoughts and comments on the pre-release version.