Interface AtomicMutation
-
- All Known Implementing Classes:
AtomicMutation.Standard
@API(MAINTAINED) public interface AtomicMutation
The particular operation to be performed by anAtomicMutationIndexMaintainer
index.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
AtomicMutation.Standard
The atomic mutations implemented straightforwardly by the FDB API.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
allowsNegative()
Determine whether this type allows negative values.BiFunction<Tuple,Tuple,Tuple>
getAggregator()
Get a function to aggregate multiple index entries.byte[]
getCompareAndClearParam()
Get a value that causes the index entry to be removed if the result of the mutation matches.Tuple
getIdentity()
Get the initial value for aggregating multiple index entries.byte[]
getMutationParam(IndexEntry value, boolean remove)
Get the underlying argument to the FDB API.MutationType
getMutationType()
Get the underlying mutation performed by the FDB API.boolean
hasLongValue()
Determine whether this type aggregates long (integer) values.boolean
hasSingleValue()
Determine whether this type aggregates exactly one value.boolean
hasValues()
Determine whether this type aggregates values (as opposed to something like counting records).boolean
isIdempotent()
Determine whether this type is idempotent.
-
-
-
Method Detail
-
getMutationType
@Nonnull MutationType getMutationType()
Get the underlying mutation performed by the FDB API.- Returns:
- the underlying mutation type
-
getMutationParam
@Nullable byte[] getMutationParam(IndexEntry value, boolean remove)
Get the underlying argument to the FDB API.- Parameters:
value
- theTuple
form of the value being stored into the indexremove
-true
if the entry is being removed from the index- Returns:
- a byte array to pass to the FDB API or
null
to do nothing for this mutation
-
getAggregator
@Nonnull BiFunction<Tuple,Tuple,Tuple> getAggregator()
Get a function to aggregate multiple index entries. For example, summing subtotals or maxing individual maxima.- Returns:
- a function that combines a running aggregate with a single entry to produce a new aggregate
- See Also:
RecordCursor.reduce(U, java.util.function.BiFunction<U, ? super T, U>)
-
getIdentity
@Nullable Tuple getIdentity()
Get the initial value for aggregating multiple index entries.- Returns:
- the initial value of a running aggregate for this type
- See Also:
RecordCursor.reduce(U, java.util.function.BiFunction<U, ? super T, U>)
-
hasValues
boolean hasValues()
Determine whether this type aggregates values (as opposed to something like counting records). The values are specified in the grouped part of theGroupingKeyExpression
.- Returns:
true
if values are allowed
-
hasSingleValue
boolean hasSingleValue()
Determine whether this type aggregates exactly one value.- Returns:
true
if only a single value is allowed
-
hasLongValue
boolean hasLongValue()
Determine whether this type aggregates long (integer) values.- Returns:
true
if only a long value is allowed
-
allowsNegative
boolean allowsNegative()
Determine whether this type allows negative values. If negative values are not allowed, an exception is thrown when a record is saved that contains a negative value in the indexed field.- Returns:
true
if negative values are allowed
-
isIdempotent
boolean isIdempotent()
Determine whether this type is idempotent. Max and min type operations are idempotent; sum and count type operations are not.- Returns:
true
if updating the index multiple times with the same value yields the same result
-
getCompareAndClearParam
@Nullable byte[] getCompareAndClearParam()
Get a value that causes the index entry to be removed if the result of the mutation matches.- Returns:
- a byte array to pass to
COMPARE_AND_CLEAR
ornull
to do nothing for this mutation
-
-