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: r1129276 - in /incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch: Extensions.cs SimpleFacetedSearch.cs
Date Mon, 30 May 2011 17:53:14 GMT
Author: digy
Date: Mon May 30 17:53:13 2011
New Revision: 1129276

URL: http://svn.apache.org/viewvc?rev=1129276&view=rev
Log:
[LUCENENET-415]

Modified:
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/Extensions.cs
    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/Extensions.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/Extensions.cs?rev=1129276&r1=1129275&r2=1129276&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/Extensions.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/Extensions.cs
Mon May 30 17:53:13 2011
@@ -41,6 +41,7 @@ namespace Lucene.Net.Search
         }
 
         //CartesianProduct - LINQ
+        //http://blogs.msdn.com/b/ericlippert/archive/2010/06/28/computing-a-cartesian-product-with-linq.aspx
         static IEnumerable<IEnumerable<T>> CartesianProduct2<T>(this IEnumerable<IEnumerable<T>>
sequences)
         {
             IEnumerable<IEnumerable<T>> emptyProduct = new[] { Enumerable.Empty<T>()
};

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=1129276&r1=1129275&r2=1129276&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
Mon May 30 17:53:13 2011
@@ -29,6 +29,7 @@ using Lucene.Net.QueryParsers;
 using Lucene.Net.Store;
 using Lucene.Net.Util;
 using System.Threading;
+using System.Threading.Tasks;
 
 /*
  Suppose, we want a faceted search on fields f1 f2 f3, 
@@ -120,37 +121,22 @@ namespace Lucene.Net.Search
 
             //Now _Groups has 7 rows (as <List<string>, BitSet> pairs) 
         }
-
         
         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);
-                        
+            Action[] actions = new Action[_Groups.Count];           
             for (int i = 0; i < _Groups.Count; i++)
             {
                 HitsPerFacet h = new HitsPerFacet(new FacetName(_Groups[i].Key.ToArray()),
_Reader, queryDocidSet, _Groups[i].Value, maxDocPerGroup);
                 hitsPerGroup.Add(h);
-                sync.WaitOne();
-                ThreadPool.QueueUserWorkItem(
-                    hpf =>
-                    {
-                        ((HitsPerFacet)hpf).Calculate();
-                        sync.Release();
-                    },
-                    h
-                );
+                actions[i] = () => h.Calculate();
             }
-
-            for (int i = 0; i < _Groups.Count; i++)
-                sync.WaitOne();
             
-            if (_Groups.Count > 0) sync.Release(_Groups.Count);
-                        
+            Parallel.Invoke(actions);
+            
             Hits hits = new Hits();
             hits.HitsPerFacet = hitsPerGroup.ToArray();
 



Mime
View raw message