public string Merge(IKaVESet <string> relZips)
        {
            Asserts.NotNull(relZips);
            Asserts.That(relZips.Count > 0);
            foreach (var relZip in relZips)
            {
                var zip = _io.GetFullPath_In(relZip);
                Asserts.That(File.Exists(zip));
            }

            var relZipOut = relZips.First();

            _log.NextGroup(relZips.Count, relZipOut);
            var zipOut = _io.GetFullPath_Merged(relZipOut);

            _io.EnsureParentExists(zipOut);

            var numEvents = 0;

            using (var wa = new WritingArchive(zipOut))
            {
                foreach (var e in ReadArchives(relZips))
                {
                    numEvents++;
                    wa.Add(e);
                }
            }

            _log.Result(numEvents);

            return(relZipOut);
        }
        public void Run()
        {
            FindZips();
            InParallel(CreateStatistics);

            Console.WriteLine("\n\nunique types: {0}", typesAll.Keys.Count);
            Console.WriteLine("unique seen methods: {0}", seenMethods.Keys.Count);
            Console.WriteLine("unique first: {0}", firstAll.Keys.Count);
            Console.WriteLine("unique super: {0}", superAll.Keys.Count);
            Console.WriteLine("unique elem: {0}", elemAll.Keys.Count);
            Console.WriteLine("unique inv: {0}", invAll.Keys.Count);

            var esFile = _io.GetFullPath_In("ctxElem.txt");

            Console.WriteLine("\ngenerating {0} ({1})", esFile, DateTime.Now);

            var sb = new StringBuilder();

            sb.AppendLine("Unique Elements:");
            foreach (var m in elemAll.Keys)
            {
                sb.AppendLine(m.ToString());
            }

            File.WriteAllText(esFile, sb.ToString());
        }
        public GroupMerger(IPreprocessingIo io, IGroupMergerLogger log)
        {
            _io  = io;
            _log = log;

            _log.WorkingIn(io.GetFullPath_In(""), io.GetFullPath_Merged(""));
        }
 protected void FindZips()
 {
     _ids = new HashSet <string>();
     _log.SearchingZips(_io.GetFullPath_In(""));
     foreach (var zip in _io.FindRelativeZipPaths())
     {
         _ids.Add(zip);
     }
     _log.FoundZips(_ids.Count);
 }
Exemple #5
0
        private EditLocationResults Analyze(string zip)
        {
            var res = new EditLocationResults {
                Zip = zip
            };
            var file = _io.GetFullPath_In(zip);

            using (var ra = new ReadingArchive(file))
            {
                var locAnal = new RelativeEditLocationAnalysis();
                while (ra.HasNext())
                {
                    var @event = ra.GetNext <IDEEvent>();
                    res.NumEvents++;

                    var complEvent = @event as CompletionEvent;
                    if (complEvent == null)
                    {
                        continue;
                    }

                    var fileName = complEvent.ActiveDocument.FileName;
                    if (fileName != null && !fileName.EndsWith(".cs"))
                    {
                        continue;
                    }

                    res.NumCompletionEvents++;

                    var loc = locAnal.Analyze(complEvent.Context2.SST);
                    if (!loc.HasEditLocation || loc.Size < 2)
                    {
                        continue;
                    }

                    res.NumLocations++;

                    if (complEvent.TerminatedState == TerminationState.Applied)
                    {
                        res.AppliedEditLocations.Add(loc);
                    }
                    else
                    {
                        res.OtherEditLocations.Add(loc);
                    }
                }
            }
            return(res);
        }
Exemple #6
0
        public MultiThreadedPreprocessing(IPreprocessingIo io,
                                          IMultiThreadedPreprocessingLogger log,
                                          int numProcs,
                                          Func <int, IIdReader> idReaderFactory,
                                          IGrouper grouper,
                                          Func <int, IGroupMerger> groupMergerFactory,
                                          Func <int, ICleaner> cleanerFactory)
        {
            _io       = io;
            _log      = log;
            _numProcs = numProcs;
            _log.Init(numProcs, _io.GetFullPath_In(""), _io.GetFullPath_Merged(""), _io.GetFullPath_Out(""));

            _idReaderFactory    = idReaderFactory;
            _grouper            = grouper;
            _groupMergerFactory = groupMergerFactory;
            _cleanerFactory     = cleanerFactory;
        }
Exemple #7
0
        private void CreateStatistics(int taskId)
        {
            _log.StartingStatCreation(taskId);

            var extractor = new InteractionStatisticsExtractor();

            string zip;

            while (GetNextZip(out zip))
            {
                _log.CreatingStats(taskId, zip);
                var file = _io.GetFullPath_In(zip);
                using (var ra = new ReadingArchive(file))
                {
                    var es    = ra.GetAllLazy <IDEEvent>();
                    var stats = extractor.CreateStatistics(es);
                    StoreResult(zip, stats);
                }
            }

            _log.FinishedStatCreation(taskId);
        }
Exemple #8
0
        private void ReadIds(int taskId)
        {
            _log.StartWorkerReadIds(taskId);
            var idReader = _idReaderFactory(taskId);

            string relZip;

            while (_data.AcquireNextUnindexedZip(out relZip))
            {
                try
                {
                    _log.ReadIds(taskId, relZip);
                    var zip = _io.GetFullPath_In(relZip);
                    var ids = idReader.Read(zip);
                    _data.StoreIds(relZip, ids);
                }
                catch (Exception e)
                {
                    _log.Error(taskId, e);
                }
            }
            _log.StopWorkerReadIds(taskId);
        }
Exemple #9
0
        public void Run()
        {
            Console.WriteLine("Comparing two folder of contexts:");
            Console.WriteLine("A: {0}", _ioA.GetFullPath_In(""));
            Console.WriteLine("B: {0}", _ioB.GetFullPath_In(""));

            Console.WriteLine("Reading A ...");
            var zipsA = _ioA.FindRelativeZipPaths();

            Console.WriteLine("Found {0} zips.", zipsA.Count);


            Console.WriteLine("Reading B ...");
            var zipsB = _ioB.FindRelativeZipPaths();

            Console.WriteLine("Found {0} zips.", zipsB.Count);

            var notInB = Sets.NewHashSet <string>();

            foreach (var zip in zipsA)
            {
                if (!zipsB.Contains(zip))
                {
                    notInB.Add(zip);
                }
            }

            var notInA = Sets.NewHashSet <string>();

            foreach (var zip in zipsB)
            {
                if (!zipsA.Contains(zip))
                {
                    notInA.Add(zip);
                }
            }

            Console.WriteLine("== {0} zips in common ==", zipsA.Count - notInB.Count);

            Console.WriteLine("== {0} zips not in A ==", notInA.Count);
            foreach (var zip in notInA)
            {
                Console.WriteLine("* {0}", zip);
            }

            Console.WriteLine("== {0} zips not in B ==", notInB.Count);
            foreach (var zip in notInB)
            {
                Console.WriteLine("* {0}", zip);
            }


            var gainedSize = Sets.NewHashSet <string>();

            Console.WriteLine("== reduced size ==");
            foreach (var zip in zipsA)
            {
                if (!notInB.Contains(zip))
                {
                    var sizeA    = _ioA.GetSize_In(zip);
                    var sizeB    = _ioB.GetSize_In(zip);
                    var delta    = (sizeB / (double)sizeA - 1) * 100;
                    var deltaAbs = Math.Abs(delta);
                    if (deltaAbs >= 0.1) // 0.001 or 0.1%
                    {
                        var sign = delta > 0 ? '+' : '-';
                        var str  = "* {0}  ({1}{2:0.0}%)".FormatEx(zip, sign, deltaAbs);

                        if (delta < 0)
                        {
                            Console.WriteLine(str);
                        }

                        if (delta > 0)
                        {
                            gainedSize.Add(str);
                        }
                    }
                }
            }

            Console.WriteLine("== gained size ==");
            foreach (var str in gainedSize)
            {
                Console.WriteLine(str);
            }
        }