public Hits Search(Query query, int maxDocPerGroup = DefaultMaxDocPerGroup)
        {
            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);
                actions[i] = () => h.Calculate();
            }
            
            Parallel.Invoke(actions);
            
            Hits hits = new Hits();
            hits.HitsPerFacet = hitsPerGroup.ToArray();

            return hits;
        }
Пример #2
0
        public Hits Search(Query query, int maxDocPerGroup)
        {
            var hitsPerGroup = new List<HitsPerFacet>();

            DocIdSet queryDocidSet = new CachingWrapperFilter(new QueryWrapperFilter(query)).GetDocIdSet(_Reader);
            var actions = new Action[_Groups.Count];           
            for (int i = 0; i < _Groups.Count; i++)
            {
                var h = new HitsPerFacet(new FacetName(_Groups[i].Key.ToArray()), _Reader, queryDocidSet, _Groups[i].Value, maxDocPerGroup);
                hitsPerGroup.Add(h);
                actions[i] = h.Calculate;
            }
            
#if !NET35
            Parallel.Invoke(actions);
#else
            foreach (var action in actions)
                action();
#endif
            
            Hits hits = new Hits {HitsPerFacet = hitsPerGroup.ToArray()};

            return hits;
        }