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 2020/07/21 09:48:35 UTC

[lucenenet] 01/24: PERFORMANCE: Lucene.Net.TestFramework: Reverted testing conditions from 2200e79938ac6de7d002fe3ab8944d3c3cdeb211 in TestUtil and BaseTermVectorsFormatTestCase back to their original values. Also discovered TestUtil.AssertAttributeReflection() was unnecessarily copying the collection that was passed to it and reverted that change.

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 cbba108d8609cfa2f2d2fc0386186d0306505a61
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Thu Jul 16 23:43:44 2020 +0700

    PERFORMANCE: Lucene.Net.TestFramework: Reverted testing conditions from 2200e79938ac6de7d002fe3ab8944d3c3cdeb211 in TestUtil and BaseTermVectorsFormatTestCase back to their original values. Also discovered TestUtil.AssertAttributeReflection() was unnecessarily copying the collection that was passed to it and reverted that change.
---
 .../Index/BaseTermVectorsFormatTestCase.cs         |  2 +-
 src/Lucene.Net.TestFramework/Util/TestUtil.cs      | 33 +++++++++-------------
 2 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/src/Lucene.Net.TestFramework/Index/BaseTermVectorsFormatTestCase.cs b/src/Lucene.Net.TestFramework/Index/BaseTermVectorsFormatTestCase.cs
index eec7a49..13d017a 100644
--- a/src/Lucene.Net.TestFramework/Index/BaseTermVectorsFormatTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Index/BaseTermVectorsFormatTestCase.cs
@@ -763,7 +763,7 @@ namespace Lucene.Net.Index
         [Test]
         public virtual void TestLotsOfFields()
         {
-            RandomDocumentFactory docFactory = new RandomDocumentFactory(this, 500, 10);
+            RandomDocumentFactory docFactory = new RandomDocumentFactory(this, 5000, 10);
             foreach (Options options in ValidOptions())
             {
                 using (Directory dir = NewDirectory())
diff --git a/src/Lucene.Net.TestFramework/Util/TestUtil.cs b/src/Lucene.Net.TestFramework/Util/TestUtil.cs
index 8e08b14..ad9c6ea 100644
--- a/src/Lucene.Net.TestFramework/Util/TestUtil.cs
+++ b/src/Lucene.Net.TestFramework/Util/TestUtil.cs
@@ -1,3 +1,5 @@
+using J2N;
+using J2N.IO;
 using J2N.Text;
 using Lucene.Net.Codecs;
 using Lucene.Net.Codecs.Lucene46;
@@ -68,11 +70,11 @@ namespace Lucene.Net.Util
                 StringBuilder b = new StringBuilder("Could not remove the following files (in the order of attempts):\n");
                 foreach (var f in unremoved)
                 {
-                    b.append("   ")
-                     .append(f.FullName)
-                     .append("\n");
+                    b.Append("   ")
+                     .Append(f.FullName)
+                     .Append("\n");
                 }
-                throw new IOException(b.toString());
+                throw new IOException(b.ToString());
             }
         }
 
@@ -362,7 +364,7 @@ namespace Lucene.Net.Util
         /// </summary>
         public static string RandomSimpleString(Random r)
         {
-            return RandomSimpleString(r, 0, 20);
+            return RandomSimpleString(r, 0, 10);
         }
 
         /// <summary>
@@ -714,7 +716,7 @@ namespace Lucene.Net.Util
                 string toRecase;
 
                 // check if the next char sequence is a surrogate pair
-                if (pos + 1 < str.Length && char.IsSurrogatePair(str[pos], str[pos+1]))
+                if (pos + 1 < str.Length && char.IsSurrogatePair(str[pos], str[pos + 1]))
                 {
                     toRecase = str.Substring(pos, 2);
                 }
@@ -885,7 +887,7 @@ namespace Lucene.Net.Util
 
         private class Lucene46CodecAnonymousInnerClassHelper : Lucene46Codec
         {
-            private PostingsFormat format;
+            private readonly PostingsFormat format;
 
             public Lucene46CodecAnonymousInnerClassHelper(PostingsFormat format)
             {
@@ -917,7 +919,7 @@ namespace Lucene.Net.Util
 
         private class Lucene46CodecAnonymousInnerClassHelper2 : Lucene46Codec
         {
-            private DocValuesFormat format;
+            private readonly DocValuesFormat format;
 
             public Lucene46CodecAnonymousInnerClassHelper2(DocValuesFormat format)
             {
@@ -1031,15 +1033,12 @@ namespace Lucene.Net.Util
         {
             IDictionary<string, object> map = new JCG.Dictionary<string, object>();
             att.ReflectWith(new AttributeReflectorAnonymousInnerClassHelper(map));
-            IDictionary<string, object> newReflectedObjects = new JCG.Dictionary<string, object>();
-            foreach (KeyValuePair<string, object> de in reflectedValues)
-                newReflectedObjects.Add(de.Key, (object)de.Value);
-            Assert.AreEqual(newReflectedObjects, map, aggressive: false, "Reflection does not produce same map");
+            Assert.AreEqual(reflectedValues, map, aggressive: false, "Reflection does not produce same map");
         }
 
         private class AttributeReflectorAnonymousInnerClassHelper : IAttributeReflector
         {
-            private IDictionary<string, object> map;
+            private readonly IDictionary<string, object> map;
 
             public AttributeReflectorAnonymousInnerClassHelper(IDictionary<string, object> map)
             {
@@ -1222,8 +1221,8 @@ namespace Lucene.Net.Util
                     CharsRef chars = new CharsRef(@ref.Length);
                     UnicodeUtil.UTF8toUTF16(@ref.Bytes, @ref.Offset, @ref.Length, chars);
                     return chars;
-                //case 3: // LUCENENET: Not ported
-                //    return CharBuffer.Wrap(@ref.Utf8ToString());
+                case 3:
+                    return CharBuffer.Wrap(@ref.Utf8ToString());
                 default:
                     return new StringCharSequence(@ref.Utf8ToString());
             }
@@ -1308,10 +1307,6 @@ namespace Lucene.Net.Util
 
         private class RandomAccessFilterStrategyAnonymousInnerClassHelper : FilteredQuery.RandomAccessFilterStrategy
         {
-            public RandomAccessFilterStrategyAnonymousInnerClassHelper()
-            {
-            }
-
             protected override bool UseRandomAccess(IBits bits, int firstFilterDoc)
             {
                 return LuceneTestCase.Random.NextBoolean();