lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [13/34] lucenenet git commit: Fixing RandomIndexWriter build errors in BaseTokenStreamTestCase
Date Fri, 12 Aug 2016 13:20:27 GMT
Fixing RandomIndexWriter build errors in BaseTokenStreamTestCase


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

Branch: refs/heads/lucenenet-indexablefield-api
Commit: 9591b70d96a9ee08d23421e70c41c6363967b37a
Parents: ef7f1dd
Author: Connie Yau <conniey@microsoft.com>
Authored: Fri Jul 22 15:06:31 2016 -0700
Committer: Connie Yau <conniey@microsoft.com>
Committed: Fri Jul 22 15:06:31 2016 -0700

----------------------------------------------------------------------
 .../Analysis/BaseTokenStreamTestCase.cs         | 23 +++++++++++---------
 1 file changed, 13 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9591b70d/src/Lucene.Net.TestFramework/Analysis/BaseTokenStreamTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Analysis/BaseTokenStreamTestCase.cs b/src/Lucene.Net.TestFramework/Analysis/BaseTokenStreamTestCase.cs
index bb1098c..9253f7e 100644
--- a/src/Lucene.Net.TestFramework/Analysis/BaseTokenStreamTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Analysis/BaseTokenStreamTestCase.cs
@@ -529,14 +529,14 @@ namespace Lucene.Net.Analysis
 
         /// <summary>
         /// utility method for blasting tokenstreams with data to make sure they don't do
anything crazy </summary>
-        public static void CheckRandomData(Random random, Analyzer a, int iterations)
+        public void CheckRandomData(Random random, Analyzer a, int iterations)
         {
             CheckRandomData(random, a, iterations, 20, false, true);
         }
 
         /// <summary>
         /// utility method for blasting tokenstreams with data to make sure they don't do
anything crazy </summary>
-        public static void CheckRandomData(Random random, Analyzer a, int iterations, int
maxWordLength)
+        public void CheckRandomData(Random random, Analyzer a, int iterations, int maxWordLength)
         {
             CheckRandomData(random, a, iterations, maxWordLength, false, true);
         }
@@ -544,13 +544,14 @@ namespace Lucene.Net.Analysis
         /// <summary>
         /// utility method for blasting tokenstreams with data to make sure they don't do
anything crazy </summary>
         /// <param name="simple"> true if only ascii strings will be used (try to avoid)
</param>
-        public static void CheckRandomData(Random random, Analyzer a, int iterations, bool
simple)
+        public void CheckRandomData(Random random, Analyzer a, int iterations, bool simple)
         {
             CheckRandomData(random, a, iterations, 20, simple, true);
         }
 
         internal class AnalysisThread : ThreadClass
         {
+            private readonly BaseTokenStreamTestCase OuterInstance;
             internal readonly int Iterations;
             internal readonly int MaxWordLength;
             internal readonly long Seed;
@@ -566,7 +567,8 @@ namespace Lucene.Net.Analysis
             // interact)... so this is just "best effort":
             public bool Failed;
 
-            internal AnalysisThread(long seed, /*CountdownEvent latch,*/ Analyzer a, int
iterations, int maxWordLength, bool useCharFilter, bool simple, bool offsetsAreCorrect, RandomIndexWriter
iw)
+            internal AnalysisThread(long seed, /*CountdownEvent latch,*/ Analyzer a, int
iterations, int maxWordLength, 
+                bool useCharFilter, bool simple, bool offsetsAreCorrect, RandomIndexWriter
iw, BaseTokenStreamTestCase outerInstance)
             {
                 this.Seed = seed;
                 this.a = a;
@@ -577,6 +579,7 @@ namespace Lucene.Net.Analysis
                 this.OffsetsAreCorrect = offsetsAreCorrect;
                 this.Iw = iw;
                 this._latch = null;
+                this.OuterInstance = outerInstance;
             }
 
             public override void Run()
@@ -587,7 +590,7 @@ namespace Lucene.Net.Analysis
                     if (_latch != null) _latch.Wait();
                     // see the part in checkRandomData where it replays the same text again
                     // to verify reproducability/reuse: hopefully this would catch thread
hazards.
-                    CheckRandomData(new Random((int)Seed), a, Iterations, MaxWordLength,
UseCharFilter, Simple, OffsetsAreCorrect, Iw);
+                    OuterInstance.CheckRandomData(new Random((int)Seed), a, Iterations, MaxWordLength,
UseCharFilter, Simple, OffsetsAreCorrect, Iw);
                     success = true;
                 }
                 catch (Exception e)
@@ -602,12 +605,12 @@ namespace Lucene.Net.Analysis
             }
         }
 
-        public static void CheckRandomData(Random random, Analyzer a, int iterations, int
maxWordLength, bool simple)
+        public void CheckRandomData(Random random, Analyzer a, int iterations, int maxWordLength,
bool simple)
         {
             CheckRandomData(random, a, iterations, maxWordLength, simple, true);
         }
 
-        public static void CheckRandomData(Random random, Analyzer a, int iterations, int
maxWordLength, bool simple, bool offsetsAreCorrect)
+        public void CheckRandomData(Random random, Analyzer a, int iterations, int maxWordLength,
bool simple, bool offsetsAreCorrect)
         {
             CheckResetException(a, "best effort");
             long seed = random.Next();
@@ -620,7 +623,7 @@ namespace Lucene.Net.Analysis
             if (Rarely(random) && codecOk)
             {
                 dir = NewFSDirectory(CreateTempDir("bttc"));
-                iw = new RandomIndexWriter(new Random((int)seed), dir, a);
+                iw = new RandomIndexWriter(new Random((int)seed), dir, a, ClassEnvRule.Similarity,
ClassEnvRule.TimeZone);
             }
 
             bool success = false;
@@ -634,7 +637,7 @@ namespace Lucene.Net.Analysis
                 var threads = new AnalysisThread[numThreads];
                 for (int i = 0; i < threads.Length; i++)
                 {
-                    threads[i] = new AnalysisThread(seed, /*startingGun,*/ a, iterations,
maxWordLength, useCharFilter, simple, offsetsAreCorrect, iw);
+                    threads[i] = new AnalysisThread(seed, /*startingGun,*/ a, iterations,
maxWordLength, useCharFilter, simple, offsetsAreCorrect, iw, this);
                 }
                 
                 Array.ForEach(threads, thread => thread.Start());                
@@ -671,7 +674,7 @@ namespace Lucene.Net.Analysis
             }
         }
 
-        private static void CheckRandomData(Random random, Analyzer a, int iterations, int
maxWordLength, bool useCharFilter, bool simple, bool offsetsAreCorrect, RandomIndexWriter
iw)
+        private void CheckRandomData(Random random, Analyzer a, int iterations, int maxWordLength,
bool useCharFilter, bool simple, bool offsetsAreCorrect, RandomIndexWriter iw)
         {
             LineFileDocs docs = new LineFileDocs(random);
             Document doc = null;


Mime
View raw message