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 c120519f51f663febf8268491a38360fada6c27d Author: Shad Storhaug <[email protected]> AuthorDate: Sun Aug 4 02:50:57 2019 +0700 BUG: Lucene.Net.TestFramework.Index.AlcoholicMergePolicy: The value chosen for Hour was supposed to be random, but it was setup to be a constant by a mistranslation from Java to .NET --- .../Index/AlcoholicMergePolicy.cs | 36 ++++++++++------------ 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/Lucene.Net.TestFramework/Index/AlcoholicMergePolicy.cs b/src/Lucene.Net.TestFramework/Index/AlcoholicMergePolicy.cs index 07089f4..60b3b3a 100644 --- a/src/Lucene.Net.TestFramework/Index/AlcoholicMergePolicy.cs +++ b/src/Lucene.Net.TestFramework/Index/AlcoholicMergePolicy.cs @@ -1,5 +1,4 @@ using System; -using System.Globalization; using System.Linq; namespace Lucene.Net.Index @@ -39,43 +38,40 @@ namespace Lucene.Net.Index /// </summary> public class AlcoholicMergePolicy : LogMergePolicy { - private readonly Random Random; - private readonly DateTime Calendar; + private readonly Random random; + private readonly DateTime calendar; public AlcoholicMergePolicy(Random random) { - this.Calendar = new GregorianCalendar().ToDateTime(1970, 1, 1, 0, 0, 0, (int)TestUtil.NextLong(random, 0, long.MaxValue)); - this.Random = random; + // LUCENENET NOTE: All we care about here is that we have a random distribution of "Hour", picking any valid + // date at random achives this. We have no actual need to create a Calendar object in .NET. + this.calendar = new DateTime(TestUtil.NextLong(random, DateTime.MinValue.Ticks, DateTime.MaxValue.Ticks)); + this.random = random; m_maxMergeSize = TestUtil.NextInt(random, 1024 * 1024, int.MaxValue); } protected override long Size(SegmentCommitInfo info) { - int hourOfDay = Calendar.Hour; - if (hourOfDay < 6 || hourOfDay > 20 || Random.Next(23) == 5) + int hourOfDay = calendar.Hour; + if (hourOfDay < 6 || hourOfDay > 20 || random.Next(23) == 5) // its 5 o'clock somewhere { - Drink.Drink_e[] values = Enum.GetValues(typeof(Drink.Drink_e)).Cast<Drink.Drink_e>().ToArray(); + Drink[] values = Enum.GetValues(typeof(Drink)).Cast<Drink>().ToArray(); // pick a random drink during the day - Drink.Drink_e drink = values[Random.Next(values.Length - 1)]; + Drink drink = values[random.Next(values.Length - 1)]; return (long)drink * info.GetSizeInBytes(); } return info.GetSizeInBytes(); } - private class Drink + private enum Drink { - private const int NumDrinks = 5; - - internal enum Drink_e - { - Beer = 15, - Wine = 17, - Champagne = 21, - WhiteRussian = 22, - SingleMalt = 30 - } + Beer = 15, + Wine = 17, + Champagne = 21, + WhiteRussian = 22, + SingleMalt = 30 } } } \ No newline at end of file
