Search in sources :

Example 1 with ReadTransactionContext

use of com.apple.foundationdb.ReadTransactionContext in project fdb-record-layer by FoundationDB.

the class IndexingByRecords method buildRange.

@Nonnull
private CompletableFuture<Void> buildRange(@Nonnull SubspaceProvider subspaceProvider, @Nullable Key.Evaluated start, @Nullable Key.Evaluated end) {
    return getRunner().runAsync(context -> context.getReadVersionAsync().thenCompose(vignore -> subspaceProvider.getSubspaceAsync(context).thenCompose(subspace -> {
        RangeSet rangeSet = new RangeSet(subspace.subspace(Tuple.from(FDBRecordStore.INDEX_RANGE_SPACE_KEY, common.getIndex().getSubspaceKey())));
        byte[] startBytes = packOrNull(convertOrNull(start));
        byte[] endBytes = packOrNull(convertOrNull(end));
        Queue<Range> rangeDeque = new ArrayDeque<>();
        ReadTransactionContext rtc = context.ensureActive();
        return rangeSet.missingRanges(rtc, startBytes, endBytes).thenAccept(rangeDeque::addAll).thenCompose(vignore2 -> buildRanges(subspaceProvider, subspace, rangeSet, rangeDeque));
    })));
}
Also used : Arrays(java.util.Arrays) LogMessageKeys(com.apple.foundationdb.record.logging.LogMessageKeys) LoggerFactory(org.slf4j.LoggerFactory) AsyncIterator(com.apple.foundationdb.async.AsyncIterator) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) CompletableFuture(java.util.concurrent.CompletableFuture) AsyncUtil(com.apple.foundationdb.async.AsyncUtil) RangeSet(com.apple.foundationdb.async.RangeSet) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) Subspace(com.apple.foundationdb.subspace.Subspace) ArrayList(java.util.ArrayList) Key(com.apple.foundationdb.record.metadata.Key) ExecuteProperties(com.apple.foundationdb.record.ExecuteProperties) Tuple(com.apple.foundationdb.tuple.Tuple) Range(com.apple.foundationdb.Range) RecordCursorResult(com.apple.foundationdb.record.RecordCursorResult) KeyValueLogMessage(com.apple.foundationdb.record.logging.KeyValueLogMessage) Lists(com.google.common.collect.Lists) Pair(org.apache.commons.lang3.tuple.Pair) EndpointType(com.apple.foundationdb.record.EndpointType) RecordCoreException(com.apple.foundationdb.record.RecordCoreException) ScanProperties(com.apple.foundationdb.record.ScanProperties) ReadTransactionContext(com.apple.foundationdb.ReadTransactionContext) IndexBuildProto(com.apple.foundationdb.record.IndexBuildProto) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) ByteArrayUtil2(com.apple.foundationdb.tuple.ByteArrayUtil2) IsolationLevel(com.apple.foundationdb.record.IsolationLevel) Logger(org.slf4j.Logger) TupleRange(com.apple.foundationdb.record.TupleRange) AtomicLong(java.util.concurrent.atomic.AtomicLong) List(java.util.List) RecordType(com.apple.foundationdb.record.metadata.RecordType) Index(com.apple.foundationdb.record.metadata.Index) Message(com.google.protobuf.Message) RecordCursor(com.apple.foundationdb.record.RecordCursor) API(com.apple.foundationdb.annotation.API) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Queue(java.util.Queue) ArrayDeque(java.util.ArrayDeque) Collections(java.util.Collections) ReadTransactionContext(com.apple.foundationdb.ReadTransactionContext) RangeSet(com.apple.foundationdb.async.RangeSet) Range(com.apple.foundationdb.Range) TupleRange(com.apple.foundationdb.record.TupleRange) ArrayDeque(java.util.ArrayDeque) Nonnull(javax.annotation.Nonnull)

Aggregations

Range (com.apple.foundationdb.Range)1 ReadTransactionContext (com.apple.foundationdb.ReadTransactionContext)1 API (com.apple.foundationdb.annotation.API)1 AsyncIterator (com.apple.foundationdb.async.AsyncIterator)1 AsyncUtil (com.apple.foundationdb.async.AsyncUtil)1 RangeSet (com.apple.foundationdb.async.RangeSet)1 EndpointType (com.apple.foundationdb.record.EndpointType)1 ExecuteProperties (com.apple.foundationdb.record.ExecuteProperties)1 IndexBuildProto (com.apple.foundationdb.record.IndexBuildProto)1 IsolationLevel (com.apple.foundationdb.record.IsolationLevel)1 RecordCoreException (com.apple.foundationdb.record.RecordCoreException)1 RecordCursor (com.apple.foundationdb.record.RecordCursor)1 RecordCursorResult (com.apple.foundationdb.record.RecordCursorResult)1 ScanProperties (com.apple.foundationdb.record.ScanProperties)1 TupleRange (com.apple.foundationdb.record.TupleRange)1 KeyValueLogMessage (com.apple.foundationdb.record.logging.KeyValueLogMessage)1 LogMessageKeys (com.apple.foundationdb.record.logging.LogMessageKeys)1 Index (com.apple.foundationdb.record.metadata.Index)1 Key (com.apple.foundationdb.record.metadata.Key)1 RecordType (com.apple.foundationdb.record.metadata.RecordType)1