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);
}
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);
}
Aggregations