You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2019/08/09 19:50:04 UTC

[lucenenet] 03/09: Lucene.Net.Highlighter.PostingsHighlight.LoadFieldValues: Changed return type from string[][] to IList (cleaner API)

This is an automated email from the ASF dual-hosted git repository.

nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git

commit bf9771e5ee921c28a27e43b1b91c44a90fa1ad2d
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Fri Aug 9 17:41:52 2019 +0700

    Lucene.Net.Highlighter.PostingsHighlight.LoadFieldValues: Changed return type from string[][] to IList<string[]> (cleaner API)
---
 src/Lucene.Net.Highlighter/PostingsHighlight/PostingsHighlighter.cs | 6 +++---
 .../PostingsHighlight/TestPostingsHighlighter.cs                    | 2 +-
 .../Search/PostingsHighlight/TestICUPostingsHighlighter.cs          | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/Lucene.Net.Highlighter/PostingsHighlight/PostingsHighlighter.cs b/src/Lucene.Net.Highlighter/PostingsHighlight/PostingsHighlighter.cs
index 58a5d7e..e8e20f3 100644
--- a/src/Lucene.Net.Highlighter/PostingsHighlight/PostingsHighlighter.cs
+++ b/src/Lucene.Net.Highlighter/PostingsHighlight/PostingsHighlighter.cs
@@ -408,7 +408,7 @@ namespace Lucene.Net.Search.PostingsHighlight
             new InPlaceMergeSorterAnonymousHelper(fields, maxPassages).Sort(0, fields.Length);
 
             // pull stored data:
-            string[][] contents = LoadFieldValues(searcher, fields, docids, maxLength);
+            IList<string[]> contents = LoadFieldValues(searcher, fields, docids, maxLength);
 
             IDictionary<string, object[]> highlights = new Dictionary<string, object[]>();
             for (int i = 0; i < fields.Length; i++)
@@ -447,7 +447,7 @@ namespace Lucene.Net.Search.PostingsHighlight
         /// and fill all values.  The returned strings must be
         /// identical to what was indexed.
         /// </summary>
-        protected virtual string[][] LoadFieldValues(IndexSearcher searcher, string[] fields, int[] docids, int maxLength)
+        protected virtual IList<string[]> LoadFieldValues(IndexSearcher searcher, string[] fields, int[] docids, int maxLength)
         {
             string[][] contents = RectangularArrays.ReturnRectangularArray<string>(fields.Length, docids.Length);
             char[] valueSeparators = new char[fields.Length];
@@ -461,7 +461,7 @@ namespace Lucene.Net.Search.PostingsHighlight
                 searcher.Doc(docids[i], visitor);
                 for (int j = 0; j < fields.Length; j++)
                 {
-                    contents[j][i] = visitor.GetValue(j).ToString();
+                    contents[j][i] = visitor.GetValue(j); // LUCENENET: No point in doing ToString() on a string
                 }
                 visitor.Reset();
             }
diff --git a/src/Lucene.Net.Tests.Highlighter/PostingsHighlight/TestPostingsHighlighter.cs b/src/Lucene.Net.Tests.Highlighter/PostingsHighlight/TestPostingsHighlighter.cs
index 1b24a8c..9235b1a 100644
--- a/src/Lucene.Net.Tests.Highlighter/PostingsHighlight/TestPostingsHighlighter.cs
+++ b/src/Lucene.Net.Tests.Highlighter/PostingsHighlight/TestPostingsHighlighter.cs
@@ -755,7 +755,7 @@ namespace Lucene.Net.Search.PostingsHighlight
                 this.text = text;
             }
 
-            protected override string[][] LoadFieldValues(IndexSearcher searcher, string[] fields, int[] docids, int maxLength)
+            protected override IList<string[]> LoadFieldValues(IndexSearcher searcher, string[] fields, int[] docids, int maxLength)
             {
                 Debug.Assert(fields.Length == 1);
                 Debug.Assert(docids.Length == 1);
diff --git a/src/dotnet/Lucene.Net.Tests.ICU/Search/PostingsHighlight/TestICUPostingsHighlighter.cs b/src/dotnet/Lucene.Net.Tests.ICU/Search/PostingsHighlight/TestICUPostingsHighlighter.cs
index b5e1f47..242f96e 100644
--- a/src/dotnet/Lucene.Net.Tests.ICU/Search/PostingsHighlight/TestICUPostingsHighlighter.cs
+++ b/src/dotnet/Lucene.Net.Tests.ICU/Search/PostingsHighlight/TestICUPostingsHighlighter.cs
@@ -755,7 +755,7 @@ namespace Lucene.Net.Search.PostingsHighlight
                 this.text = text;
             }
 
-            protected override string[][] LoadFieldValues(IndexSearcher searcher, string[] fields, int[] docids, int maxLength)
+            protected override IList<string[]> LoadFieldValues(IndexSearcher searcher, string[] fields, int[] docids, int maxLength)
             {
                 Debug.Assert( fields.Length == 1);
                 Debug.Assert( docids.Length == 1);