aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-08-16 20:41:22 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2016-08-17 11:26:33 +0000
commitd1910c35673123654b251af478320cf05a96d9e0 (patch)
treec5d5aaf6fc96eba2ff80a14130e8f4022b518bfc
parent2f36f313b9d10e89611207422a4271f733fe49df (diff)
Share source paths for more compact res proto serialization
Source abs paths can be pretty long. If a value file like colors.xml has N resources then we serialize the path N times. Instead, make a table and just serialize the index. Can reduce resource proto sizes from X to 0.65*X. in some experiments. CPU instructions executed is slightly lower, but critical path impact is pretty minimal since parsing happens in parallel anyway. This doesn't help with drawables (path only shows up once) but doesn't really hurt (an extra index number). I tried sharing the root (a table of the res dirs). That can be another 10%, and helps with the drawable case. However, a naive enumeration of roots (src.getParent().getParent()) added *much* more overhead to the writing stage, so I didn't go on with that. -- MOS_MIGRATED_REVID=130440810
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/AndroidDataSerializer.java45
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/DataResourceXml.java10
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/DataSourceTable.java102
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/DataValue.java3
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/DataValueFile.java16
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/XmlResourceValue.java4
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/XmlResourceValues.java4
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/proto/serialize_format.proto8
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/xml/ArrayXmlResourceValue.java4
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/xml/AttrXmlResourceValue.java4
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/xml/IdXmlResourceValue.java4
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/xml/PluralXmlResourceValue.java4
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/xml/PublicXmlResourceValue.java4
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/xml/SimpleXmlResourceValue.java4
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/xml/StyleXmlResourceValue.java4
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/xml/StyleableXmlResourceValue.java4
16 files changed, 173 insertions, 51 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/AndroidDataSerializer.java b/src/tools/android/java/com/google/devtools/build/android/AndroidDataSerializer.java
index 1b1c0fbb19..bf6d52dd1c 100644
--- a/src/tools/android/java/com/google/devtools/build/android/AndroidDataSerializer.java
+++ b/src/tools/android/java/com/google/devtools/build/android/AndroidDataSerializer.java
@@ -14,10 +14,10 @@
package com.google.devtools.build.android;
import com.google.common.base.Stopwatch;
+import com.google.common.collect.Maps;
import com.google.devtools.build.android.ParsedAndroidData.KeyValueConsumer;
import com.google.devtools.build.android.proto.SerializeFormat;
import com.google.devtools.build.android.proto.SerializeFormat.Header;
-import com.google.protobuf.InvalidProtocolBufferException;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -27,7 +27,6 @@ import java.nio.file.FileSystem;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
-import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NavigableMap;
@@ -71,19 +70,31 @@ public class AndroidDataSerializer {
try (OutputStream outStream =
new BufferedOutputStream(
Files.newOutputStream(out, StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE))) {
+
// Set the header for the deserialization process.
- Header.newBuilder()
- .setEntryCount(entries.size())
+ SerializeFormat.Header.Builder headerBuilder = Header.newBuilder()
+ .setEntryCount(entries.size());
+
+ // Create table of source paths to allow references in the serialization format via an index.
+ ByteArrayOutputStream sourceTableOutputStream = new ByteArrayOutputStream(2048);
+ DataSourceTable sourceTable =
+ DataSourceTable.createAndWrite(entries, sourceTableOutputStream, headerBuilder);
+
+ headerBuilder
.build()
.writeDelimitedTo(outStream);
- writeKeyValuesTo(entries, outStream);
+ writeKeyValuesTo(entries, outStream, sourceTable, sourceTableOutputStream.toByteArray());
}
logger.fine(
String.format("Serialized merged in %sms", timer.elapsed(TimeUnit.MILLISECONDS)));
}
- private void writeKeyValuesTo(NavigableMap<DataKey, DataValue> map, OutputStream outStream)
+ private void writeKeyValuesTo(
+ NavigableMap<DataKey, DataValue> map,
+ OutputStream outStream,
+ DataSourceTable sourceTable,
+ byte[] sourceTableBytes)
throws IOException {
Set<Entry<DataKey, DataValue>> entries = map.entrySet();
int[] orderedValueSizes = new int[entries.size()];
@@ -94,13 +105,15 @@ public class AndroidDataSerializer {
ByteArrayOutputStream valuesOutputStream = new ByteArrayOutputStream(2048);
for (Map.Entry<DataKey, DataValue> entry : entries) {
orderedValueSizes[valueSizeIndex++] = entry.getValue()
- .serializeTo(entry.getKey(), valuesOutputStream);
+ .serializeTo(entry.getKey(), sourceTable, valuesOutputStream);
}
// Serialize all the keys in sorted order
valueSizeIndex = 0;
for (Map.Entry<DataKey, DataValue> entry : entries) {
entry.getKey().serializeTo(outStream, orderedValueSizes[valueSizeIndex++]);
}
+ // write the source table
+ outStream.write(sourceTableBytes);
// write the values to the output stream.
outStream.write(valuesOutputStream.toByteArray());
}
@@ -122,7 +135,7 @@ public class AndroidDataSerializer {
if (header == null) {
throw new DeserializationException("No Header found in " + inPath);
}
- readEntriesSegment(consumers, in, currentFileSystem, header.getEntryCount());
+ readEntriesSegment(consumers, in, currentFileSystem, header);
} catch (IOException e) {
throw new DeserializationException(e);
} finally {
@@ -135,9 +148,11 @@ public class AndroidDataSerializer {
KeyValueConsumers consumers,
InputStream in,
FileSystem currentFileSystem,
- int numberOfEntries)
- throws IOException, InvalidProtocolBufferException {
- Map<DataKey, KeyValueConsumer<DataKey, ? extends DataValue>> keys = new LinkedHashMap<>();
+ Header header)
+ throws IOException {
+ int numberOfEntries = header.getEntryCount();
+ Map<DataKey, KeyValueConsumer<DataKey, ? extends DataValue>> keys =
+ Maps.newLinkedHashMapWithExpectedSize(numberOfEntries);
for (int i = 0; i < numberOfEntries; i++) {
SerializeFormat.DataKey protoKey = SerializeFormat.DataKey.parseDelimitedFrom(in);
if (protoKey.hasResourceType()) {
@@ -152,9 +167,13 @@ public class AndroidDataSerializer {
}
}
+ // Read back the sources table.
+ DataSourceTable sourceTable = DataSourceTable.read(in, currentFileSystem, header);
+
// TODO(corysmith): Make this a lazy read of the values.
for (Entry<DataKey, KeyValueConsumer<DataKey, ?>> entry : keys.entrySet()) {
SerializeFormat.DataValue protoValue = SerializeFormat.DataValue.parseDelimitedFrom(in);
+ Path source = sourceTable.sourceFromId(protoValue.getSourceId());
if (protoValue.hasXmlValue()) {
// TODO(corysmith): Figure out why the generics are wrong.
// If I use Map<DataKey, KeyValueConsumer<DataKey, ? extends DataValue>>, I can put
@@ -165,12 +184,12 @@ public class AndroidDataSerializer {
@SuppressWarnings("unchecked")
KeyValueConsumer<DataKey, DataValue> value =
(KeyValueConsumer<DataKey, DataValue>) entry.getValue();
- value.consume(entry.getKey(), DataResourceXml.from(protoValue, currentFileSystem));
+ value.consume(entry.getKey(), DataResourceXml.from(protoValue, source));
} else {
@SuppressWarnings("unchecked")
KeyValueConsumer<DataKey, DataValue> value =
(KeyValueConsumer<DataKey, DataValue>) entry.getValue();
- value.consume(entry.getKey(), DataValueFile.from(protoValue, currentFileSystem));
+ value.consume(entry.getKey(), DataValueFile.from(source));
}
}
}
diff --git a/src/tools/android/java/com/google/devtools/build/android/DataResourceXml.java b/src/tools/android/java/com/google/devtools/build/android/DataResourceXml.java
index bb874e2c6d..13d44d9081 100644
--- a/src/tools/android/java/com/google/devtools/build/android/DataResourceXml.java
+++ b/src/tools/android/java/com/google/devtools/build/android/DataResourceXml.java
@@ -39,7 +39,6 @@ import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
-import java.nio.file.FileSystem;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Objects;
@@ -134,11 +133,11 @@ public class DataResourceXml implements DataResource {
}
@SuppressWarnings("deprecation")
- public static DataValue from(SerializeFormat.DataValue protoValue, FileSystem currentFileSystem)
+ public static DataValue from(SerializeFormat.DataValue protoValue, Path source)
throws InvalidProtocolBufferException {
DataValueXml xmlValue = protoValue.getXmlValue();
return createWithNamespaces(
- currentFileSystem.getPath(protoValue.getSource().getFilename()),
+ source,
valueFromProto(xmlValue),
Namespaces.from(xmlValue.getNamespace()));
}
@@ -293,8 +292,9 @@ public class DataResourceXml implements DataResource {
}
@Override
- public int serializeTo(DataKey key, OutputStream outStream) throws IOException {
- return xml.serializeTo(source, namespaces, outStream);
+ public int serializeTo(DataKey key, DataSourceTable sourceTable, OutputStream outStream)
+ throws IOException {
+ return xml.serializeTo(sourceTable.getSourceId(source), namespaces, outStream);
}
// TODO(corysmith): Clean up all the casting. The type structure is unclean.
diff --git a/src/tools/android/java/com/google/devtools/build/android/DataSourceTable.java b/src/tools/android/java/com/google/devtools/build/android/DataSourceTable.java
new file mode 100644
index 0000000000..4ffff3bcde
--- /dev/null
+++ b/src/tools/android/java/com/google/devtools/build/android/DataSourceTable.java
@@ -0,0 +1,102 @@
+// Copyright 2016 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.android;
+
+import com.google.devtools.build.android.proto.SerializeFormat;
+import com.google.devtools.build.android.proto.SerializeFormat.Header;
+import com.google.devtools.build.android.proto.SerializeFormat.ProtoSource;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.file.FileSystem;
+import java.nio.file.Path;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.NavigableMap;
+
+/**
+ * Tracks mappings from resource source paths (/foo/bar/res/values/colors.xml) to an ID for a more
+ * compact serialization format.
+ */
+class DataSourceTable {
+
+ private final Map<Path, Integer> sourceTable = new HashMap<>();
+ private Path[] idToSource;
+
+ /**
+ * Creates a DataSourceTable and serialize to the given outstream. Assigns each resource source
+ * path a number to enable {@link #getSourceId(Path)} queries.
+ *
+ * @param map the final map of resources
+ * @param outStream stream to serialize the source table
+ * @param headerBuilder the header to serialize
+ * @throws IOException if this fails to serialize the table to the outStream
+ */
+ public static DataSourceTable createAndWrite(
+ NavigableMap<DataKey, DataValue> map, OutputStream outStream, Header.Builder headerBuilder)
+ throws IOException {
+ DataSourceTable sourceTable = new DataSourceTable();
+ sourceTable.writeSourceInfo(map, outStream);
+ sourceTable.setHeader(headerBuilder);
+ return sourceTable;
+ }
+
+ /** Convert the absolute source path to the source table index */
+ public int getSourceId(Path source) {
+ return sourceTable.get(source);
+ }
+
+ private void writeSourceInfo(NavigableMap<DataKey, DataValue> map, OutputStream outStream)
+ throws IOException {
+ int sourceNumber = 0;
+ for (Map.Entry<DataKey, DataValue> entry : map.entrySet()) {
+ Path source = entry.getValue().source();
+ if (!sourceTable.containsKey(source)) {
+ sourceTable.put(source, sourceNumber);
+ ++sourceNumber;
+ ProtoSource.newBuilder().setFilename(source.toString()).build().writeDelimitedTo(outStream);
+ }
+ }
+ }
+
+ /** Fill in the serialize format header information required to deserialize */
+ private Header.Builder setHeader(Header.Builder headerBuilder) {
+ return headerBuilder.setSourceCount(sourceTable.size());
+ }
+
+ /** Deserialize the source table and allow {@link #sourceFromId(int)} queries. */
+ public static DataSourceTable read(InputStream in, FileSystem currentFileSystem, Header header)
+ throws IOException {
+ DataSourceTable sourceTable = new DataSourceTable();
+ sourceTable.readSourceInfo(in, currentFileSystem, header);
+ return sourceTable;
+ }
+
+ /** Convert the source ID to full Path */
+ public Path sourceFromId(int sourceId) {
+ return idToSource[sourceId];
+ }
+
+ private void readSourceInfo(InputStream in, FileSystem currentFileSystem, Header header)
+ throws IOException {
+ int numberOfSources = header.getSourceCount();
+ // Read back the sources.
+ idToSource = new Path[numberOfSources];
+ for (int i = 0; i < numberOfSources; i++) {
+ ProtoSource protoSource = SerializeFormat.ProtoSource.parseDelimitedFrom(in);
+ Path source = currentFileSystem.getPath(protoSource.getFilename());
+ idToSource[i] = source;
+ }
+ }
+}
diff --git a/src/tools/android/java/com/google/devtools/build/android/DataValue.java b/src/tools/android/java/com/google/devtools/build/android/DataValue.java
index f30916f1f6..e8427a4a34 100644
--- a/src/tools/android/java/com/google/devtools/build/android/DataValue.java
+++ b/src/tools/android/java/com/google/devtools/build/android/DataValue.java
@@ -32,5 +32,6 @@ public interface DataValue {
/**
* Serializes to a supplied stream and returns the number of bytes written.
*/
- int serializeTo(DataKey key, OutputStream output) throws IOException;
+ int serializeTo(
+ DataKey key, DataSourceTable sourceTable, OutputStream output) throws IOException;
}
diff --git a/src/tools/android/java/com/google/devtools/build/android/DataValueFile.java b/src/tools/android/java/com/google/devtools/build/android/DataValueFile.java
index e25ab44c12..b2166f3c16 100644
--- a/src/tools/android/java/com/google/devtools/build/android/DataValueFile.java
+++ b/src/tools/android/java/com/google/devtools/build/android/DataValueFile.java
@@ -13,15 +13,12 @@
// limitations under the License.
package com.google.devtools.build.android;
+import com.android.ide.common.res2.MergingException;
import com.google.common.base.MoreObjects;
import com.google.devtools.build.android.proto.SerializeFormat;
import com.google.protobuf.CodedOutputStream;
-
-import com.android.ide.common.res2.MergingException;
-
import java.io.IOException;
import java.io.OutputStream;
-import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.util.Objects;
@@ -45,9 +42,8 @@ public class DataValueFile implements DataResource, DataAsset {
/**
* Creates a {@link DataValueFile} from a {@link SerializeFormat.DataValue}.
*/
- public static DataValueFile from(
- SerializeFormat.DataValue protoValue, FileSystem currentFileSystem) {
- return of(currentFileSystem.getPath(protoValue.getSource().getFilename()));
+ public static DataValueFile from(Path source) {
+ return of(source);
}
@Override
@@ -87,10 +83,10 @@ public class DataValueFile implements DataResource, DataAsset {
}
@Override
- public int serializeTo(DataKey key, OutputStream output) throws IOException {
+ public int serializeTo(DataKey key, DataSourceTable sourceTable, OutputStream output)
+ throws IOException {
SerializeFormat.DataValue.Builder builder = SerializeFormat.DataValue.newBuilder();
- SerializeFormat.DataValue value =
- builder.setSource(builder.getSourceBuilder().setFilename(source.toString())).build();
+ SerializeFormat.DataValue value = builder.setSourceId(sourceTable.getSourceId(source)).build();
value.writeDelimitedTo(output);
return CodedOutputStream.computeUInt32SizeNoTag(value.getSerializedSize())
+ value.getSerializedSize();
diff --git a/src/tools/android/java/com/google/devtools/build/android/XmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/XmlResourceValue.java
index 88be7e528c..6818637220 100644
--- a/src/tools/android/java/com/google/devtools/build/android/XmlResourceValue.java
+++ b/src/tools/android/java/com/google/devtools/build/android/XmlResourceValue.java
@@ -32,8 +32,8 @@ public interface XmlResourceValue {
void write(FullyQualifiedName key, Path source, AndroidDataWritingVisitor mergedDataWriter);
/** Serializes the resource value to the OutputStream and returns the bytes written. */
- int serializeTo(Path source, Namespaces namespaces, OutputStream out) throws IOException;
-
+ int serializeTo(int sourceId, Namespaces namespaces, OutputStream out) throws IOException;
+
/**
* Combines these xml values together and returns a single value.
*
diff --git a/src/tools/android/java/com/google/devtools/build/android/XmlResourceValues.java b/src/tools/android/java/com/google/devtools/build/android/XmlResourceValues.java
index 7bda269b58..2cc49a8c34 100644
--- a/src/tools/android/java/com/google/devtools/build/android/XmlResourceValues.java
+++ b/src/tools/android/java/com/google/devtools/build/android/XmlResourceValues.java
@@ -419,9 +419,9 @@ public class XmlResourceValues {
return false;
}
- public static SerializeFormat.DataValue.Builder newSerializableDataValueBuilder(Path source) {
+ public static SerializeFormat.DataValue.Builder newSerializableDataValueBuilder(int sourceId) {
SerializeFormat.DataValue.Builder builder = SerializeFormat.DataValue.newBuilder();
- return builder.setSource(builder.getSourceBuilder().setFilename(source.toString()));
+ return builder.setSourceId(sourceId);
}
public static int serializeProtoDataValue(
diff --git a/src/tools/android/java/com/google/devtools/build/android/proto/serialize_format.proto b/src/tools/android/java/com/google/devtools/build/android/proto/serialize_format.proto
index 0090aefe36..3c24f5f54d 100644
--- a/src/tools/android/java/com/google/devtools/build/android/proto/serialize_format.proto
+++ b/src/tools/android/java/com/google/devtools/build/android/proto/serialize_format.proto
@@ -24,7 +24,9 @@ option java_package = "com.google.devtools.build.android.proto";
// how these messages are used.
message Header {
// The number of entries stored in a serialized buffer.
- optional int32 entry_count = 1;
+ optional uint32 entry_count = 1;
+ // The number of ProtoSource entries.
+ optional uint32 source_count = 2;
}
// The serialized format for a DataKey.
@@ -44,8 +46,10 @@ message DataKey {
// The serialized format for a DataValue.
message DataValue {
+ // The index of the ProtoSource in the source table section.
// Required
- optional ProtoSource source = 1;
+ optional uint32 source_id = 1;
+
// If xml_value is defined it's an xml value, otherwise, it's a file value.
optional DataValueXml xml_value= 2;
}
diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/ArrayXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/ArrayXmlResourceValue.java
index 46a382f5bb..f9cfd6a332 100644
--- a/src/tools/android/java/com/google/devtools/build/android/xml/ArrayXmlResourceValue.java
+++ b/src/tools/android/java/com/google/devtools/build/android/xml/ArrayXmlResourceValue.java
@@ -138,11 +138,11 @@ public class ArrayXmlResourceValue implements XmlResourceValue {
}
@Override
- public int serializeTo(Path source, Namespaces namespaces, OutputStream output)
+ public int serializeTo(int sourceId, Namespaces namespaces, OutputStream output)
throws IOException {
return XmlResourceValues.serializeProtoDataValue(
output,
- XmlResourceValues.newSerializableDataValueBuilder(source)
+ XmlResourceValues.newSerializableDataValueBuilder(sourceId)
.setXmlValue(
SerializeFormat.DataValueXml.newBuilder()
.addAllListValue(values)
diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/AttrXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/AttrXmlResourceValue.java
index dc8968cb12..c19c3be45c 100644
--- a/src/tools/android/java/com/google/devtools/build/android/xml/AttrXmlResourceValue.java
+++ b/src/tools/android/java/com/google/devtools/build/android/xml/AttrXmlResourceValue.java
@@ -343,10 +343,10 @@ public class AttrXmlResourceValue implements XmlResourceValue {
@SuppressWarnings("deprecation")
@Override
- public int serializeTo(Path source, Namespaces namespaces, OutputStream output)
+ public int serializeTo(int sourceId, Namespaces namespaces, OutputStream output)
throws IOException {
SerializeFormat.DataValue.Builder builder =
- XmlResourceValues.newSerializableDataValueBuilder(source);
+ XmlResourceValues.newSerializableDataValueBuilder(sourceId);
SerializeFormat.DataValueXml.Builder xmlValueBuilder =
SerializeFormat.DataValueXml.newBuilder();
xmlValueBuilder
diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/IdXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/IdXmlResourceValue.java
index d9a36488e6..ec870d31b5 100644
--- a/src/tools/android/java/com/google/devtools/build/android/xml/IdXmlResourceValue.java
+++ b/src/tools/android/java/com/google/devtools/build/android/xml/IdXmlResourceValue.java
@@ -87,7 +87,7 @@ public class IdXmlResourceValue implements XmlResourceValue {
}
@Override
- public int serializeTo(Path source, Namespaces namespaces, OutputStream output)
+ public int serializeTo(int sourceId, Namespaces namespaces, OutputStream output)
throws IOException {
Builder xmlValue =
SerializeFormat.DataValueXml.newBuilder()
@@ -97,7 +97,7 @@ public class IdXmlResourceValue implements XmlResourceValue {
xmlValue.setValue(value);
}
SerializeFormat.DataValue dataValue =
- XmlResourceValues.newSerializableDataValueBuilder(source).setXmlValue(xmlValue).build();
+ XmlResourceValues.newSerializableDataValueBuilder(sourceId).setXmlValue(xmlValue).build();
dataValue.writeDelimitedTo(output);
return CodedOutputStream.computeUInt32SizeNoTag(dataValue.getSerializedSize())
+ dataValue.getSerializedSize();
diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/PluralXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/PluralXmlResourceValue.java
index a8e92e4b19..7649117f05 100644
--- a/src/tools/android/java/com/google/devtools/build/android/xml/PluralXmlResourceValue.java
+++ b/src/tools/android/java/com/google/devtools/build/android/xml/PluralXmlResourceValue.java
@@ -133,10 +133,10 @@ public class PluralXmlResourceValue implements XmlResourceValue {
}
@Override
- public int serializeTo(Path source, Namespaces namespaces, OutputStream output)
+ public int serializeTo(int sourceId, Namespaces namespaces, OutputStream output)
throws IOException {
SerializeFormat.DataValue.Builder builder =
- XmlResourceValues.newSerializableDataValueBuilder(source);
+ XmlResourceValues.newSerializableDataValueBuilder(sourceId);
SerializeFormat.DataValue value =
builder
.setXmlValue(
diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/PublicXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/PublicXmlResourceValue.java
index ec6aa91c41..9a0308dc7c 100644
--- a/src/tools/android/java/com/google/devtools/build/android/xml/PublicXmlResourceValue.java
+++ b/src/tools/android/java/com/google/devtools/build/android/xml/PublicXmlResourceValue.java
@@ -134,7 +134,7 @@ public class PublicXmlResourceValue implements XmlResourceValue {
}
@Override
- public int serializeTo(Path source, Namespaces namespaces, OutputStream output)
+ public int serializeTo(int sourceId, Namespaces namespaces, OutputStream output)
throws IOException {
Map<String, String> assignments = Maps.newLinkedHashMapWithExpectedSize(typeToId.size());
for (Entry<ResourceType, Optional<Integer>> entry : typeToId.entrySet()) {
@@ -143,7 +143,7 @@ public class PublicXmlResourceValue implements XmlResourceValue {
assignments.put(entry.getKey().toString(), stringValue);
}
SerializeFormat.DataValue.Builder builder =
- XmlResourceValues.newSerializableDataValueBuilder(source);
+ XmlResourceValues.newSerializableDataValueBuilder(sourceId);
builder.setXmlValue(
builder
.getXmlValueBuilder()
diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/SimpleXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/SimpleXmlResourceValue.java
index bc7c44a3f0..d6442a9e63 100644
--- a/src/tools/android/java/com/google/devtools/build/android/xml/SimpleXmlResourceValue.java
+++ b/src/tools/android/java/com/google/devtools/build/android/xml/SimpleXmlResourceValue.java
@@ -218,10 +218,10 @@ public class SimpleXmlResourceValue implements XmlResourceValue {
}
@Override
- public int serializeTo(Path source, Namespaces namespaces, OutputStream output)
+ public int serializeTo(int sourceId, Namespaces namespaces, OutputStream output)
throws IOException {
SerializeFormat.DataValue.Builder builder =
- XmlResourceValues.newSerializableDataValueBuilder(source);
+ XmlResourceValues.newSerializableDataValueBuilder(sourceId);
Builder xmlValueBuilder =
builder
.getXmlValueBuilder()
diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/StyleXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/StyleXmlResourceValue.java
index 1bd20dab77..e539c98e5c 100644
--- a/src/tools/android/java/com/google/devtools/build/android/xml/StyleXmlResourceValue.java
+++ b/src/tools/android/java/com/google/devtools/build/android/xml/StyleXmlResourceValue.java
@@ -112,7 +112,7 @@ public class StyleXmlResourceValue implements XmlResourceValue {
}
@Override
- public int serializeTo(Path source, Namespaces namespaces, OutputStream output)
+ public int serializeTo(int sourceId, Namespaces namespaces, OutputStream output)
throws IOException {
SerializeFormat.DataValueXml.Builder xmlValueBuilder =
SerializeFormat.DataValueXml.newBuilder()
@@ -124,7 +124,7 @@ public class StyleXmlResourceValue implements XmlResourceValue {
}
return XmlResourceValues.serializeProtoDataValue(
output,
- XmlResourceValues.newSerializableDataValueBuilder(source).setXmlValue(xmlValueBuilder));
+ XmlResourceValues.newSerializableDataValueBuilder(sourceId).setXmlValue(xmlValueBuilder));
}
@Override
diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/StyleableXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/StyleableXmlResourceValue.java
index d37e34d5b0..822b43e9d4 100644
--- a/src/tools/android/java/com/google/devtools/build/android/xml/StyleableXmlResourceValue.java
+++ b/src/tools/android/java/com/google/devtools/build/android/xml/StyleableXmlResourceValue.java
@@ -143,11 +143,11 @@ public class StyleableXmlResourceValue implements XmlResourceValue {
}
@Override
- public int serializeTo(Path source, Namespaces namespaces, OutputStream output)
+ public int serializeTo(int sourceId, Namespaces namespaces, OutputStream output)
throws IOException {
return XmlResourceValues.serializeProtoDataValue(
output,
- XmlResourceValues.newSerializableDataValueBuilder(source)
+ XmlResourceValues.newSerializableDataValueBuilder(sourceId)
.setXmlValue(
SerializeFormat.DataValueXml.newBuilder()
.setType(XmlType.STYLEABLE)