lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [48/58] [abbrv] lucenenet git commit: Renamed AbstractGroupHead to AbstractAllGroupHeadsCollector_GroupHead so it is similar to its original name, AbstractAllGroupHeadsCollector.GroupHead. Due to conflicts with other classes named GroupHead in derived cl
Date Thu, 10 Nov 2016 11:33:59 GMT
Renamed AbstractGroupHead to AbstractAllGroupHeadsCollector_GroupHead so it is similar to its original name, AbstractAllGroupHeadsCollector.GroupHead. Due to conflicts with other classes named GroupHead in derived classes of AbstractAllGroupHeadsCollector, the original name could not be used.


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/95bb6692
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/95bb6692
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/95bb6692

Branch: refs/heads/grouping
Commit: 95bb669287a986c676b6e4ecf5f95d48341cacf1
Parents: 840c67b
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sun Nov 6 21:47:59 2016 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Tue Nov 8 02:24:58 2016 +0700

----------------------------------------------------------------------
 .../AbstractAllGroupHeadsCollector.cs           |  13 +-
 .../Function/FunctionAllGroupHeadsCollector.cs  |   2 +-
 .../Term/TermAllGroupHeadsCollector.cs          | 993 +++++++++----------
 3 files changed, 505 insertions(+), 503 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/95bb6692/src/Lucene.Net.Grouping/AbstractAllGroupHeadsCollector.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Grouping/AbstractAllGroupHeadsCollector.cs b/src/Lucene.Net.Grouping/AbstractAllGroupHeadsCollector.cs
index f27d2e4..5668b19 100644
--- a/src/Lucene.Net.Grouping/AbstractAllGroupHeadsCollector.cs
+++ b/src/Lucene.Net.Grouping/AbstractAllGroupHeadsCollector.cs
@@ -10,7 +10,7 @@ using System.Threading.Tasks;
 namespace Lucene.Net.Search.Grouping
 {
     public abstract class AbstractAllGroupHeadsCollector<GH> : AbstractAllGroupHeadsCollector
-        where GH : AbstractGroupHead /*AbstractAllGroupHeadsCollector<GH>.GroupHead*/
+        where GH : AbstractAllGroupHeadsCollector_GroupHead
     {
         protected readonly int[] reversed;
         protected readonly int compIDXEnd;
@@ -150,16 +150,19 @@ namespace Lucene.Net.Search.Grouping
     /// </para>
     /// </summary>
     /// <remarks>
-    /// LUCENENET: moved this class outside of the AbstractAllGroupHeadsCollector,
-    /// made non-generic, and renamed from GroupHead to AbstractGroupHead.
+    /// LUCENENET: moved this class from of the <see cref="AbstractAllGroupHeadsCollector{TGroupValue}"/>,
+    /// to <see cref="AbstractAllGroupHeadsCollector"/>, made it non-generic so the generic closing type doesn't need 
+    /// to be specified in classes that use <see cref="AbstractAllGroupHeadsCollector_GroupHead"/> as a generic closing type, and renamed 
+    /// it from GroupHead to <see cref="AbstractAllGroupHeadsCollector_GroupHead"/> to avoid naming conflicts with nested classes 
+    /// named GroupHead in derived classes of <see cref="AbstractAllGroupHeadsCollector"/>.
     /// </remarks>
-    public abstract class AbstractGroupHead /*<TGroupValue>*/
+    public abstract class AbstractAllGroupHeadsCollector_GroupHead /*<TGroupValue>*/
     {
 
         //public readonly TGroupValue groupValue;
         public int Doc { get; protected set; }
 
-        protected AbstractGroupHead(/*TGroupValue groupValue,*/ int doc)
+        protected AbstractAllGroupHeadsCollector_GroupHead(/*TGroupValue groupValue,*/ int doc)
         {
             //this.groupValue = groupValue;
             this.Doc = doc;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/95bb6692/src/Lucene.Net.Grouping/Function/FunctionAllGroupHeadsCollector.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Grouping/Function/FunctionAllGroupHeadsCollector.cs b/src/Lucene.Net.Grouping/Function/FunctionAllGroupHeadsCollector.cs
index c50219d..9b7f0cd 100644
--- a/src/Lucene.Net.Grouping/Function/FunctionAllGroupHeadsCollector.cs
+++ b/src/Lucene.Net.Grouping/Function/FunctionAllGroupHeadsCollector.cs
@@ -111,7 +111,7 @@ namespace Lucene.Net.Search.Grouping.Function
         /** Holds current head document for a single group.
          *
          * @lucene.experimental */
-        public class GroupHead : AbstractGroupHead /*AbstractAllGroupHeadsCollector.GroupHead<MutableValue>*/
+        public class GroupHead : AbstractAllGroupHeadsCollector_GroupHead /*AbstractAllGroupHeadsCollector.GroupHead<MutableValue>*/
         {
 
             private readonly FunctionAllGroupHeadsCollector outerInstance;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/95bb6692/src/Lucene.Net.Grouping/Term/TermAllGroupHeadsCollector.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Grouping/Term/TermAllGroupHeadsCollector.cs b/src/Lucene.Net.Grouping/Term/TermAllGroupHeadsCollector.cs
index fbbec34..054dacc 100644
--- a/src/Lucene.Net.Grouping/Term/TermAllGroupHeadsCollector.cs
+++ b/src/Lucene.Net.Grouping/Term/TermAllGroupHeadsCollector.cs
@@ -18,7 +18,8 @@ namespace Lucene.Net.Search.Grouping.Terms
     /// @lucene.experimental
     /// </summary>
     /// <typeparam name="GH"></typeparam>
-    public abstract class TermAllGroupHeadsCollector<GH> : AbstractAllGroupHeadsCollector<GH> where GH : AbstractGroupHead /*AbstractAllGroupHeadsCollector<GH>.GroupHead*/
+    public abstract class TermAllGroupHeadsCollector<GH> : AbstractAllGroupHeadsCollector<GH>
+        where GH : AbstractAllGroupHeadsCollector_GroupHead
     {
         internal readonly string groupField;
         internal readonly BytesRef scratchBytesRef = new BytesRef();
@@ -112,696 +113,694 @@ namespace Lucene.Net.Search.Grouping.Terms
 
     // A general impl that works for any group sort.
     internal class GeneralAllGroupHeadsCollector : TermAllGroupHeadsCollector<GeneralAllGroupHeadsCollector.GroupHead>
-        {
+    {
 
-            private readonly Sort sortWithinGroup;
-            private readonly IDictionary<BytesRef, GroupHead> groups;
+        private readonly Sort sortWithinGroup;
+        private readonly IDictionary<BytesRef, GroupHead> groups;
 
-            internal Scorer scorer;
+        internal Scorer scorer;
 
-            internal GeneralAllGroupHeadsCollector(string groupField, Sort sortWithinGroup)
-                : base(groupField, sortWithinGroup.GetSort().Length)
-            {
-                this.sortWithinGroup = sortWithinGroup;
-                groups = new HashMap<BytesRef, GroupHead>();
+        internal GeneralAllGroupHeadsCollector(string groupField, Sort sortWithinGroup)
+            : base(groupField, sortWithinGroup.GetSort().Length)
+        {
+            this.sortWithinGroup = sortWithinGroup;
+            groups = new HashMap<BytesRef, GroupHead>();
 
-                SortField[] sortFields = sortWithinGroup.GetSort();
-                for (int i = 0; i < sortFields.Length; i++)
-                {
-                    reversed[i] = sortFields[i].Reverse ? -1 : 1;
-                }
+            SortField[] sortFields = sortWithinGroup.GetSort();
+            for (int i = 0; i < sortFields.Length; i++)
+            {
+                reversed[i] = sortFields[i].Reverse ? -1 : 1;
             }
+        }
 
-            protected override void RetrieveGroupHeadAndAddIfNotExist(int doc)
+        protected override void RetrieveGroupHeadAndAddIfNotExist(int doc)
+        {
+            int ord = groupIndex.GetOrd(doc);
+            BytesRef groupValue;
+            if (ord == -1)
             {
-                int ord = groupIndex.GetOrd(doc);
-                BytesRef groupValue;
-                if (ord == -1)
-                {
-                    groupValue = null;
-                }
-                else
-                {
-                    groupIndex.LookupOrd(ord, scratchBytesRef);
-                    groupValue = scratchBytesRef;
-                }
-                GroupHead groupHead;
-                if (!groups.TryGetValue(groupValue, out groupHead))
-                {
-                    groupHead = new GroupHead(this, groupValue, sortWithinGroup, doc);
-                    groups[groupValue == null ? null : BytesRef.DeepCopyOf(groupValue)] = groupHead;
-                    temporalResult.stop = true;
-                }
-                else
-                {
-                    temporalResult.stop = false;
-                }
-                temporalResult.groupHead = groupHead;
+                groupValue = null;
             }
-
-            protected override ICollection<GroupHead> GetCollectedGroupHeads()
+            else
             {
-                return groups.Values;
+                groupIndex.LookupOrd(ord, scratchBytesRef);
+                groupValue = scratchBytesRef;
             }
-
-            public override AtomicReaderContext NextReader
+            GroupHead groupHead;
+            if (!groups.TryGetValue(groupValue, out groupHead))
             {
-                set
-                {
-                    this.readerContext = value;
-                    groupIndex = FieldCache.DEFAULT.GetTermsIndex(value.AtomicReader, groupField);
-
-                    foreach (GroupHead groupHead in groups.Values)
-                    {
-                        for (int i = 0; i < groupHead.comparators.Length; i++)
-                        {
-                            groupHead.comparators[i] = groupHead.comparators[i].SetNextReader(value);
-                        }
-                    }
-                }
+                groupHead = new GroupHead(this, groupValue, sortWithinGroup, doc);
+                groups[groupValue == null ? null : BytesRef.DeepCopyOf(groupValue)] = groupHead;
+                temporalResult.stop = true;
             }
-
-            public override Scorer Scorer
+            else
             {
-                set
-                {
-                    this.scorer = value;
-                    foreach (GroupHead groupHead in groups.Values)
-                    {
-                        foreach (FieldComparator comparator in groupHead.comparators)
-                        {
-                            comparator.Scorer = value;
-                        }
-                    }
-                }
+                temporalResult.stop = false;
             }
+            temporalResult.groupHead = groupHead;
+        }
 
-            internal class GroupHead : AbstractGroupHead /*AbstractAllGroupHeadsCollector.GroupHead<BytesRef>*/
-            {
-                private readonly GeneralAllGroupHeadsCollector outerInstance;
-                public readonly BytesRef groupValue;
+        protected override ICollection<GroupHead> GetCollectedGroupHeads()
+        {
+            return groups.Values;
+        }
 
-                internal readonly FieldComparator[] comparators;
+        public override AtomicReaderContext NextReader
+        {
+            set
+            {
+                this.readerContext = value;
+                groupIndex = FieldCache.DEFAULT.GetTermsIndex(value.AtomicReader, groupField);
 
-                internal GroupHead(GeneralAllGroupHeadsCollector outerInstance, BytesRef groupValue, Sort sort, int doc)
-                    : base(doc + outerInstance.readerContext.DocBase)
+                foreach (GroupHead groupHead in groups.Values)
                 {
-                    this.outerInstance = outerInstance;
-                    SortField[] sortFields = sort.GetSort();
-                    comparators = new FieldComparator[sortFields.Length];
-                    for (int i = 0; i < sortFields.Length; i++)
+                    for (int i = 0; i < groupHead.comparators.Length; i++)
                     {
-                        comparators[i] = sortFields[i].GetComparator(1, i).SetNextReader(outerInstance.readerContext);
-                        comparators[i].Scorer = outerInstance.scorer;
-                        comparators[i].Copy(0, doc);
-                        comparators[i].Bottom = 0;
+                        groupHead.comparators[i] = groupHead.comparators[i].SetNextReader(value);
                     }
                 }
+            }
+        }
 
-                public override int Compare(int compIDX, int doc)
-                {
-                    return comparators[compIDX].CompareBottom(doc);
-                }
-
-                public override void UpdateDocHead(int doc)
+        public override Scorer Scorer
+        {
+            set
+            {
+                this.scorer = value;
+                foreach (GroupHead groupHead in groups.Values)
                 {
-                    foreach (FieldComparator comparator in comparators)
+                    foreach (FieldComparator comparator in groupHead.comparators)
                     {
-                        comparator.Copy(0, doc);
-                        comparator.Bottom = 0;
+                        comparator.Scorer = value;
                     }
-                    this.Doc = doc + outerInstance.readerContext.DocBase;
                 }
             }
         }
 
-
-        // AbstractAllGroupHeadsCollector optimized for ord fields and scores.
-        internal class OrdScoreAllGroupHeadsCollector : TermAllGroupHeadsCollector<OrdScoreAllGroupHeadsCollector.GroupHead>
+        internal class GroupHead : AbstractAllGroupHeadsCollector_GroupHead /*AbstractAllGroupHeadsCollector.GroupHead<BytesRef>*/
         {
-            //private readonly TermAllGroupHeadsCollector<GH> outerInstance;
-            private readonly SentinelIntSet ordSet;
-            private readonly IList<GroupHead> collectedGroups;
-            private readonly SortField[] fields;
+            private readonly GeneralAllGroupHeadsCollector outerInstance;
+            public readonly BytesRef groupValue;
 
-            private SortedDocValues[] sortsIndex;
-            private Scorer scorer;
-            private GroupHead[] segmentGroupHeads;
+            internal readonly FieldComparator[] comparators;
 
-            internal OrdScoreAllGroupHeadsCollector(/*TermAllGroupHeadsCollector<GH> outerInstance,*/ string groupField, Sort sortWithinGroup, int initialSize)
-                : base(groupField, sortWithinGroup.GetSort().Length)
+            internal GroupHead(GeneralAllGroupHeadsCollector outerInstance, BytesRef groupValue, Sort sort, int doc)
+                : base(doc + outerInstance.readerContext.DocBase)
             {
-                //this.outerInstance = outerInstance;
-                ordSet = new SentinelIntSet(initialSize, -2);
-                collectedGroups = new List<GroupHead>(initialSize);
+                this.outerInstance = outerInstance;
+                this.groupValue = groupValue;
 
-                SortField[] sortFields = sortWithinGroup.GetSort();
-                fields = new SortField[sortFields.Length];
-                sortsIndex = new SortedDocValues[sortFields.Length];
+                SortField[] sortFields = sort.GetSort();
+                comparators = new FieldComparator[sortFields.Length];
                 for (int i = 0; i < sortFields.Length; i++)
                 {
-                    reversed[i] = sortFields[i].Reverse ? -1 : 1;
-                    fields[i] = sortFields[i];
+                    comparators[i] = sortFields[i].GetComparator(1, i).SetNextReader(outerInstance.readerContext);
+                    comparators[i].Scorer = outerInstance.scorer;
+                    comparators[i].Copy(0, doc);
+                    comparators[i].Bottom = 0;
                 }
             }
 
-            protected override ICollection<GroupHead> GetCollectedGroupHeads()
+            public override int Compare(int compIDX, int doc)
             {
-                return collectedGroups;
+                return comparators[compIDX].CompareBottom(doc);
             }
 
-            public override Scorer Scorer
+            public override void UpdateDocHead(int doc)
             {
-                set
+                foreach (FieldComparator comparator in comparators)
                 {
-                    this.scorer = value;
+                    comparator.Copy(0, doc);
+                    comparator.Bottom = 0;
                 }
+                this.Doc = doc + outerInstance.readerContext.DocBase;
             }
+        }
+    }
+
 
+    // AbstractAllGroupHeadsCollector optimized for ord fields and scores.
+    internal class OrdScoreAllGroupHeadsCollector : TermAllGroupHeadsCollector<OrdScoreAllGroupHeadsCollector.GroupHead>
+    {
+        //private readonly TermAllGroupHeadsCollector<GH> outerInstance;
+        private readonly SentinelIntSet ordSet;
+        private readonly IList<GroupHead> collectedGroups;
+        private readonly SortField[] fields;
 
-            protected override void RetrieveGroupHeadAndAddIfNotExist(int doc)
+        private SortedDocValues[] sortsIndex;
+        private Scorer scorer;
+        private GroupHead[] segmentGroupHeads;
+
+        internal OrdScoreAllGroupHeadsCollector(/*TermAllGroupHeadsCollector<GH> outerInstance,*/ string groupField, Sort sortWithinGroup, int initialSize)
+            : base(groupField, sortWithinGroup.GetSort().Length)
+        {
+            //this.outerInstance = outerInstance;
+            ordSet = new SentinelIntSet(initialSize, -2);
+            collectedGroups = new List<GroupHead>(initialSize);
+
+            SortField[] sortFields = sortWithinGroup.GetSort();
+            fields = new SortField[sortFields.Length];
+            sortsIndex = new SortedDocValues[sortFields.Length];
+            for (int i = 0; i < sortFields.Length; i++)
             {
-                int key = groupIndex.GetOrd(doc);
-                GroupHead groupHead;
-                if (!ordSet.Exists(key))
+                reversed[i] = sortFields[i].Reverse ? -1 : 1;
+                fields[i] = sortFields[i];
+            }
+        }
+
+        protected override ICollection<GroupHead> GetCollectedGroupHeads()
+        {
+            return collectedGroups;
+        }
+
+        public override Scorer Scorer
+        {
+            set
+            {
+                this.scorer = value;
+            }
+        }
+
+
+        protected override void RetrieveGroupHeadAndAddIfNotExist(int doc)
+        {
+            int key = groupIndex.GetOrd(doc);
+            GroupHead groupHead;
+            if (!ordSet.Exists(key))
+            {
+                ordSet.Put(key);
+                BytesRef term;
+                if (key == -1)
                 {
-                    ordSet.Put(key);
-                    BytesRef term;
-                    if (key == -1)
-                    {
-                        term = null;
-                    }
-                    else
-                    {
-                        term = new BytesRef();
-                        groupIndex.LookupOrd(key, term);
-                    }
-                    groupHead = new GroupHead(this, doc, term);
-                    collectedGroups.Add(groupHead);
-                    segmentGroupHeads[key + 1] = groupHead;
-                    temporalResult.stop = true;
+                    term = null;
                 }
                 else
                 {
-                    temporalResult.stop = false;
-                    groupHead = segmentGroupHeads[key + 1];
+                    term = new BytesRef();
+                    groupIndex.LookupOrd(key, term);
                 }
-                temporalResult.groupHead = groupHead;
+                groupHead = new GroupHead(this, doc, term);
+                collectedGroups.Add(groupHead);
+                segmentGroupHeads[key + 1] = groupHead;
+                temporalResult.stop = true;
+            }
+            else
+            {
+                temporalResult.stop = false;
+                groupHead = segmentGroupHeads[key + 1];
             }
+            temporalResult.groupHead = groupHead;
+        }
 
-            public override AtomicReaderContext NextReader
+        public override AtomicReaderContext NextReader
+        {
+            set
             {
-                set
+                this.readerContext = value;
+                groupIndex = FieldCache.DEFAULT.GetTermsIndex(value.AtomicReader, groupField);
+                for (int i = 0; i < fields.Length; i++)
                 {
-                    this.readerContext = value;
-                    groupIndex = FieldCache.DEFAULT.GetTermsIndex(value.AtomicReader, groupField);
-                    for (int i = 0; i < fields.Length; i++)
+                    if (fields[i].Type == SortField.Type_e.SCORE)
                     {
-                        if (fields[i].Type == SortField.Type_e.SCORE)
-                        {
-                            continue;
-                        }
-
-                        sortsIndex[i] = FieldCache.DEFAULT.GetTermsIndex(value.AtomicReader, fields[i].Field);
+                        continue;
                     }
 
-                    // Clear ordSet and fill it with previous encountered groups that can occur in the current segment.
-                    ordSet.Clear();
-                    segmentGroupHeads = new GroupHead[groupIndex.ValueCount + 1];
-                    foreach (GroupHead collectedGroup in collectedGroups)
+                    sortsIndex[i] = FieldCache.DEFAULT.GetTermsIndex(value.AtomicReader, fields[i].Field);
+                }
+
+                // Clear ordSet and fill it with previous encountered groups that can occur in the current segment.
+                ordSet.Clear();
+                segmentGroupHeads = new GroupHead[groupIndex.ValueCount + 1];
+                foreach (GroupHead collectedGroup in collectedGroups)
+                {
+                    int ord;
+                    if (collectedGroup.groupValue == null)
                     {
-                        int ord;
-                        if (collectedGroup.groupValue == null)
-                        {
-                            ord = -1;
-                        }
-                        else
-                        {
-                            ord = groupIndex.LookupTerm(collectedGroup.groupValue);
-                        }
-                        if (collectedGroup.groupValue == null || ord >= 0)
-                        {
-                            ordSet.Put(ord);
-                            segmentGroupHeads[ord + 1] = collectedGroup;
+                        ord = -1;
+                    }
+                    else
+                    {
+                        ord = groupIndex.LookupTerm(collectedGroup.groupValue);
+                    }
+                    if (collectedGroup.groupValue == null || ord >= 0)
+                    {
+                        ordSet.Put(ord);
+                        segmentGroupHeads[ord + 1] = collectedGroup;
 
-                            for (int i = 0; i < sortsIndex.Length; i++)
+                        for (int i = 0; i < sortsIndex.Length; i++)
+                        {
+                            if (fields[i].Type == SortField.Type_e.SCORE)
+                            {
+                                continue;
+                            }
+                            int sortOrd;
+                            if (collectedGroup.sortValues[i] == null)
                             {
-                                if (fields[i].Type == SortField.Type_e.SCORE)
-                                {
-                                    continue;
-                                }
-                                int sortOrd;
-                                if (collectedGroup.sortValues[i] == null)
-                                {
-                                    sortOrd = -1;
-                                }
-                                else
-                                {
-                                    sortOrd = sortsIndex[i].LookupTerm(collectedGroup.sortValues[i]);
-                                }
-                                collectedGroup.sortOrds[i] = sortOrd;
+                                sortOrd = -1;
                             }
+                            else
+                            {
+                                sortOrd = sortsIndex[i].LookupTerm(collectedGroup.sortValues[i]);
+                            }
+                            collectedGroup.sortOrds[i] = sortOrd;
                         }
                     }
                 }
-
             }
 
-            internal class GroupHead : AbstractGroupHead /*AbstractAllGroupHeadsCollector.GroupHead<BytesRef>*/
-            {
-                private readonly OrdScoreAllGroupHeadsCollector outerInstance;
-                public readonly BytesRef groupValue;
+        }
+
+        internal class GroupHead : AbstractAllGroupHeadsCollector_GroupHead /*AbstractAllGroupHeadsCollector.GroupHead<BytesRef>*/
+        {
+            private readonly OrdScoreAllGroupHeadsCollector outerInstance;
+            public readonly BytesRef groupValue;
 
-                internal BytesRef[] sortValues;
-                internal int[] sortOrds;
-                internal float[] scores;
+            internal BytesRef[] sortValues;
+            internal int[] sortOrds;
+            internal float[] scores;
 
-                internal GroupHead(OrdScoreAllGroupHeadsCollector outerInstance, int doc, BytesRef groupValue)
-                    : base(doc + outerInstance.readerContext.DocBase)
-                {
-                    this.outerInstance = outerInstance;
-                    this.groupValue = groupValue;
+            internal GroupHead(OrdScoreAllGroupHeadsCollector outerInstance, int doc, BytesRef groupValue)
+                : base(doc + outerInstance.readerContext.DocBase)
+            {
+                this.outerInstance = outerInstance;
+                this.groupValue = groupValue;
 
-                    sortValues = new BytesRef[outerInstance.sortsIndex.Length];
-                    sortOrds = new int[outerInstance.sortsIndex.Length];
-                    scores = new float[outerInstance.sortsIndex.Length];
-                    for (int i = 0; i < outerInstance.sortsIndex.Length; i++)
+                sortValues = new BytesRef[outerInstance.sortsIndex.Length];
+                sortOrds = new int[outerInstance.sortsIndex.Length];
+                scores = new float[outerInstance.sortsIndex.Length];
+                for (int i = 0; i < outerInstance.sortsIndex.Length; i++)
+                {
+                    if (outerInstance.fields[i].Type == SortField.Type_e.SCORE)
                     {
-                        if (outerInstance.fields[i].Type == SortField.Type_e.SCORE)
-                        {
-                            scores[i] = outerInstance.scorer.Score();
-                        }
-                        else
+                        scores[i] = outerInstance.scorer.Score();
+                    }
+                    else
+                    {
+                        sortOrds[i] = outerInstance.sortsIndex[i].GetOrd(doc);
+                        sortValues[i] = new BytesRef();
+                        if (sortOrds[i] != -1)
                         {
-                            sortOrds[i] = outerInstance.sortsIndex[i].GetOrd(doc);
-                            sortValues[i] = new BytesRef();
-                            if (sortOrds[i] != -1)
-                            {
-                                outerInstance.sortsIndex[i].Get(doc, sortValues[i]);
-                            }
+                            outerInstance.sortsIndex[i].Get(doc, sortValues[i]);
                         }
                     }
                 }
+            }
 
-                public override int Compare(int compIDX, int doc)
+            public override int Compare(int compIDX, int doc)
+            {
+                if (outerInstance.fields[compIDX].Type == SortField.Type_e.SCORE)
                 {
-                    if (outerInstance.fields[compIDX].Type == SortField.Type_e.SCORE)
+                    float score = outerInstance.scorer.Score();
+                    if (scores[compIDX] < score)
                     {
-                        float score = outerInstance.scorer.Score();
-                        if (scores[compIDX] < score)
-                        {
-                            return 1;
-                        }
-                        else if (scores[compIDX] > score)
-                        {
-                            return -1;
-                        }
-                        return 0;
+                        return 1;
                     }
-                    else
+                    else if (scores[compIDX] > score)
+                    {
+                        return -1;
+                    }
+                    return 0;
+                }
+                else
+                {
+                    if (sortOrds[compIDX] < 0)
                     {
-                        if (sortOrds[compIDX] < 0)
+                        // The current segment doesn't contain the sort value we encountered before. Therefore the ord is negative.
+                        if (outerInstance.sortsIndex[compIDX].GetOrd(doc) == -1)
                         {
-                            // The current segment doesn't contain the sort value we encountered before. Therefore the ord is negative.
-                            if (outerInstance.sortsIndex[compIDX].GetOrd(doc) == -1)
-                            {
-                                outerInstance.scratchBytesRef.Length = 0;
-                            }
-                            else
-                            {
-                                outerInstance.sortsIndex[compIDX].Get(doc, outerInstance.scratchBytesRef);
-                            }
-                            return sortValues[compIDX].CompareTo(outerInstance.scratchBytesRef);
+                            outerInstance.scratchBytesRef.Length = 0;
                         }
                         else
                         {
-                            return sortOrds[compIDX] - outerInstance.sortsIndex[compIDX].GetOrd(doc);
+                            outerInstance.sortsIndex[compIDX].Get(doc, outerInstance.scratchBytesRef);
                         }
+                        return sortValues[compIDX].CompareTo(outerInstance.scratchBytesRef);
+                    }
+                    else
+                    {
+                        return sortOrds[compIDX] - outerInstance.sortsIndex[compIDX].GetOrd(doc);
                     }
                 }
+            }
 
-                public override void UpdateDocHead(int doc)
+            public override void UpdateDocHead(int doc)
+            {
+                for (int i = 0; i < outerInstance.sortsIndex.Length; i++)
                 {
-                    for (int i = 0; i < outerInstance.sortsIndex.Length; i++)
+                    if (outerInstance.fields[i].Type == Search.SortField.Type_e.SCORE)
                     {
-                        if (outerInstance.fields[i].Type == Search.SortField.Type_e.SCORE)
+                        scores[i] = outerInstance.scorer.Score();
+                    }
+                    else
+                    {
+                        sortOrds[i] = outerInstance.sortsIndex[i].GetOrd(doc);
+                        if (sortOrds[i] == -1)
                         {
-                            scores[i] = outerInstance.scorer.Score();
+                            sortValues[i].Length = 0;
                         }
                         else
                         {
-                            sortOrds[i] = outerInstance.sortsIndex[i].GetOrd(doc);
-                            if (sortOrds[i] == -1)
-                            {
-                                sortValues[i].Length = 0;
-                            }
-                            else
-                            {
-                                outerInstance.sortsIndex[i].Get(doc, sortValues[i]);
-                            }
+                            outerInstance.sortsIndex[i].Get(doc, sortValues[i]);
                         }
                     }
-                    this.Doc = doc + outerInstance.readerContext.DocBase;
                 }
+                this.Doc = doc + outerInstance.readerContext.DocBase;
             }
         }
+    }
 
 
-        // AbstractAllGroupHeadsCollector optimized for ord fields.
-        internal class OrdAllGroupHeadsCollector : TermAllGroupHeadsCollector<OrdAllGroupHeadsCollector.GroupHead>
-        {
-            //private readonly TermAllGroupHeadsCollector<GH> outerInstance;
-            private readonly SentinelIntSet ordSet;
-            private readonly IList<GroupHead> collectedGroups;
-            private readonly SortField[] fields;
+    // AbstractAllGroupHeadsCollector optimized for ord fields.
+    internal class OrdAllGroupHeadsCollector : TermAllGroupHeadsCollector<OrdAllGroupHeadsCollector.GroupHead>
+    {
+        //private readonly TermAllGroupHeadsCollector<GH> outerInstance;
+        private readonly SentinelIntSet ordSet;
+        private readonly IList<GroupHead> collectedGroups;
+        private readonly SortField[] fields;
 
-            private SortedDocValues[] sortsIndex;
-            private GroupHead[] segmentGroupHeads;
+        private SortedDocValues[] sortsIndex;
+        private GroupHead[] segmentGroupHeads;
 
-            internal OrdAllGroupHeadsCollector(/*TermAllGroupHeadsCollector<GH> outerInstance,*/ string groupField, Sort sortWithinGroup, int initialSize)
-                        : base(groupField, sortWithinGroup.GetSort().Length)
+        internal OrdAllGroupHeadsCollector(/*TermAllGroupHeadsCollector<GH> outerInstance,*/ string groupField, Sort sortWithinGroup, int initialSize)
+                    : base(groupField, sortWithinGroup.GetSort().Length)
+        {
+            //this.outerInstance = outerInstance;
+            ordSet = new SentinelIntSet(initialSize, -2);
+            collectedGroups = new List<GroupHead>(initialSize);
+
+            SortField[] sortFields = sortWithinGroup.GetSort();
+            fields = new SortField[sortFields.Length];
+            sortsIndex = new SortedDocValues[sortFields.Length];
+            for (int i = 0; i < sortFields.Length; i++)
             {
-                //this.outerInstance = outerInstance;
-                ordSet = new SentinelIntSet(initialSize, -2);
-                collectedGroups = new List<GroupHead>(initialSize);
-
-                SortField[] sortFields = sortWithinGroup.GetSort();
-                fields = new SortField[sortFields.Length];
-                sortsIndex = new SortedDocValues[sortFields.Length];
-                for (int i = 0; i < sortFields.Length; i++)
-                {
-                    reversed[i] = sortFields[i].Reverse ? -1 : 1;
-                    fields[i] = sortFields[i];
-                }
+                reversed[i] = sortFields[i].Reverse ? -1 : 1;
+                fields[i] = sortFields[i];
             }
+        }
 
-            protected override ICollection<GroupHead> GetCollectedGroupHeads()
-            {
-                return collectedGroups;
-            }
+        protected override ICollection<GroupHead> GetCollectedGroupHeads()
+        {
+            return collectedGroups;
+        }
 
-            public override Scorer Scorer
+        public override Scorer Scorer
+        {
+            set
             {
-                set
-                {
-                }
             }
+        }
 
 
-            protected override void RetrieveGroupHeadAndAddIfNotExist(int doc)
+        protected override void RetrieveGroupHeadAndAddIfNotExist(int doc)
+        {
+            int key = groupIndex.GetOrd(doc);
+            GroupHead groupHead;
+            if (!ordSet.Exists(key))
             {
-                int key = groupIndex.GetOrd(doc);
-                GroupHead groupHead;
-                if (!ordSet.Exists(key))
+                ordSet.Put(key);
+                BytesRef term;
+                if (key == -1)
                 {
-                    ordSet.Put(key);
-                    BytesRef term;
-                    if (key == -1)
-                    {
-                        term = null;
-                    }
-                    else
-                    {
-                        term = new BytesRef();
-                        groupIndex.LookupOrd(key, term);
-                    }
-                    groupHead = new GroupHead(this, doc, term);
-                    collectedGroups.Add(groupHead);
-                    segmentGroupHeads[key + 1] = groupHead;
-                    temporalResult.stop = true;
+                    term = null;
                 }
                 else
                 {
-                    temporalResult.stop = false;
-                    groupHead = segmentGroupHeads[key + 1];
+                    term = new BytesRef();
+                    groupIndex.LookupOrd(key, term);
                 }
-                temporalResult.groupHead = groupHead;
+                groupHead = new GroupHead(this, doc, term);
+                collectedGroups.Add(groupHead);
+                segmentGroupHeads[key + 1] = groupHead;
+                temporalResult.stop = true;
             }
+            else
+            {
+                temporalResult.stop = false;
+                groupHead = segmentGroupHeads[key + 1];
+            }
+            temporalResult.groupHead = groupHead;
+        }
 
-            public override AtomicReaderContext NextReader
+        public override AtomicReaderContext NextReader
+        {
+            set
             {
-                set
+                this.readerContext = value;
+                groupIndex = FieldCache.DEFAULT.GetTermsIndex(value.AtomicReader, groupField);
+                for (int i = 0; i < fields.Length; i++)
+                {
+                    sortsIndex[i] = FieldCache.DEFAULT.GetTermsIndex(value.AtomicReader, fields[i].Field);
+                }
+
+                // Clear ordSet and fill it with previous encountered groups that can occur in the current segment.
+                ordSet.Clear();
+                segmentGroupHeads = new GroupHead[groupIndex.ValueCount + 1];
+                foreach (GroupHead collectedGroup in collectedGroups)
                 {
-                    this.readerContext = value;
-                    groupIndex = FieldCache.DEFAULT.GetTermsIndex(value.AtomicReader, groupField);
-                    for (int i = 0; i < fields.Length; i++)
+                    int groupOrd;
+                    if (collectedGroup.groupValue == null)
                     {
-                        sortsIndex[i] = FieldCache.DEFAULT.GetTermsIndex(value.AtomicReader, fields[i].Field);
+                        groupOrd = -1;
                     }
-
-                    // Clear ordSet and fill it with previous encountered groups that can occur in the current segment.
-                    ordSet.Clear();
-                    segmentGroupHeads = new GroupHead[groupIndex.ValueCount + 1];
-                    foreach (GroupHead collectedGroup in collectedGroups)
+                    else
                     {
-                        int groupOrd;
-                        if (collectedGroup.groupValue == null)
-                        {
-                            groupOrd = -1;
-                        }
-                        else
-                        {
-                            groupOrd = groupIndex.LookupTerm(collectedGroup.groupValue);
-                        }
-                        if (collectedGroup.groupValue == null || groupOrd >= 0)
-                        {
-                            ordSet.Put(groupOrd);
-                            segmentGroupHeads[groupOrd + 1] = collectedGroup;
+                        groupOrd = groupIndex.LookupTerm(collectedGroup.groupValue);
+                    }
+                    if (collectedGroup.groupValue == null || groupOrd >= 0)
+                    {
+                        ordSet.Put(groupOrd);
+                        segmentGroupHeads[groupOrd + 1] = collectedGroup;
 
-                            for (int i = 0; i < sortsIndex.Length; i++)
+                        for (int i = 0; i < sortsIndex.Length; i++)
+                        {
+                            int sortOrd;
+                            if (collectedGroup.sortOrds[i] == -1)
                             {
-                                int sortOrd;
-                                if (collectedGroup.sortOrds[i] == -1)
-                                {
-                                    sortOrd = -1;
-                                }
-                                else
-                                {
-                                    sortOrd = sortsIndex[i].LookupTerm(collectedGroup.sortValues[i]);
-                                }
-                                collectedGroup.sortOrds[i] = sortOrd;
+                                sortOrd = -1;
                             }
+                            else
+                            {
+                                sortOrd = sortsIndex[i].LookupTerm(collectedGroup.sortValues[i]);
+                            }
+                            collectedGroup.sortOrds[i] = sortOrd;
                         }
                     }
                 }
             }
+        }
 
-            internal class GroupHead : AbstractGroupHead /* AbstractAllGroupHeadsCollector.GroupHead<BytesRef>*/
+        internal class GroupHead : AbstractAllGroupHeadsCollector_GroupHead /* AbstractAllGroupHeadsCollector.GroupHead<BytesRef>*/
+        {
+            private readonly OrdAllGroupHeadsCollector outerInstance;
+            public readonly BytesRef groupValue;
+            internal BytesRef[] sortValues;
+            internal int[] sortOrds;
+
+            internal GroupHead(OrdAllGroupHeadsCollector outerInstance, int doc, BytesRef groupValue)
+                : base(doc + outerInstance.readerContext.DocBase)
             {
-                private readonly OrdAllGroupHeadsCollector outerInstance;
-                public readonly BytesRef groupValue;
-                internal BytesRef[] sortValues;
-                internal int[] sortOrds;
+                this.outerInstance = outerInstance;
+                this.groupValue = groupValue;
 
-                internal GroupHead(OrdAllGroupHeadsCollector outerInstance, int doc, BytesRef groupValue)
-                    : base(doc + outerInstance.readerContext.DocBase)
+                sortValues = new BytesRef[outerInstance.sortsIndex.Length];
+                sortOrds = new int[outerInstance.sortsIndex.Length];
+                for (int i = 0; i < outerInstance.sortsIndex.Length; i++)
                 {
-                    this.outerInstance = outerInstance;
-                    this.groupValue = groupValue;
-
-                    sortValues = new BytesRef[outerInstance.sortsIndex.Length];
-                    sortOrds = new int[outerInstance.sortsIndex.Length];
-                    for (int i = 0; i < outerInstance.sortsIndex.Length; i++)
+                    sortOrds[i] = outerInstance.sortsIndex[i].GetOrd(doc);
+                    sortValues[i] = new BytesRef();
+                    if (sortOrds[i] != -1)
                     {
-                        sortOrds[i] = outerInstance.sortsIndex[i].GetOrd(doc);
-                        sortValues[i] = new BytesRef();
-                        if (sortOrds[i] != -1)
-                        {
-                            outerInstance.sortsIndex[i].Get(doc, sortValues[i]);
-                        }
+                        outerInstance.sortsIndex[i].Get(doc, sortValues[i]);
                     }
                 }
+            }
 
-                public override int Compare(int compIDX, int doc)
+            public override int Compare(int compIDX, int doc)
+            {
+                if (sortOrds[compIDX] < 0)
                 {
-                    if (sortOrds[compIDX] < 0)
+                    // The current segment doesn't contain the sort value we encountered before. Therefore the ord is negative.
+                    if (outerInstance.sortsIndex[compIDX].GetOrd(doc) == -1)
                     {
-                        // The current segment doesn't contain the sort value we encountered before. Therefore the ord is negative.
-                        if (outerInstance.sortsIndex[compIDX].GetOrd(doc) == -1)
-                        {
-                            outerInstance.scratchBytesRef.Length = 0;
-                        }
-                        else
-                        {
-                            outerInstance.sortsIndex[compIDX].Get(doc, outerInstance.scratchBytesRef);
-                        }
-                        return sortValues[compIDX].CompareTo(outerInstance.scratchBytesRef);
+                        outerInstance.scratchBytesRef.Length = 0;
                     }
                     else
                     {
-                        return sortOrds[compIDX] - outerInstance.sortsIndex[compIDX].GetOrd(doc);
+                        outerInstance.sortsIndex[compIDX].Get(doc, outerInstance.scratchBytesRef);
                     }
+                    return sortValues[compIDX].CompareTo(outerInstance.scratchBytesRef);
+                }
+                else
+                {
+                    return sortOrds[compIDX] - outerInstance.sortsIndex[compIDX].GetOrd(doc);
                 }
+            }
 
-                public override void UpdateDocHead(int doc)
+            public override void UpdateDocHead(int doc)
+            {
+                for (int i = 0; i < outerInstance.sortsIndex.Length; i++)
                 {
-                    for (int i = 0; i < outerInstance.sortsIndex.Length; i++)
+                    sortOrds[i] = outerInstance.sortsIndex[i].GetOrd(doc);
+                    if (sortOrds[i] == -1)
                     {
-                        sortOrds[i] = outerInstance.sortsIndex[i].GetOrd(doc);
-                        if (sortOrds[i] == -1)
-                        {
-                            sortValues[i].Length = 0;
-                        }
-                        else
-                        {
-                            outerInstance.sortsIndex[i].LookupOrd(sortOrds[i], sortValues[i]);
-                        }
+                        sortValues[i].Length = 0;
+                    }
+                    else
+                    {
+                        outerInstance.sortsIndex[i].LookupOrd(sortOrds[i], sortValues[i]);
                     }
-                    this.Doc = doc + outerInstance.readerContext.DocBase;
                 }
-
+                this.Doc = doc + outerInstance.readerContext.DocBase;
             }
 
         }
 
+    }
 
-        // AbstractAllGroupHeadsCollector optimized for scores.
-        internal class ScoreAllGroupHeadsCollector : TermAllGroupHeadsCollector<ScoreAllGroupHeadsCollector.GroupHead>
-        {
-            //private readonly TermAllGroupHeadsCollector<GH> outerInstance;
-            private readonly SentinelIntSet ordSet;
-            private readonly IList<GroupHead> collectedGroups;
-            private readonly SortField[] fields;
 
-            private Scorer scorer;
-            private GroupHead[] segmentGroupHeads;
+    // AbstractAllGroupHeadsCollector optimized for scores.
+    internal class ScoreAllGroupHeadsCollector : TermAllGroupHeadsCollector<ScoreAllGroupHeadsCollector.GroupHead>
+    {
+        //private readonly TermAllGroupHeadsCollector<GH> outerInstance;
+        private readonly SentinelIntSet ordSet;
+        private readonly IList<GroupHead> collectedGroups;
+        private readonly SortField[] fields;
 
-            internal ScoreAllGroupHeadsCollector(/*TermAllGroupHeadsCollector<GH> outerInstance,*/ string groupField, Sort sortWithinGroup, int initialSize)
-                        : base(groupField, sortWithinGroup.GetSort().Length)
-            {
-                //this.outerInstance = outerInstance;
-                ordSet = new SentinelIntSet(initialSize, -2);
-                collectedGroups = new List<GroupHead>(initialSize);
+        private Scorer scorer;
+        private GroupHead[] segmentGroupHeads;
 
-                SortField[] sortFields = sortWithinGroup.GetSort();
-                fields = new SortField[sortFields.Length];
-                for (int i = 0; i < sortFields.Length; i++)
-                {
-                    reversed[i] = sortFields[i].Reverse ? -1 : 1;
-                    fields[i] = sortFields[i];
-                }
-            }
+        internal ScoreAllGroupHeadsCollector(/*TermAllGroupHeadsCollector<GH> outerInstance,*/ string groupField, Sort sortWithinGroup, int initialSize)
+                    : base(groupField, sortWithinGroup.GetSort().Length)
+        {
+            //this.outerInstance = outerInstance;
+            ordSet = new SentinelIntSet(initialSize, -2);
+            collectedGroups = new List<GroupHead>(initialSize);
 
-            protected override ICollection<GroupHead> GetCollectedGroupHeads()
+            SortField[] sortFields = sortWithinGroup.GetSort();
+            fields = new SortField[sortFields.Length];
+            for (int i = 0; i < sortFields.Length; i++)
             {
-                return collectedGroups;
+                reversed[i] = sortFields[i].Reverse ? -1 : 1;
+                fields[i] = sortFields[i];
             }
+        }
 
-            public override Scorer Scorer
+        protected override ICollection<GroupHead> GetCollectedGroupHeads()
+        {
+            return collectedGroups;
+        }
+
+        public override Scorer Scorer
+        {
+            set
             {
-                set
-                {
-                    this.scorer = value;
-                }
+                this.scorer = value;
             }
+        }
 
-            protected override void RetrieveGroupHeadAndAddIfNotExist(int doc)
+        protected override void RetrieveGroupHeadAndAddIfNotExist(int doc)
+        {
+            int key = groupIndex.GetOrd(doc);
+            GroupHead groupHead;
+            if (!ordSet.Exists(key))
             {
-                int key = groupIndex.GetOrd(doc);
-                GroupHead groupHead;
-                if (!ordSet.Exists(key))
+                ordSet.Put(key);
+                BytesRef term;
+                if (key == -1)
                 {
-                    ordSet.Put(key);
-                    BytesRef term;
-                    if (key == -1)
-                    {
-                        term = null;
-                    }
-                    else
-                    {
-                        term = new BytesRef();
-                        groupIndex.LookupOrd(key, term);
-                    }
-                    groupHead = new GroupHead(this, doc, term);
-                    collectedGroups.Add(groupHead);
-                    segmentGroupHeads[key + 1] = groupHead;
-                    temporalResult.stop = true;
+                    term = null;
                 }
                 else
                 {
-                    temporalResult.stop = false;
-                    groupHead = segmentGroupHeads[key + 1];
+                    term = new BytesRef();
+                    groupIndex.LookupOrd(key, term);
                 }
-                temporalResult.groupHead = groupHead;
+                groupHead = new GroupHead(this, doc, term);
+                collectedGroups.Add(groupHead);
+                segmentGroupHeads[key + 1] = groupHead;
+                temporalResult.stop = true;
             }
-            public override AtomicReaderContext NextReader
+            else
             {
-                set
-                {
-                    this.readerContext = value;
-                    groupIndex = FieldCache.DEFAULT.GetTermsIndex(value.AtomicReader, groupField);
-
-                    // Clear ordSet and fill it with previous encountered groups that can occur in the current segment.
-                    ordSet.Clear();
-                    segmentGroupHeads = new GroupHead[groupIndex.ValueCount + 1];
-                    foreach (GroupHead collectedGroup in collectedGroups)
-                    {
-                        int ord;
-                        if (collectedGroup.groupValue == null)
-                        {
-                            ord = -1;
-                        }
-                        else
-                        {
-                            ord = groupIndex.LookupTerm(collectedGroup.groupValue);
-                        }
-                        if (collectedGroup.groupValue == null || ord >= 0)
-                        {
-                            ordSet.Put(ord);
-                            segmentGroupHeads[ord + 1] = collectedGroup;
-                        }
-                    }
-                }
+                temporalResult.stop = false;
+                groupHead = segmentGroupHeads[key + 1];
             }
-
-            internal class GroupHead : AbstractGroupHead /*AbstractAllGroupHeadsCollector.GroupHead<BytesRef>*/
+            temporalResult.groupHead = groupHead;
+        }
+        public override AtomicReaderContext NextReader
+        {
+            set
             {
-                private readonly ScoreAllGroupHeadsCollector outerInstance;
-                public readonly BytesRef groupValue;
-                internal float[] scores;
+                this.readerContext = value;
+                groupIndex = FieldCache.DEFAULT.GetTermsIndex(value.AtomicReader, groupField);
 
-                internal GroupHead(ScoreAllGroupHeadsCollector outerInstance, int doc, BytesRef groupValue)
-                    : base(doc + outerInstance.readerContext.DocBase)
+                // Clear ordSet and fill it with previous encountered groups that can occur in the current segment.
+                ordSet.Clear();
+                segmentGroupHeads = new GroupHead[groupIndex.ValueCount + 1];
+                foreach (GroupHead collectedGroup in collectedGroups)
                 {
-                    this.outerInstance = outerInstance;
-                    this.groupValue = groupValue;
-
-                    scores = new float[outerInstance.fields.Length];
-                    float score = outerInstance.scorer.Score();
-                    for (int i = 0; i < scores.Length; i++)
+                    int ord;
+                    if (collectedGroup.groupValue == null)
                     {
-                        scores[i] = score;
+                        ord = -1;
                     }
-                }
-
-                public override int Compare(int compIDX, int doc)
-                {
-                    float score = outerInstance.scorer.Score();
-                    if (scores[compIDX] < score)
+                    else
                     {
-                        return 1;
+                        ord = groupIndex.LookupTerm(collectedGroup.groupValue);
                     }
-                    else if (scores[compIDX] > score)
+                    if (collectedGroup.groupValue == null || ord >= 0)
                     {
-                        return -1;
+                        ordSet.Put(ord);
+                        segmentGroupHeads[ord + 1] = collectedGroup;
                     }
-                    return 0;
                 }
+            }
+        }
+
+        internal class GroupHead : AbstractAllGroupHeadsCollector_GroupHead /*AbstractAllGroupHeadsCollector.GroupHead<BytesRef>*/
+        {
+            private readonly ScoreAllGroupHeadsCollector outerInstance;
+            public readonly BytesRef groupValue;
+            internal float[] scores;
+
+            internal GroupHead(ScoreAllGroupHeadsCollector outerInstance, int doc, BytesRef groupValue)
+                : base(doc + outerInstance.readerContext.DocBase)
+            {
+                this.outerInstance = outerInstance;
+                this.groupValue = groupValue;
 
-                public override void UpdateDocHead(int doc)
+                scores = new float[outerInstance.fields.Length];
+                float score = outerInstance.scorer.Score();
+                for (int i = 0; i < scores.Length; i++)
                 {
-                    float score = outerInstance.scorer.Score();
-                    for (int i = 0; i < scores.Length; i++)
-                    {
-                        scores[i] = score;
-                    }
-                    this.Doc = doc + outerInstance.readerContext.DocBase;
+                    scores[i] = score;
                 }
-
             }
 
-        
+            public override int Compare(int compIDX, int doc)
+            {
+                float score = outerInstance.scorer.Score();
+                if (scores[compIDX] < score)
+                {
+                    return 1;
+                }
+                else if (scores[compIDX] > score)
+                {
+                    return -1;
+                }
+                return 0;
+            }
 
+            public override void UpdateDocHead(int doc)
+            {
+                float score = outerInstance.scorer.Score();
+                for (int i = 0; i < scores.Length; i++)
+                {
+                    scores[i] = score;
+                }
+                this.Doc = doc + outerInstance.readerContext.DocBase;
+            }
 
+        }
     }
 }


Mime
View raw message