Class Reads
KVStore.
Only the (ranges of) keys read are retained, not the values.
Instances are not thread safe.
-
Constructor Summary
ConstructorsConstructorDescriptionReads()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, inStringform.booleanisConflict(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, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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- ifrangesis 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- ifinputis nullIllegalArgumentException- ifinputis 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
mutationsin this order: removes, puts, adjusts.- Parameters:
mutations- mutations to check for conflicts- Returns:
- true if the
mutationsare invisible to this instance, false if this instance contains a key modified bymutations - Throws:
IllegalArgumentException- ifmutationsis 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
KVStoresnapshot, and T1 writesmutationsand T2 reads according to this instance, then T2 can be ordered after T1 while still preserving linearizable semantics. That is, the givenmutationsare invisible to this instance.This method guarantees that it will access the given
mutationsin this order: removes, puts, adjusts.- Parameters:
mutations- mutations to check for conflicts- Returns:
- the first
Conflictfound, or null if there are no conflicts - Throws:
IllegalArgumentException- ifmutationsis null- See Also:
-
getConflicts
List all of the conflicts between the given mutations and any of the keys read by this instance, inStringform.This method simply invokes
getAllConflicts()and returns the resulting list converted intoStringobjects viaObject.toString().This method guarantees that it will access the given
mutationsin 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- ifmutationsis 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
mutationsin 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- ifmutationsis null- See Also:
-
clone
Description copied from class:KeyRangesClone this instance.The returned clone will always be mutable, even if this instance is not.
-
readOnlySnapshot
Description copied from class:KeyRangesReturn an immutable snapshot of this instance.- Overrides:
readOnlySnapshotin classKeyRanges- Returns:
- immutable snapshot
-