Class BitmapValueIndexMaintainer
- 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.BitmapValueIndexMaintainer
-
@API(EXPERIMENTAL) public class BitmapValueIndexMaintainer extends StandardIndexMaintainer
An index maintainer for storing bitmaps of which records meet a specific condition.The index is defined on a position field, grouped by zero or more value conditions. The position should be an integer that is unique and reasonably dense, since compression of the index is traded off in favor of simplicity and concurrent updates. If the position is not set, then the item is not indexed at all.
Instead of one key per record, the index stores one bit per record in a fixed-size bitmap aligned on even multiples of the position key.
The position bitmaps behave as aggregate functions additionally grouped by ranges of the position.
A
unique
option means that the index checks uniqueness of the position, with the expense of an additional read at update time. Also, when a uniqueness violation does occur, it is not possible to know what other record caused it. A separate unique index on the position field, if it is not the primary key, is therefore generally preferable.
-
-
Field Summary
Fields Modifier and Type Field Description static String
AGGREGATE_FUNCTION_NAME
static int
DEFAULT_ENTRY_SIZE
static int
MAX_ENTRY_SIZE
-
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 BitmapValueIndexMaintainer(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.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.RecordCursor<IndexEntry>
scan(IndexScanType scanType, TupleRange range, 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, canEvaluateRecordFunction, checkKeyValueSizes, checkUniqueness, commonKeys, deleteWhere, evaluateIndex, evaluateRecordFunction, filteredIndexEntries, getExecutor, getGroupedCount, getGroupingCount, getTimer, indexEntryKey, isIdempotent, 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
-
-
-
-
Field Detail
-
AGGREGATE_FUNCTION_NAME
public static final String AGGREGATE_FUNCTION_NAME
- See Also:
- Constant Field Values
-
DEFAULT_ENTRY_SIZE
public static final int DEFAULT_ENTRY_SIZE
- See Also:
- Constant Field Values
-
MAX_ENTRY_SIZE
public static final int MAX_ENTRY_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BitmapValueIndexMaintainer
public BitmapValueIndexMaintainer(IndexMaintainerState state)
-
-
Method Detail
-
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
@Nonnull 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
@Nonnull 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
-
-