Пример #1
0
        public void optimize_only_scavenged_chunks()
        {
            TFChunkReaderExistsAtOptimizer _existsAtOptimizer = new TFChunkReaderExistsAtOptimizer(3);
            var chunk = CreateChunk(0, false);

            _existsAtOptimizer.Optimize(chunk);
            Assert.AreEqual(false, _existsAtOptimizer.IsOptimized(chunk));

            chunk.MarkForDeletion();
            chunk.WaitForDestroy(5000);
        }
Пример #2
0
        public void optimize_only_maxcached_items_at_a_time()
        {
            int            maxCached = 3;
            List <TFChunk> chunks    = new List <TFChunk>();
            TFChunkReaderExistsAtOptimizer _existsAtOptimizer = new TFChunkReaderExistsAtOptimizer(maxCached);

            for (int i = 0; i < 7; i++)
            {
                var chunk = CreateChunk(i, true);
                chunks.Add(chunk);
                Assert.IsFalse(_existsAtOptimizer.IsOptimized(chunk));
                _existsAtOptimizer.Optimize(chunk);
            }


            //only the last maxCached chunks should still be optimized
            int cached = maxCached;

            for (int i = 7 - 1; i >= 0; i--)
            {
                if (cached > 0)
                {
                    Assert.AreEqual(true, _existsAtOptimizer.IsOptimized(chunks[i]));
                    cached--;
                }
                else
                {
                    Assert.AreEqual(false, _existsAtOptimizer.IsOptimized(chunks[i]));
                }
            }

            foreach (var chunk in chunks)
            {
                chunk.MarkForDeletion();
                chunk.WaitForDestroy(5000);
            }
        }
Пример #3
0
        public void posmap_items_should_exist_in_chunk()
        {
            TFChunkReaderExistsAtOptimizer _existsAtOptimizer = new TFChunkReaderExistsAtOptimizer(3);
            List <PosMap> posmap;
            var           chunk = CreateChunk(0, true, out posmap);

            //before optimization
            Assert.AreEqual(false, _existsAtOptimizer.IsOptimized(chunk));
            foreach (var p in posmap)
            {
                Assert.AreEqual(true, chunk.ExistsAt(p.LogPos));
            }

            //after optimization
            _existsAtOptimizer.Optimize(chunk);
            Assert.AreEqual(true, _existsAtOptimizer.IsOptimized(chunk));
            foreach (var p in posmap)
            {
                Assert.AreEqual(true, chunk.ExistsAt(p.LogPos));
            }

            chunk.MarkForDeletion();
            chunk.WaitForDestroy(5000);
        }