aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/skyframe
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe')
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/TestSuiteExpansionKeyCodec.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/serialization/BUILD2
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/serialization/LabelCodec.java50
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/serialization/PackageIdentifierCodec.java49
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/serialization/PathCodec.java59
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/serialization/PathFragmentCodec.java56
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/serialization/RepositoryNameCodec.java56
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/serialization/SerializationCommonUtils.java19
8 files changed, 1 insertions, 292 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/TestSuiteExpansionKeyCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/TestSuiteExpansionKeyCodec.java
index c32a0f8154..d466391e39 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/TestSuiteExpansionKeyCodec.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/TestSuiteExpansionKeyCodec.java
@@ -15,8 +15,8 @@ package com.google.devtools.build.lib.skyframe;
import com.google.common.collect.ImmutableSortedSet;
import com.google.devtools.build.lib.cmdline.Label;
+import com.google.devtools.build.lib.cmdline.LabelCodec;
import com.google.devtools.build.lib.skyframe.TestSuiteExpansionValue.TestSuiteExpansionKey;
-import com.google.devtools.build.lib.skyframe.serialization.LabelCodec;
import com.google.devtools.build.lib.skyframe.serialization.ObjectCodec;
import com.google.devtools.build.lib.skyframe.serialization.SerializationException;
import com.google.protobuf.CodedInputStream;
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/BUILD b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/BUILD
index 10c813df2d..bb25cbcffd 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/BUILD
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/BUILD
@@ -11,8 +11,6 @@ java_library(
name = "serialization",
srcs = glob(["**/*.java"]),
deps = [
- "//src/main/java/com/google/devtools/build/lib/cmdline",
- "//src/main/java/com/google/devtools/build/lib/vfs",
"//src/main/java/com/google/devtools/build/skyframe:skyframe-objects",
"//third_party:guava",
"//third_party/protobuf:protobuf_java",
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/LabelCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/LabelCodec.java
deleted file mode 100644
index 89978baa67..0000000000
--- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/LabelCodec.java
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2017 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.build.lib.skyframe.serialization;
-
-import com.google.devtools.build.lib.cmdline.Label;
-import com.google.devtools.build.lib.cmdline.PackageIdentifier;
-import com.google.devtools.build.lib.skyframe.serialization.strings.StringCodecs;
-import com.google.protobuf.CodedInputStream;
-import com.google.protobuf.CodedOutputStream;
-import java.io.IOException;
-
-/** Custom serialization logic for {@link Label}s. */
-public class LabelCodec implements ObjectCodec<Label> {
- public static final LabelCodec INSTANCE = new LabelCodec();
-
- // TODO(michajlo): Share single instance of package id codec among all the codecs.
- private final PackageIdentifierCodec packageIdCodec = new PackageIdentifierCodec();
- private final ObjectCodec<String> stringCodec = StringCodecs.asciiOptimized();
-
- @Override
- public Class<Label> getEncodedClass() {
- return Label.class;
- }
-
- @Override
- public void serialize(Label label, CodedOutputStream codedOut)
- throws IOException, SerializationException {
- packageIdCodec.serialize(label.getPackageIdentifier(), codedOut);
- stringCodec.serialize(label.getName(), codedOut);
- }
-
- @Override
- public Label deserialize(CodedInputStream codedIn) throws SerializationException, IOException {
- PackageIdentifier packageId = packageIdCodec.deserialize(codedIn);
- String name = stringCodec.deserialize(codedIn);
- return Label.createUnvalidated(packageId, name);
- }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/PackageIdentifierCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/PackageIdentifierCodec.java
deleted file mode 100644
index 73aede67b1..0000000000
--- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/PackageIdentifierCodec.java
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2017 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.build.lib.skyframe.serialization;
-
-import com.google.devtools.build.lib.cmdline.PackageIdentifier;
-import com.google.devtools.build.lib.cmdline.RepositoryName;
-import com.google.devtools.build.lib.vfs.PathFragment;
-import com.google.protobuf.CodedInputStream;
-import com.google.protobuf.CodedOutputStream;
-import java.io.IOException;
-
-/** Custom serialization logic for {@link PackageIdentifier}s. */
-class PackageIdentifierCodec implements ObjectCodec<PackageIdentifier> {
-
- private final RepositoryNameCodec repoNameCodec = new RepositoryNameCodec();
- private final PathFragmentCodec pathFragmentCodec = new PathFragmentCodec();
-
- @Override
- public Class<PackageIdentifier> getEncodedClass() {
- return PackageIdentifier.class;
- }
-
- @Override
- public void serialize(PackageIdentifier pkgId, CodedOutputStream codedOut)
- throws IOException, SerializationException {
- repoNameCodec.serialize(pkgId.getRepository(), codedOut);
- pathFragmentCodec.serialize(pkgId.getPackageFragment(), codedOut);
- }
-
- @Override
- public PackageIdentifier deserialize(CodedInputStream codedIn)
- throws IOException, SerializationException {
- RepositoryName repoName = repoNameCodec.deserialize(codedIn);
- PathFragment pathFragment = pathFragmentCodec.deserialize(codedIn);
- return PackageIdentifier.create(repoName, pathFragment);
- }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/PathCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/PathCodec.java
deleted file mode 100644
index 5c44f9c0b5..0000000000
--- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/PathCodec.java
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright 2017 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.build.lib.skyframe.serialization;
-
-import com.google.common.base.Preconditions;
-import com.google.devtools.build.lib.vfs.FileSystem;
-import com.google.devtools.build.lib.vfs.Path;
-import com.google.devtools.build.lib.vfs.PathFragment;
-import com.google.protobuf.CodedInputStream;
-import com.google.protobuf.CodedOutputStream;
-import java.io.IOException;
-
-/** Custom serialization for {@link Path}s. */
-public class PathCodec implements ObjectCodec<Path> {
-
- private final FileSystem fileSystem;
- private final PathFragmentCodec pathFragmentCodec;
-
- /** Create an instance for serializing and deserializing {@link Path}s on {@code fileSystem}. */
- PathCodec(FileSystem fileSystem) {
- this.fileSystem = fileSystem;
- this.pathFragmentCodec = new PathFragmentCodec();
- }
-
- @Override
- public Class<Path> getEncodedClass() {
- return Path.class;
- }
-
- @Override
- public void serialize(Path path, CodedOutputStream codedOut)
- throws IOException, SerializationException {
- Preconditions.checkState(
- path.getFileSystem() == fileSystem,
- "Path's FileSystem (%s) did not match the configured FileSystem (%s)",
- path.getFileSystem(),
- fileSystem);
- pathFragmentCodec.serialize(path.asFragment(), codedOut);
- }
-
- @Override
- public Path deserialize(CodedInputStream codedIn)
- throws IOException, SerializationException {
- PathFragment pathFragment = pathFragmentCodec.deserialize(codedIn);
- return fileSystem.getPath(pathFragment);
- }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/PathFragmentCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/PathFragmentCodec.java
deleted file mode 100644
index a2f9e25955..0000000000
--- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/PathFragmentCodec.java
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2017 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.build.lib.skyframe.serialization;
-
-import com.google.devtools.build.lib.skyframe.serialization.strings.StringCodecs;
-import com.google.devtools.build.lib.vfs.PathFragment;
-import com.google.protobuf.CodedInputStream;
-import com.google.protobuf.CodedOutputStream;
-import java.io.IOException;
-
-/** Custom serialization for {@link PathFragment}s. */
-class PathFragmentCodec implements ObjectCodec<PathFragment> {
-
- private final ObjectCodec<String> stringCodec = StringCodecs.asciiOptimized();
-
- @Override
- public Class<PathFragment> getEncodedClass() {
- return PathFragment.class;
- }
-
- @Override
- public void serialize(PathFragment pathFragment, CodedOutputStream codedOut)
- throws IOException, SerializationException {
- codedOut.writeInt32NoTag(pathFragment.getDriveLetter());
- codedOut.writeBoolNoTag(pathFragment.isAbsolute());
- codedOut.writeInt32NoTag(pathFragment.segmentCount());
- for (int i = 0; i < pathFragment.segmentCount(); i++) {
- stringCodec.serialize(pathFragment.getSegment(i), codedOut);
- }
- }
-
- @Override
- public PathFragment deserialize(CodedInputStream codedIn)
- throws IOException, SerializationException {
- char driveLetter = (char) codedIn.readInt32();
- boolean isAbsolute = codedIn.readBool();
- int segmentCount = codedIn.readInt32();
- String[] segments = new String[segmentCount];
- for (int i = 0; i < segmentCount; i++) {
- segments[i] = stringCodec.deserialize(codedIn);
- }
- return PathFragment.create(driveLetter, isAbsolute, segments);
- }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/RepositoryNameCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/RepositoryNameCodec.java
deleted file mode 100644
index c9d0976acd..0000000000
--- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/RepositoryNameCodec.java
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2017 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.build.lib.skyframe.serialization;
-
-import com.google.devtools.build.lib.cmdline.LabelSyntaxException;
-import com.google.devtools.build.lib.cmdline.RepositoryName;
-import com.google.protobuf.CodedInputStream;
-import com.google.protobuf.CodedOutputStream;
-import java.io.IOException;
-
-/** Custom serialization for {@link RepositoryName}. */
-class RepositoryNameCodec implements ObjectCodec<RepositoryName> {
-
- @Override
- public Class<RepositoryName> getEncodedClass() {
- return RepositoryName.class;
- }
-
- @Override
- public void serialize(RepositoryName repoName, CodedOutputStream codedOut) throws IOException {
- boolean isMain = repoName.isMain();
- // Main is by far the most common. Use boolean to short-circuit string encoding on
- // serialization and byte[]/ByteString creation on deserialization.
- codedOut.writeBoolNoTag(isMain);
- if (!isMain) {
- codedOut.writeStringNoTag(repoName.getName());
- }
- }
-
- @Override
- public RepositoryName deserialize(CodedInputStream codedIn)
- throws SerializationException, IOException {
- boolean isMain = codedIn.readBool();
- if (isMain) {
- return RepositoryName.MAIN;
- }
- try {
- // We can read the string we wrote back as bytes to avoid string decoding/copying.
- return SerializationCommonUtils.deserializeRepoName(codedIn.readBytes());
- } catch (LabelSyntaxException e) {
- throw new SerializationException("Failed to deserialize RepositoryName", e);
- }
- }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/SerializationCommonUtils.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/SerializationCommonUtils.java
index 85abc95e17..b5baec07b2 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/SerializationCommonUtils.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/SerializationCommonUtils.java
@@ -14,10 +14,7 @@
package com.google.devtools.build.lib.skyframe.serialization;
-import com.google.devtools.build.lib.cmdline.LabelSyntaxException;
-import com.google.devtools.build.lib.cmdline.RepositoryName;
import com.google.devtools.build.lib.skyframe.serialization.strings.StringCodecs;
-import com.google.protobuf.ByteString;
import com.google.protobuf.CodedInputStream;
import com.google.protobuf.CodedOutputStream;
import java.io.IOException;
@@ -26,22 +23,6 @@ import java.io.IOException;
public class SerializationCommonUtils {
public static final ImmutableListCodec<String> STRING_LIST_CODEC =
new ImmutableListCodec<>(StringCodecs.asciiOptimized());
- private static final ByteString DEFAULT_REPOSITORY =
- ByteString.copyFromUtf8(RepositoryName.DEFAULT.getName());
- private static final ByteString MAIN_REPOSITORY =
- ByteString.copyFromUtf8(RepositoryName.MAIN.getName());
-
- public static RepositoryName deserializeRepoName(ByteString repoNameBytes)
- throws LabelSyntaxException {
- // We expect MAIN_REPOSITORY the vast majority of the time, so check for it first.
- if (repoNameBytes.equals(MAIN_REPOSITORY)) {
- return RepositoryName.MAIN;
- } else if (repoNameBytes.equals(DEFAULT_REPOSITORY)) {
- return RepositoryName.DEFAULT;
- } else {
- return RepositoryName.create(repoNameBytes.toStringUtf8());
- }
- }
public static <T> void serializeNullable(T obj, CodedOutputStream out, ObjectCodec<T> codec)
throws IOException, SerializationException {