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

Class DeltaRGA

  • All Implemented Interfaces:
    DeltaCRDT, GenericCRDT


    public class DeltaRGA
    extends DeltaBasedCRDT
    A delta-based Replicated Growable Array (RGA). Array nodes can be inserted (and removed) through given positions. The array supports generic types implemented as SerializableTypes.
    • Field Detail

      • serializer

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

      • DeltaRGA

        public DeltaRGA(ReplicaID replicaID)
        Creates a delta RGA with a given replicaID.
        Parameters:
        replicaID - the replica identifier
      • DeltaRGA

        public DeltaRGA(VVState state)
        Creates a delta RGA with a given replica state.
        Parameters:
        state - replica current state
      • DeltaRGA

        public DeltaRGA(ReplicaID replicaID,
                        List<SerializableType> initialValues)
        Creates a delta RGA with a given replicaID and a list of initial values.
        Parameters:
        replicaID - the replica identifier
        initialValues - the initial values of the CRDT
      • DeltaRGA

        public DeltaRGA(VVState state,
                        List<SerializableType> initialValues)
        Creates a delta RGA with a given replica state and a list of initial values.
        Parameters:
        state - replica current state
        initialValues - the initial values of the CRDT
    • Method Detail

      • insertAt

        public DeltaRGA insertAt(int index,
                                 SerializableType element)
        Insert an element into position index
        Parameters:
        index - position to insert the element
        element - element to be inserted
        Returns:
        a delta representing the operation
        Throws:
        IndexOutOfBoundsException - if the index is out of the array bounds
      • removeAt

        public DeltaRGA removeAt(int index)
        Removes an element at position index
        Parameters:
        index - position to insert the element
        Returns:
        a delta representing the operation
        Throws:
        IndexOutOfBoundsException - if the index is out of the array bounds
      • get

        public Iterator<SerializableType> get()
        An iterator with all the elements inside the array
        Returns:
        an iterator with all the elements inside the array
      • getAt

        public SerializableType getAt(int index)
        Obtains the element at position index
        Parameters:
        index - the index of the element
        Returns:
        the element or null if it doesn't exist
        Throws:
        IndexOutOfBoundsException - if the index is out of the array bounds
      • 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.