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: r1129803 - in /incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch: HitsPerFacet.cs HitsPerGroup.cs SimpleFacetedSearch.csproj
Date Tue, 31 May 2011 17:05:03 GMT
Author: digy
Date: Tue May 31 17:05:03 2011
New Revision: 1129803

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

Added:
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/HitsPerFacet.cs
Removed:
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/HitsPerGroup.cs
Modified:
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/SimpleFacetedSearch.csproj

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/HitsPerFacet.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/HitsPerFacet.cs?rev=1129803&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/HitsPerFacet.cs
(added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/HitsPerFacet.cs
Tue May 31 17:05:03 2011
@@ -0,0 +1,122 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using Lucene.Net.Analysis;
+using Lucene.Net.Documents;
+using Lucene.Net.Analysis.Standard;
+using Lucene.Net.Index;
+using Lucene.Net.Search;
+using Lucene.Net.QueryParsers;
+using Lucene.Net.Store;
+using Lucene.Net.Util;
+
+namespace Lucene.Net.Search
+{
+    public partial class SimpleFacetedSearch
+    {
+        public class HitsPerFacet : IEnumerable<Document>, IEnumerator<Document>
+        {
+            IndexReader _Reader;
+            int _MaxDocPerFacet;
+            int _ItemsReturned = 0;
+            DocIdSetIterator _ResultIterator;
+            OpenBitSetDISI _ResultBitSet;
+            int _CurrentDocId;
+            DocIdSet _QueryDocidSet;
+            OpenBitSetDISI _GroupBitSet;
+
+            FacetName _FacetName;
+            long _HitCount = -1;
+
+            internal HitsPerFacet(FacetName facetName, IndexReader reader, DocIdSet queryDocidSet,
OpenBitSetDISI groupBitSet, int maxDocPerFacet)
+            {
+                this._FacetName = facetName;
+                this._Reader = reader;
+                this._MaxDocPerFacet = maxDocPerFacet;
+                this._QueryDocidSet = queryDocidSet;
+                this._GroupBitSet = groupBitSet;
+                
+            }
+
+            internal void Calculate()
+            {
+                _ResultBitSet = new OpenBitSetDISI(_QueryDocidSet.Iterator(), _Reader.MaxDoc());
+                _ResultBitSet.And(_GroupBitSet);
+
+                _ResultIterator = _ResultBitSet.Iterator();
+
+                _HitCount = _ResultBitSet.Cardinality();
+            }
+
+            public FacetName Name
+            {
+                get { return _FacetName; }
+            }
+
+            public long HitCount
+            {
+                get{ return _HitCount; }
+            }
+
+            public Document Current
+            {
+                get { return _Reader.Document(_CurrentDocId); }
+            }
+
+            object System.Collections.IEnumerator.Current
+            {
+                get { return _Reader.Document(_CurrentDocId); }
+            }
+
+            public bool MoveNext()
+            {
+                _CurrentDocId = _ResultIterator.NextDoc();
+                return _CurrentDocId != DocIdSetIterator.NO_MORE_DOCS && ++_ItemsReturned
<= _MaxDocPerFacet;
+            }
+
+            public IEnumerator<Document> GetEnumerator()
+            {
+                return this;
+            }
+
+            System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
+            {
+                return this;
+            }
+
+            public void Reset()
+            {
+                throw new NotImplementedException();
+            }
+
+            public void Dispose()
+            {
+
+            }
+
+            public HitsPerFacet Documents
+            {
+                get { return this; }
+            }
+        }
+    }
+}

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/SimpleFacetedSearch.csproj
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/SimpleFacetedSearch.csproj?rev=1129803&r1=1129802&r2=1129803&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/SimpleFacetedSearch.csproj
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/SimpleFacetedSearch.csproj
Tue May 31 17:05:03 2011
@@ -44,7 +44,7 @@
     <Compile Include="FieldValuesBitSets.cs" />
     <Compile Include="FacetName.cs" />
     <Compile Include="Hits.cs" />
-    <Compile Include="HitsPerGroup.cs" />
+    <Compile Include="HitsPerFacet.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="SimpleFacetedSearch.cs" />
   </ItemGroup>



Mime
View raw message