Constructor and Description |
---|
Writes() |
Modifier and Type | Method and Description |
---|---|
static void |
apply(Mutations mutations,
KVStore target)
Deprecated.
use
KVStore.apply(io.permazen.kv.mvcc.Mutations) instead |
void |
applyTo(KVStore target)
Apply all mutations contained in this instance to the given
KVStore . |
void |
clear()
Clear all mutations.
|
Writes |
clone()
Clone this instance.
|
static Writes |
deserialize(InputStream input)
Deserialize a mutable instance created by
serialize() . |
static Writes |
deserialize(InputStream input,
boolean immutable)
Deserialize an instance created by
serialize() . |
static Mutations |
deserializeOnline(InputStream input)
|
Iterable<Map.Entry<byte[],Long>> |
getAdjustPairs()
Get the counter adjustments contained by this instance.
|
NavigableMap<byte[],Long> |
getAdjusts()
Get the set of counter adjustments contained by this instance.
|
Iterable<Map.Entry<byte[],byte[]>> |
getPutPairs()
Get the written key/value pairs contained by this instance.
|
NavigableMap<byte[],byte[]> |
getPuts()
Get the written key/value pairs contained by this instance.
|
NavigableSet<KeyRange> |
getRemoveRanges()
Get the key ranges removals contained by this instance.
|
KeyRanges |
getRemoves()
Get the key ranges removals contained by this instance.
|
Writes |
immutableSnapshot()
Return an immutable snapshot of this instance.
|
boolean |
isEmpty()
Determine whether this instance is empty, i.e., contains zero mutations.
|
void |
serialize(OutputStream out)
Serialize this instance.
|
long |
serializedLength()
Calculate the number of bytes required to serialize this instance via
serialize() . |
String |
toString() |
public KeyRanges getRemoves()
public NavigableMap<byte[],byte[]> getPuts()
The caller must not modify any of the returned byte[]
arrays.
public NavigableMap<byte[],Long> getAdjusts()
The caller must not modify any of the returned byte[]
arrays.
public boolean isEmpty()
public void clear()
public NavigableSet<KeyRange> getRemoveRanges()
Mutations
The caller must not invoke Iterator.remove()
.
getRemoveRanges
in interface Mutations
public Iterable<Map.Entry<byte[],byte[]>> getPutPairs()
Mutations
The caller must not modify any of the returned byte[]
arrays, nor invoke Iterator.remove()
.
getPutPairs
in interface Mutations
public Iterable<Map.Entry<byte[],Long>> getAdjustPairs()
Mutations
The caller must not modify any of the returned byte[]
arrays, nor invoke Iterator.remove()
.
getAdjustPairs
in interface Mutations
public void applyTo(KVStore target)
KVStore
.
Mutations are applied in this order: removes, puts, counter adjustments.
target
- target for recorded mutationsIllegalArgumentException
- if target
is null@Deprecated public static void apply(Mutations mutations, KVStore target)
KVStore.apply(io.permazen.kv.mvcc.Mutations)
insteadMutations
to the given KVStore
.
Mutations are applied in this order: removes, puts, counter adjustments.
mutations
- mutations to applytarget
- target for mutationsIllegalArgumentException
- if either parameter is nullUnsupportedOperationException
- if this instance is immutablepublic void serialize(OutputStream out) throws IOException
out
- outputIOException
- if an error occurspublic long serializedLength()
serialize()
.public static Writes deserialize(InputStream input) throws IOException
serialize()
.
Equivalent to deserialize
(input, false)
.
input
- input stream containing data from serialize()
IllegalArgumentException
- if input
is nullIllegalArgumentException
- if malformed input is detectedIOException
- if an I/O error occurspublic static Writes deserialize(InputStream input, boolean immutable) throws IOException
serialize()
.input
- input stream containing data from serialize()
immutable
- true for an immutable instance, otherwise falseIllegalArgumentException
- if input
is nullIllegalArgumentException
- if malformed input is detectedIOException
- if an I/O error occurspublic static Mutations deserializeOnline(InputStream input)
Mutations
view of a serialized Writes
instance.
This method returns a Mutations
instance that decodes the serialized Writes
from the given
input in an "online" fashion, i.e., it does not load the whole thing into memory. The returned Mutations
iterators 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 an IllegalStateException
.
If an IOException
is thrown by input
, the Iterator
being used will throw a RuntimeException
wrapping it; if invalid data is encountered, the Iterator
being used will throw an IllegalArgumentException
.
input
- input stream containing data from serialize()
Mutations
view of input
IllegalArgumentException
- if input
is nullpublic Writes clone()
This is a "mostly deep" clone: all of the mutations are copied, but the actual
byte[]
keys and values, which are already assumed non-mutable, are not copied.
The returned clone will always be mutable, even if this instance is not.
public Writes immutableSnapshot()
Copyright © 2022. All rights reserved.