Beispiel #1
0
 public bool Shutdown(DocumentIndexShutdownSetup setup)
 {
     if (!_isAlive)
     {
         return(true);
     }
     if (ShouldShutdown(setup))
     {
         Log("[Shutdown] started");
         DoOptimize(true);
         try
         {
             _hoot.FreeMemory(false);
             _hoot.Shutdown();
             if (setup.CleanStorage)
             {
                 string[] files = Directory.GetFiles(_hoot.Path, _hoot.FileName + ".*", SearchOption.AllDirectories);
                 foreach (var file in files)
                 {
                     File.Delete(file);
                 }
             }
             _shuttedDown();
             Log("[Shutdown] finished successfull");
             return(true);
         }
         finally
         {
             _isAlive = false;
         }
     }
     return(false);
 }
Beispiel #2
0
 /// <summary>
 /// The form is closing shutdown hoot indexer
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (hoot != null)
     {
         hoot.Shutdown();
     }
 }
Beispiel #3
0
 public bool Shutdown(DocumentIndexShutdownSetup setup)
 {
     lock (_gate)
     {
         if (!_isAlive)
         {
             return(true);
         }
         if (setup.ForceShutdown || _lastUsedTime.AddMinutes(_documentIndexSetup.AliveTimeoutInMinutes) < DateTime.UtcNow)
         {
             try
             {
                 _shuttingDown();
                 _hoot.FreeMemory(false);
                 _hoot.Shutdown();
                 if (setup.CleanStorage)
                 {
                     string[] files = Directory.GetFiles(_hoot.Path, _hoot.FileName + ".*", SearchOption.AllDirectories);
                     foreach (var file in files)
                     {
                         File.Delete(file);
                     }
                 }
                 return(true);
             }
             finally
             {
                 _isAlive = false;
             }
         }
     }
     return(false);
 }
        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));
        }
        public void ProjectWithSpacebars()
        {
            var          h   = new Hoot(Directory.GetCurrentDirectory(), "Fake", _ => { }, _ => { }, new CharacterTokensParser());
            const string key = "project                    ";
            var          d   = h.GenerateWordFreq(key);

            d.ContainsKey("project").Should(Be.True);
            h.Shutdown();
        }