Skip to content

Commit b5052b8

Browse files
justinhorvitzcopybara-github
authored andcommitted
Remove remaining calls to getOrderedValuesAndExceptions and tests.
After this, all that remains is unused implementations. PiperOrigin-RevId: 485928424 Change-Id: Idfa158fc1dfed3d13f1b23b55d23867b5db5b956
1 parent c20b1d6 commit b5052b8

25 files changed

+168
-262
lines changed

src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetAndData.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import com.google.devtools.build.lib.packages.Target;
2525
import com.google.devtools.build.skyframe.SkyFunction;
2626
import com.google.devtools.build.skyframe.SkyKey;
27-
import com.google.devtools.build.skyframe.SkyframeIterableResult;
27+
import com.google.devtools.build.skyframe.SkyframeLookupResult;
2828
import javax.annotation.Nullable;
2929

3030
/**
@@ -104,15 +104,16 @@ static ConfiguredTargetAndData fromConfiguredTargetInSkyframe(
104104
} else {
105105
packageAndMaybeConfiguration = ImmutableSet.of(packageKey, configurationKeyMaybe);
106106
}
107-
SkyframeIterableResult packageAndMaybeConfigurationValues =
108-
env.getOrderedValuesAndExceptions(packageAndMaybeConfiguration);
107+
SkyframeLookupResult packageAndMaybeConfigurationValues =
108+
env.getValuesAndExceptions(packageAndMaybeConfiguration);
109109
// Don't test env.valuesMissing(), because values may already be missing from the caller.
110-
PackageValue packageValue = (PackageValue) packageAndMaybeConfigurationValues.next();
110+
PackageValue packageValue = (PackageValue) packageAndMaybeConfigurationValues.get(packageKey);
111111
if (packageValue == null) {
112112
return null;
113113
}
114114
if (configurationKeyMaybe != null) {
115-
configuration = (BuildConfigurationValue) packageAndMaybeConfigurationValues.next();
115+
configuration =
116+
(BuildConfigurationValue) packageAndMaybeConfigurationValues.get(configurationKeyMaybe);
116117
if (configuration == null) {
117118
return null;
118119
}

src/main/java/com/google/devtools/build/lib/skyframe/ConstraintValueLookupUtil.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.google.devtools.build.lib.server.FailureDetails.Toolchain.Code;
2525
import com.google.devtools.build.skyframe.SkyFunction.Environment;
2626
import com.google.devtools.build.skyframe.SkyframeIterableResult;
27+
import com.google.devtools.build.skyframe.SkyframeLookupResult;
2728
import java.util.ArrayList;
2829
import java.util.List;
2930
import javax.annotation.Nullable;
@@ -36,7 +37,7 @@ public static List<ConstraintValueInfo> getConstraintValueInfo(
3637
Iterable<ConfiguredTargetKey> constraintValueKeys, Environment env)
3738
throws InterruptedException, InvalidConstraintValueException {
3839

39-
SkyframeIterableResult values = env.getOrderedValuesAndExceptions(constraintValueKeys);
40+
SkyframeLookupResult values = env.getValuesAndExceptions(constraintValueKeys);
4041
boolean valuesMissing = env.valuesMissing();
4142
List<ConstraintValueInfo> constraintValues = valuesMissing ? null : new ArrayList<>();
4243
for (ConfiguredTargetKey key : constraintValueKeys) {
@@ -59,13 +60,12 @@ public static List<ConstraintValueInfo> getConstraintValueInfo(
5960
*/
6061
@Nullable
6162
private static ConstraintValueInfo findConstraintValueInfo(
62-
ConfiguredTargetKey key, SkyframeIterableResult values)
63-
throws InvalidConstraintValueException {
64-
63+
ConfiguredTargetKey key, SkyframeLookupResult values) throws InvalidConstraintValueException {
6564
try {
6665
ConfiguredTargetValue ctv =
6766
(ConfiguredTargetValue)
68-
values.nextOrThrow(
67+
values.getOrThrow(
68+
key,
6969
ConfiguredValueCreationException.class,
7070
NoSuchThingException.class,
7171
ActionConflictException.class);

src/main/java/com/google/devtools/build/lib/skyframe/EnvironmentBackedRecursivePackageProvider.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import com.google.devtools.build.lib.vfs.RootedPath;
3737
import com.google.devtools.build.skyframe.SkyFunction.Environment;
3838
import com.google.devtools.build.skyframe.SkyKey;
39-
import com.google.devtools.build.skyframe.SkyframeIterableResult;
39+
import com.google.devtools.build.skyframe.SkyframeLookupResult;
4040
import java.util.ArrayList;
4141
import java.util.List;
4242
import java.util.Map;
@@ -199,23 +199,23 @@ public void streamPackagesUnderDirectory(
199199
ImmutableSet.copyOf(
200200
Iterables.filter(ignoredSubdirectories, path -> path.startsWith(directory)));
201201

202-
SkyframeIterableResult recursivePackageValues =
203-
env.getOrderedValuesAndExceptions(
204-
Iterables.transform(
205-
roots,
206-
r ->
207-
RecursivePkgValue.key(
208-
repository,
209-
RootedPath.toRootedPath(r, directory),
210-
filteredIgnoredSubdirectories)));
202+
Iterable<RecursivePkgValue.Key> recursivePackageKeys =
203+
Iterables.transform(
204+
roots,
205+
r ->
206+
RecursivePkgValue.key(
207+
repository,
208+
RootedPath.toRootedPath(r, directory),
209+
filteredIgnoredSubdirectories));
210+
SkyframeLookupResult recursivePackageValues = env.getValuesAndExceptions(recursivePackageKeys);
211211
NoSuchPackageException firstNspe = null;
212-
while (recursivePackageValues.hasNext()) {
212+
for (RecursivePkgValue.Key key : recursivePackageKeys) {
213213
RecursivePkgValue lookup;
214214
try {
215215
lookup =
216216
(RecursivePkgValue)
217-
recursivePackageValues.nextOrThrow(
218-
NoSuchPackageException.class, ProcessPackageDirectoryException.class);
217+
recursivePackageValues.getOrThrow(
218+
key, NoSuchPackageException.class, ProcessPackageDirectoryException.class);
219219
} catch (NoSuchPackageException e) {
220220
// NoSuchPackageException can happen during error bubbling in a no-keep-going build.
221221
if (firstNspe == null) {

src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
import com.google.devtools.build.skyframe.SkyFunctionException.Transience;
7878
import com.google.devtools.build.skyframe.SkyKey;
7979
import com.google.devtools.build.skyframe.SkyValue;
80-
import com.google.devtools.build.skyframe.SkyframeIterableResult;
8180
import com.google.devtools.build.skyframe.SkyframeLookupResult;
8281
import com.google.errorprone.annotations.CanIgnoreReturnValue;
8382
import java.io.IOException;
@@ -286,10 +285,10 @@ private static void handleGlobDepsAndPropagateFilesystemExceptions(
286285
throws InternalInconsistentFilesystemException, FileSymlinkException, InterruptedException {
287286
checkState(Iterables.all(depKeys, SkyFunctions.isSkyFunction(SkyFunctions.GLOB)), depKeys);
288287
FileSymlinkException arbitraryFse = null;
289-
SkyframeIterableResult skyframeIterableResult = env.getOrderedValuesAndExceptions(depKeys);
290-
while (skyframeIterableResult.hasNext()) {
288+
SkyframeLookupResult result = env.getValuesAndExceptions(depKeys);
289+
for (SkyKey key : depKeys) {
291290
try {
292-
skyframeIterableResult.nextOrThrow(IOException.class, BuildFileNotFoundException.class);
291+
result.getOrThrow(key, IOException.class, BuildFileNotFoundException.class);
293292
} catch (InconsistentFilesystemException e) {
294293
throw new InternalInconsistentFilesystemException(packageIdentifier, e);
295294
} catch (FileSymlinkException e) {
@@ -725,11 +724,12 @@ private static List<BzlLoadValue> computeBzlLoadsNoInlining(
725724
Environment env, List<BzlLoadValue.Key> keys)
726725
throws InterruptedException, BzlLoadFailedException {
727726
List<BzlLoadValue> bzlLoads = Lists.newArrayListWithExpectedSize(keys.size());
728-
SkyframeIterableResult starlarkLookupResults = env.getOrderedValuesAndExceptions(keys);
729-
for (int i = 0; i < keys.size(); i++) {
727+
SkyframeLookupResult starlarkLookupResults = env.getValuesAndExceptions(keys);
728+
for (BzlLoadValue.Key key : keys) {
730729
// TODO(adonovan): if get fails, report the source location
731730
// in the corresponding programLoads[i] (see caller).
732-
bzlLoads.add((BzlLoadValue) starlarkLookupResults.nextOrThrow(BzlLoadFailedException.class));
731+
bzlLoads.add(
732+
(BzlLoadValue) starlarkLookupResults.getOrThrow(key, BzlLoadFailedException.class));
733733
}
734734
return env.valuesMissing() ? null : bzlLoads;
735735
}

src/main/java/com/google/devtools/build/lib/skyframe/PlatformLookupUtil.java

+10-12
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.google.devtools.build.lib.server.FailureDetails.Toolchain.Code;
3636
import com.google.devtools.build.skyframe.SkyFunction.Environment;
3737
import com.google.devtools.build.skyframe.SkyframeIterableResult;
38+
import com.google.devtools.build.skyframe.SkyframeLookupResult;
3839
import java.util.HashMap;
3940
import java.util.Map;
4041
import javax.annotation.Nullable;
@@ -51,7 +52,7 @@ public static Map<ConfiguredTargetKey, PlatformInfo> getPlatformInfo(
5152
return null;
5253
}
5354

54-
SkyframeIterableResult values = env.getOrderedValuesAndExceptions(platformKeys);
55+
SkyframeLookupResult values = env.getValuesAndExceptions(platformKeys);
5556
boolean valuesMissing = env.valuesMissing();
5657
Map<ConfiguredTargetKey, PlatformInfo> platforms = valuesMissing ? null : new HashMap<>();
5758
for (ConfiguredTargetKey key : platformKeys) {
@@ -80,12 +81,13 @@ private static void validatePlatformKeys(
8081
.map(PackageValue::key)
8182
.collect(toImmutableSet());
8283

83-
SkyframeIterableResult values = env.getOrderedValuesAndExceptions(packageKeys);
84+
SkyframeLookupResult values = env.getValuesAndExceptions(packageKeys);
8485
boolean valuesMissing = env.valuesMissing();
8586
Map<PackageIdentifier, Package> packages = valuesMissing ? null : new HashMap<>();
86-
while (values.hasNext()) {
87+
for (PackageValue.Key packageKey : packageKeys) {
8788
try {
88-
PackageValue packageValue = (PackageValue) values.nextOrThrow(NoSuchPackageException.class);
89+
PackageValue packageValue =
90+
(PackageValue) values.getOrThrow(packageKey, NoSuchPackageException.class);
8991
if (!valuesMissing && packageValue != null) {
9092
packages.put(packageValue.getPackage().getPackageIdentifier(), packageValue.getPackage());
9193
}
@@ -125,13 +127,13 @@ private static void validatePlatformKeys(
125127
* InvalidPlatformException} is thrown.
126128
*/
127129
@Nullable
128-
private static PlatformInfo findPlatformInfo(
129-
ConfiguredTargetKey key, SkyframeIterableResult values) throws InvalidPlatformException {
130-
130+
private static PlatformInfo findPlatformInfo(ConfiguredTargetKey key, SkyframeLookupResult values)
131+
throws InvalidPlatformException {
131132
try {
132133
ConfiguredTargetValue ctv =
133134
(ConfiguredTargetValue)
134-
values.nextOrThrow(
135+
values.getOrThrow(
136+
key,
135137
ConfiguredValueCreationException.class,
136138
NoSuchThingException.class,
137139
ActionConflictException.class);
@@ -191,10 +193,6 @@ public InvalidPlatformException(Label label, ActionConflictException e) {
191193
super(formatError(label, DEFAULT_ERROR), e);
192194
}
193195

194-
InvalidPlatformException(Label label, String error) {
195-
super(formatError(label, error));
196-
}
197-
198196
@Override
199197
protected Code getDetailedCode() {
200198
return Code.INVALID_PLATFORM_VALUE;

src/main/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunction.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import com.google.devtools.build.skyframe.SkyFunction;
3535
import com.google.devtools.build.skyframe.SkyKey;
3636
import com.google.devtools.build.skyframe.SkyValue;
37-
import com.google.devtools.build.skyframe.SkyframeIterableResult;
37+
import com.google.devtools.build.skyframe.SkyframeLookupResult;
3838
import javax.annotation.Nullable;
3939

4040
/**
@@ -103,15 +103,16 @@ public SkyValue compute(SkyKey skyKey, Environment env) throws InterruptedExcept
103103
RepositoryMapping mainRepoMapping = repositoryMappingValue.getRepositoryMapping();
104104
ImmutableList<SkyKey> skyKeys = getSkyKeys(skyKey, eventHandler, mainRepoMapping);
105105

106-
SkyframeIterableResult tokensByKey = env.getOrderedValuesAndExceptions(skyKeys);
106+
SkyframeLookupResult tokensByKey = env.getValuesAndExceptions(skyKeys);
107107
if (env.valuesMissing()) {
108108
return null;
109109
}
110110

111111
for (SkyKey key : skyKeys) {
112112
try {
113113
SkyValue value =
114-
tokensByKey.nextOrThrow(
114+
tokensByKey.getOrThrow(
115+
key,
115116
TargetParsingException.class,
116117
ProcessPackageDirectoryException.class,
117118
InconsistentFilesystemException.class);

src/main/java/com/google/devtools/build/lib/skyframe/RecursiveDirectoryTraversalFunction.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import com.google.devtools.build.skyframe.SkyFunction.Environment;
2828
import com.google.devtools.build.skyframe.SkyKey;
2929
import com.google.devtools.build.skyframe.SkyValue;
30-
import com.google.devtools.build.skyframe.SkyframeIterableResult;
30+
import com.google.devtools.build.skyframe.SkyframeLookupResult;
3131
import com.google.errorprone.annotations.ForOverride;
3232
import java.util.Map;
3333
import javax.annotation.Nullable;
@@ -145,7 +145,7 @@ public final ReturnT visitDirectory(RecursivePkgKey recursivePkgKey, Environment
145145
Iterable<SkyKey> childDeps = processPackageDirectoryResult.getChildDeps();
146146
ConsumerT consumer = getInitialConsumer();
147147

148-
SkyframeIterableResult dependentSkyValues;
148+
SkyframeLookupResult dependentSkyValues;
149149
if (processPackageDirectoryResult.packageExists()) {
150150
PathFragment rootRelativePath = recursivePkgKey.getRootedPath().getRootRelativePath();
151151
SkyKey packageErrorMessageKey =
@@ -155,13 +155,13 @@ public final ReturnT visitDirectory(RecursivePkgKey recursivePkgKey, Environment
155155
// NoSuchPackageException. Since we don't catch such an exception here, this SkyFunction will
156156
// return immediately with a missing value, and the NoSuchPackageException will propagate up.
157157
dependentSkyValues =
158-
env.getOrderedValuesAndExceptions(
158+
env.getValuesAndExceptions(
159159
Iterables.concat(ImmutableList.of(packageErrorMessageKey), childDeps));
160160
if (env.valuesMissing()) {
161161
return null;
162162
}
163163
PackageErrorMessageValue pkgErrorMessageValue =
164-
(PackageErrorMessageValue) dependentSkyValues.next();
164+
(PackageErrorMessageValue) dependentSkyValues.get(packageErrorMessageKey);
165165
if (pkgErrorMessageValue == null) {
166166
return null;
167167
}
@@ -185,15 +185,15 @@ public final ReturnT visitDirectory(RecursivePkgKey recursivePkgKey, Environment
185185
throw new IllegalStateException(pkgErrorMessageValue.getResult().toString());
186186
}
187187
} else {
188-
dependentSkyValues = env.getOrderedValuesAndExceptions(childDeps);
188+
dependentSkyValues = env.getValuesAndExceptions(childDeps);
189189
if (env.valuesMissing()) {
190-
return null;
191-
}
190+
return null;
191+
}
192192
}
193193
ImmutableMap.Builder<SkyKey, SkyValue> subdirectorySkyValuesFromDeps =
194194
ImmutableMap.builderWithExpectedSize(Iterables.size(childDeps));
195195
for (SkyKey skyKey : childDeps) {
196-
SkyValue skyValue = dependentSkyValues.next();
196+
SkyValue skyValue = dependentSkyValues.get(skyKey);
197197
if (skyValue == null) {
198198
return null;
199199
}

src/main/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunction.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
import com.google.devtools.build.skyframe.SkyFunctionException;
5858
import com.google.devtools.build.skyframe.SkyKey;
5959
import com.google.devtools.build.skyframe.SkyValue;
60-
import com.google.devtools.build.skyframe.SkyframeIterableResult;
60+
import com.google.devtools.build.skyframe.SkyframeLookupResult;
6161
import java.io.IOException;
6262
import java.math.BigInteger;
6363
import java.util.ArrayList;
@@ -706,11 +706,11 @@ private ImmutableList<RecursiveFilesystemTraversalValue> traverseSourceChildren(
706706
}
707707
}
708708

709-
SkyframeIterableResult result = env.getOrderedValuesAndExceptions(childKeys);
709+
SkyframeLookupResult result = env.getValuesAndExceptions(childKeys);
710710
ImmutableList.Builder<RecursiveFilesystemTraversalValue> childValues =
711711
ImmutableList.builderWithExpectedSize(childKeys.size());
712712
for (SkyKey key : childKeys) {
713-
SkyValue value = result.next();
713+
SkyValue value = result.get(key);
714714
if (value == null) {
715715
continue;
716716
}

src/main/java/com/google/devtools/build/lib/skyframe/RegisteredExecutionPlatformsFunction.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
import com.google.devtools.build.skyframe.SkyFunctionException.Transience;
5151
import com.google.devtools.build.skyframe.SkyKey;
5252
import com.google.devtools.build.skyframe.SkyValue;
53-
import com.google.devtools.build.skyframe.SkyframeIterableResult;
53+
import com.google.devtools.build.skyframe.SkyframeLookupResult;
5454
import java.util.List;
5555
import javax.annotation.Nullable;
5656
import net.starlark.java.eval.StarlarkSemantics;
@@ -200,13 +200,13 @@ private static ImmutableList<ConfiguredTargetKey> configureRegisteredExecutionPl
200200
.build())
201201
.collect(toImmutableList());
202202

203-
SkyframeIterableResult values = env.getOrderedValuesAndExceptions(keys);
203+
SkyframeLookupResult values = env.getValuesAndExceptions(keys);
204204
ImmutableList.Builder<ConfiguredTargetKey> validPlatformKeys = new ImmutableList.Builder<>();
205205
boolean valuesMissing = false;
206206
for (ConfiguredTargetKey platformKey : keys) {
207207
Label platformLabel = platformKey.getLabel();
208208
try {
209-
SkyValue value = values.nextOrThrow(ConfiguredValueCreationException.class);
209+
SkyValue value = values.getOrThrow(platformKey, ConfiguredValueCreationException.class);
210210
if (value == null) {
211211
valuesMissing = true;
212212
continue;

src/main/java/com/google/devtools/build/lib/skyframe/RegisteredToolchainsFunction.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import com.google.devtools.build.skyframe.SkyFunctionException.Transience;
4545
import com.google.devtools.build.skyframe.SkyKey;
4646
import com.google.devtools.build.skyframe.SkyValue;
47-
import com.google.devtools.build.skyframe.SkyframeIterableResult;
47+
import com.google.devtools.build.skyframe.SkyframeLookupResult;
4848
import java.util.List;
4949
import javax.annotation.Nullable;
5050
import net.starlark.java.eval.StarlarkSemantics;
@@ -189,14 +189,14 @@ private static ImmutableList<DeclaredToolchainInfo> configureRegisteredToolchain
189189
.build())
190190
.collect(toImmutableList());
191191

192-
SkyframeIterableResult values = env.getOrderedValuesAndExceptions(keys);
192+
SkyframeLookupResult values = env.getValuesAndExceptions(keys);
193193
ImmutableList.Builder<DeclaredToolchainInfo> toolchains = new ImmutableList.Builder<>();
194194
boolean valuesMissing = false;
195195
for (SkyKey key : keys) {
196196
ConfiguredTargetKey configuredTargetKey = (ConfiguredTargetKey) key.argument();
197197
Label toolchainLabel = configuredTargetKey.getLabel();
198198
try {
199-
SkyValue value = values.nextOrThrow(ConfiguredValueCreationException.class);
199+
SkyValue value = values.getOrThrow(key, ConfiguredValueCreationException.class);
200200
if (value == null) {
201201
valuesMissing = true;
202202
continue;

0 commit comments

Comments
 (0)