Class Writes
KVStore.
Each mutation is either a key/value put, the removal of a key range (possibly containing only a single key), or a counter adjustment.
Instances are not thread safe.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidDeprecated.voidApply all mutations contained in this instance to the givenKVStore.voidclear()Clear all mutations.clone()Clone this instance.static Writesdeserialize(InputStream input) Deserialize a mutable instance created byserialize().static Writesdeserialize(InputStream input, boolean immutable) Deserialize an instance created byserialize().static MutationsdeserializeOnline(InputStream input) Get the counter adjustments contained by this instance.Get the set of counter adjustments contained by this instance.Get the written key/value pairs contained by this instance.getPuts()Get the written key/value pairs contained by this instance.Get the key ranges removals contained by this instance.Get the key ranges removals contained by this instance.booleanisEmpty()Determine whether this instance is empty, i.e., contains zero mutations.Return an immutable snapshot of this instance.voidserialize(OutputStream out) Serialize this instance.longCalculate the number of bytes required to serialize this instance viaserialize().toString()
-
Constructor Details
-
Writes
public Writes()
-
-
Method Details
-
getRemoves
Get the key ranges removals contained by this instance.- Returns:
- key ranges removed
-
getPuts
Get the written key/value pairs contained by this instance.- Returns:
- mapping from key to corresponding value
-
getAdjusts
Get the set of counter adjustments contained by this instance.- Returns:
- mapping from key to corresponding counter adjustment
-
isEmpty
public boolean isEmpty()Determine whether this instance is empty, i.e., contains zero mutations.- Returns:
- true if this instance contains zero mutations, otherwise false
-
clear
public void clear()Clear all mutations. -
getRemoveRanges
Description copied from interface:MutationsGet the key ranges removals contained by this instance.- Specified by:
getRemoveRangesin interfaceMutations- Returns:
- key ranges removed
-
getPutPairs
Description copied from interface:MutationsGet the written key/value pairs contained by this instance.- Specified by:
getPutPairsin interfaceMutations- Returns:
- mapping from key to corresponding value
-
getAdjustPairs
Description copied from interface:MutationsGet the counter adjustments contained by this instance.- Specified by:
getAdjustPairsin interfaceMutations- Returns:
- mapping from key to corresponding counter adjustment
-
applyTo
Apply all mutations contained in this instance to the givenKVStore.Mutations are applied in this order: removes, puts, counter adjustments.
- Parameters:
target- target for recorded mutations- Throws:
IllegalArgumentException- iftargetis null
-
apply
Deprecated.useKVStore.apply(io.permazen.kv.mvcc.Mutations)insteadApply all the givenMutationsto the givenKVStore.Mutations are applied in this order: removes, puts, counter adjustments.
- Parameters:
mutations- mutations to applytarget- target for mutations- Throws:
IllegalArgumentException- if either parameter is nullUnsupportedOperationException- if this instance is immutable
-
serialize
Serialize this instance.- Parameters:
out- output- Throws:
IOException- if an error occurs
-
serializedLength
public long serializedLength()Calculate the number of bytes required to serialize this instance viaserialize().- Returns:
- number of serialized bytes
- Throws:
IllegalArgumentException- if the total exceedsLong.MAX_VALUE
-
deserialize
Deserialize a mutable instance created byserialize().Equivalent to
deserialize(input, false).- Parameters:
input- input stream containing data fromserialize()- Returns:
- mutable deserialized instance
- Throws:
IllegalArgumentException- ifinputis nullIllegalArgumentException- if malformed input is detectedIOException- if an I/O error occurs
-
deserialize
Deserialize an instance created byserialize().- Parameters:
input- input stream containing data fromserialize()immutable- true for an immutable instance, otherwise false- Returns:
- deserialized instance
- Throws:
IllegalArgumentException- ifinputis nullIllegalArgumentException- if malformed input is detectedIOException- if an I/O error occurs
-
deserializeOnline
Create an "online"Mutationsview of a serializedWritesinstance.This method returns a
Mutationsinstance that decodes the serializedWritesfrom the given input in an "online" fashion, i.e., it does not load the whole thing into memory. The returnedMutationsiterators may only be accessed once, and they must be accessed in this order: removes, puts, adjusts. Any duplicate or out-of-order access will result in anIllegalStateException.If an
IOExceptionis thrown byinput, theIteratorbeing used will throw aRuntimeExceptionwrapping it; if invalid data is encountered, theIteratorbeing used will throw anIllegalArgumentException.- Parameters:
input- input stream containing data fromserialize()- Returns:
- online
Mutationsview ofinput - Throws:
IllegalArgumentException- ifinputis null
-
clone
Clone this instance.The returned clone will always be mutable, even if this instance is not.
-
readOnlySnapshot
Return an immutable snapshot of this instance.- Returns:
- immutable snapshot
-
toString
-
KVStore.apply(io.permazen.kv.mvcc.Mutations)instead