pt.unl.fct.di.novasys.babel.crdts.delta.implementations

Class DeltaMVMap

  • All Implemented Interfaces:
    DeltaCRDT, GenericCRDT


    public class DeltaMVMap
    extends DeltaBasedCRDT
    A delta-based multi-value map. The map supports generic types implemented as SerializableTypes. Values on the map can be written concurrently and are stored as sets until a write replaces them. It provides methods to put, delete and get for elements. Additionally, it is possible to iterate over the different elements of the map.
    • Field Detail

      • serializer

        public static pt.unl.fct.di.novasys.network.ISerializer<DeltaMVMap> serializer
        A serializer that serializes the CRDT into (and from) a ByteBuf.
    • Constructor Detail

      • DeltaMVMap

        public DeltaMVMap(ReplicaID replicaID)
        Creates a delta multi-value map with a given replicaID.
        Parameters:
        replicaID - the replica identifier
      • DeltaMVMap

        public DeltaMVMap(VVState state)
        Creates a delta multi-value map with a given replica state.
        Parameters:
        state - replica current state
    • Method Detail

      • put

        public DeltaMVMap put(String key,
                              SerializableType value)
        Puts a value into the map, with a given key. The value is only updated if it doesn't exist, or if the timestamp associated with the previous value is older than the current one.
        Parameters:
        key - key of the value
        value - element to be inserted
        Returns:
        a delta representing the operation in question
      • get

        public Set<SerializableType> get(String key)
        Gets the set of elements associated with the given key.
        Parameters:
        key - key to be searched
        Returns:
        the set of elements associated with the key or null if it doesn't exist.
      • delete

        public DeltaMVMap delete(String key)
        Deletes the value associated with key. The value is deleted by associating a null value to the given key.
        Parameters:
        key - key to be deleted
        Returns:
        a delta representing the operation in question
      • copy

        public GenericCRDT copy()
        Description copied from interface: GenericCRDT
        Creates a copy of the CRDT. Modifications on the copy don't modify the original.
        Returns:
        a copy of the CRDT
      • serialize

        public void serialize(io.netty.buffer.ByteBuf in)
                       throws IOException
        Description copied from interface: GenericCRDT
        Serializes the CRDT into a ByteBuf
        Parameters:
        in - ByteBuf to serialize the CRDT to
        Throws:
        IOException - if an error occurs while serializing

Copyright © 2024. All rights reserved.