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 2021/04/05 20:00:59 UTC

[lucenenet] branch master updated (94b0e3c -> ffaf565)

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

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


    from 94b0e3c  PERFORMANCE: Lucene.Net.Tartarus.Snowball: Refactored to use Func<bool> instead of a Reflection call to execute stemmer code as in the original C# port: https://github.com/snowballstem/snowball
     new fa6e2fc  Fixed casting bug in grouping search
     new 2d3ba67  Added Additional GroupingSearch tests to demonstrate usage.
     new ca67f23  Made minor changes to comments related to Grouping Search
     new 15962b5  Added missing [Test] tag to a recently added Grouping test
     new 88ea775  Fixed issue with newly added Grouping Tests not passing in Unix.
     new ffaf565  Improved approach of fixing bug in newly added Grouping unit tests on unix.

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../AbstractAllGroupHeadsCollector.cs              |   2 +-
 src/Lucene.Net.Grouping/GroupingSearch.cs          |   4 +-
 src/Lucene.Net.Tests.Grouping/TestGroupingExtra.cs | 512 +++++++++++++++++++++
 3 files changed, 516 insertions(+), 2 deletions(-)
 create mode 100644 src/Lucene.Net.Tests.Grouping/TestGroupingExtra.cs

[lucenenet] 05/06: Fixed issue with newly added Grouping Tests not passing in Unix.

Posted by ni...@apache.org.
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 88ea775e20ba7d856faa06bb139a4f35ffd6ce20
Author: Ron Clabo <ro...@GiftOasis.com>
AuthorDate: Mon Apr 5 08:24:29 2021 -0400

    Fixed issue with newly added Grouping Tests not passing in Unix.
---
 src/Lucene.Net.Tests.Grouping/TestGroupingExtra.cs | 29 +++++++++++++---------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/src/Lucene.Net.Tests.Grouping/TestGroupingExtra.cs b/src/Lucene.Net.Tests.Grouping/TestGroupingExtra.cs
index 4db2f77..1a5f880 100644
--- a/src/Lucene.Net.Tests.Grouping/TestGroupingExtra.cs
+++ b/src/Lucene.Net.Tests.Grouping/TestGroupingExtra.cs
@@ -21,6 +21,7 @@
 
 using Lucene.Net.Analysis;
 using Lucene.Net.Analysis.Standard;
+using Lucene.Net.Attributes;
 using Lucene.Net.Documents;
 using Lucene.Net.Index;
 using Lucene.Net.Queries.Function;
@@ -47,6 +48,7 @@ namespace Lucene.Net.Search.Grouping
         /// 2 pass by field name approach. Uses FieldCache, not DocValues.
         /// </summary>
         [Test]
+        [LuceneNetSpecific]
         public void GroupingSearch_ViaName_StringSorted_UsingFieldCache_Top3Groups_Top4DocsEach()
         {
             string[,] carData = GetCarData();
@@ -91,17 +93,17 @@ namespace Lucene.Net.Search.Grouping
             {
                 if (groupDocs.GroupValue != null)
                 {
-                    sb.AppendLine($"\r\nGroup: {groupDocs.GroupValue.Utf8ToString()}");
+                    sb.Append($"\r\nGroup: {groupDocs.GroupValue.Utf8ToString()}\r\n");
                 }
                 else
                 {
-                    sb.AppendLine($"\r\nUngrouped");    //Happens when matching documents don't contain the group field
+                    sb.Append($"\r\nUngrouped\r\n");    //Happens when matching documents don't contain the group field
                 }
 
                 foreach (ScoreDoc scoreDoc in groupDocs.ScoreDocs)
                 {
                     doc = searcher.Doc(scoreDoc.Doc);
-                    sb.AppendLine($"{doc.GetField("carMake").GetStringValue()} {doc.GetField("carModel").GetStringValue()} {doc.GetField("carColor").GetStringValue()}");
+                    sb.Append($"{doc.GetField("carMake").GetStringValue()} {doc.GetField("carModel").GetStringValue()} {doc.GetField("carColor").GetStringValue()}\r\n");
                 }
             }
 
@@ -138,6 +140,7 @@ namespace Lucene.Net.Search.Grouping
         /// 2 pass by field name approach. Uses FieldCache, not DocValues.
         /// </summary>
         [Test]
+        [LuceneNetSpecific]
         public void GroupingSearch_ViaName_StringSorted_UsingDocValues_Top3Groups_Top4DocsEach()
         {
             string[,] carData = GetCarData();
@@ -184,17 +187,17 @@ namespace Lucene.Net.Search.Grouping
             {
                 if (groupDocs.GroupValue != null)
                 {
-                    sb.AppendLine($"\r\nGroup: {groupDocs.GroupValue.Utf8ToString()}");
+                    sb.Append($"\r\nGroup: {groupDocs.GroupValue.Utf8ToString()}\r\n");
                 }
                 else
                 {
-                    sb.AppendLine($"\r\nUngrouped");    //Happens when matching documents don't contain the group field
+                    sb.Append($"\r\nUngrouped\r\n");    //Happens when matching documents don't contain the group field
                 }
 
                 foreach (ScoreDoc scoreDoc in groupDocs.ScoreDocs)
                 {
                     doc = searcher.Doc(scoreDoc.Doc);
-                    sb.AppendLine($"{doc.GetField("carMake").GetStringValue()} {doc.GetField("carModel").GetStringValue()} {doc.GetField("carColor").GetStringValue()}");
+                    sb.Append($"{doc.GetField("carMake").GetStringValue()} {doc.GetField("carModel").GetStringValue()} {doc.GetField("carColor").GetStringValue()}\r\n");
                 }
             }
 
@@ -230,6 +233,7 @@ namespace Lucene.Net.Search.Grouping
         /// 2 pass by field name approach. Uses FieldCache, not DocValues.
         /// </summary>
         [Test]
+        [LuceneNetSpecific]
         public virtual void GroupingSearch_ViaName_Int32Sorted_UsingFieldCache_Top10Groups_Top10DocsEach()
         {
             int[,] numericData = GetNumbers();
@@ -288,17 +292,17 @@ namespace Lucene.Net.Search.Grouping
                 if (groupDocs.GroupValue != null)
                 {
                     int val2 = NumericUtils.PrefixCodedToInt32(groupDocs.GroupValue);
-                    sb.AppendLine($"\r\nGroup: {val2}");
+                    sb.Append($"\r\nGroup: {val2}\r\n");
                 }
                 else
                 {
-                    sb.AppendLine($"\r\nUngrouped");    //Happens when matching documents don't contain the group field
+                    sb.Append($"\r\nUngrouped\r\n");    //Happens when matching documents don't contain the group field
                 }
 
                 foreach (ScoreDoc scoreDoc in groupDocs.ScoreDocs)
                 {
                     doc = searcher.Doc(scoreDoc.Doc);
-                    sb.AppendLine($"{doc.GetField("major").GetInt32Value()} {doc.GetField("minor").GetInt32Value()} {doc.GetField("rev").GetInt32Value()}");
+                    sb.Append($"{doc.GetField("major").GetInt32Value()} {doc.GetField("minor").GetInt32Value()} {doc.GetField("rev").GetInt32Value()}\r\n");
                 }
             }
 
@@ -338,6 +342,7 @@ namespace Lucene.Net.Search.Grouping
         /// 2 pass by function/ValueSource/MutableValue approach. Uses FieldCache, not DocValues.
         /// </summary>
         [Test]
+        [LuceneNetSpecific]
         public virtual void GroupingSearch_ViaFunction_Int32Sorted_UsingFieldCache_Top10Groups_Top10DocsEach()
         {
             int[,] numericData = GetNumbers();
@@ -400,17 +405,17 @@ namespace Lucene.Net.Search.Grouping
                 {
                     BytesRef bytesRef = ((MutableValueStr)groupDocs.GroupValue).Value;
                     int major = NumericUtils.PrefixCodedToInt32(bytesRef);
-                    sb.AppendLine($"\r\nGroup: {major}");
+                    sb.Append($"\r\nGroup: {major}\r\n");
                 }
                 else
                 {
-                    sb.AppendLine($"\r\nUngrouped");    //Happens when matching documents don't contain the group field
+                    sb.Append($"\r\nUngrouped\r\n");    //Happens when matching documents don't contain the group field
                 }
 
                 foreach (ScoreDoc scoreDoc in groupDocs.ScoreDocs)
                 {
                     doc = searcher.Doc(scoreDoc.Doc);
-                    sb.AppendLine($"{doc.GetField("major").GetInt32Value()} {doc.GetField("minor").GetInt32Value()} {doc.GetField("rev").GetInt32Value()}");
+                    sb.Append($"{doc.GetField("major").GetInt32Value()} {doc.GetField("minor").GetInt32Value()} {doc.GetField("rev").GetInt32Value()}\r\n");
                 }
             }
 

[lucenenet] 04/06: Added missing [Test] tag to a recently added Grouping test

Posted by ni...@apache.org.
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 15962b5f444906459bdd859c22a2b563085753d0
Author: Ron Clabo <ro...@GiftOasis.com>
AuthorDate: Fri Apr 2 17:35:27 2021 -0400

    Added missing [Test] tag to a recently added Grouping test
---
 src/Lucene.Net.Tests.Grouping/TestGroupingExtra.cs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/Lucene.Net.Tests.Grouping/TestGroupingExtra.cs b/src/Lucene.Net.Tests.Grouping/TestGroupingExtra.cs
index 52d7243..4db2f77 100644
--- a/src/Lucene.Net.Tests.Grouping/TestGroupingExtra.cs
+++ b/src/Lucene.Net.Tests.Grouping/TestGroupingExtra.cs
@@ -229,6 +229,7 @@ namespace Lucene.Net.Search.Grouping
         /// LUCENENET: Additional Unit Test.  Tests grouping by an Int32 via the
         /// 2 pass by field name approach. Uses FieldCache, not DocValues.
         /// </summary>
+        [Test]
         public virtual void GroupingSearch_ViaName_Int32Sorted_UsingFieldCache_Top10Groups_Top10DocsEach()
         {
             int[,] numericData = GetNumbers();

[lucenenet] 02/06: Added Additional GroupingSearch tests to demonstrate usage.

Posted by ni...@apache.org.
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 2d3ba67e49cac4260298dbf59e9b5c71076570b2
Author: Ron Clabo <ro...@GiftOasis.com>
AuthorDate: Fri Apr 2 17:28:32 2021 -0400

    Added Additional GroupingSearch tests to demonstrate usage.
---
 src/Lucene.Net.Tests.Grouping/TestGroupingExtra.cs | 502 +++++++++++++++++++++
 1 file changed, 502 insertions(+)

diff --git a/src/Lucene.Net.Tests.Grouping/TestGroupingExtra.cs b/src/Lucene.Net.Tests.Grouping/TestGroupingExtra.cs
new file mode 100644
index 0000000..52d7243
--- /dev/null
+++ b/src/Lucene.Net.Tests.Grouping/TestGroupingExtra.cs
@@ -0,0 +1,502 @@
+/*
+ *
+ * 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 Lucene.Net.Analysis;
+using Lucene.Net.Analysis.Standard;
+using Lucene.Net.Documents;
+using Lucene.Net.Index;
+using Lucene.Net.Queries.Function;
+using Lucene.Net.Queries.Function.ValueSources;
+using Lucene.Net.Store;
+using Lucene.Net.Util;
+using Lucene.Net.Util.Mutable;
+using NUnit.Framework;
+using System.Collections;
+using System.Text;
+
+namespace Lucene.Net.Search.Grouping
+{
+
+    /// <summary>
+    /// LUCENENET: File not includes in java Lucene. This file contains extra
+    /// tests to test a few specific ways of using grouping.  
+    /// </summary>
+    public class TestGroupingExtra : LuceneTestCase
+    {
+
+        /// <summary>
+        /// LUCENENET: Additional Unit Test.  Tests grouping by a StringField via the
+        /// 2 pass by field name approach. Uses FieldCache, not DocValues.
+        /// </summary>
+        [Test]
+        public void GroupingSearch_ViaName_StringSorted_UsingFieldCache_Top3Groups_Top4DocsEach()
+        {
+            string[,] carData = GetCarData();
+
+            Directory indexDir = NewDirectory();
+            Analyzer standardAnalyzer = new StandardAnalyzer(LuceneVersion.LUCENE_48);
+
+            IndexWriterConfig indexConfig = new IndexWriterConfig(LuceneVersion.LUCENE_48, standardAnalyzer);
+            IndexWriter writer = new IndexWriter(indexDir, indexConfig);
+
+            int carCount = carData.GetLength(0);
+            Document doc = new Document();
+            for (int i = 0; i < carCount; i++)
+            {
+                doc.Fields.Clear();
+                doc.Add(new StringField("carMake", carData[i, 0], Field.Store.YES));
+                doc.Add(new StringField("carModel", carData[i, 1], Field.Store.YES));
+                doc.Add(new StringField("carColor", carData[i, 2], Field.Store.YES));
+                writer.AddDocument(doc);
+            }
+            writer.Commit();
+
+            GroupingSearch groupingSearch = new GroupingSearch("carMake");
+            groupingSearch.SetAllGroups(true);                      //true = compute all groups matching the query
+            groupingSearch.SetGroupDocsLimit(4);                   //max docs returned in a group
+            groupingSearch.SetGroupSort(new Sort(new SortField("carMake", SortFieldType.STRING)));
+            groupingSearch.SetSortWithinGroup(new Sort(new SortField("carModel", SortFieldType.STRING)));
+            groupingSearch.SetFillSortFields(true);
+            groupingSearch.SetCachingInMB(10, cacheScores: true);
+
+            IndexReader reader = writer.GetReader(applyAllDeletes: true);
+            IndexSearcher searcher = new IndexSearcher(reader);
+            Query matchAllQuery = new MatchAllDocsQuery();
+            ITopGroups<object> topGroups = groupingSearch.Search(searcher, matchAllQuery, groupOffset: 0, groupLimit: 3);
+
+
+            int? totalGroupCount = topGroups.TotalGroupCount;               //null if not computed
+            int totalGroupedHitCount = topGroups.TotalGroupedHitCount;
+
+            StringBuilder sb = new StringBuilder();
+            foreach (GroupDocs<BytesRef> groupDocs in topGroups.Groups)
+            {
+                if (groupDocs.GroupValue != null)
+                {
+                    sb.AppendLine($"\r\nGroup: {groupDocs.GroupValue.Utf8ToString()}");
+                }
+                else
+                {
+                    sb.AppendLine($"\r\nUngrouped");    //Happens when matching documents don't contain the group field
+                }
+
+                foreach (ScoreDoc scoreDoc in groupDocs.ScoreDocs)
+                {
+                    doc = searcher.Doc(scoreDoc.Doc);
+                    sb.AppendLine($"{doc.GetField("carMake").GetStringValue()} {doc.GetField("carModel").GetStringValue()} {doc.GetField("carColor").GetStringValue()}");
+                }
+            }
+
+            string output = sb.ToString();
+            string expectdValue = "\r\nGroup: Audi\r\nAudi A3 Orange\r\nAudi A3 Green\r\nAudi A3 Blue\r\nAudi S4 Yellow\r\n\r\nGroup: Bently\r\nBently Arnage Grey\r\nBently Arnage Blue\r\nBently Azure Green\r\nBently Azure Blue\r\n\r\nGroup: Ford\r\nFord Aspire Yellow\r\nFord Aspire Blue\r\nFord Bronco Green\r\nFord Bronco Orange\r\n";
+            assertEquals(expectdValue, output);
+
+            /*  Output:
+             
+                Group: Audi
+                Audi A3 Orange
+                Audi A3 Green
+                Audi A3 Blue
+                Audi S4 Yellow
+
+                Group: Bently
+                Bently Arnage Grey
+                Bently Arnage Blue
+                Bently Azure Green
+                Bently Azure Blue
+
+                Group: Ford
+                Ford Aspire Yellow
+                Ford Aspire Blue
+                Ford Bronco Green
+                Ford Bronco Orange
+            */
+
+
+        }
+
+        /// <summary>
+        /// LUCENENET: Additional Unit Test.  Tests grouping by a StringField via the
+        /// 2 pass by field name approach. Uses FieldCache, not DocValues.
+        /// </summary>
+        [Test]
+        public void GroupingSearch_ViaName_StringSorted_UsingDocValues_Top3Groups_Top4DocsEach()
+        {
+            string[,] carData = GetCarData();
+
+            Directory indexDir = NewDirectory();
+            Analyzer standardAnalyzer = new StandardAnalyzer(LuceneVersion.LUCENE_48);
+
+            IndexWriterConfig indexConfig = new IndexWriterConfig(LuceneVersion.LUCENE_48, standardAnalyzer);
+            IndexWriter writer = new IndexWriter(indexDir, indexConfig);
+
+            int carCount = carData.GetLength(0);
+            Document doc = new Document();
+            for (int i = 0; i < carCount; i++)
+            {
+                doc.Fields.Clear();
+                doc.Add(new StringField("carMake", carData[i, 0], Field.Store.YES));
+                doc.Add(new SortedDocValuesField("carMake_dv", new BytesRef(carData[i, 0])));
+                doc.Add(new StringField("carModel", carData[i, 1], Field.Store.YES));
+                doc.Add(new SortedDocValuesField("carModel_dv", new BytesRef(carData[i, 1])));
+                doc.Add(new StringField("carColor", carData[i, 2], Field.Store.YES));
+                writer.AddDocument(doc);
+            }
+            writer.Commit();
+
+            GroupingSearch groupingSearch = new GroupingSearch("carMake");
+            groupingSearch.SetAllGroups(true);                    //true = compute all groups matching the query
+            groupingSearch.SetGroupDocsLimit(4);                 //max docs returned in a group
+            groupingSearch.SetGroupSort(new Sort(new SortField("carMake_dv", SortFieldType.STRING)));
+            groupingSearch.SetSortWithinGroup(new Sort(new SortField("carModel_dv", SortFieldType.STRING)));
+            groupingSearch.SetFillSortFields(true);
+            groupingSearch.SetCachingInMB(10, cacheScores: true);
+
+            IndexReader reader = writer.GetReader(applyAllDeletes: true);
+            IndexSearcher searcher = new IndexSearcher(reader);
+            Query matchAllQuery = new MatchAllDocsQuery();
+            ITopGroups<object> topGroups = groupingSearch.Search(searcher, matchAllQuery, groupOffset: 0, groupLimit: 3);
+
+
+            int? totalGroupCount = topGroups.TotalGroupCount;               //null if not computed
+            int totalGroupedHitCount = topGroups.TotalGroupedHitCount;
+
+            StringBuilder sb = new StringBuilder();
+            foreach (GroupDocs<BytesRef> groupDocs in topGroups.Groups)
+            {
+                if (groupDocs.GroupValue != null)
+                {
+                    sb.AppendLine($"\r\nGroup: {groupDocs.GroupValue.Utf8ToString()}");
+                }
+                else
+                {
+                    sb.AppendLine($"\r\nUngrouped");    //Happens when matching documents don't contain the group field
+                }
+
+                foreach (ScoreDoc scoreDoc in groupDocs.ScoreDocs)
+                {
+                    doc = searcher.Doc(scoreDoc.Doc);
+                    sb.AppendLine($"{doc.GetField("carMake").GetStringValue()} {doc.GetField("carModel").GetStringValue()} {doc.GetField("carColor").GetStringValue()}");
+                }
+            }
+
+            string output = sb.ToString();
+            string expectdValue = "\r\nGroup: Audi\r\nAudi A3 Orange\r\nAudi A3 Green\r\nAudi A3 Blue\r\nAudi S4 Yellow\r\n\r\nGroup: Bently\r\nBently Arnage Grey\r\nBently Arnage Blue\r\nBently Azure Green\r\nBently Azure Blue\r\n\r\nGroup: Ford\r\nFord Aspire Yellow\r\nFord Aspire Blue\r\nFord Bronco Green\r\nFord Bronco Orange\r\n";
+            assertEquals(expectdValue, output);
+
+            /*  Output:
+             
+                Group: Audi
+                Audi A3 Orange
+                Audi A3 Green
+                Audi A3 Blue
+                Audi S4 Yellow
+
+                Group: Bently
+                Bently Arnage Grey
+                Bently Arnage Blue
+                Bently Azure Green
+                Bently Azure Blue
+
+                Group: Ford
+                Ford Aspire Yellow
+                Ford Aspire Blue
+                Ford Bronco Green
+                Ford Bronco Orange
+
+            */
+        }
+
+        /// <summary>
+        /// LUCENENET: Additional Unit Test.  Tests grouping by an Int32 via the
+        /// 2 pass by field name approach. Uses FieldCache, not DocValues.
+        /// </summary>
+        public virtual void GroupingSearch_ViaName_Int32Sorted_UsingFieldCache_Top10Groups_Top10DocsEach()
+        {
+            int[,] numericData = GetNumbers();
+
+            Directory indexDir = NewDirectory();
+            Analyzer standardAnalyzer = new StandardAnalyzer(LuceneVersion.LUCENE_48);
+
+            IndexWriterConfig indexConfig = new IndexWriterConfig(LuceneVersion.LUCENE_48, standardAnalyzer);
+            IndexWriter writer = new IndexWriter(indexDir, indexConfig);
+
+            //Normally we can not group on a Int32Field because it's stored as a 8 term trie structure
+            //by default.  But by specifying int.MaxValue as the NumericPrecisionStep we force the inverted
+            //index to store the value as a single term. This allows us to use it for grouping (although
+            //it's no longer good for range queries as they will be slow if the range is large). 
+
+            var int32OneTerm = new FieldType
+            {
+                IsIndexed = true,
+                IsTokenized = true,
+                OmitNorms = true,
+                IndexOptions = IndexOptions.DOCS_ONLY,
+                NumericType = Documents.NumericType.INT32,
+                NumericPrecisionStep = int.MaxValue,             //Ensures a single term is generated not a trie
+                IsStored = true
+            };
+            int32OneTerm.Freeze();
+
+            int rowCount = numericData.GetLength(0);
+            Document doc = new Document();
+            for (int i = 0; i < rowCount; i++)
+            {
+                doc.Fields.Clear();
+                doc.Add(new Int32Field("major", numericData[i, 0], int32OneTerm));
+                doc.Add(new Int32Field("minor", numericData[i, 1], int32OneTerm));
+                doc.Add(new StoredField("rev", numericData[i, 2]));
+                writer.AddDocument(doc);
+            }
+            writer.Commit();
+
+            GroupingSearch groupingSearch = new GroupingSearch("major");
+            groupingSearch.SetAllGroups(true);                      //true = compute all groups matching the query
+            groupingSearch.SetGroupDocsLimit(10);                   //max docs returned in a group
+            groupingSearch.SetGroupSort(new Sort(new SortField("major", SortFieldType.INT32)));
+            groupingSearch.SetSortWithinGroup(new Sort(new SortField("minor", SortFieldType.INT32)));
+
+            IndexReader reader = writer.GetReader(applyAllDeletes: true);
+            IndexSearcher searcher = new IndexSearcher(reader);
+            Query matchAllQuery = new MatchAllDocsQuery();
+            ITopGroups<BytesRef> topGroups = groupingSearch.Search<BytesRef>(searcher, matchAllQuery, groupOffset: 0, groupLimit: 10);
+
+            var val = FieldCache.DEFAULT;
+
+            StringBuilder sb = new StringBuilder();
+            foreach (GroupDocs<BytesRef> groupDocs in topGroups.Groups)
+            {
+                if (groupDocs.GroupValue != null)
+                {
+                    int val2 = NumericUtils.PrefixCodedToInt32(groupDocs.GroupValue);
+                    sb.AppendLine($"\r\nGroup: {val2}");
+                }
+                else
+                {
+                    sb.AppendLine($"\r\nUngrouped");    //Happens when matching documents don't contain the group field
+                }
+
+                foreach (ScoreDoc scoreDoc in groupDocs.ScoreDocs)
+                {
+                    doc = searcher.Doc(scoreDoc.Doc);
+                    sb.AppendLine($"{doc.GetField("major").GetInt32Value()} {doc.GetField("minor").GetInt32Value()} {doc.GetField("rev").GetInt32Value()}");
+                }
+            }
+
+            string output = sb.ToString();
+            string expectdValue = "\r\nGroup: 1000\r\n1000 1102 21\r\n1000 1123 45\r\n\r\nGroup: 2000\r\n2000 2222 7\r\n2000 2888 88\r\n\r\nGroup: 3000\r\n3000 3123 11\r\n3000 3222 37\r\n3000 3993 9\r\n\r\nGroup: 4000\r\n4000 4001 88\r\n4000 4011 10\r\n\r\nGroup: 8000\r\n8000 8123 28\r\n8000 8888 8\r\n8000 8998 92\r\n";
+            assertEquals(expectdValue, output);
+
+            /*  Output:
+
+                Group: 1000
+                1000 1102 21
+                1000 1123 45
+
+                Group: 2000
+                2000 2222 7
+                2000 2888 88
+
+                Group: 3000
+                3000 3123 11
+                3000 3222 37
+                3000 3993 9
+
+                Group: 4000
+                4000 4001 88
+                4000 4011 10
+
+                Group: 8000
+                8000 8123 28
+                8000 8888 8
+                8000 8998 92
+            */
+        }
+
+
+        /// <summary>
+        /// LUCENENET: Additional Unit Test.  Tests grouping by an Int32 via the
+        /// 2 pass by function/ValueSource/MutableValue approach. Uses FieldCache, not DocValues.
+        /// </summary>
+        [Test]
+        public virtual void GroupingSearch_ViaFunction_Int32Sorted_UsingFieldCache_Top10Groups_Top10DocsEach()
+        {
+            int[,] numericData = GetNumbers();
+
+            Directory indexDir = NewDirectory();
+            Analyzer standardAnalyzer = new StandardAnalyzer(LuceneVersion.LUCENE_48);
+
+            IndexWriterConfig indexConfig = new IndexWriterConfig(LuceneVersion.LUCENE_48, standardAnalyzer);
+            IndexWriter writer = new IndexWriter(indexDir, indexConfig);
+
+
+            //Normally we can not group on a Int32Field because it's stored as a 8 term trie structure
+            //by default.  But by specifying int.MaxValue as the NumericPrecisionStep we force the inverted
+            //index to store the value as a single term. This allows us to use it for grouping (although
+            //it's no longer good for range queries as they will be slow if the range is large). 
+
+            var int32OneTerm = new FieldType
+            {
+                IsIndexed = true,
+                IsTokenized = true,
+                OmitNorms = true,
+                IndexOptions = IndexOptions.DOCS_ONLY,
+                NumericType = Documents.NumericType.INT32,
+                NumericPrecisionStep = int.MaxValue,             //Ensures a single term is generated not a trie
+                IsStored = true
+            };
+            int32OneTerm.Freeze();
+
+            int rowCount = numericData.GetLength(0);
+            Document doc = new Document();
+            for (int i = 0; i < rowCount; i++)
+            {
+                doc.Fields.Clear();
+                doc.Add(new Int32Field("major", numericData[i, 0], int32OneTerm));
+                doc.Add(new Int32Field("minor", numericData[i, 1], int32OneTerm));
+                doc.Add(new StoredField("rev", numericData[i, 2]));
+                writer.AddDocument(doc);
+            }
+            writer.Commit();
+
+            ValueSource vs = new BytesRefFieldSource("major");
+            GroupingSearch groupingSearch = new GroupingSearch(vs, new Hashtable());
+            groupingSearch.SetAllGroups(true);                      //true = compute all groups matching the query
+            groupingSearch.SetGroupDocsLimit(10);                   //max docs returned in a group
+            groupingSearch.SetGroupSort(new Sort(new SortField("major", SortFieldType.INT32)));
+            groupingSearch.SetSortWithinGroup(new Sort(new SortField("minor", SortFieldType.INT32)));
+
+            IndexReader reader = writer.GetReader(applyAllDeletes: true);
+            IndexSearcher searcher = new IndexSearcher(reader);
+            Query matchAllQuery = new MatchAllDocsQuery();
+            ITopGroups<object> topGroups = groupingSearch.Search(searcher, matchAllQuery, groupOffset: 0, groupLimit: 10);
+
+            var val = FieldCache.DEFAULT;
+
+            StringBuilder sb = new StringBuilder();
+            foreach (GroupDocs<MutableValue> groupDocs in topGroups.Groups)
+            {
+
+                if(groupDocs.GroupValue != null)
+                {
+                    BytesRef bytesRef = ((MutableValueStr)groupDocs.GroupValue).Value;
+                    int major = NumericUtils.PrefixCodedToInt32(bytesRef);
+                    sb.AppendLine($"\r\nGroup: {major}");
+                }
+                else
+                {
+                    sb.AppendLine($"\r\nUngrouped");    //Happens when matching documents don't contain the group field
+                }
+
+                foreach (ScoreDoc scoreDoc in groupDocs.ScoreDocs)
+                {
+                    doc = searcher.Doc(scoreDoc.Doc);
+                    sb.AppendLine($"{doc.GetField("major").GetInt32Value()} {doc.GetField("minor").GetInt32Value()} {doc.GetField("rev").GetInt32Value()}");
+                }
+            }
+
+            string output = sb.ToString();
+            string expectdValue = "\r\nGroup: 1000\r\n1000 1102 21\r\n1000 1123 45\r\n\r\nGroup: 2000\r\n2000 2222 7\r\n2000 2888 88\r\n\r\nGroup: 3000\r\n3000 3123 11\r\n3000 3222 37\r\n3000 3993 9\r\n\r\nGroup: 4000\r\n4000 4001 88\r\n4000 4011 10\r\n\r\nGroup: 8000\r\n8000 8123 28\r\n8000 8888 8\r\n8000 8998 92\r\n";
+            assertEquals(expectdValue, output);
+
+            /*  Output:
+             *  
+                Group: 1000
+                1000 1102 21
+                1000 1123 45
+
+                Group: 2000
+                2000 2222 7
+                2000 2888 88
+
+                Group: 3000
+                3000 3123 11
+                3000 3222 37
+                3000 3993 9
+
+                Group: 4000
+                4000 4001 88
+                4000 4011 10
+
+                Group: 8000
+                8000 8123 28
+                8000 8888 8
+                8000 8998 92
+            */
+        }
+
+
+        private string[,] GetCarData()
+        {
+
+            return new string[,] {
+                { "Toyota", "4Runner" , "Blue" },
+                { "Toyota", "4Runner" , "Green" },
+                { "Ford", "Bronco" , "Green" },
+                { "Ford", "Expedition" , "Yellow" },
+                { "Ford", "Expedition" , "Blue" },
+                { "Toyota", "Celica" , "Orange" },
+                { "Audi", "S4" , "Yellow" },
+                { "Audi", "A3" , "Orange" },
+                { "Toyota", "Camry" , "Yellow" },
+                { "Ford", "F150 Truck" , "Green" },
+                { "Bently", "Azure" , "Green" },
+                { "Ford", "Bronco" , "Orange" },
+                { "Ford", "Aspire" , "Yellow" },
+                { "Audi", "A3" , "Green" },
+                { "Audi", "S4" , "Blue" },
+                { "Bently", "Arnage" , "Grey" },
+                { "Toyota", "4Runner" , "Yellow" },
+                { "Toyota", "Camry" , "Blue" },
+                { "Bently", "Azure" , "Blue" },
+                { "Ford", "Bronco" , "Blue" },
+                { "Ford", "Expedition" , "Green" },
+                { "Ford", "F150 Truck" , "Blue" },
+                { "Toyota", "Celica" , "Blue" },
+                { "Ford", "F150 Truck" , "Yellow" },
+                { "Ford", "Aspire" , "Blue" },
+                { "Audi", "A3" , "Blue" },
+                { "Bently", "Arnage" , "Blue" },
+            };
+        }
+
+        private int[,] GetNumbers()
+        {
+
+            return new int[,] {
+                { 1000, 1102 , 21 },
+                { 4000, 4001 , 88 },
+                { 8000, 8123 , 28 },
+                { 4000, 4011 , 10 },
+                { 2000, 2222 , 7 },
+                { 3000, 3222 , 37 },
+                { 2000, 2888 , 88 },
+                { 3000, 3123 , 11 },
+                { 8000, 8888 , 8 },
+                { 1000, 1123 , 45 },
+                { 3000, 3993 , 9 },
+                { 8000, 8998 , 92 },
+            };
+        }
+
+
+    }
+}

[lucenenet] 03/06: Made minor changes to comments related to Grouping Search

Posted by ni...@apache.org.
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 ca67f23a4b231500499f6084f9f21a828c6b4b22
Author: Ron Clabo <ro...@GiftOasis.com>
AuthorDate: Fri Apr 2 17:29:49 2021 -0400

    Made minor changes to comments related to Grouping Search
---
 src/Lucene.Net.Grouping/AbstractAllGroupHeadsCollector.cs | 2 +-
 src/Lucene.Net.Grouping/GroupingSearch.cs                 | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/Lucene.Net.Grouping/AbstractAllGroupHeadsCollector.cs b/src/Lucene.Net.Grouping/AbstractAllGroupHeadsCollector.cs
index bab2515..8360b2d 100644
--- a/src/Lucene.Net.Grouping/AbstractAllGroupHeadsCollector.cs
+++ b/src/Lucene.Net.Grouping/AbstractAllGroupHeadsCollector.cs
@@ -153,7 +153,7 @@ namespace Lucene.Net.Search.Grouping
 
     /// <summary>
     /// Represents a group head. A group head is the most relevant document for a particular group.
-    /// The relevancy is based is usually based on the sort.
+    /// The relevancy is usually based on the sort.
     /// <para>
     /// The group head contains a group value with its associated most relevant document id.
     /// </para>
diff --git a/src/Lucene.Net.Grouping/GroupingSearch.cs b/src/Lucene.Net.Grouping/GroupingSearch.cs
index 0f29d6a..a0c7d15 100644
--- a/src/Lucene.Net.Grouping/GroupingSearch.cs
+++ b/src/Lucene.Net.Grouping/GroupingSearch.cs
@@ -107,6 +107,7 @@ namespace Lucene.Net.Search.Grouping
         /// <param name="groupLimit">The number of groups to return from the specified group offset</param>
         /// <returns>the grouped result as a <see cref="ITopGroups{Object}"/> instance</returns>
         /// <exception cref="IOException">If any I/O related errors occur</exception>
+        // LUCENENET additional method signature. Makes discovering the return type easier. 
         public virtual ITopGroups<object> Search(IndexSearcher searcher, Query query, int groupOffset, int groupLimit)
         {
             return Search<object>(searcher, null, query, groupOffset, groupLimit);
@@ -138,6 +139,7 @@ namespace Lucene.Net.Search.Grouping
         /// <param name="groupLimit">The number of groups to return from the specified group offset</param>
         /// <returns>the grouped result as a <see cref="ITopGroups{Object}"/> instance</returns>
         /// <exception cref="IOException">If any I/O related errors occur</exception>
+        // LUCENENET additional method signature. Makes discovering the return type easier. 
         public virtual ITopGroups<object> Search(IndexSearcher searcher, Filter filter, Query query, int groupOffset, int groupLimit)
         {
             if (groupFunction != null)

[lucenenet] 01/06: Fixed casting bug in grouping search

Posted by ni...@apache.org.
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 fa6e2fc7b9b2dd3e95be9f468bfa44ea1a4669e6
Author: Ron Clabo <ro...@GiftOasis.com>
AuthorDate: Fri Apr 2 16:38:33 2021 -0400

    Fixed casting bug in grouping search
---
 src/Lucene.Net.Grouping/GroupingSearch.cs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Lucene.Net.Grouping/GroupingSearch.cs b/src/Lucene.Net.Grouping/GroupingSearch.cs
index 6a018b8..0f29d6a 100644
--- a/src/Lucene.Net.Grouping/GroupingSearch.cs
+++ b/src/Lucene.Net.Grouping/GroupingSearch.cs
@@ -274,7 +274,7 @@ namespace Lucene.Net.Search.Grouping
 
             if (allGroups)
             {
-                matchingGroups = (IList)allGroupsCollector.Groups;
+                matchingGroups = (ICollection)allGroupsCollector.Groups;
             }
             else
             {

[lucenenet] 06/06: Improved approach of fixing bug in newly added Grouping unit tests on unix.

Posted by ni...@apache.org.
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 ffaf56520fe999bb1912ec25ff3ff3e6882abe82
Author: Ron Clabo <ro...@GiftOasis.com>
AuthorDate: Mon Apr 5 14:37:31 2021 -0400

    Improved approach of fixing bug in newly added Grouping unit tests on unix.
---
 src/Lucene.Net.Tests.Grouping/TestGroupingExtra.cs | 40 ++++++++++++----------
 1 file changed, 22 insertions(+), 18 deletions(-)

diff --git a/src/Lucene.Net.Tests.Grouping/TestGroupingExtra.cs b/src/Lucene.Net.Tests.Grouping/TestGroupingExtra.cs
index 1a5f880..22bf00d 100644
--- a/src/Lucene.Net.Tests.Grouping/TestGroupingExtra.cs
+++ b/src/Lucene.Net.Tests.Grouping/TestGroupingExtra.cs
@@ -30,6 +30,7 @@ using Lucene.Net.Store;
 using Lucene.Net.Util;
 using Lucene.Net.Util.Mutable;
 using NUnit.Framework;
+using System;
 using System.Collections;
 using System.Text;
 
@@ -91,24 +92,25 @@ namespace Lucene.Net.Search.Grouping
             StringBuilder sb = new StringBuilder();
             foreach (GroupDocs<BytesRef> groupDocs in topGroups.Groups)
             {
+                sb.AppendLine();
                 if (groupDocs.GroupValue != null)
                 {
-                    sb.Append($"\r\nGroup: {groupDocs.GroupValue.Utf8ToString()}\r\n");
+                    sb.AppendLine($"Group: {groupDocs.GroupValue.Utf8ToString()}");
                 }
                 else
                 {
-                    sb.Append($"\r\nUngrouped\r\n");    //Happens when matching documents don't contain the group field
+                    sb.AppendLine($"Ungrouped");    //Happens when matching documents don't contain the group field
                 }
 
                 foreach (ScoreDoc scoreDoc in groupDocs.ScoreDocs)
                 {
                     doc = searcher.Doc(scoreDoc.Doc);
-                    sb.Append($"{doc.GetField("carMake").GetStringValue()} {doc.GetField("carModel").GetStringValue()} {doc.GetField("carColor").GetStringValue()}\r\n");
+                    sb.AppendLine($"{doc.GetField("carMake").GetStringValue()} {doc.GetField("carModel").GetStringValue()} {doc.GetField("carColor").GetStringValue()}");
                 }
             }
 
             string output = sb.ToString();
-            string expectdValue = "\r\nGroup: Audi\r\nAudi A3 Orange\r\nAudi A3 Green\r\nAudi A3 Blue\r\nAudi S4 Yellow\r\n\r\nGroup: Bently\r\nBently Arnage Grey\r\nBently Arnage Blue\r\nBently Azure Green\r\nBently Azure Blue\r\n\r\nGroup: Ford\r\nFord Aspire Yellow\r\nFord Aspire Blue\r\nFord Bronco Green\r\nFord Bronco Orange\r\n";
+            string expectdValue = "\r\nGroup: Audi\r\nAudi A3 Orange\r\nAudi A3 Green\r\nAudi A3 Blue\r\nAudi S4 Yellow\r\n\r\nGroup: Bently\r\nBently Arnage Grey\r\nBently Arnage Blue\r\nBently Azure Green\r\nBently Azure Blue\r\n\r\nGroup: Ford\r\nFord Aspire Yellow\r\nFord Aspire Blue\r\nFord Bronco Green\r\nFord Bronco Orange\r\n".Replace("\r\n", Environment.NewLine);
             assertEquals(expectdValue, output);
 
             /*  Output:
@@ -185,24 +187,25 @@ namespace Lucene.Net.Search.Grouping
             StringBuilder sb = new StringBuilder();
             foreach (GroupDocs<BytesRef> groupDocs in topGroups.Groups)
             {
+                sb.AppendLine();
                 if (groupDocs.GroupValue != null)
                 {
-                    sb.Append($"\r\nGroup: {groupDocs.GroupValue.Utf8ToString()}\r\n");
+                    sb.AppendLine($"Group: {groupDocs.GroupValue.Utf8ToString()}");
                 }
                 else
                 {
-                    sb.Append($"\r\nUngrouped\r\n");    //Happens when matching documents don't contain the group field
+                    sb.AppendLine($"Ungrouped");    //Happens when matching documents don't contain the group field
                 }
 
                 foreach (ScoreDoc scoreDoc in groupDocs.ScoreDocs)
                 {
                     doc = searcher.Doc(scoreDoc.Doc);
-                    sb.Append($"{doc.GetField("carMake").GetStringValue()} {doc.GetField("carModel").GetStringValue()} {doc.GetField("carColor").GetStringValue()}\r\n");
+                    sb.AppendLine($"{doc.GetField("carMake").GetStringValue()} {doc.GetField("carModel").GetStringValue()} {doc.GetField("carColor").GetStringValue()}");
                 }
             }
 
             string output = sb.ToString();
-            string expectdValue = "\r\nGroup: Audi\r\nAudi A3 Orange\r\nAudi A3 Green\r\nAudi A3 Blue\r\nAudi S4 Yellow\r\n\r\nGroup: Bently\r\nBently Arnage Grey\r\nBently Arnage Blue\r\nBently Azure Green\r\nBently Azure Blue\r\n\r\nGroup: Ford\r\nFord Aspire Yellow\r\nFord Aspire Blue\r\nFord Bronco Green\r\nFord Bronco Orange\r\n";
+            string expectdValue = "\r\nGroup: Audi\r\nAudi A3 Orange\r\nAudi A3 Green\r\nAudi A3 Blue\r\nAudi S4 Yellow\r\n\r\nGroup: Bently\r\nBently Arnage Grey\r\nBently Arnage Blue\r\nBently Azure Green\r\nBently Azure Blue\r\n\r\nGroup: Ford\r\nFord Aspire Yellow\r\nFord Aspire Blue\r\nFord Bronco Green\r\nFord Bronco Orange\r\n".Replace("\r\n", Environment.NewLine);
             assertEquals(expectdValue, output);
 
             /*  Output:
@@ -289,25 +292,26 @@ namespace Lucene.Net.Search.Grouping
             StringBuilder sb = new StringBuilder();
             foreach (GroupDocs<BytesRef> groupDocs in topGroups.Groups)
             {
+                sb.AppendLine();
                 if (groupDocs.GroupValue != null)
                 {
                     int val2 = NumericUtils.PrefixCodedToInt32(groupDocs.GroupValue);
-                    sb.Append($"\r\nGroup: {val2}\r\n");
+                    sb.AppendLine($"Group: {val2}");
                 }
                 else
                 {
-                    sb.Append($"\r\nUngrouped\r\n");    //Happens when matching documents don't contain the group field
+                    sb.AppendLine($"Ungrouped");    //Happens when matching documents don't contain the group field
                 }
 
                 foreach (ScoreDoc scoreDoc in groupDocs.ScoreDocs)
                 {
                     doc = searcher.Doc(scoreDoc.Doc);
-                    sb.Append($"{doc.GetField("major").GetInt32Value()} {doc.GetField("minor").GetInt32Value()} {doc.GetField("rev").GetInt32Value()}\r\n");
+                    sb.AppendLine($"{doc.GetField("major").GetInt32Value()} {doc.GetField("minor").GetInt32Value()} {doc.GetField("rev").GetInt32Value()}");
                 }
             }
 
             string output = sb.ToString();
-            string expectdValue = "\r\nGroup: 1000\r\n1000 1102 21\r\n1000 1123 45\r\n\r\nGroup: 2000\r\n2000 2222 7\r\n2000 2888 88\r\n\r\nGroup: 3000\r\n3000 3123 11\r\n3000 3222 37\r\n3000 3993 9\r\n\r\nGroup: 4000\r\n4000 4001 88\r\n4000 4011 10\r\n\r\nGroup: 8000\r\n8000 8123 28\r\n8000 8888 8\r\n8000 8998 92\r\n";
+            string expectdValue = "\r\nGroup: 1000\r\n1000 1102 21\r\n1000 1123 45\r\n\r\nGroup: 2000\r\n2000 2222 7\r\n2000 2888 88\r\n\r\nGroup: 3000\r\n3000 3123 11\r\n3000 3222 37\r\n3000 3993 9\r\n\r\nGroup: 4000\r\n4000 4001 88\r\n4000 4011 10\r\n\r\nGroup: 8000\r\n8000 8123 28\r\n8000 8888 8\r\n8000 8998 92\r\n".Replace("\r\n", Environment.NewLine);
             assertEquals(expectdValue, output);
 
             /*  Output:
@@ -400,27 +404,27 @@ namespace Lucene.Net.Search.Grouping
             StringBuilder sb = new StringBuilder();
             foreach (GroupDocs<MutableValue> groupDocs in topGroups.Groups)
             {
-
-                if(groupDocs.GroupValue != null)
+                sb.AppendLine();
+                if (groupDocs.GroupValue != null)
                 {
                     BytesRef bytesRef = ((MutableValueStr)groupDocs.GroupValue).Value;
                     int major = NumericUtils.PrefixCodedToInt32(bytesRef);
-                    sb.Append($"\r\nGroup: {major}\r\n");
+                    sb.AppendLine($"Group: {major}");
                 }
                 else
                 {
-                    sb.Append($"\r\nUngrouped\r\n");    //Happens when matching documents don't contain the group field
+                    sb.AppendLine($"Ungrouped");    //Happens when matching documents don't contain the group field
                 }
 
                 foreach (ScoreDoc scoreDoc in groupDocs.ScoreDocs)
                 {
                     doc = searcher.Doc(scoreDoc.Doc);
-                    sb.Append($"{doc.GetField("major").GetInt32Value()} {doc.GetField("minor").GetInt32Value()} {doc.GetField("rev").GetInt32Value()}\r\n");
+                    sb.AppendLine($"{doc.GetField("major").GetInt32Value()} {doc.GetField("minor").GetInt32Value()} {doc.GetField("rev").GetInt32Value()}");
                 }
             }
 
             string output = sb.ToString();
-            string expectdValue = "\r\nGroup: 1000\r\n1000 1102 21\r\n1000 1123 45\r\n\r\nGroup: 2000\r\n2000 2222 7\r\n2000 2888 88\r\n\r\nGroup: 3000\r\n3000 3123 11\r\n3000 3222 37\r\n3000 3993 9\r\n\r\nGroup: 4000\r\n4000 4001 88\r\n4000 4011 10\r\n\r\nGroup: 8000\r\n8000 8123 28\r\n8000 8888 8\r\n8000 8998 92\r\n";
+            string expectdValue = "\r\nGroup: 1000\r\n1000 1102 21\r\n1000 1123 45\r\n\r\nGroup: 2000\r\n2000 2222 7\r\n2000 2888 88\r\n\r\nGroup: 3000\r\n3000 3123 11\r\n3000 3222 37\r\n3000 3993 9\r\n\r\nGroup: 4000\r\n4000 4001 88\r\n4000 4011 10\r\n\r\nGroup: 8000\r\n8000 8123 28\r\n8000 8888 8\r\n8000 8998 92\r\n".Replace("\r\n", Environment.NewLine);
             assertEquals(expectdValue, output);
 
             /*  Output: