NAME
rdf/store - std/db-backed RDF quad store.
SYNOPSIS
from rdf/store import RDFStore;
from rdf/term import rdf_iri, rdf_literal, rdf_quad;
let store := RDFStore.temp();
store.install_schema();
store.add_quad(rdf_quad(
rdf_iri("http://example.com/s"),
rdf_iri("http://example.com/p"),
rdf_literal("value"),
));
let quads := store.find(rdf_iri("http://example.com/s"));
DESCRIPTION
RDFStore stores RDF quads in relational tables managed through std/db. Terms are interned, quads are indexed for lookup, and all graph operations use RDF term identity rather than object identity. The schema must be installed before use.
EXPORTS
Classes
RDFStoreConstruct with
new RDFStore(dbh: dbh)for SQLite or with an explicitbackendofsqlite,mysql, orpostgresql.prefixcontrols the table name prefix and defaults tordf_.temp()Returns
new RDFStore(dbh: DB.temp()).install_schema()Creates the store tables and indexes if needed.
schema_version()Returns the installed schema version, or
0if the schema is absent.verify_schema(Boolean strict := true)Checks that required schema objects exist. Throws on failure when
strictis true; otherwise returns false.drop_schema()Drops the store tables for this prefix.
begin(),commit(),rollback()Transaction helpers delegated to the database handle.
with_transaction(Function todo)Runs
todoinside a transaction, committing on success and rolling back on exception.add_term(term)Interns an RDF term and returns its database id.
term_for_key(String key)Returns the RDF term previously interned for
key, ornull.add_quad(RDFQuad quad),add_quads(Array quads)Adds one or more quads. Duplicate quads are ignored by the store schema.
add_quads_bulk(Array quads)Adds many quads inside a transaction.
remove_quad(RDFQuad quad),remove_quads(Array quads)Removes one or more exact quads.
remove_match(subject := null, predicate := null, object := null, graph := null)Removes quads matching the supplied RDF term pattern.
nullis a wildcard.clear()Removes every quad.
clear_graph(graph := null)Removes quads in the supplied graph, or the default graph when omitted.
graph_names()Returns named graph terms present in the store.
graph_exists(graph := null)Returns whether the supplied graph has any quads.
copy_graph(source := null, target := null)Copies all quads from
sourcetotarget.add_graph(source := null, target := null)Adds quads from
sourceintotargetwithout clearingtarget.move_graph(source := null, target := null)Copies then clears
source.replace_graph(graph := null, Array quads := [])Clears
graphand inserts the supplied quads into it.merge_store(RDFStore other)Adds all quads from another store.
count_quads(),count_terms()Return store counts.
statistics()Returns a dictionary of store counts and graph information.
diagnostics()Returns schema and backend diagnostic information.
explain_find(subject := null, predicate := null, object := null, graph := null)Returns a description of the lookup path selected for a pattern.
explicit_find(subject := null, predicate := null, object := null, graph := null)Returns matching stored quads without entailment.
find(subject := null, predicate := null, object := null, graph := null)Returns matching quads. Subclasses may add inferred quads.
serialize(serializer := null)Serializes all quads in the store. Defaults to
NQuadsSerializerwhen no serializer object is supplied.serialize_to(Path path, serializer := null)Serializes all quads in the store to
path. Defaults toNQuadsSerializerwhen no serializer object is supplied.
COPYRIGHT AND LICENCE
rdf/store is copyright Toby Inkster.
It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.