Skip to content

Commit

Permalink
Internal serialization framework change.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 665333127
Change-Id: Ic427e954e19a3bde2fd001f37a8875ba96169806
  • Loading branch information
jin authored and copybara-github committed Aug 20, 2024
1 parent af7eabc commit 603d593
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.protobuf.CodedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;
import javax.annotation.Nullable;

/**
Expand Down Expand Up @@ -90,7 +91,7 @@ public ObjectCodecs withDependencyOverridesForTesting(ClassToInstanceMap<?> depe
}

@VisibleForTesting // private
public ObjectCodecs withCodecOverridesForTesting(ObjectCodec<?>... codecs) {
public ObjectCodecs withCodecOverridesForTesting(List<ObjectCodec<?>> codecs) {
ObjectCodecRegistry.Builder registryBuilder = getCodecRegistry().getBuilder();
for (ObjectCodec<?> codec : codecs) {
registryBuilder.add(codec);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,18 @@ public static ObjectCodecRegistry.Builder addStarlarkFunctionality(
return builder;
}

public static final ImmutableList<ObjectCodec<?>> ANALYSIS_CACHING_CODECS =
ImmutableList.<ObjectCodec<?>>builder()
.add(ArrayCodec.forComponentType(Artifact.class))
.add(new DeferredNestedSetCodec())
.add(Label.valueSharingCodec())
.add(PackageIdentifier.valueSharingCodec())
.add(ConfiguredTargetKey.valueSharingCodec())
.add(TransitiveInfoProviderMapImpl.valueSharingCodec())
.add(RemoteConfiguredTargetValue.codec())
.addAll(ArtifactCodecs.VALUE_SHARING_CODECS)
.build();

/**
* Initializes an {@link ObjectCodecRegistry} for analysis serialization.
*
Expand All @@ -134,16 +146,9 @@ public static Supplier<ObjectCodecRegistry> createAnalysisCodecRegistrySupplier(
AutoRegistry.get()
.getBuilder()
.addReferenceConstants(additionalReferenceConstants)
.computeChecksum(false)
.add(ArrayCodec.forComponentType(Artifact.class))
.add(new DeferredNestedSetCodec())
.add(Label.valueSharingCodec())
.add(PackageIdentifier.valueSharingCodec())
.add(ConfiguredTargetKey.valueSharingCodec())
.add(RemoteConfiguredTargetValue.codec())
.add(TransitiveInfoProviderMapImpl.valueSharingCodec());
.computeChecksum(false);
builder = addStarlarkFunctionality(builder, runtime.getRuleClassProvider());
ArtifactCodecs.VALUE_SHARING_CODECS.forEach(builder::add);
ANALYSIS_CACHING_CODECS.forEach(builder::add);
return builder.build();
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.google.common.base.Equivalence;
import com.google.common.collect.ImmutableClassToInstanceMap;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.testing.EqualsTester;
import com.google.common.testing.EquivalenceTester;
Expand Down Expand Up @@ -359,7 +360,7 @@ public void sourceArtifactCodecRecyclesSourceArtifactInstances(
if (useSharedValues) {
service = FingerprintValueService.createForTesting(FingerprintValueStore.inMemoryStore());
for (ObjectCodec<? extends Artifact> codec : ArtifactCodecs.VALUE_SHARING_CODECS) {
objectCodecs = objectCodecs.withCodecOverridesForTesting(codec);
objectCodecs = objectCodecs.withCodecOverridesForTesting(ImmutableList.of(codec));
}
}

Expand Down

0 comments on commit 603d593

Please sign in to comment.