class RDF::Repository

An RDF repository.

@example Creating a transient in-memory repository

repository = RDF::Repository.new

@example Checking whether a repository is readable/writable

repository.readable?
repository.writable?

@example Checking whether a repository is persistent or transient

repository.persistent?
repository.transient?

@example Checking whether a repository is empty

repository.empty?

@example Checking how many statements a repository contains

repository.count

@example Checking whether a repository contains a specific statement

repository.statement?(statement)

@example Enumerating statements in a repository

repository.each_statement { |statement| statement.inspect! }

@example Inserting statements into a repository

repository.insert(*statements)
repository.insert(statement)
repository.insert([subject, predicate, object])
repository << statement
repository << [subject, predicate, object]

@example Deleting statements from a repository

repository.delete(*statements)
repository.delete(statement)
repository.delete([subject, predicate, object])

@example Deleting all statements from a repository

repository.clear!

Repositories support transactions with a variety of ACID semantics:

Atomicity is indicated by ‘#supports?(:atomic_write)`. When atomicity is supported, writes through {#transaction}, {#apply_changeset} and {#delete_insert} are applied atomically.

Consistency should be guaranteed, in general. Repositories that don’t support consistency, or that have specialized definitions of consistency above those declared by the RDF data model, should advertise this fact in their documentation.

Isolation may be supported at various levels, indicated by {#isolation_level}:

- `:read_uncommitted`: Inserts & deletes in an uncommitted transaction 
   scope may be visible to other transactions (or via `#each`, etc...)
- `:read_committed`: Inserts & deletes may be visible to other 
   transactions once committed
- `:repeatable_read`: Phantom reads may be possible
- `:snapshot`: A transaction reads a consistent snapshot of the data. 
   Write skew anomalies may occur (for various definitions of consistency)
- `:serializable`: A transaction reads a consistent snapshot of the data.
   When two or more transactions attempt conflicting writes, only one of
   them may succeed.

Durability is noted via {RDF::Durable} support and {#durable?} /{#nondurable?}.

@example Transational read from a repository

repository.transaction do |tx|
  tx.statement?(statement)
  tx.query([:s, :p, :o])
end

@example Transational read/write of a repository

repository.transaction(mutable: true) do |tx|
  tx.insert(*statements)
  tx.insert(statement)
  tx.insert([subject, predicate, object])
  tx.delete(*statements)
  tx.delete(statement)
  tx.delete([subject, predicate, object])
end