lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [30/47] lucenenet git commit: Fixed infinite recursion bug in TestFramework.Index.BaseTermVectorsTestCase.RandomDocument.
Date Tue, 11 Oct 2016 18:35:15 GMT
Fixed infinite recursion bug in TestFramework.Index.BaseTermVectorsTestCase.RandomDocument.


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

Branch: refs/heads/master
Commit: 6d50af125870adb383f451604c868022e53d346c
Parents: c574b75
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Mon Oct 10 18:23:10 2016 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Tue Oct 11 00:26:26 2016 +0700

----------------------------------------------------------------------
 .../Index/BaseTermVectorsFormatTestCase.cs              | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6d50af12/src/Lucene.Net.TestFramework/Index/BaseTermVectorsFormatTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Index/BaseTermVectorsFormatTestCase.cs b/src/Lucene.Net.TestFramework/Index/BaseTermVectorsFormatTestCase.cs
index 97b9e59..85207ad 100644
--- a/src/Lucene.Net.TestFramework/Index/BaseTermVectorsFormatTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Index/BaseTermVectorsFormatTestCase.cs
@@ -421,10 +421,14 @@ namespace Lucene.Net.Index
                 HashSet<string> usedFileNames = new HashSet<string>();
                 for (int i = 0; i < fieldCount; ++i)
                 {
-                    do
-                    {
-                        this.FieldNames[i] = RandomInts.RandomFrom(Random(), fieldNames);
-                    } while (usedFileNames.Contains(this.FieldNames[i]));
+                    // LUCENENET NOTE: Using a simple Linq query to filter rather than using
brute force makes this a lot
+                    // faster (and won't infinitely retry due to poor random distribution).
+                    this.FieldNames[i] = RandomInts.RandomFrom(Random(), fieldNames.Except(usedFileNames).ToArray());
+                    //do
+                    //{
+                    //    this.FieldNames[i] = RandomInts.RandomFrom(Random(), fieldNames);
+                    //} while (usedFileNames.Contains(this.FieldNames[i]));
+
                     usedFileNames.Add(this.FieldNames[i]);
                     TokenStreams[i] = new RandomTokenStream(outerInstance, TestUtil.NextInt(Random(),
1, maxTermCount), sampleTerms, sampleTermBytes);
                 }


Mime
View raw message