Class Key<Value>

  • Direct Known Subclasses:
    CounterKey, FlagKey, MapKey, MergeRegisterKey, MVRegisterKey, RegisterKey, SetKey

    public abstract class Key<Value>
    extends java.lang.Object
    An Antidote key consists of a CRDT type and a corresponding key. It can be used as a top-level-key of an Antidote object in a bucket or as a key in a map_rr.

    Use the static methods of this class to create keys for the respective CRDT types.

    • Method Detail

      • getKey

        public com.google.protobuf.ByteString getKey()
        Returns:
        the ByteString component of this key
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public final boolean equals​(java.lang.Object obj)
        Equality and hashCode on keys is defined only in terms of the key and type fields.
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public final int hashCode()
        Equality and hashCode on keys is defined only in terms of the key and type fields.
        Overrides:
        hashCode in class java.lang.Object
      • counter

        public static CounterKey counter​(com.google.protobuf.ByteString key)
        A counter CRDT.
      • counter

        public static CounterKey counter​(java.lang.String key)
        A counter CRDT.
      • fatCounter

        public static CounterKey fatCounter​(com.google.protobuf.ByteString key)
        A counter CRDT. Is like a counter, but can be reset and is less efficient.
      • fatCounter

        public static CounterKey fatCounter​(java.lang.String key)
        A counter CRDT. Is like a counter, but can be reset and is less efficient.
      • register

        public static <T> RegisterKey<T> register​(com.google.protobuf.ByteString key,
                                                  ValueCoder<T> format)
        A last-writer-wins register.
        Type Parameters:
        T - type of value stored in the register
        Parameters:
        key - the key
        format - format of values stored in the register
      • register

        public static <T> RegisterKey<T> register​(java.lang.String key,
                                                  ValueCoder<T> format)
        A last-writer-wins register.
        Type Parameters:
        T - type of value stored in the register
        Parameters:
        key - the key
        format - format of values stored in the register
      • multiValueRegister

        public static <T> MVRegisterKey<T> multiValueRegister​(com.google.protobuf.ByteString key,
                                                              ValueCoder<T> format)
        A multi-value register. Reading a value returns all written values, which are not overridden by another write-operation.
      • set

        public static <T> SetKey<T> set​(com.google.protobuf.ByteString key,
                                        ValueCoder<T> format)
        An add-wins set.
      • set_removeWins

        public static <T> SetKey<T> set_removeWins​(com.google.protobuf.ByteString key,
                                                   ValueCoder<T> format)
        A remove-wins set.
      • map_rr

        public static MapKey map_rr​(com.google.protobuf.ByteString key)
        Remove-resets map. Removing an entry resets the corresponding CRDT. Entries using a CRDT that does not support resets cannot be removed form the map. Therefore this map should mainly be used with embedded CRDTs that support a reset operation.

        Reading the map only returns entries which have a value, where the internal state is not equal to the initial CRDT state.

      • map_g

        public static MapKey map_g​(com.google.protobuf.ByteString key)
        Grow-only map. Does not support removing entries. It can be used for modelling struct, where the set of keys does not change over time.
      • flag_ew

        public static FlagKey flag_ew​(com.google.protobuf.ByteString key)
      • flag_ew

        public static FlagKey flag_ew​(java.lang.String key)
      • flag_dw

        public static FlagKey flag_dw​(com.google.protobuf.ByteString key)
      • flag_dw

        public static FlagKey flag_dw​(java.lang.String key)
      • create

        public static Key<?> create​(AntidotePB.CRDT_type type,
                                    com.google.protobuf.ByteString k)
        Creates a Key from a CRDT_type and a ByteString.
      • reset

        @CheckReturnValue
        public UpdateOp reset()
        Creates a reset operation. If the underlying CRDT type has full support for reset, this operation has the effect of undoing all previous operations and it has no effect on concurrent operations.

        Use the methods on Bucket to execute the update.