Class RankIndexMaintainer
- 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.RankIndexMaintainer
-
@API(MAINTAINED) public class RankIndexMaintainer extends StandardIndexMaintainer
An index maintainer for keeping aRankedSet
of record field values. A rank index is used to implement these operations in queries:- rank: Given a record, where would its field value be in an ordered enumeration of all record's values.
- select: Given a range of ranks, return (the primary keys for) the records with values in that range.
Any number of fields in the index can optionally separate records into non-overlapping groups. Each group, determined by the values of those fields, has separate ranking.
Physical layout:
- primary subspace: an ordinary B-tree index by
[group, ..., score, ...]
. - secondary subspace: a ranked set per group, that is, with any group key as a prefix.
-
-
Field Summary
-
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 Constructor Description RankIndexMaintainer(IndexMaintainerState state)
-
Method Summary
All 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.boolean
canEvaluateRecordFunction(IndexRecordFunction<?> function)
Returntrue
if this index be used to evaluate the given record function.CompletableFuture<Void>
deleteWhere(Transaction tr, Tuple prefix)
Clear index storage associated with the given key prefix.CompletableFuture<Tuple>
evaluateAggregateFunction(IndexAggregateFunction function, TupleRange range, IsolationLevel isolationLevel)
Evaluate an aggregate function over the given range using this index.<T,M extends Message>
CompletableFuture<T>evaluateRecordFunction(EvaluationContext context, IndexRecordFunction<T> function, FDBRecord<M> record)
Evaluate a record function on the given record.boolean
isIdempotent()
Whether updating or removing a record on this index is idempotent.<M extends Message>
CompletableFuture<Long>rank(FDBRecord<M> record)
RecordCursor<IndexEntry>
scan(IndexScanType scanType, TupleRange rankRange, byte[] continuation, ScanProperties scanProperties)
Scan entries in the index.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, checkKeyValueSizes, checkUniqueness, commonKeys, decodeValue, evaluateIndex, filteredIndexEntries, getExecutor, getGroupedCount, getGroupingCount, getTimer, indexEntryKey, makeMutable, performOperation, removeUniquenessViolationsAsync, saveIndexEntryAsKeyValue, scan, scanUniquenessViolations, skipUpdateForUnchangedKeys, trimTooLargeTuple, unpackKeyValue, unpackKeyValue, update, updateIndexKeysFunction, updateOneKeyAsync, validateEntries, validateMissingEntries, validateOrphanEntries
-
Methods inherited from class com.apple.foundationdb.record.provider.foundationdb.IndexMaintainer
getIndexSubspace, getSecondarySubspace, unsupportedAggregateFunction, unsupportedRecordFunction
-
-
-
-
Constructor Detail
-
RankIndexMaintainer
public RankIndexMaintainer(IndexMaintainerState state)
-
-
Method Detail
-
scan
@Nonnull public RecordCursor<IndexEntry> scan(@Nonnull IndexScanType scanType, @Nonnull TupleRange rankRange, @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 performrankRange
- 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
-
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
-
canEvaluateRecordFunction
public boolean canEvaluateRecordFunction(@Nonnull IndexRecordFunction<?> function)
Description copied from class:IndexMaintainer
Returntrue
if this index be used to evaluate the given record function.- Overrides:
canEvaluateRecordFunction
in classStandardIndexMaintainer
- Parameters:
function
- requested function- Returns:
true
if this index can be used to evaluate the given function
-
evaluateRecordFunction
@Nonnull public <T,M extends Message> CompletableFuture<T> evaluateRecordFunction(@Nonnull EvaluationContext context, @Nonnull IndexRecordFunction<T> function, @Nonnull FDBRecord<M> record)
Description copied from class:IndexMaintainer
Evaluate a record function on the given record.- Overrides:
evaluateRecordFunction
in classStandardIndexMaintainer
- Type Parameters:
T
- the result type of the functionM
- the message type of the record- Parameters:
context
- context for evaluationfunction
- the record function to apply to the given recordrecord
- record against which to evaluate- Returns:
- a future that completes with the result of evaluation
-
rank
public <M extends Message> CompletableFuture<Long> rank(@Nonnull FDBRecord<M> record)
-
deleteWhere
public CompletableFuture<Void> deleteWhere(Transaction tr, @Nonnull Tuple prefix)
Description copied from class:IndexMaintainer
Clear index storage associated with the given key prefix.- Overrides:
deleteWhere
in classStandardIndexMaintainer
- Parameters:
tr
- transaction in which to access the databaseprefix
- prefix of primary key to clear- Returns:
- a future that is complete when the given prefix has been cleared from this index
-
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 isolationLevel)
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 aggregateisolationLevel
- the isolation level at which to perform the scan- Returns:
- a future that completes with the aggregate result
-
-