lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [Lucene.Net] svn commit: r1128915 - /incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/SimpleFacetedSearch.cs
Date Sun, 29 May 2011 17:53:04 GMT
Author: digy
Date: Sun May 29 17:53:03 2011
New Revision: 1128915

URL: http://svn.apache.org/viewvc?rev=1128915&view=rev
Log:
[LUCENENET-415] A Possible Sync. bug.

Modified:
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/SimpleFacetedSearch.cs

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/SimpleFacetedSearch.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/SimpleFacetedSearch.cs?rev=1128915&r1=1128914&r2=1128915&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/SimpleFacetedSearch.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/SimpleFacetedSearch.cs
Sun May 29 17:53:03 2011
@@ -63,8 +63,7 @@ namespace Lucene.Net.Search
 
         IndexReader _Reader;
         List<KeyValuePair<List<string>, OpenBitSetDISI>> _Groups = new
List<KeyValuePair<List<string>, OpenBitSetDISI>>();
-        Semaphore _Sync;
-
+        
         public SimpleFacetedSearch(IndexReader reader, string groupByField) : this(reader,
new string[] { groupByField })
         {
         }
@@ -120,13 +119,14 @@ namespace Lucene.Net.Search
             }
 
             //Now _Groups has 7 rows (as <List<string>, BitSet> pairs) 
-
-           if( _Groups.Count>0)  _Sync = new Semaphore(_Groups.Count, _Groups.Count);
         }
 
         
         public Hits Search(Query query, int maxDocPerGroup = DefaultMaxDocPerGroup)
         {
+            Semaphore sync=null;
+            if (_Groups.Count > 0) sync = new Semaphore(_Groups.Count, _Groups.Count);
+
             List<HitsPerFacet> hitsPerGroup = new List<HitsPerFacet>();
 
             DocIdSet queryDocidSet = new CachingWrapperFilter(new QueryWrapperFilter(query)).GetDocIdSet(_Reader);
@@ -135,21 +135,21 @@ namespace Lucene.Net.Search
             {
                 HitsPerFacet h = new HitsPerFacet(new FacetName(_Groups[i].Key.ToArray()),
_Reader, queryDocidSet, _Groups[i].Value, maxDocPerGroup);
                 hitsPerGroup.Add(h);
-                _Sync.WaitOne();
+                sync.WaitOne();
                 ThreadPool.QueueUserWorkItem(
                     hpf =>
                     {
                         ((HitsPerFacet)hpf).Calculate();
-                        _Sync.Release();
+                        sync.Release();
                     },
                     h
                 );
             }
 
             for (int i = 0; i < _Groups.Count; i++)
-                _Sync.WaitOne();
+                sync.WaitOne();
             
-            if (_Groups.Count > 0) _Sync.Release(_Groups.Count);
+            if (_Groups.Count > 0) sync.Release(_Groups.Count);
                         
             Hits hits = new Hits();
             hits.HitsPerFacet = hitsPerGroup.ToArray();



Mime
View raw message