pt.unl.fct.di.novasys.babel.crdts.state.utils

Class VersionVector



  • public class VersionVector
    extends Object
    Represents a version vector. The version vector stores pairs (replicaID, counter)
    • Field Detail

      • serializer

        public static pt.unl.fct.di.novasys.network.ISerializer<VersionVector> serializer
        Static method to serialize (and deserialize) a version vector
    • Constructor Detail

      • VersionVector

        public VersionVector()
        Creates a new, and empty, version vector.
      • VersionVector

        public VersionVector(VersionVector vv)
        Creates a version vector based on another passed as argument.
        Parameters:
        vv - the version vector to initialize.
      • VersionVector

        public VersionVector(ConcurrentMap<ReplicaID,Integer> entries)
        Creates a version vector with a given set of entries
        Parameters:
        entries - entries of another version vector
    • Method Detail

      • getEntry

        public Integer getEntry(ReplicaID replicaID)
        Gets the entry (the counter) of a specific replica
        Parameters:
        replicaID - replica identifer
        Returns:
        returns the replica identifier or -1 if the replica entry doesn't exist
      • max

        public Integer max()
        Calculates the maximum entry (biggest counter) of the version vector.
        Returns:
        the maximum of all entries
      • contains

        public boolean contains(Timestamp ts)
        Checks if a timestamp is cointained (i.e., if the counter is more recent) in the version vector
        Parameters:
        ts - the timestamp
        Returns:
        true if it is, or false otherwise
      • updateTs

        public void updateTs(Timestamp ts)
        Updates the version vector with a given timestamp, if there is a valid entry for the replica in question.
        Parameters:
        ts - a timestamp
      • updateVV

        public void updateVV(VersionVector vv)
        Updates the version vector by performing the union if another version vector. The entries are updated if they counter value is more recent
        Parameters:
        vv - a version vector
      • isVVSmallerOrEquals

        public boolean isVVSmallerOrEquals(VersionVector vv)
        Checks if a version vector is smaller (all entries are smaller) or is equal(all entries are equal) to this version vector
        Parameters:
        vv - a version vector
        Returns:
        true if it is, or false otherwise
      • isVVSmaller

        public boolean isVVSmaller(VersionVector vv)
        Checks if a version vector is smaller (all entries are smaller) to this version vector
        Parameters:
        vv - a version vector
        Returns:
        true if it is, or false otherwise
      • isVVGreaterOrEquals

        public boolean isVVGreaterOrEquals(VersionVector vv)
        Checks if a version vector is greater (all entries are bigger) or is equal(all entries are equal) to this version vector
        Parameters:
        vv - a version vector
        Returns:
        true if it is, or false otherwise
      • isVVGreater

        public boolean isVVGreater(VersionVector vv)
        Checks if a version vector is greater (all entries are bigger)
        Parameters:
        vv - a version vector
        Returns:
        true if it is, or false otherwise
      • isVVConcurrent

        public boolean isVVConcurrent(VersionVector vv)
        Checks a version vector is concurrent (i.e., is not comparable due to concurrent updates)
        Parameters:
        vv - a version vector
        Returns:
        true if it is, or false otherwise
      • copy

        public VersionVector copy()
        Creates a copy of this version vector
        Returns:
        a copy of the version vector

Copyright © 2024. All rights reserved.