lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [5/5] lucenenet git commit: Lucene.Net.Core.Search.FieldComparer refactor: Changed Value(int) to this[int]
Date Thu, 26 Jan 2017 05:28:11 GMT
Lucene.Net.Core.Search.FieldComparer refactor: Changed Value(int) to this[int]


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

Branch: refs/heads/api-work
Commit: 53ab67133ed621f33fe3bc4b86983853108cb375
Parents: 715372a
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Thu Jan 26 12:24:08 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Thu Jan 26 12:24:08 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Core/Search/FieldComparator.cs   | 43 ++++++++++----------
 .../Search/FieldValueHitQueue.cs                |  2 +-
 .../ExpressionComparator.cs                     |  5 ++-
 .../AbstractFirstPassGroupingCollector.cs       |  2 +-
 .../BlockGroupingCollector.cs                   |  2 +-
 .../ToParentBlockJoinCollector.cs               |  2 +-
 .../ToParentBlockJoinFieldComparator.cs         |  5 ++-
 .../Index/Sorter/BlockJoinComparatorSource.cs   | 10 +++--
 src/Lucene.Net.Queries/Function/ValueSource.cs  |  5 ++-
 .../core/Search/JustCompileSearch.cs            |  5 ++-
 .../core/Search/TestElevationComparator.cs      |  5 ++-
 11 files changed, 48 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/53ab6713/src/Lucene.Net.Core/Search/FieldComparator.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/FieldComparator.cs b/src/Lucene.Net.Core/Search/FieldComparator.cs
index f40d95e..0019688 100644
--- a/src/Lucene.Net.Core/Search/FieldComparator.cs
+++ b/src/Lucene.Net.Core/Search/FieldComparator.cs
@@ -311,10 +311,11 @@ namespace Lucene.Net.Search
 
         /// <summary>
         /// Return the actual value in the slot.
+        /// LUCENENET NOTE: This was value(int) in Lucene.
         /// </summary>
         /// <param name="slot"> the value </param>
         /// <returns> value in this slot </returns>
-        public abstract IComparable Value(int slot); // LUCENENET TODO: Change to this[int
slot] ? or GetValue(int slot) ?
+        public abstract IComparable this[int slot] { get; }
 
         /// <summary>
         /// Base FieldComparer class for numeric types
@@ -420,9 +421,9 @@ namespace Lucene.Net.Search
                 topValue = (sbyte)value;
             }
 
-            public override IComparable Value(int slot)
+            public override IComparable this[int slot]
             {
-                return values[slot];
+                get { return values[slot]; }
             }
 
             public override int CompareTop(int doc)
@@ -507,9 +508,9 @@ namespace Lucene.Net.Search
                 topValue = (double)value;
             }
 
-            public override IComparable Value(int slot)
+            public override IComparable this[int slot]
             {
-                return values[slot];
+                get { return values[slot]; }
             }
 
             public override int CompareTop(int doc)
@@ -595,9 +596,9 @@ namespace Lucene.Net.Search
                 topValue = (float)value;
             }
 
-            public override IComparable Value(int slot)
+            public override IComparable this[int slot]
             {
-                return values[slot];
+                get { return values[slot]; }
             }
 
             public override int CompareTop(int doc)
@@ -685,9 +686,9 @@ namespace Lucene.Net.Search
                 topValue = (short)value;
             }
 
-            public override IComparable Value(int slot)
+            public override IComparable this[int slot]
             {
-                return values[slot];
+                get { return values[slot]; }
             }
 
             public override int CompareTop(int doc)
@@ -771,9 +772,9 @@ namespace Lucene.Net.Search
                 topValue = (int)value;
             }
 
-            public override IComparable Value(int slot)
+            public override IComparable this[int slot]
             {
-                return values[slot];
+                get { return values[slot]; }
             }
 
             public override int CompareTop(int doc)
@@ -860,9 +861,9 @@ namespace Lucene.Net.Search
                 topValue = (long)value;
             }
 
-            public override IComparable Value(int slot)
+            public override IComparable this[int slot]
             {
-                return values[slot];
+                get { return values[slot]; }
             }
 
             public override int CompareTop(int doc)
@@ -946,9 +947,9 @@ namespace Lucene.Net.Search
                 }
             }
 
-            public override IComparable Value(int slot)
+            public override IComparable this[int slot]
             {
-                return Convert.ToSingle(scores[slot]);
+                get { return Convert.ToSingle(scores[slot]); }
             }
 
             // Override because we sort reverse of natural Float order:
@@ -1017,9 +1018,9 @@ namespace Lucene.Net.Search
                 topValue = (int)value;
             }
 
-            public override IComparable Value(int slot)
+            public override IComparable this[int slot]
             {
-                return Convert.ToInt32(docIDs[slot]);
+                get { return Convert.ToInt32(docIDs[slot]); }
             }
 
             public override int CompareTop(int doc)
@@ -1297,9 +1298,9 @@ namespace Lucene.Net.Search
                 //System.out.println("setTopValue " + topValue);
             }
 
-            public override IComparable Value(int slot)
+            public override IComparable this[int slot]
             {
-                return values[slot];
+                get { return values[slot]; }
             }
 
             public override int CompareTop(int doc)
@@ -1437,9 +1438,9 @@ namespace Lucene.Net.Search
                 topValue = (BytesRef)value;
             }
 
-            public override IComparable Value(int slot)
+            public override IComparable this[int slot]
             {
-                return values[slot];
+                get { return values[slot]; }
             }
 
             public override int CompareValues(BytesRef val1, BytesRef val2)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/53ab6713/src/Lucene.Net.Core/Search/FieldValueHitQueue.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/FieldValueHitQueue.cs b/src/Lucene.Net.Core/Search/FieldValueHitQueue.cs
index ca30b89..c01d2b8 100644
--- a/src/Lucene.Net.Core/Search/FieldValueHitQueue.cs
+++ b/src/Lucene.Net.Core/Search/FieldValueHitQueue.cs
@@ -244,7 +244,7 @@ namespace Lucene.Net.Search
             IComparable[] fields = new IComparable[n];
             for (int i = 0; i < n; ++i)
             {
-                fields[i] = m_comparers[i].Value(entry.Slot);
+                fields[i] = m_comparers[i][entry.Slot];
             }
             //if (maxscore > 1.0f) doc.score /= maxscore;   // normalize scores
             return new FieldDoc(entry.Doc, entry.Score, fields);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/53ab6713/src/Lucene.Net.Expressions/ExpressionComparator.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Expressions/ExpressionComparator.cs b/src/Lucene.Net.Expressions/ExpressionComparator.cs
index 24abae4..cae906b 100644
--- a/src/Lucene.Net.Expressions/ExpressionComparator.cs
+++ b/src/Lucene.Net.Expressions/ExpressionComparator.cs
@@ -77,9 +77,10 @@ namespace Lucene.Net.Expressions
             return this;
         }
 
-        public override IComparable Value(int slot)
+        // LUCENENET NOTE: This was value(int) in Lucene.
+        public override IComparable this[int slot]
         {
-            return (values[slot]);
+            get { return values[slot]; }
         }
 
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/53ab6713/src/Lucene.Net.Grouping/AbstractFirstPassGroupingCollector.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Grouping/AbstractFirstPassGroupingCollector.cs b/src/Lucene.Net.Grouping/AbstractFirstPassGroupingCollector.cs
index 0a2b7ed..750177d 100644
--- a/src/Lucene.Net.Grouping/AbstractFirstPassGroupingCollector.cs
+++ b/src/Lucene.Net.Grouping/AbstractFirstPassGroupingCollector.cs
@@ -140,7 +140,7 @@ namespace Lucene.Net.Search.Grouping
                     searchGroup.SortValues = new object[sortFieldCount];
                     for (int sortFieldIDX = 0; sortFieldIDX < sortFieldCount; sortFieldIDX++)
                     {
-                        searchGroup.SortValues[sortFieldIDX] = comparers[sortFieldIDX].Value(group.ComparerSlot);
+                        searchGroup.SortValues[sortFieldIDX] = comparers[sortFieldIDX][group.ComparerSlot];
                     }
                 }
                 result.Add(searchGroup);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/53ab6713/src/Lucene.Net.Grouping/BlockGroupingCollector.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Grouping/BlockGroupingCollector.cs b/src/Lucene.Net.Grouping/BlockGroupingCollector.cs
index e522e41..165f386 100644
--- a/src/Lucene.Net.Grouping/BlockGroupingCollector.cs
+++ b/src/Lucene.Net.Grouping/BlockGroupingCollector.cs
@@ -448,7 +448,7 @@ namespace Lucene.Net.Search.Grouping
                     groupSortValues = new IComparable[comparers.Length];
                     for (int sortFieldIDX = 0; sortFieldIDX < comparers.Length; sortFieldIDX++)
                     {
-                        groupSortValues[sortFieldIDX] = comparers[sortFieldIDX].Value(og.comparerSlot);
+                        groupSortValues[sortFieldIDX] = comparers[sortFieldIDX][og.comparerSlot];
                     }
                 }
                 else

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/53ab6713/src/Lucene.Net.Join/ToParentBlockJoinCollector.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Join/ToParentBlockJoinCollector.cs b/src/Lucene.Net.Join/ToParentBlockJoinCollector.cs
index cbae9ab..46a0e54 100644
--- a/src/Lucene.Net.Join/ToParentBlockJoinCollector.cs
+++ b/src/Lucene.Net.Join/ToParentBlockJoinCollector.cs
@@ -514,7 +514,7 @@ namespace Lucene.Net.Join
                     groupSortValues = new object[comparers.Length];
                     for (int sortFieldIdx = 0; sortFieldIdx < comparers.Length; sortFieldIdx++)
                     {
-                        groupSortValues[sortFieldIdx] = comparers[sortFieldIdx].Value(og.Slot);
+                        groupSortValues[sortFieldIdx] = comparers[sortFieldIdx][og.Slot];
                     }
                 }
                 else

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/53ab6713/src/Lucene.Net.Join/ToParentBlockJoinFieldComparator.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Join/ToParentBlockJoinFieldComparator.cs b/src/Lucene.Net.Join/ToParentBlockJoinFieldComparator.cs
index cdc0f36..5b9d91f 100644
--- a/src/Lucene.Net.Join/ToParentBlockJoinFieldComparator.cs
+++ b/src/Lucene.Net.Join/ToParentBlockJoinFieldComparator.cs
@@ -112,9 +112,10 @@ namespace Lucene.Net.Join
             return set;
         }
 
-        public override IComparable Value(int slot)
+        // LUCENENET NOTE: This was value(int) in Lucene.
+        public override IComparable this[int slot]
         {
-            return _wrappedComparer.Value(slot);
+            get { return _wrappedComparer[slot]; }
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/53ab6713/src/Lucene.Net.Misc/Index/Sorter/BlockJoinComparatorSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Misc/Index/Sorter/BlockJoinComparatorSource.cs b/src/Lucene.Net.Misc/Index/Sorter/BlockJoinComparatorSource.cs
index 8e299cf..d2f0fbc 100644
--- a/src/Lucene.Net.Misc/Index/Sorter/BlockJoinComparatorSource.cs
+++ b/src/Lucene.Net.Misc/Index/Sorter/BlockJoinComparatorSource.cs
@@ -192,10 +192,14 @@ namespace Lucene.Net.Index.Sorter
                 return this;
             }
 
-            public override IComparable Value(int slot)
+            // LUCENENET NOTE: This was value(int) in Lucene.
+            public override IComparable this[int slot]
             {
-                // really our sort "value" is more complex...
-                throw new System.NotSupportedException("filling sort field values is not
yet supported");
+                get
+                {
+                    // really our sort "value" is more complex...
+                    throw new System.NotSupportedException("filling sort field values is
not yet supported");
+                }
             }
 
             public override void SetScorer(Scorer scorer)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/53ab6713/src/Lucene.Net.Queries/Function/ValueSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSource.cs
index f42d71c..55f737d 100644
--- a/src/Lucene.Net.Queries/Function/ValueSource.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSource.cs
@@ -183,9 +183,10 @@ namespace Lucene.Net.Queries.Function
                 this.topValue = (double)value;
             }
 
-            public override IComparable Value(int slot)
+            // LUCENENET NOTE: This was value(int) in Lucene.
+            public override IComparable this[int slot]
             {
-                return values[slot];
+                get { return values[slot]; }
             }
 
             public override int CompareTop(int doc)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/53ab6713/src/Lucene.Net.Tests/core/Search/JustCompileSearch.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Search/JustCompileSearch.cs b/src/Lucene.Net.Tests/core/Search/JustCompileSearch.cs
index 8d2eb86..c610709 100644
--- a/src/Lucene.Net.Tests/core/Search/JustCompileSearch.cs
+++ b/src/Lucene.Net.Tests/core/Search/JustCompileSearch.cs
@@ -152,9 +152,10 @@ namespace Lucene.Net.Search
                 throw new System.NotSupportedException(UNSUPPORTED_MSG);
             }
 
-            public override IComparable Value(int slot)
+            // LUCENENET NOTE: This was value(int) in Lucene.
+            public override IComparable this[int slot]
             {
-                throw new System.NotSupportedException(UNSUPPORTED_MSG);
+                get { throw new System.NotSupportedException(UNSUPPORTED_MSG); }
             }
 
             public override int CompareTop(int doc)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/53ab6713/src/Lucene.Net.Tests/core/Search/TestElevationComparator.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Search/TestElevationComparator.cs b/src/Lucene.Net.Tests/core/Search/TestElevationComparator.cs
index edcd05d..832dc1b 100644
--- a/src/Lucene.Net.Tests/core/Search/TestElevationComparator.cs
+++ b/src/Lucene.Net.Tests/core/Search/TestElevationComparator.cs
@@ -225,9 +225,10 @@ namespace Lucene.Net.Search
                 return this;
             }
 
-            public override IComparable Value(int slot)
+            // LUCENENET NOTE: This was value(int) in Lucene.
+            public override IComparable this[int slot]
             {
-                return Convert.ToInt32(values[slot]);
+                get { return values[slot]; }
             }
 
             public override int CompareTop(int doc)


Mime
View raw message