Module Rdf_graph

module Rdf_graph: sig .. end
Graph abstraction.

The graph provides an abstraction of the storage used (memory, database, ...). The graph is modified in place.

Example of usage:

let options =
    "storage", "mysql" ;
    "database", "mydb";
    "user", "john" ;
let graph = Rdf_graph.open_graph ~options (Rdf_uri.uri "") in
  ~sub: (Rdf_node.node_of_uri_string "")
  ~pred: (Rdf_node.node_of_uri_string "")
  ~obj: (Rdf_node.node_of_literal_string "");


type options = (string * string) list 
val get_option : ?def:string -> string -> options -> string
get_options name options returns the value associated to the option with the given name, in option list. If the option name is not found in the list, the function raises the Failure exception with a message about the missing option.
def : can be used to specify a default value; in this case, if the option name was not found in list, the default value is returned instead of raising Failure.

Creating storages

This is useful only to create your own storage.

module type Storage = sig .. end
A storage is a module with this interface.
exception Storage_error of string * string * exn
This is the exception raised by the module we get when applying Rdf_graph.Make on a storage.

Each call to a Rdf_graph.Storage function is embedded so that the Rdf_graph.Storage_error exception is raised when an error occurs in a storage function. The exception provides the name of the storage, the error message (obtained with Rdf_graph.Storage.string_of_error) and the original exception.

Refer to the documentation of Rdf_graph.Storage for information about the functions provided by the resulting module.

module type Graph = sig .. end
module Make: 
functor (S : Storage) -> Graph with type g = S.g

Registering storages

val add_storage : (module Rdf_graph.Storage) -> unit
Add a storage to the list of registered storages.
type graph = {
   name :unit -> Rdf_uri.uri;
   add_triple :sub:Rdf_node.node -> pred:Rdf_node.node -> obj:Rdf_node.node -> unit;
   rem_triple :sub:Rdf_node.node -> pred:Rdf_node.node -> obj:Rdf_node.node -> unit;
   add_triple_t :Rdf_node.node * Rdf_node.node * Rdf_node.node -> unit;
   rem_triple_t :Rdf_node.node * Rdf_node.node * Rdf_node.node -> unit;
   subjects_of :pred:Rdf_node.node -> obj:Rdf_node.node -> Rdf_node.node list;
   predicates_of :sub:Rdf_node.node -> obj:Rdf_node.node -> Rdf_node.node list;
   objects_of :sub:Rdf_node.node -> pred:Rdf_node.node -> Rdf_node.node list;
   find :?sub:Rdf_node.node ->
?pred:Rdf_node.node -> ?obj:Rdf_node.node -> unit -> Rdf_node.triple list
   exists :?sub:Rdf_node.node ->
?pred:Rdf_node.node -> ?obj:Rdf_node.node -> unit -> bool
   exists_t :Rdf_node.triple -> bool;
   subjects :unit -> Rdf_node.node list;
   predicates :unit -> Rdf_node.node list;
   objects :unit -> Rdf_node.node list;
   transaction_start :unit -> unit;
   transaction_commit :unit -> unit;
   transaction_rollback :unit -> unit;
   new_blank_id :unit -> Rdf_node.blank_id;
   namespaces :unit -> (Rdf_uri.uri * string) list;
This is the structure returned by Rdf_graph.open_graph. It contains the same functions as in Rdf_graph.Graph, except the graph data is hidden, like in a class interface. Refer to the documentation of Rdf_graph.Storage for information about the functions in the fields.

Graph creation

val open_graph : ?options:(string * string) list -> Rdf_uri.uri -> graph
open_graph ~options uri_name creates a new graph. The storage used is specified by the "storage" option. For example, having ("storage", "mysql") in the options indicates to use the storage "mysql".

If the specified storage is not registered, the function raises Failure. Other options may be used by each storage.

To make sure the storage you want to use is registered, beware of linking the corresponding module in your executable, either by using the -linkall option or by adding a reference to the module in your code.

val merge : graph -> graph -> unit
merge g1 g2 add triples from g2 to g1.