Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
import com.apple.foundationdb.record.RecordCoreArgumentException;
import com.apple.foundationdb.record.logging.LogMessageKeys;
import com.apple.foundationdb.record.provider.foundationdb.FDBRecordContext;
import com.apple.foundationdb.tuple.ByteArrayUtil2;
import com.apple.foundationdb.tuple.Tuple;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.concurrent.CompletableFuture;

/**
Expand All @@ -37,24 +38,45 @@
public class DataInKeySpacePath {

@Nonnull
private final CompletableFuture<ResolvedKeySpacePath> resolvedPath;
private final KeySpacePath path;
@Nullable
private final Tuple remainder;
@Nonnull
private final byte[] value;

public DataInKeySpacePath(KeySpacePath path, KeyValue rawKeyValue, FDBRecordContext context) {
this.resolvedPath = path.toResolvedPathAsync(context, rawKeyValue.getKey());
this.value = rawKeyValue.getValue();
if (this.value == null) {
public DataInKeySpacePath(@Nonnull final KeySpacePath path, @Nullable final Tuple remainder,
@Nullable final byte[] value) {
this.path = path;
this.remainder = remainder;
if (value == null) {
throw new RecordCoreArgumentException("Value cannot be null")
.addLogInfo(LogMessageKeys.KEY, ByteArrayUtil2.loggable(rawKeyValue.getKey()));
.addLogInfo(LogMessageKeys.KEY, path);
}
}

public CompletableFuture<ResolvedKeySpacePath> getResolvedPath() {
return resolvedPath;
this.value = value;

Check warning on line 55 in fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/keyspace/DataInKeySpacePath.java

View check run for this annotation

fdb.teamscale.io / Teamscale | Findings

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/keyspace/DataInKeySpacePath.java#L55

Store a copy of `value` https://fdb.teamscale.io/findings/details/foundationdb-fdb-record-layer?t=FORK_MR%2F3716%2FScottDugas%2Fnon-resolved-data-in-keyspace%3AHEAD&id=070A7A05FB4C44121B9F0942728F357E
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of copying the byte[] here and in getValue, I created an issue to convert it to ByteString: #3717

}

public byte[] getValue() {
return this.value;

Check warning on line 59 in fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/keyspace/DataInKeySpacePath.java

View check run for this annotation

fdb.teamscale.io / Teamscale | Findings

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/keyspace/DataInKeySpacePath.java#L59

Return a copy of `value` https://fdb.teamscale.io/findings/details/foundationdb-fdb-record-layer?t=FORK_MR%2F3716%2FScottDugas%2Fnon-resolved-data-in-keyspace%3AHEAD&id=28DE7718F7668214DBBA0276EDF01F54
}

@Nonnull
public KeySpacePath getPath() {
return path;
}

@Nullable
public Tuple getRemainder() {
return remainder;
}

/**
* Converts this data item to a {@link ResolvedKeySpacePath} by resolving the path and applying the remainder.
* @param context the context to use for resolving the path
* @return a future that completes with the resolved path including the remainder
*/
@Nonnull
public CompletableFuture<ResolvedKeySpacePath> getResolvedPath(@Nonnull FDBRecordContext context) {
return path.toResolvedPathAsync(context)
.thenApply(resolvedPath -> remainder == null ? resolvedPath : resolvedPath.withRemainder(remainder));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,11 @@ public RecordCursor<DataInKeySpacePath> exportAllData(@Nonnull FDBRecordContext
.setScanProperties(scanProperties)
.build()),
context.getExecutor())
.map(keyValue -> new DataInKeySpacePath(this, keyValue, context));
.mapPipelined(keyValue ->
toResolvedPathAsync(context, keyValue.getKey())
.thenApply(resolvedKey ->
new DataInKeySpacePath(resolvedKey.toPath(), resolvedKey.getRemainder(), keyValue.getValue())),
1);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.apple.foundationdb.subspace.Subspace;
import com.apple.foundationdb.tuple.ByteArrayUtil2;
import com.apple.foundationdb.tuple.Tuple;
import com.google.common.annotations.VisibleForTesting;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -279,7 +278,6 @@ public static void appendValue(StringBuilder sb, Object value) {
* @return a new {@code ResolvedKeySpacePath} that is the same as this, except with a different {@link #getRemainder()}.
*/
@Nonnull
@VisibleForTesting
ResolvedKeySpacePath withRemainder(@Nullable final Tuple newRemainder) {
// this could probably copy the cachedTuple & cachedSubspace
return new ResolvedKeySpacePath(parent, inner, value, newRemainder);
Expand Down
Loading
Loading