Speed
- From: darryl vandorp <dvandorp gmail com>
- To: Dashboard <dashboard-hackers gnome org>
- Subject: Speed
- Date: Thu, 21 Oct 2004 10:09:11 -0500
Hey all,
I took a look at LuceneDriver.cs and think I have a couple optimiziations.
Basically it looks like the list of pending items is being walked
quite a few times.
The following patch made things speedier for me and seems to work ok.
Of course, I've never coded c-sharp before so i may be
misunderstanding what's supposed to be going on here.
Index: LuceneDriver.cs
===================================================================
RCS file: /cvs/gnome/beagle/beagled/LuceneDriver.cs,v
retrieving revision 1.31
diff -u -r1.31 LuceneDriver.cs
--- LuceneDriver.cs 19 Oct 2004 23:43:11 -0000 1.31
+++ LuceneDriver.cs 21 Oct 2004 15:01:55 -0000
@@ -798,32 +798,23 @@
// to Id numbers and store them in idsToDelete
watch.Restart ();
LNS.BooleanQuery uriQuery = new LNS.BooleanQuery ();
+ IndexReader reader;
+ reader = IndexReader.Open (driver.Store);
foreach (QueueItem item in pending) {
Uri uri = item.Uri;
- if (item.IsDelete && ! item.IsSilent)
- Log.Debug ("- {0}", uri);
+ if (item.IsDelete && ! item.IsSilent) {
+ Log.Debug ("- {0}", uri);
Term term = new Term ("Uri", uri.ToString ());
- LNS.Query termQuery = new LNS.TermQuery (term);
- uriQuery.Add (termQuery, false, false);
+ reader.Delete (term);
+ }
}
- LNS.Searcher searcher = new LNS.IndexSearcher (driver.Store);
- LNS.Hits uriHits = searcher.Search (uriQuery);
- for (int i = 0; i < uriHits.Length (); ++i) {
- int id = uriHits.Id (i);
- idsToDelete.Add (id);
- }
- searcher.Close ();
+ reader.Close();
watch.Stop ();
Log.Debug ("Step #1: {0} {1} {2}", watch, pending.Count,
watch.ElapsedTime / pending.Count);
// Step #2: Walk across the list of ids and delete all
// of those documents.
watch.Restart ();
- IndexReader reader;
- reader = IndexReader.Open (driver.Store);
- foreach (int id in idsToDelete)
- reader.Delete (id);
- reader.Close ();
watch.Stop ();
Log.Debug ("Step #2: {0}", watch);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]