Legend:
Library
Module
Module type
Parameter
Class
Class type
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" ;
]
in
let graph = Graph.open_graph ~options (Iri.iri "http://hello.fr") in
graph.add_triple
~sub: (Term.term_of_iri_string "http://john.net")
~pred: (Iri.iri "http://relations.org/hasMailbox")
~obj: (Term.term_of_literal_string "john\@john.net");
...
Options
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.
parameterdef
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.
Interface to query Basic Graph Patterns (BGP) in a graph. Here the term representation is abstracted, so that it can be for example an id in a database table, which will make triple matching and joining faster when matching a BGP by querying the real terms only for the result of the whole BGP, instead of retrieving terms and joining results of each triple.
This is the exception raised by the module we get when applying Make on a storage.
Each call to a Storage function is embedded so that the 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 Storage.string_of_error) and the original exception.
Refer to the documentation of Storage for information about the functions provided by the resulting module.
This is the structure returned by open_graph. It contains the same functions as in Graph, except the graph data is hidden, like in a class interface. Refer to the documentation of Storage for information about the functions in the fields.
Graph creation
val open_graph : ?options:(string * string) list->Iri.t->graph
open_graph ~options iri_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.
The "rdf" namespace is automatically added at creation time, associated to http://www.w3.org/1999/02/22-rdf-syntax-ns#.
can be used to explicitely map terms from g2. When merging blank nodes, if map returns a term, then it is kept as is. Else the blank node is replaced by a fresh one. Default map function always returns None.
root_opt g returns the first root term found in the graph, i.e. a node present in the graph which does not appear as object of a triple. If there are more than one root node, only the first one is returned. If the search falls into a cycle, a node of the cycle is returned. If the graph is empty, None is returned.