/// <summary>
        /// Deserializes an instance of <see cref="IncrementalSchedulingPathMapping{T}"/> from a reader.
        /// </summary>
        public static IncrementalSchedulingPathMapping <T> Deserialize(BuildXLReader reader, Func <BinaryReader, T> readValue)
        {
            Contract.Requires(reader != null);

            var valueToPathApproximation = new ConcurrentBigMap <T, List <AbsolutePath> >();
            var pathToValue = ConcurrentBigMap <AbsolutePath, HashSet <T> > .Deserialize(
                reader,
                () =>
            {
                var path       = reader.ReadAbsolutePath();
                var valueCount = reader.ReadInt32Compact();
                var values     = new HashSet <T>();

                for (int i = 0; i < valueCount; i++)
                {
                    T value = readValue(reader);

                    // Reconstruct the approximation map.
                    AddHelper(valueToPathApproximation, value, path);

                    values.Add(value);
                }

                return(new KeyValuePair <AbsolutePath, HashSet <T> >(path, values));
            });

            return(new IncrementalSchedulingPathMapping <T>(pathToValue, valueToPathApproximation));
        }
Пример #2
0
        /// <summary>
        /// Deserializes an instance of <see cref="PipProducers"/>.
        /// </summary>
        public static PipProducers Deserialize(BuildXLReader reader)
        {
            Contract.Requires(reader != null);

            var producedPaths = new ConcurrentBigMap <PipStableId, HashSet <AbsolutePath> >();
            var pipProducers  = ConcurrentBigMap <AbsolutePath, PipStableId> .Deserialize(
                reader,
                () =>
            {
                var path     = reader.ReadAbsolutePath();
                var producer = reader.ReadPipStableId();

                producedPaths.AddOrUpdate(
                    producer,
                    path,
                    (pip, pathToAdd) => new HashSet <AbsolutePath> {
                    pathToAdd
                },
                    (pip, pathToAdd, existingSet) =>
                {
                    existingSet.Add(pathToAdd);
                    return(existingSet);
                });

                return(new KeyValuePair <AbsolutePath, PipStableId>(path, producer));
            });

            return(new PipProducers(pipProducers, producedPaths));
        }
Пример #3
0
        /// <summary>
        /// Deserialize symlink definitions serialized using <see cref="Serialize(BuildXLWriter, SymlinkDefinitions)"/>
        /// </summary>
        public static Possible <SymlinkDefinitions> Deserialize(LoggingContext loggingContext, PathTable pathTable, BuildXLReader reader)
        {
            try
            {
                bool isNull = reader.ReadBoolean();
                if (isNull)
                {
                    return((SymlinkDefinitions)null);
                }

                var pathMap = ConcurrentBigMap <AbsolutePath, AbsolutePath> .Deserialize(
                    reader,
                    () => new KeyValuePair <AbsolutePath, AbsolutePath>(
                        key : reader.ReadAbsolutePath(),
                        value : reader.ReadAbsolutePath()));

                return(new SymlinkDefinitions(pathTable, pathMap));
            }
            catch (Exception ex)
            {
                Logger.Log.FailedLoadSymlinkFile(loggingContext, ex.GetLogEventMessage());
                return(new Failure <string>("Failed loading symlink definition file"));
            }
        }