Search in sources :

Example 6 with ReadTransaction

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

the class FDBRecordStore method loadRawRecordAsync.

/**
 * Asynchronously read a record from the database.
 * @param primaryKey the key for the record to be loaded
 * @param sizeInfo a size info to fill in from serializer
 * @param snapshot whether to snapshot read
 * @return a CompletableFuture that will return a message or null if there was no record with that key
 */
@Nonnull
private CompletableFuture<FDBRawRecord> loadRawRecordAsync(@Nonnull final Tuple primaryKey, @Nullable final SplitHelper.SizeInfo sizeInfo, final boolean snapshot) {
    final FDBPreloadRecordCache.Entry entry = preloadCache.get(primaryKey);
    if (entry != null) {
        return CompletableFuture.completedFuture(entry.orElse(null));
    }
    final RecordMetaData metaData = metaDataProvider.getRecordMetaData();
    final ReadTransaction tr = snapshot ? ensureContextActive().snapshot() : ensureContextActive();
    return SplitHelper.loadWithSplit(tr, context, recordsSubspace(), primaryKey, metaData.isSplitLongRecords(), omitUnsplitRecordSuffix, sizeInfo);
}
Also used : RecordMetaData(com.apple.foundationdb.record.RecordMetaData) ReadTransaction(com.apple.foundationdb.ReadTransaction) Nonnull(javax.annotation.Nonnull)

Example 7 with ReadTransaction

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

the class FDBRecordStore method recordExistsAsync.

@Override
@Nonnull
public CompletableFuture<Boolean> recordExistsAsync(@Nonnull final Tuple primaryKey, @Nonnull final IsolationLevel isolationLevel) {
    final RecordMetaData metaData = metaDataProvider.getRecordMetaData();
    final ReadTransaction tr = isolationLevel.isSnapshot() ? ensureContextActive().snapshot() : ensureContextActive();
    return SplitHelper.keyExists(tr, context, recordsSubspace(), primaryKey, metaData.isSplitLongRecords(), omitUnsplitRecordSuffix);
}
Also used : RecordMetaData(com.apple.foundationdb.record.RecordMetaData) ReadTransaction(com.apple.foundationdb.ReadTransaction) Nonnull(javax.annotation.Nonnull)

Aggregations

ReadTransaction (com.apple.foundationdb.ReadTransaction)7 Nonnull (javax.annotation.Nonnull)5 KeyValue (com.apple.foundationdb.KeyValue)4 RecordMetaData (com.apple.foundationdb.record.RecordMetaData)4 Transaction (com.apple.foundationdb.Transaction)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 MutationType (com.apple.foundationdb.MutationType)2 Range (com.apple.foundationdb.Range)2 API (com.apple.foundationdb.annotation.API)2 SpotBugsSuppressWarnings (com.apple.foundationdb.annotation.SpotBugsSuppressWarnings)2 AsyncIterable (com.apple.foundationdb.async.AsyncIterable)2 AsyncIterator (com.apple.foundationdb.async.AsyncIterator)2 AsyncUtil (com.apple.foundationdb.async.AsyncUtil)2 CloseableAsyncIterator (com.apple.foundationdb.async.CloseableAsyncIterator)2 MoreAsyncUtil (com.apple.foundationdb.async.MoreAsyncUtil)2 RangeSet (com.apple.foundationdb.async.RangeSet)2 AggregateFunctionNotSupportedException (com.apple.foundationdb.record.AggregateFunctionNotSupportedException)2 ByteScanLimiter (com.apple.foundationdb.record.ByteScanLimiter)2 CursorStreamingMode (com.apple.foundationdb.record.CursorStreamingMode)2 EndpointType (com.apple.foundationdb.record.EndpointType)2