K
- the map key typeV
- the map value typeR
- the return type of MapEntryOperations
specified fro the queried mappublic interface MapRemoteOperations<K,V,R>
ChronicleMap
.
Example: Grow-only set values CRDT:
class GrowOnlySetValuedMapEntryOperations<K, E>
implements MapEntryOperations<K, Set<E>, Void> {
@Override
public Void remove(@NotNull MapEntry<K, Set<E>> entry) {
throw new UnsupportedOperationException("Map with grow-only set values " +
"doesn't support map value removals");
}
}
class GrowOnlySetValuedMapRemoteOperations<K, E>
implements MapRemoteOperations<K, Set<E>, Void> {
@Override
public void put(MapRemoteQueryContext<K, Set<E>, Void> q,
Data<Set<E>, ?> newValue) {
MapReplicableEntry<K, Set<E>> entry = q.entry();
if (entry != null) {
Set<E> merged = new HashSet<>(entry.value().get());
merged.addAll(newValue.get());
q.replaceValue(entry, q.wrapValueAsData(merged));
} else {
q.insert(q.absentEntry(), newValue);
q.entry().updateOrigin(q.remoteIdentifier(), q.remoteTimestamp());
}
}
@Override
public void remove(MapRemoteQueryContext<K, Set<E>, Void> q) {
throw new UnsupportedOperationException();
}
}
Modifier and Type | Method and Description |
---|---|
default void |
put(MapRemoteQueryContext<K,V,R> q,
Data<V> newValue)
Handle remote
put call or replication event, i. |
default void |
remove(MapRemoteQueryContext<K,V,R> q)
Handle remote
remove call and remove replication event, i. |
default void remove(MapRemoteQueryContext<K,V,R> q)
remove
call and remove
replication event, i. e. when the entry
with the query key (q.queriedKey()
) was removed on some ChronicleMap
node.q
- the remote operation contextdefault void put(MapRemoteQueryContext<K,V,R> q, Data<V> newValue)
put
call or replication event, i. e. when the entry with the queried
key (q.queriedKey()
) was changed on some remote ChronicleMap
node, with the
given newValue
.q
- the remote operation contextnewValue
- the new value to putCopyright © 2015. All rights reserved.