Ejemplo n.º 1
0
        public void GetAll()
        {
            PrepareZip("a", "b", "c");

            var actual   = _sut.GetAll <string>();
            var expected = new List <string> {
                "a", "b", "c"
            };

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 2
0
 private IEnumerable <string> ReadZip()
 {
     using (var ra = new ReadingArchive(_zipPath))
     {
         return(ra.GetAll <string>());
     }
 }
Ejemplo n.º 3
0
 protected IList <T> ReadZip <T>(string file)
 {
     Assert.IsTrue(file.StartsWith(DirTestRoot));
     using (var ra = new ReadingArchive(file))
     {
         return(ra.GetAll <T>());
     }
 }
Ejemplo n.º 4
0
 private void WriteEventStream(string zip, string relFile)
 {
     using (var ra = new ReadingArchive(zip))
     {
         var events = ra.GetAll <IDEEvent>();
         _export.Write(events, relFile);
     }
 }
        private void Expect(string relFile, params IDEEvent[] expecteds)
        {
            var file = Path.Combine(MergedDir, relFile);

            using (var ra = new ReadingArchive(file))
            {
                var actuals = ra.GetAll <IDEEvent>();
                CollectionAssert.AreEqual(expecteds, actuals);
            }
        }
 private void AssertZipContent(string fileName, params string[] expectedsArr)
 {
     using (var ra = new ReadingArchive(fileName))
     {
         var expecteds = new List <string>();
         expecteds.AddRange(expectedsArr);
         var actuals = ra.GetAll <string>();
         Assert.AreEqual(expecteds, actuals);
     }
 }
Ejemplo n.º 7
0
        public void AddTuples()
        {
            var q = new Query
            {
                type = new CoReTypeName("Ln/T")
            };
            var expected = Tuple.Create(q, q);

            _sut.OpenCache();
            _sut.AddTuple(expected);
            _sut.CloseCache();

            using (var ra = new ReadingArchive(Path.Combine(_dirHistories, "Ln", "T", "0.zip")))
            {
                var ts = ra.GetAll <Tuple <Query, Query> >();

                Assert.AreEqual(1, ts.Count);
                Assert.AreEqual(expected, ts[0]);
            }
        }
Ejemplo n.º 8
0
        private void ExtractEvents(IKaVEList <Event> events)
        {
            var logs      = FindSSTLogs(_dirCtxs);
            var generator = new EventStreamGenerator();

            foreach (var log in logs)
            {
                Console.WriteLine("##################################################");
                Console.WriteLine("reading {0}...", Path.GetFileName(log));
                using (var ra = new ReadingArchive(log))
                {
                    var ctxs = ra.GetAll <Context>();
                    Console.WriteLine("\tFound {0} contexts", ctxs.Count);
                    Console.Write("\tExtracting events... ");
                    foreach (var ctx in ctxs)
                    {
                        ctx.SST.Accept(generator, events);
                        Console.Write('.');
                    }
                    Console.WriteLine(" done");
                }
            }
        }
Ejemplo n.º 9
0
        public void Run()
        {
            var startTime = DateTime.Now;
            var ctxZips   = FindInputFiles();

            var numZips    = ctxZips.Count();
            var currentZip = 1;

            var numTotalCtxs   = 0;
            var numTotalUsages = 0;

            using (var cache = new ZipFolderLRUCache <CoReTypeName>(_dirOut, 1000))
            {
                foreach (var fileName in ctxZips)
                {
                    try
                    {
                        Log("### processing zip {0}/{1}: {2}", currentZip++, numZips, fileName);

                        var numLocalCtxs   = 0;
                        var numLocalUsages = 0;

                        var fullFileIn = _dirIn + fileName;

                        using (var ra = new ReadingArchive(fullFileIn))
                        {
                            Log("reading contexts...");
                            var ctxs    = ra.GetAll <Context>();
                            var numCtxs = ctxs.Count;
                            Log("found {0} contexts, exporting usages...\n\n", numCtxs);

                            var colCounter = 0;
                            foreach (var ctx in ctxs)
                            {
                                if (colCounter == 25)
                                {
                                    Console.WriteLine();
                                    colCounter = 0;
                                }
                                colCounter++;

                                var usages = ExtractUsages(ctx);
                                var msg    = usages.Count == 0
                                    ? "."
                                    : string.Format("{0}", usages.Count);
                                Console.Write(msg.PadLeft(5));

                                foreach (var u in usages)
                                {
                                    cache.GetArchive(u.type).Add(u);
                                }

                                numLocalCtxs++;
                                numLocalUsages += usages.Count;
                            }
                        }
                        Append("\n");
                        Log(
                            "--> {0} contexts, {1} usages\n\n",
                            numLocalCtxs,
                            numLocalUsages);

                        numTotalCtxs   += numLocalCtxs;
                        numTotalUsages += numLocalUsages;
                    }
                    catch (Exception e)
                    {
                        Log("oops, something went wrong...\n{0}", e);
                    }
                }
            }

            Log("finished! (started at {0})", startTime);
            Log(
                "found a total of {0} contexts and extracted {1} usages\n\n",
                numTotalCtxs,
                numTotalUsages);
        }