Skip to content

Commit 2c0d271

Browse files
author
Tom Johnson
committed
Repository ACID documentation
1 parent daac23c commit 2c0d271

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

lib/rdf/repository.rb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,48 @@ module RDF
4040
# @example Deleting all statements from a repository
4141
# repository.clear!
4242
#
43+
# Repositories support transactions with a variety of ACID semantics:
44+
#
45+
# Atomicity is indicated by `#supports?(:atomic_write)`. When atomicity is
46+
# supported, writes through `#transaction`, `#apply_changeset` and
47+
# `#delete_insert` are applied atomically.
48+
#
49+
# Consistency should be guaranteed, in general. Repositories that don't
50+
# support consistency, or that have specialized definitions of consistency
51+
# above those declared by the RDF data model, should advertise this fact in
52+
# their documentation.
53+
#
54+
# Isolation may be supported at various levels, indicated by `#supports?`:
55+
# - `:read_uncommitted`: inserts & deletes in an uncommitted transaction
56+
# scope may be visible to other transactions (or via `#each`, etc...)
57+
# - `:read_committed`: inserts & deletes may be visible to other
58+
# transactions once committed
59+
# - `:repeatable_read`: Phantom reads may be possible
60+
# - `:snapshot`: A transaction reads a consistent snapshot of the data.
61+
# Write skew anomalies may occur (for various definitions of consistency)
62+
# - `:serializable`: A transaction reads a consistent snapshot of the data.
63+
# When two or more transactions attempt conflicting writes, only one of
64+
# them may succeed.
65+
#
66+
# Durability is noted via `RDF::Durable` support and `#durable?`
67+
# /`#nondurable?`.
68+
#
69+
# @example Transational read from a repository
70+
# repository.transaction do |tx|
71+
# tx.has_statement?(statement)
72+
# tx.query([:s, :p, :o])
73+
# end
74+
#
75+
# @example Transational read/write of a repository
76+
# repository.transaction(mutable: true) do |tx|
77+
# tx.insert(*statements)
78+
# tx.insert(statement)
79+
# tx.insert([subject, predicate, object])
80+
# tx.delete(*statements)
81+
# tx.delete(statement)
82+
# tx.delete([subject, predicate, object])
83+
# end
84+
#
4385
class Repository < Dataset
4486
include RDF::Mutable
4587

@@ -192,6 +234,9 @@ def begin_transaction(mutable: false, graph_name: nil)
192234
end
193235

194236
##
237+
# A default Repository implementation supporting atomic writes and
238+
# serializable transactions.
239+
#
195240
# @see RDF::Repository
196241
module Implementation
197242
require 'hamster'

0 commit comments

Comments
 (0)