Пример #1
0
        public void SomeLittleShit()
        {
            const string key          = "squadnull";
            const string hootFileName = "Fake";
            var          hootPath     = Directory.GetCurrentDirectory();

            foreach (var file in Directory.GetFiles(hootPath, hootFileName + ".*", SearchOption.TopDirectoryOnly))
            {
                File.Delete(file);
            }

            var h = new Hoot(hootPath, hootFileName, _ => { }, _ => { }, new CharacterTokensParser());

            for (int i = 0; i < 11000; i++)
            {
                h.Index(i, key);
            }
            var rowsBeforeOptimize = h.FindRows(key);

            rowsBeforeOptimize.Count().Should(Be.EqualTo(11000));

            h.OptimizeIndex(true);
            var rowsAfterOptimize = h.FindRows(key);

            h.Shutdown();

            foreach (var file in Directory.GetFiles(hootPath, hootFileName + ".*", SearchOption.TopDirectoryOnly))
            {
                File.Delete(file);
            }

            rowsAfterOptimize.Count().Should(Be.EqualTo(11000));
        }
Пример #2
0
 public void Optimize(bool freeMemory)
 {
     lock (_gate)
     {
         if (!_isAlive)
         {
             return;
         }
         UpdateToken();
         _hoot.OptimizeIndex(freeMemory);
     }
 }
Пример #3
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            string[]         files = e.Argument as string[];
            BackgroundWorker wrk   = sender as BackgroundWorker;
            int i = 0;

            foreach (string fn in files)
            {
                if (wrk.CancellationPending)
                {
                    e.Cancel = true;
                    break;
                }
                backgroundWorker1.ReportProgress(1, fn);
                try
                {
                    if (hoot.IsIndexed(fn) == false)
                    {
                        TextReader tf = new EPocalipse.IFilter.FilterReader(fn);
                        string     s  = "";
                        if (tf != null)
                        {
                            s = tf.ReadToEnd();
                        }

                        hoot.Index(new myDoc(new FileInfo(fn), s), true);
                    }
                }
                catch { }
                i++;
                if (i > 1000)
                {
                    i = 0;
                    hoot.Save();
                }
            }
            hoot.Save();
            hoot.OptimizeIndex();
        }
Пример #4
0
 private void DoOptimize(bool freeMemory)
 {
     _hoot.OptimizeIndex(freeMemory);
     _isOptimized = true;
 }