/// <summary> /// Serializes list of pips to a file. /// </summary> public void Serialize(AbsolutePath filePath, IReadOnlyCollection <Pip> pipsToSerialize, string fragmentDescription = null) { Contract.Requires(filePath.IsValid); Contract.Requires(pipsToSerialize != null); string fileName = filePath.ToString(m_pipExecutionContext.PathTable); using (var stream = new FileStream(fileName, FileMode.CreateNew, FileAccess.Write, FileShare.None)) using (var writer = new PipRemapWriter(m_pipExecutionContext, m_pipGraphFragmentContext, stream)) { FragmentDescription = fragmentDescription ?? fileName; writer.WriteNullableString(FragmentDescription); m_totalPipsToSerialize = pipsToSerialize.Count; writer.Write(pipsToSerialize.Count); foreach (var pip in pipsToSerialize) { pip.Serialize(writer); // Pip id is not serialized when pip is serialized. // Pip id is serialized as part of serializing the pip table. However, since pip table is not // part of graph fragment, then pip id needs to be serialized separately here. writer.Write(pip.PipId.Value); Stats.Increment(pip, serialize: true); } } }
private void SerializeHeader(PipRemapWriter writer, string fragmentDescription, bool topSort) { writer.WriteNullableString(fragmentDescription); writer.Write(topSort); }