package rdf

  1. Overview
  2. Docs
val name : string

The name of the storage, for example "mysql".

type g

The type of the graph, abstract. It usually includes all information needed by the other functions, as various graphs of the same kind can be used in the same application.

Errors

type error

A specific type for errors.

exception Error of error

This is the exception raised by the functions of the module in case of error.

val string_of_error : error -> string

This function returns a message from the given error.

Creation and modification

val open_graph : ?options:(string * string) list -> Iri.t -> g

Creationg of the graph. The graph has a name which is a IRI.

val graph_name : g -> Iri.t

Access to the graph name, as specified at its creation.

val graph_size : g -> int

Return the number of triples in the graph.

val add_triple : g -> sub:Term.term -> pred:Iri.t -> obj:Term.term -> unit

Adding a triple to the graph.

val rem_triple : g -> sub:Term.term -> pred:Iri.t -> obj:Term.term -> unit

Removing a triple from the graph.

val add_triple_t : g -> Term.triple -> unit

Adding a triple to the graph, curryfied form.

val rem_triple_t : g -> Term.triple -> unit

Removing a triple from the graph, curryfied form.

Querying the graph

val subjects_of : g -> pred:Iri.t -> obj:Term.term -> Term.term list

subjects_of g ~pred ~obj returns the list of nodes which are subjects in triples with the specified predicate and object.

val predicates_of : g -> sub:Term.term -> obj:Term.term -> Iri.t list

predicates_of g ~sub ~obj returns the list of nodes which are predicates in triples with the specified subject and object.

val objects_of : g -> sub:Term.term -> pred:Iri.t -> Term.term list

objects_of g ~sub ~pred returns the list of nodes which are objects in triples with the specified subject and predicate.

val find : ?sub:Term.term -> ?pred:Iri.t -> ?obj:Term.term -> g -> Term.triple list

find ?sub ?pred ?obj g returns the list of triples matching the constraints given by the optional subject, predicate and object. One can specify, zero, one, two or three of these nodes.

val exists : ?sub:Term.term -> ?pred:Iri.t -> ?obj:Term.term -> g -> bool

Same as find but only returns true if at least one triple of the graph matches the constraints.

val exists_t : Term.triple -> g -> bool

Curryfied version of exists.

val subjects : g -> Term.term list

Return the list of nodes appearing in subject position.

val predicates : g -> Iri.t list

Return the list of nodes appearing in predicate position.

val objects : g -> Term.term list

Return the list of nodes appearing in object position.

val folder : g -> Rdf.Term.TSet.t Iri.Map.t Rdf.Term.TMap.t option

If available, return a structure to iterate depth first in the graph.

Transactions

val transaction_start : g -> unit

Start a transaction. All storage may not support transactions.

val transaction_commit : g -> unit

Commit.

val transaction_rollback : g -> unit

Rollback.

val copy : g -> g

Copy graph. May raise an exception if storage does not support this operation.

val new_blank_id : g -> Term.blank_id

Forging a new, unique blank node id.

Namespaces

val namespaces : g -> (Iri.t * string) list
val add_namespace : g -> Iri.t -> string -> unit
val rem_namespace : g -> string -> unit
val set_namespaces : g -> (Iri.t * string) list -> unit

Evaluating basic graph patterns

module BGP : Storage_BGP with type g = g
OCaml

Innovation. Community. Security.