/// <summary> /// Background Worker processor /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BackgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { string[] files = e.Argument as string[]; BackgroundWorker wrk = sender as BackgroundWorker; int i = 0; SetButton1Visiblablity(false); foreach (string fn in files) { if (wrk.CancellationPending) { e.Cancel = true; break; } backgroundWorker1.ReportProgress(1, fn); try { if (hoot.IsIndexed(fn) == false) { using (TextReader tf = File.OpenText(fn)) { string s = ""; if (tf != null) { s = tf.ReadToEnd(); } if (s != "") { if (Path.GetExtension(fn).Equals(".html", StringComparison.OrdinalIgnoreCase)) { hoot.Index(new myDoc(new FileInfo(fn), s), true, new HtmlFilter()); } else { hoot.Index(new myDoc(new FileInfo(fn), s), true); } } } } } catch { } i++; if (i > 1000) { i = 0; hoot.Save(); } backgroundWorker1.ReportProgress(1, "File Load Complete."); } hoot.Save(); SetButton1Visiblablity(true); //hoot.OptimizeIndex(); }
public IndexResult Index(hOOt.Document document, bool deleteOld, DocumentIndexOptimizeSetup setup) { if (!_isAlive) { return(new IndexResult()); } UpdateLastUsedToken(); var indexResult = _hoot.Index(document, deleteOld); Optimize(setup); return(indexResult); }
public IndexResult Index(hOOt.Document document, bool deleteOld /*, bool optimize*/) { lock (_gate) { if (!_isAlive) { return(new IndexResult()); } UpdateToken(); return(_hoot.Index(document, deleteOld /*, optimize*/)); } }
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)); }
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) { using (TextReader tf = new EPocalipse.IFilter.FilterReader(fn)) { string s = ""; if (tf != null) { s = tf.ReadToEnd(); } if (s != "") { hoot.Index(new myDoc(new FileInfo(fn), s), true); } } } } catch { } i++; if (i > 1000) { i = 0; hoot.Save(); } } hoot.Save(); //hoot.OptimizeIndex(); }