Class Reads
KVStore
.
Only the (ranges of) keys read are retained, not the values.
Instances are not thread safe.
-
Constructor Summary
ConstructorDescriptionReads()
Construct an empty instance.Construct an instance containing the given key ranges.Reads
(InputStream input) Constructor to deserialize an instance created byserialize()
. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Clone this instance.findConflict
(Mutations mutations) Determine whether any of the given mutations conflict with any of the keys read by this instance, and report the first conflict found.getAllConflicts
(Mutations mutations) List all of the conflicts between the given mutations and any of the keys read by this instance.getConflicts
(Mutations mutations) List all of the conflicts between the given mutations and any of the keys read by this instance, inString
form.boolean
isConflict
(Mutations mutations) Determine whether any of the given mutations conflict with any of the keys read by this instance.Return an immutable snapshot of this instance.Methods inherited from class io.permazen.kv.KeyRanges
add, add, asList, asSet, clear, contains, contains, contains, deserializeIterator, empty, equals, findKey, forPrefix, full, getMax, getMin, hashCode, intersect, intersect, intersects, inverse, isEmpty, isFull, iterator, prefixedBy, remove, remove, seekHigher, seekLower, serialize, serializedLength, size, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Reads
public Reads()Construct an empty instance. -
Reads
Construct an instance containing the given key ranges.- Parameters:
ranges
- initial key ranges- Throws:
IllegalArgumentException
- ifranges
is null
-
Reads
Constructor to deserialize an instance created byserialize()
.- Parameters:
input
- input stream containing data fromserialize()
- Throws:
IOException
- if an I/O error occursEOFException
- if the input ends unexpectedlyIllegalArgumentException
- ifinput
is nullIllegalArgumentException
- ifinput
is invalid
-
-
Method Details
-
isConflict
Determine whether any of the given mutations conflict with any of the keys read by this instance.This method is equivalent to invoking
findConflict()
and checking whether it returns non-null.This method guarantees that it will access the given
mutations
in this order: removes, puts, adjusts.- Parameters:
mutations
- mutations to check for conflicts- Returns:
- true if the
mutations
are invisible to this instance, false if this instance contains a key modified bymutations
- Throws:
IllegalArgumentException
- ifmutations
is null- See Also:
-
findConflict
Determine whether any of the given mutations conflict with any of the keys read by this instance, and report the first conflict found.If this method returns null, then if two transactions T1 and T2 are based on the same underlying
KVStore
snapshot, and T1 writesmutations
and T2 reads according to this instance, then T2 can be ordered after T1 while still preserving linearizable semantics. That is, the givenmutations
are invisible to this instance.This method guarantees that it will access the given
mutations
in this order: removes, puts, adjusts.- Parameters:
mutations
- mutations to check for conflicts- Returns:
- the first
Conflict
found, or null if there are no conflicts - Throws:
IllegalArgumentException
- ifmutations
is null- See Also:
-
getConflicts
List all of the conflicts between the given mutations and any of the keys read by this instance, inString
form.This method simply invokes
getAllConflicts()
and returns the resulting list converted intoString
objects viaObject.toString()
.This method guarantees that it will access the given
mutations
in this order: removes, puts, adjusts.- Parameters:
mutations
- mutations to check for conflicts with this instance- Returns:
- a description of each conflict between this instance and the given mutations
- Throws:
IllegalArgumentException
- ifmutations
is null- See Also:
-
getAllConflicts
List all of the conflicts between the given mutations and any of the keys read by this instance.This method guarantees that it will access the given
mutations
in this order: removes, puts, adjusts.- Parameters:
mutations
- mutations to check for conflicts with this instance- Returns:
- list of each conflict between this instance and the given mutations
- Throws:
IllegalArgumentException
- ifmutations
is null- See Also:
-
clone
Description copied from class:KeyRanges
Clone this instance.The returned clone will always be mutable, even if this instance is not.
-
readOnlySnapshot
Description copied from class:KeyRanges
Return an immutable snapshot of this instance.- Overrides:
readOnlySnapshot
in classKeyRanges
- Returns:
- immutable snapshot
-