@API(value=MAINTAINED) public abstract class IndexMaintainer extends Object
IndexMaintainerState
.
A functional base class is provided by StandardIndexMaintainer
.
An IndexMaintainer
instance is associated with a particular record store and index meta-data.
Implementers should assume that the same maintainer might be used to perform multiple record updates,
even though this never happens today.IndexMaintainerFactory
Modifier and Type | Field and Description |
---|---|
protected IndexMaintainerState |
state |
Modifier | Constructor and Description |
---|---|
protected |
IndexMaintainer(IndexMaintainerState state) |
Modifier and Type | Method and Description |
---|---|
abstract CompletableFuture<Boolean> |
addedRangeWithKey(Tuple primaryKey)
Whether this key has been added to some range within the
RangeSet
associated with this index. |
abstract boolean |
canDeleteWhere(QueryToKeyMatcher matcher,
Key.Evaluated evaluated)
Get whether this index scan delete records matching a particular key query.
|
abstract boolean |
canEvaluateAggregateFunction(IndexAggregateFunction function)
Get whether this index can be used to evaluate the given aggregate function.
|
abstract boolean |
canEvaluateRecordFunction(IndexRecordFunction<?> function)
Return
true if this index be used to evaluate the given record function. |
abstract CompletableFuture<Void> |
deleteWhere(Transaction tr,
Tuple prefix)
Clear index storage associated with the given key prefix.
|
abstract CompletableFuture<Tuple> |
evaluateAggregateFunction(IndexAggregateFunction function,
TupleRange range,
IsolationLevel isolationLevel)
Evaluate an aggregate function over the given range using this index.
|
abstract <T,M extends Message> |
evaluateRecordFunction(EvaluationContext context,
IndexRecordFunction<T> function,
FDBRecord<M> record)
Evaluate a record function on the given record.
|
Subspace |
getIndexSubspace()
Returns the subspace in which the index data is stored.
|
Subspace |
getSecondarySubspace()
Returns the secondary subspace in which the index data is stored.
|
abstract boolean |
isIdempotent()
Whether updating or removing a record on this index is idempotent.
|
abstract CompletableFuture<IndexOperationResult> |
performOperation(IndexOperation operation)
Perform a type-specific operation on index.
|
abstract RecordCursor<IndexEntry> |
scan(IndexScanType scanType,
TupleRange range,
byte[] continuation,
ScanProperties scanProperties)
Scan entries in the index.
|
abstract RecordCursor<IndexEntry> |
scanUniquenessViolations(TupleRange range,
byte[] continuation,
ScanProperties scanProperties)
Scans through the list of uniqueness violations within the database.
|
protected CompletableFuture<Tuple> |
unsupportedAggregateFunction(IndexAggregateFunction function) |
protected <T> CompletableFuture<T> |
unsupportedRecordFunction(IndexRecordFunction<T> function) |
abstract <M extends Message> |
update(FDBIndexableRecord<M> oldRecord,
FDBIndexableRecord<M> newRecord)
Update associated index for a changed record.
|
abstract void |
updateUniquenessViolations(Tuple valueKey,
Tuple primaryKey,
Tuple existingKey,
boolean remove)
Remove or add a uniqueness violation within the database.
|
abstract RecordCursor<InvalidIndexEntry> |
validateEntries(byte[] continuation,
ScanProperties scanProperties)
Validates the integrity of the index entries.
|
protected final IndexMaintainerState state
protected IndexMaintainer(IndexMaintainerState state)
@Nonnull public Subspace getIndexSubspace()
@Nonnull public Subspace getSecondarySubspace()
@Nonnull public abstract RecordCursor<IndexEntry> scan(@Nonnull IndexScanType scanType, @Nonnull TupleRange range, @Nullable byte[] continuation, @Nonnull ScanProperties scanProperties)
scanType
- the type
of scan to performrange
- the range to scancontinuation
- any continuation from a previous scan invocationscanProperties
- skip, limit and other properties of the scan@Nonnull public abstract <M extends Message> CompletableFuture<Void> update(@Nullable FDBIndexableRecord<M> oldRecord, @Nullable FDBIndexableRecord<M> newRecord)
M
- type of messageoldRecord
- the previous stored record or null
if a new record is being creatednewRecord
- the new record or null
if an old record is being deleted@Nonnull public abstract void updateUniquenessViolations(@Nonnull Tuple valueKey, @Nonnull Tuple primaryKey, @Nullable Tuple existingKey, boolean remove)
valueKey
- the indexed key that is (apparently) not uniqueprimaryKey
- the primary key of one record that is causing a violationexistingKey
- the primary key of another record that is causing a violation (or null
if none specified)remove
- true
if removing the violation and false
if adding it@Nonnull public abstract RecordCursor<IndexEntry> scanUniquenessViolations(@Nonnull TupleRange range, @Nullable byte[] continuation, @Nonnull ScanProperties scanProperties)
IndexEntry
instances where the
getKey()
will return the primary key
of the record causing a problem and getValue()
will return the index value that is being duplicated.range
- range of tuples to readcontinuation
- any continuation from a previous invocationscanProperties
- row limit and other scan properties@API(value=EXPERIMENTAL) @Nonnull public abstract RecordCursor<InvalidIndexEntry> validateEntries(@Nullable byte[] continuation, @Nullable ScanProperties scanProperties)
IndexValidator
.continuation
- any continuation from a previous validation invocationscanProperties
- skip, limit and other properties of the validation (use default values if null
)public abstract boolean canEvaluateRecordFunction(@Nonnull IndexRecordFunction<?> function)
true
if this index be used to evaluate the given record function.function
- requested functiontrue
if this index can be used to evaluate the given function@Nonnull public abstract <T,M extends Message> CompletableFuture<T> evaluateRecordFunction(@Nonnull EvaluationContext context, @Nonnull IndexRecordFunction<T> function, @Nonnull FDBRecord<M> record)
T
- the result type of the functionM
- the message type of the recordcontext
- context for evaluationfunction
- the record function to apply to the given recordrecord
- record against which to evaluate@Nonnull protected <T> CompletableFuture<T> unsupportedRecordFunction(@Nonnull IndexRecordFunction<T> function)
public abstract boolean canEvaluateAggregateFunction(@Nonnull IndexAggregateFunction function)
function
- the requested aggregate functiontrue
if this index be used to evaluate the given aggregate function@Nonnull public abstract CompletableFuture<Tuple> evaluateAggregateFunction(@Nonnull IndexAggregateFunction function, @Nonnull TupleRange range, @Nonnull IsolationLevel isolationLevel)
function
- the aggregate function to evaluaterange
- the range over which to accumulate the aggregateisolationLevel
- the isolation level at which to perform the scan@Nonnull protected CompletableFuture<Tuple> unsupportedAggregateFunction(@Nonnull IndexAggregateFunction function)
public abstract boolean isIdempotent()
@Nonnull public abstract CompletableFuture<Boolean> addedRangeWithKey(@Nonnull Tuple primaryKey)
RangeSet
associated with this index. This is used within the context of seeing if one should update a non-idempotent
write-only index with a new key. If the key is in some range, then it means that one should update the index
as it is based off of stale data. If the key is not in some range, then it means that one should not update
the index, as the rebuild job will handle it later.primaryKey
- the record key of the record to checktrue
if some range contains the record and false
otherwisepublic abstract boolean canDeleteWhere(@Nonnull QueryToKeyMatcher matcher, @Nonnull Key.Evaluated evaluated)
matcher
- the key queryevaluated
- parameters to the key querytrue
if this index accommodate a whereRecordsWhere
public abstract CompletableFuture<Void> deleteWhere(@Nonnull Transaction tr, @Nonnull Tuple prefix)
tr
- transaction in which to access the databaseprefix
- prefix of primary key to clearpublic abstract CompletableFuture<IndexOperationResult> performOperation(@Nonnull IndexOperation operation)
operation
- the requested operation