lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [lucenenet] 03/04: BREAKING: Lucene.Net.Highlighter.VectorHiglight.ScoreOrderFragmentsBuilder.ScoreComparer: Implemented singleton pattern so the class can only be used via the Default property.
Date Sat, 24 Jul 2021 19:00:41 GMT
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 9de7ffc14738efb6f0ba32e406abb2a9ea3c2e71
Author: Shad Storhaug <shad@shadstorhaug.com>
AuthorDate: Sun Jul 11 21:50:23 2021 +0700

    BREAKING: Lucene.Net.Highlighter.VectorHiglight.ScoreOrderFragmentsBuilder.ScoreComparer:
Implemented singleton pattern so the class can only be used via the Default property.
---
 .../VectorHighlight/ScoreOrderFragmentsBuilder.cs                | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/Lucene.Net.Highlighter/VectorHighlight/ScoreOrderFragmentsBuilder.cs b/src/Lucene.Net.Highlighter/VectorHighlight/ScoreOrderFragmentsBuilder.cs
index 86ce070..82819a3 100644
--- a/src/Lucene.Net.Highlighter/VectorHighlight/ScoreOrderFragmentsBuilder.cs
+++ b/src/Lucene.Net.Highlighter/VectorHighlight/ScoreOrderFragmentsBuilder.cs
@@ -59,7 +59,7 @@ namespace Lucene.Net.Search.VectorHighlight
         /// </summary>
         public override IList<WeightedFragInfo> GetWeightedFragInfoList(IList<WeightedFragInfo>
src)
         {
-            CollectionUtil.TimSort(src, new ScoreComparer());
+            CollectionUtil.TimSort(src, ScoreComparer.Default);
             return src;
         }
 
@@ -69,6 +69,13 @@ namespace Lucene.Net.Search.VectorHighlight
         /// </summary>
         public class ScoreComparer : IComparer<WeightedFragInfo>
         {
+            private ScoreComparer() { } // Singleton only
+
+            /// <summary>
+            /// Returns a default score comparer.
+            /// </summary>
+            public static IComparer<WeightedFragInfo> Default { get; } = new ScoreComparer();
// LUCENENET specific: use singleton pattern
+
             public virtual int Compare(WeightedFragInfo o1, WeightedFragInfo o2)
             {
                 if (o1.TotalBoost > o2.TotalBoost) return -1;

Mime
View raw message