Package eu.antidotedb.client
Class Key<Value>
- java.lang.Object
-
- eu.antidotedb.client.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 Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CounterKey
counter(com.google.protobuf.ByteString key)
A counter CRDT.static CounterKey
counter(java.lang.String key)
A counter CRDT.static Key<?>
create(AntidotePB.CRDT_type type, com.google.protobuf.ByteString k)
Creates a Key from a CRDT_type and a ByteString.boolean
equals(java.lang.Object obj)
Equality and hashCode on keys is defined only in terms of the key and type fields.static CounterKey
fatCounter(com.google.protobuf.ByteString key)
A counter CRDT.static CounterKey
fatCounter(java.lang.String key)
A counter CRDT.static FlagKey
flag_dw(com.google.protobuf.ByteString key)
static FlagKey
flag_dw(java.lang.String key)
static FlagKey
flag_ew(com.google.protobuf.ByteString key)
static FlagKey
flag_ew(java.lang.String key)
com.google.protobuf.ByteString
getKey()
AntidotePB.CRDT_type
getType()
int
hashCode()
Equality and hashCode on keys is defined only in terms of the key and type fields.static MapKey
map_g(com.google.protobuf.ByteString key)
Grow-only map.static MapKey
map_g(java.lang.String key)
static MapKey
map_rr(com.google.protobuf.ByteString key)
Remove-resets map.static MapKey
map_rr(java.lang.String key)
static <V> MergeRegisterKey<V>
mergeRegister(com.google.protobuf.ByteString key, ValueCoder<V> format, MergeRegisterKey.ValueMerger<V> merger)
static <V> MergeRegisterKey<V>
mergeRegister(java.lang.String key, ValueCoder<V> format, MergeRegisterKey.ValueMerger<V> merger)
static MVRegisterKey<java.lang.String>
multiValueRegister(com.google.protobuf.ByteString key)
static <T> MVRegisterKey<T>
multiValueRegister(com.google.protobuf.ByteString key, ValueCoder<T> format)
A multi-value register.static MVRegisterKey<java.lang.String>
multiValueRegister(java.lang.String key)
static <T> MVRegisterKey<T>
multiValueRegister(java.lang.String key, ValueCoder<T> format)
static RegisterKey<java.lang.String>
register(com.google.protobuf.ByteString key)
static <T> RegisterKey<T>
register(com.google.protobuf.ByteString key, ValueCoder<T> format)
A last-writer-wins register.static RegisterKey<java.lang.String>
register(java.lang.String key)
static <T> RegisterKey<T>
register(java.lang.String key, ValueCoder<T> format)
A last-writer-wins register.UpdateOp
reset()
Creates a reset operation.static SetKey<java.lang.String>
set(com.google.protobuf.ByteString key)
static <T> SetKey<T>
set(com.google.protobuf.ByteString key, ValueCoder<T> format)
An add-wins set.static SetKey<java.lang.String>
set(java.lang.String key)
static <T> SetKey<T>
set(java.lang.String key, ValueCoder<T> format)
static SetKey<java.lang.String>
set_removeWins(com.google.protobuf.ByteString key)
static <T> SetKey<T>
set_removeWins(com.google.protobuf.ByteString key, ValueCoder<T> format)
A remove-wins set.static SetKey<java.lang.String>
set_removeWins(java.lang.String key)
static <T> SetKey<T>
set_removeWins(java.lang.String key, ValueCoder<T> format)
java.lang.String
toString()
-
-
-
Method Detail
-
getType
public AntidotePB.CRDT_type getType()
- Returns:
- the CRDT type for this key
-
getKey
public com.google.protobuf.ByteString getKey()
- Returns:
- the ByteString component of this key
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.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 classjava.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 classjava.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 keyformat
- format of values stored in the register
-
register
public static RegisterKey<java.lang.String> register(com.google.protobuf.ByteString key)
- See Also:
register(ByteString, ValueCoder)
-
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 keyformat
- format of values stored in the register
-
register
public static RegisterKey<java.lang.String> register(java.lang.String key)
- See Also:
register(ByteString, ValueCoder)
-
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.
-
multiValueRegister
public static MVRegisterKey<java.lang.String> multiValueRegister(com.google.protobuf.ByteString key)
-
multiValueRegister
public static <T> MVRegisterKey<T> multiValueRegister(java.lang.String key, ValueCoder<T> format)
-
multiValueRegister
public static MVRegisterKey<java.lang.String> multiValueRegister(java.lang.String key)
-
set
public static <T> SetKey<T> set(com.google.protobuf.ByteString key, ValueCoder<T> format)
An add-wins set.
-
set
public static SetKey<java.lang.String> set(com.google.protobuf.ByteString key)
- See Also:
set(ByteString, ValueCoder)
-
set
public static <T> SetKey<T> set(java.lang.String key, ValueCoder<T> format)
- See Also:
set(ByteString, ValueCoder)
-
set
public static SetKey<java.lang.String> set(java.lang.String key)
- See Also:
set(ByteString, ValueCoder)
-
set_removeWins
public static <T> SetKey<T> set_removeWins(com.google.protobuf.ByteString key, ValueCoder<T> format)
A remove-wins set.
-
set_removeWins
public static SetKey<java.lang.String> set_removeWins(com.google.protobuf.ByteString key)
- See Also:
set_removeWins(ByteString, ValueCoder)
-
set_removeWins
public static <T> SetKey<T> set_removeWins(java.lang.String key, ValueCoder<T> format)
- See Also:
set_removeWins(ByteString, ValueCoder)
-
set_removeWins
public static SetKey<java.lang.String> set_removeWins(java.lang.String key)
- See Also:
set_removeWins(ByteString, ValueCoder)
-
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_rr
public static MapKey map_rr(java.lang.String key)
- See Also:
map_rr(ByteString)
-
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.
-
map_g
public static MapKey map_g(java.lang.String key)
- See Also:
map_g(ByteString)
-
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)
-
mergeRegister
public static <V> MergeRegisterKey<V> mergeRegister(com.google.protobuf.ByteString key, ValueCoder<V> format, MergeRegisterKey.ValueMerger<V> merger)
-
mergeRegister
public static <V> MergeRegisterKey<V> mergeRegister(java.lang.String key, ValueCoder<V> format, MergeRegisterKey.ValueMerger<V> merger)
-
create
public static Key<?> create(AntidotePB.CRDT_type type, com.google.protobuf.ByteString k)
Creates a Key from a CRDT_type and a ByteString.
-
-