*
* @param dependencies list of dependencies to serialize
* @return byte array with the serialized format
*/
byte[] serializeDependenciesForward(Collection<DependencyEntry> dependencies) throws IOException {
final DataOutputImpl dataOutput = new DataOutputImpl();
// total number of dependencies
dataOutput.writeInt(dependencies.size());
for (DependencyEntry dependencyEntry : dependencies) {
// we store the master record id, because that is how they are stored in the backward table
final byte[] masterTableBytes = Bytes.toBytes(dependencyEntry.getDependency().getTable());
final byte[] masterBytes = dependencyEntry.getDependency().getRecordId().getMaster().toBytes();
dataOutput.writeInt(masterTableBytes.length);
dataOutput.writeBytes(masterTableBytes);
dataOutput.writeInt(masterBytes.length);
dataOutput.writeBytes(masterBytes);
final byte[] variantPropertiesBytes = serializeVariantPropertiesPattern(createVariantPropertiesPattern(
dependencyEntry.getDependency().getRecordId().getVariantProperties(),
dependencyEntry.getMoreDimensionedVariants()));
dataOutput.writeBytes(variantPropertiesBytes);
}
return dataOutput.toByteArray();
}