示例#1
0
        public void CompressionTest()
        {
            int indexedPages = 1000000000;

            // may be increased to 1,000,000,000 (>2 GB) if: >=16 GB RAM, 64 bit Windows, .NET version >= 4.5,  <gcAllowVeryLargeObjects> in config file, Project / Properties / Buld / Prefer 32-bit disabled!
            // http://stackoverflow.com/questions/25225249/maxsize-of-array-in-net-framework-4-5
            int maximumPostingListLength = 100000;

            for (int postingListLength = 10; postingListLength <= maximumPostingListLength; postingListLength *= 10)
            {
                // posting list creation
                Trace.WriteLine($"Create posting list with {postingListLength} items...");
                List <uint> postingList1 = GeneratePostingList(postingListLength, indexedPages);

                // compression
                Trace.Write("Compress posting list");
                var sw = Stopwatch.StartNew();
                var compressedBuffer1 = new EliasFanoList((uint)indexedPages, maximumPostingListLength, postingList1);
                Trace.WriteLine($" in {sw.ElapsedMilliseconds}ms...");

                // decompression
                Trace.Write("Decompress posting list");
                sw.Restart();
                var postingList10 = compressedBuffer1.ToList();
                Trace.WriteLine($" in {sw.ElapsedMilliseconds}ms...");

                // verification
                Trace.WriteLine("Verify posting list...");
                Assert.AreEqual(postingList1.Count, postingList10.Count);
                for (int i = 0; i < postingList1.Count; i++)
                {
                    Assert.AreEqual(postingList1[i], postingList10[i]);
                }
            }
        }
示例#2
0
        public void EnumeratorReturnsCorrectResults()
        {
            // compression
            var compressedBuffer1 = new EliasFanoList(_postingList.Last(), _postingList.Count, _postingList);

            // decompression
            var postingList10 = compressedBuffer1.ToList();

            // verification
            Assert.AreEqual(_postingList.Count, postingList10.Count);
            for (int i = 0; i < _postingList.Count; i++)
            {
                Assert.AreEqual(_postingList[i], postingList10[i]);
            }
        }