Class AtomicMutationIndexMaintainer
- java.lang.Object
-
- com.apple.foundationdb.record.provider.foundationdb.IndexMaintainer
-
- com.apple.foundationdb.record.provider.foundationdb.indexes.StandardIndexMaintainer
-
- com.apple.foundationdb.record.provider.foundationdb.indexes.AtomicMutationIndexMaintainer
-
@API(MAINTAINED) public class AtomicMutationIndexMaintainer extends StandardIndexMaintainer
An index that maintains an aggregate value in a low-contention way.Normally, when two transactions read, modify, and write the same location, they conflict. This makes a straightforward implementation of most aggregate indexes inefficient. Ones that use the atomic mutation feature of FDB avoid this problem.
-
-
Field Summary
Fields Modifier and Type Field Description protected AtomicMutation
mutation
-
Fields inherited from class com.apple.foundationdb.record.provider.foundationdb.indexes.StandardIndexMaintainer
TOO_LARGE_VALUE_MESSAGE_LIMIT
-
Fields inherited from class com.apple.foundationdb.record.provider.foundationdb.IndexMaintainer
state
-
-
Constructor Summary
Constructors Modifier Constructor Description AtomicMutationIndexMaintainer(IndexMaintainerState state)
protected
AtomicMutationIndexMaintainer(IndexMaintainerState state, AtomicMutation mutation)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canEvaluateAggregateFunction(IndexAggregateFunction function)
Get whether this index can be used to evaluate the given aggregate function.protected Tuple
decodeValue(byte[] value)
Decode value portion of key value pair.CompletableFuture<Tuple>
evaluateAggregateFunction(IndexAggregateFunction function, TupleRange range, IsolationLevel isolationveLevel)
Evaluate an aggregate function over the given range using this index.protected static AtomicMutation
getAtomicMutation(Index index)
protected static boolean
getClearWhenZero(Index index)
boolean
isIdempotent()
Whether updating or removing a record on this index is idempotent.protected boolean
matchesAggregateFunction(IndexAggregateFunction function)
RecordCursor<IndexEntry>
scan(IndexScanType scanType, TupleRange range, byte[] continuation, ScanProperties scanProperties)
Scan entries in the index.boolean
skipUpdateForUnchangedKeys()
protected <M extends Message>
CompletableFuture<Void>updateIndexKeys(FDBIndexableRecord<M> savedRecord, boolean remove, List<IndexEntry> indexEntries)
Update index according to record keys.-
Methods inherited from class com.apple.foundationdb.record.provider.foundationdb.indexes.StandardIndexMaintainer
addedRangeWithKey, addUniquenessViolation, canDeleteWhere, canDeleteWhere, canEvaluateRecordFunction, checkKeyValueSizes, checkUniqueness, commonKeys, deleteWhere, evaluateIndex, evaluateRecordFunction, filteredIndexEntries, getExecutor, getGroupedCount, getGroupingCount, getTimer, indexEntryKey, makeMutable, performOperation, removeUniquenessViolationsAsync, saveIndexEntryAsKeyValue, scan, scanUniquenessViolations, trimTooLargeTuple, unpackKeyValue, unpackKeyValue, update, updateIndexKeysFunction, updateOneKeyAsync, validateEntries, validateMissingEntries, validateOrphanEntries
-
Methods inherited from class com.apple.foundationdb.record.provider.foundationdb.IndexMaintainer
getIndexSubspace, getSecondarySubspace, unsupportedAggregateFunction, unsupportedRecordFunction
-
-
-
-
Field Detail
-
mutation
protected final AtomicMutation mutation
-
-
Constructor Detail
-
AtomicMutationIndexMaintainer
public AtomicMutationIndexMaintainer(IndexMaintainerState state)
-
AtomicMutationIndexMaintainer
protected AtomicMutationIndexMaintainer(IndexMaintainerState state, AtomicMutation mutation)
-
-
Method Detail
-
getAtomicMutation
protected static AtomicMutation getAtomicMutation(@Nonnull Index index)
-
scan
@Nonnull public RecordCursor<IndexEntry> scan(@Nonnull IndexScanType scanType, @Nonnull TupleRange range, @Nullable byte[] continuation, @Nonnull ScanProperties scanProperties)
Description copied from class:IndexMaintainer
Scan entries in the index.- Specified by:
scan
in classIndexMaintainer
- Parameters:
scanType
- thetype
of scan to performrange
- the range to scancontinuation
- any continuation from a previous scan invocationscanProperties
- skip, limit and other properties of the scan- Returns:
- a cursor over index entries in the given range
-
updateIndexKeys
protected <M extends Message> CompletableFuture<Void> updateIndexKeys(@Nonnull FDBIndexableRecord<M> savedRecord, boolean remove, @Nonnull List<IndexEntry> indexEntries)
Description copied from class:StandardIndexMaintainer
Update index according to record keys. Often this operation returns an already completed future because there is no asynchronous work to be done.- Overrides:
updateIndexKeys
in classStandardIndexMaintainer
- Type Parameters:
M
- the message type of the record- Parameters:
savedRecord
- the record being indexedremove
-true
if removing from indexindexEntries
- the result ofStandardIndexMaintainer.evaluateIndex(FDBRecord)
- Returns:
- a future completed when update is done
-
decodeValue
protected Tuple decodeValue(@Nonnull byte[] value)
Description copied from class:StandardIndexMaintainer
Decode value portion of key value pair.- Overrides:
decodeValue
in classStandardIndexMaintainer
- Parameters:
value
- the raw value portion of a key value pair- Returns:
- a decoded tuple of any values stored in the value side of the index, which is usually empty
-
canEvaluateAggregateFunction
public boolean canEvaluateAggregateFunction(@Nonnull IndexAggregateFunction function)
Description copied from class:IndexMaintainer
Get whether this index can be used to evaluate the given aggregate function.- Overrides:
canEvaluateAggregateFunction
in classStandardIndexMaintainer
- Parameters:
function
- the requested aggregate function- Returns:
true
if this index be used to evaluate the given aggregate function
-
evaluateAggregateFunction
@Nonnull public CompletableFuture<Tuple> evaluateAggregateFunction(@Nonnull IndexAggregateFunction function, @Nonnull TupleRange range, @Nonnull IsolationLevel isolationveLevel)
Description copied from class:IndexMaintainer
Evaluate an aggregate function over the given range using this index.- Overrides:
evaluateAggregateFunction
in classStandardIndexMaintainer
- Parameters:
function
- the aggregate function to evaluaterange
- the range over which to accumulate the aggregateisolationveLevel
- the isolation level at which to perform the scan- Returns:
- a future that completes with the aggregate result
-
matchesAggregateFunction
protected boolean matchesAggregateFunction(@Nonnull IndexAggregateFunction function)
-
isIdempotent
public boolean isIdempotent()
Description copied from class:IndexMaintainer
Whether updating or removing a record on this index is idempotent. In principle, all index updates in the normal case are idempotent as long as the index update and the record insertion or deletion is atomic. However, certain indexes (mostly aggregate indexes) have the property that the index update on its own are not idempotent.- Overrides:
isIdempotent
in classStandardIndexMaintainer
- Returns:
- whether updating this index is idempotent
-
skipUpdateForUnchangedKeys
public boolean skipUpdateForUnchangedKeys()
- Overrides:
skipUpdateForUnchangedKeys
in classStandardIndexMaintainer
-
-