lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [17/50] [abbrv] lucenenet git commit: Fixed bugs in Core.Search.FieldCache and Core.Search.TestFieldCache that were causing the TestFieldCache tests to fail.
Date Sun, 23 Oct 2016 13:02:03 GMT
Fixed bugs in Core.Search.FieldCache and Core.Search.TestFieldCache that were causing the TestFieldCache
tests to fail.


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

Branch: refs/heads/master
Commit: 8cd8a60ce35ba3e8435973290673d0a55f03dc3c
Parents: a696d70
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Mon Oct 17 21:50:14 2016 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Thu Oct 20 18:20:55 2016 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Core/Search/FieldCache.cs        | 20 ++++++++--------
 .../core/Search/TestFieldCache.cs               | 24 +++++++++++---------
 2 files changed, 23 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8cd8a60c/src/Lucene.Net.Core/Search/FieldCache.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/FieldCache.cs b/src/Lucene.Net.Core/Search/FieldCache.cs
index 5626f0e..2e269c0 100644
--- a/src/Lucene.Net.Core/Search/FieldCache.cs
+++ b/src/Lucene.Net.Core/Search/FieldCache.cs
@@ -1,12 +1,12 @@
+using Lucene.Net.Documents;
 using System;
+using System.Globalization;
+using System.IO;
+using System.Runtime.CompilerServices;
 using System.Text;
-using Lucene.Net.Documents;
-using Lucene.Net.Index;
 
 namespace Lucene.Net.Search
 {
-    using System.IO;
-    using System.Runtime.CompilerServices;
     using AtomicReader = Lucene.Net.Index.AtomicReader;
     using BinaryDocValues = Lucene.Net.Index.BinaryDocValues;
     using Bits = Lucene.Net.Util.Bits;
@@ -496,7 +496,7 @@ namespace Lucene.Net.Search
                 // UTF8 bytes... but really users should use
                 // IntField, instead, which already decodes
                 // directly from byte[]
-                return sbyte.Parse(term.Utf8ToString());
+                return sbyte.Parse(term.Utf8ToString(), CultureInfo.InvariantCulture);
             }
 
             public override string ToString()
@@ -520,7 +520,7 @@ namespace Lucene.Net.Search
                 // UTF8 bytes... but really users should use
                 // IntField, instead, which already decodes
                 // directly from byte[]
-                return short.Parse(term.Utf8ToString());
+                return short.Parse(term.Utf8ToString(), NumberStyles.Integer, CultureInfo.InvariantCulture);
             }
 
             public override string ToString()
@@ -544,7 +544,7 @@ namespace Lucene.Net.Search
                 // UTF8 bytes... but really users should use
                 // IntField, instead, which already decodes
                 // directly from byte[]
-                return int.Parse(term.Utf8ToString());
+                return int.Parse(term.Utf8ToString(), NumberStyles.Integer, CultureInfo.InvariantCulture);
             }
 
             public TermsEnum TermsEnum(Terms terms)
@@ -568,7 +568,7 @@ namespace Lucene.Net.Search
                 // UTF8 bytes... but really users should use
                 // FloatField, instead, which already decodes
                 // directly from byte[]
-                return float.Parse(term.Utf8ToString());
+                return float.Parse(term.Utf8ToString(), NumberStyles.Float, CultureInfo.InvariantCulture);
             }
 
             public TermsEnum TermsEnum(Terms terms)
@@ -592,7 +592,7 @@ namespace Lucene.Net.Search
                 // UTF8 bytes... but really users should use
                 // LongField, instead, which already decodes
                 // directly from byte[]
-                return long.Parse(term.Utf8ToString());
+                return long.Parse(term.Utf8ToString(), NumberStyles.Integer, CultureInfo.InvariantCulture);
             }
 
             public TermsEnum TermsEnum(Terms terms)
@@ -616,7 +616,7 @@ namespace Lucene.Net.Search
                 // UTF8 bytes... but really users should use
                 // DoubleField, instead, which already decodes
                 // directly from byte[]
-                return double.Parse(term.Utf8ToString());
+                return double.Parse(term.Utf8ToString(), NumberStyles.Float, CultureInfo.InvariantCulture);
             }
 
             public TermsEnum TermsEnum(Terms terms)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8cd8a60c/src/Lucene.Net.Tests/core/Search/TestFieldCache.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Search/TestFieldCache.cs b/src/Lucene.Net.Tests/core/Search/TestFieldCache.cs
index ea634f7..abe05f7 100644
--- a/src/Lucene.Net.Tests/core/Search/TestFieldCache.cs
+++ b/src/Lucene.Net.Tests/core/Search/TestFieldCache.cs
@@ -1,9 +1,13 @@
+using Lucene.Net.Randomized.Generators;
+using Lucene.Net.Support;
+using Lucene.Net.Util;
+using NUnit.Framework;
 using System;
 using System.Diagnostics;
 using System.Collections.Generic;
+using System.Globalization;
 using System.IO;
 using System.Threading;
-using Lucene.Net.Util;
 
 namespace Lucene.Net.Search
 {
@@ -60,9 +64,7 @@ namespace Lucene.Net.Search
     using IOUtils = Lucene.Net.Util.IOUtils;
     using LuceneTestCase = Lucene.Net.Util.LuceneTestCase;
     using TestUtil = Lucene.Net.Util.TestUtil;
-    using Lucene.Net.Randomized.Generators;
-    using Lucene.Net.Support;
-    using NUnit.Framework;
+    
 
     [TestFixture]
     public class TestFieldCache : LuceneTestCase
@@ -98,15 +100,15 @@ namespace Lucene.Net.Search
             for (int i = 0; i < NUM_DOCS; i++)
             {
                 Document doc = new Document();
-                doc.Add(NewStringField("theLong", Convert.ToString(theLong--), Field.Store.NO));
-                doc.Add(NewStringField("theDouble", Convert.ToString(theDouble--), Field.Store.NO));
-                doc.Add(NewStringField("theByte", Convert.ToString(theByte--), Field.Store.NO));
-                doc.Add(NewStringField("theShort", Convert.ToString(theShort--), Field.Store.NO));
-                doc.Add(NewStringField("theInt", Convert.ToString(theInt--), Field.Store.NO));
-                doc.Add(NewStringField("theFloat", Convert.ToString(theFloat--), Field.Store.NO));
+                doc.Add(NewStringField("theLong", (theLong--).ToString(CultureInfo.InvariantCulture),
Field.Store.NO));
+                doc.Add(NewStringField("theDouble", (theDouble--).ToString("R", CultureInfo.InvariantCulture),
Field.Store.NO));
+                doc.Add(NewStringField("theByte", (theByte--).ToString(CultureInfo.InvariantCulture),
Field.Store.NO));
+                doc.Add(NewStringField("theShort", (theShort--).ToString(CultureInfo.InvariantCulture),
Field.Store.NO));
+                doc.Add(NewStringField("theInt", (theInt--).ToString(CultureInfo.InvariantCulture),
Field.Store.NO));
+                doc.Add(NewStringField("theFloat", (theFloat--).ToString("R", CultureInfo.InvariantCulture),
Field.Store.NO));
                 if (i % 2 == 0)
                 {
-                    doc.Add(NewStringField("sparse", Convert.ToString(i), Field.Store.NO));
+                    doc.Add(NewStringField("sparse", (i).ToString(CultureInfo.InvariantCulture),
Field.Store.NO));
                 }
 
                 if (i % 2 == 0)


Mime
View raw message