Beispiel #1
0
        public async Task TestGraphFailSerialization()
        {
            using (var stream = new MemoryStream())
            {
                var writer = new BinaryWriter(stream);
                writer.Write(7);
                writer.Write(7);

                stream.Position = 0;

                bool encounteredAcceptableException = false;
                try
                {
                    DeserializedDirectedGraph deserialized =
                        await DeserializedDirectedGraph.DeserializeAsync(new BuildXLReader(debug : false, stream : stream, leaveOpen : false));
                }
                catch (IOException)
                {
                    encounteredAcceptableException = true;
                }
                catch (BuildXLException)
                {
                    encounteredAcceptableException = true;
                }

                XAssert.IsTrue(encounteredAcceptableException);
            }
        }
Beispiel #2
0
        public async Task TestGraphSerialization()
        {
            using (var stream = new MemoryStream())
            {
                MutableDirectedGraph graph;
                NodeId[]             nodes;

                CreateGraph(out graph, out nodes);

                var writer = new BuildXLWriter(debug: false, stream: stream, leaveOpen: true, logStats: false);
                graph.Serialize(writer);

                MutableDirectedGraph newMutableGraph;
                stream.Position = 0;
                var reader = new BuildXLReader(debug: false, stream: stream, leaveOpen: true);
                newMutableGraph = MutableDirectedGraph.Deserialize(reader);

                DeserializedDirectedGraph newImmutableDirectedGraph;
                stream.Position           = 0;
                newImmutableDirectedGraph = await DeserializedDirectedGraph.DeserializeAsync(reader);

                XAssert.IsTrue(newMutableGraph.ContainsEdge(nodes[11], nodes[8]));
                XAssert.IsFalse(newMutableGraph.ContainsEdge(nodes[11], nodes[2]));

                TestGraphSerializationPerformCommonValidations(newImmutableDirectedGraph, nodes, graph);
                TestGraphSerializationPerformCommonValidations(newMutableGraph, nodes, graph);
            }
        }
Beispiel #3
0
        public bool Deserialize(string path)
        {
            Console.WriteLine("Deserializing data...");
            using (var fs = new ProgressStream(File.Open(path, FileMode.Open), "DeserializedData"))
                using (var reader = new BuildXLReader(false, fs, false))
                {
                    Guid readVersion = reader.ReadGuid();
                    if (readVersion != VersionGuid)
                    {
                        return(false);
                    }

                    DataflowGraph = DeserializedDirectedGraph.DeserializeAsync(reader).Result;
                    var maxNode = (uint)DataflowGraph.NodeCount;
                    //reader.Read(maxNode, AggregateCosts, r => r.ReadUInt64());
                    reader.Read(maxNode, PipIds, r => r.ReadInt32());
                    reader.Read(maxNode, SemiStableHashes, r => r.ReadUInt64());
                    reader.Read(maxNode, StartTimes, r => r.ReadUInt64());
                    reader.Read(maxNode, Durations, r => r.ReadUInt64());
                    reader.Read(maxNode, PipTypes, r => (PipType)r.ReadByte());
                    //reader.Read(maxNode, CriticalChain, ReadNode);
                    MinStartTime  = reader.ReadUInt64();
                    MaxEndTime    = reader.ReadUInt64();
                    TotalDuration = reader.ReadUInt64();
                    //MaxAggregateCost = reader.ReadUInt64();
                    //CriticalPathHeadNode = ReadNode(reader);
                    //reader.Read(CriticalPath, ReadNode);
                    var stringTable = StringTable.DeserializeAsync(reader).Result;
                    SymbolTable = SymbolTable.DeserializeAsync(reader, Task.FromResult(stringTable)).Result;
                    reader.Read(maxNode, OutputValues, r => r.ReadFullSymbol());
                }

            Console.WriteLine("End deserializing data");
            Compute();
            return(true);
        }