Skip to content

Commit 474a3c9

Browse files
author
Tom Johnson
committed
Fill in some SerializedTransaction docs
1 parent 2c0d271 commit 474a3c9

1 file changed

Lines changed: 29 additions & 5 deletions

File tree

lib/rdf/repository.rb

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ module RDF
5151
# above those declared by the RDF data model, should advertise this fact in
5252
# their documentation.
5353
#
54-
# Isolation may be supported at various levels, indicated by `#supports?`:
55-
# - `:read_uncommitted`: inserts & deletes in an uncommitted transaction
54+
# Isolation may be supported at various levels, indicated by
55+
# `#isolation_level`:
56+
# - `:read_uncommitted`: Inserts & deletes in an uncommitted transaction
5657
# scope may be visible to other transactions (or via `#each`, etc...)
57-
# - `:read_committed`: inserts & deletes may be visible to other
58+
# - `:read_committed`: Inserts & deletes may be visible to other
5859
# transactions once committed
5960
# - `:repeatable_read`: Phantom reads may be possible
6061
# - `:snapshot`: A transaction reads a consistent snapshot of the data.
@@ -509,22 +510,32 @@ def delete_from(data, statement)
509510
##
510511
# A transaction for the Hamster-based `RDF::Repository::Implementation`
511512
# with full serializability.
512-
#
513+
#
513514
# @todo refactor me!
514515
# @see RDF::Transaction
515516
class SerializedTransaction < Transaction
517+
##
518+
# @see Transaction#initialize
516519
def initialize(*)
517520
super
518521
@base_snapshot = @snapshot
519522
end
520523

524+
##
525+
# Inserts the statement to the transaction's working snapshot.
526+
#
527+
# @see Transaction#insert_statement
521528
def insert_statement(statement)
522529
@snapshot = @snapshot.class
523530
.new(data: @snapshot.send(:insert_to,
524531
@snapshot.send(:data),
525532
process_statement(statement)))
526533
end
527534

535+
##
536+
# Deletes the statement from the transaction's working snapshot.
537+
#
538+
# @see Transaction#insert_statement
528539
def delete_statement(statement)
529540
@snapshot = @snapshot.class
530541
.new(data: @snapshot.send(:delete_from,
@@ -537,7 +548,20 @@ def delete_statement(statement)
537548
def isolation_level
538549
:serializable
539550
end
540-
551+
552+
##
553+
# Replaces repository data with the transaction's snapshot in a safely
554+
# serializable fashion.
555+
#
556+
# @note this transaction uses a pessimistic merge strategy which
557+
# fails the transaction if any data has changed in the repository
558+
# since transaction start time. However, the specific guarantee is
559+
# softer: multiple concurrent conflicting transactions will not
560+
# succeed. We may choose to implement a less pessimistic merge
561+
# strategy as a non-breaking change.
562+
#
563+
# @raise [TransactionError] when the transaction can't be merged.
564+
# @see Transaction#execute
541565
def execute
542566
raise TransactionError, 'Cannot execute a rolled back transaction. ' \
543567
'Open a new one instead.' if @rolledback

0 commit comments

Comments
 (0)