Muck out a lot of code, particularly serialization-related:
1. Split up libraries that were including more than they needed to.
2. Remove a lot of dead/half-dead serialization code. PathFragment had a custom codec, @AutoCodec annotations, and native serialization! Remove handwritten codecs in favor of DynamicCodec. DirectoryListingStateValue should get a bit smaller, because we're now serializing the raw compact arrays rather than the list of Dirents.
3. Stop using StringCodec explicitly. This costs us a couple of bytes because we now have to record that it's a string, but it's cleaner and if we ever memoize strings, we'll be glad to be going through the standard machinery.
PiperOrigin-RevId: 309023361
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/PathFragmentTest.java b/src/test/java/com/google/devtools/build/lib/vfs/PathFragmentTest.java
index 8a93ce2..3440e83 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/PathFragmentTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/PathFragmentTest.java
@@ -19,12 +19,15 @@
import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.testing.EqualsTester;
+import com.google.devtools.build.lib.skyframe.serialization.DeserializationContext;
import com.google.devtools.build.lib.skyframe.serialization.testutils.SerializationTester;
-import com.google.devtools.build.lib.testutil.TestUtils;
+import com.google.devtools.build.lib.skyframe.serialization.testutils.TestUtils;
import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem;
+import com.google.protobuf.ByteString;
import java.io.File;
import java.util.Collections;
import java.util.List;
@@ -572,25 +575,26 @@
@Test
public void testSerializationSimple() throws Exception {
- checkSerialization("a", 91);
+ checkSerialization("a", 6);
}
@Test
public void testSerializationAbsolute() throws Exception {
- checkSerialization("/foo", 94);
+ checkSerialization("/foo", 9);
}
@Test
public void testSerializationNested() throws Exception {
- checkSerialization("foo/bar/baz", 101);
+ checkSerialization("foo/bar/baz", 16);
}
private void checkSerialization(String pathFragmentString, int expectedSize) throws Exception {
PathFragment a = create(pathFragmentString);
- byte[] sa = TestUtils.serializeObject(a);
- assertThat(sa).hasLength(expectedSize);
+ ByteString sa = TestUtils.toBytes(a, ImmutableMap.of());
+ assertThat(sa.size()).isEqualTo(expectedSize);
- PathFragment a2 = (PathFragment) TestUtils.deserializeObject(sa);
+ PathFragment a2 =
+ (PathFragment) TestUtils.fromBytes(new DeserializationContext(ImmutableMap.of()), sa);
assertThat(a2).isEqualTo(a);
}
}