lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [05/18] lucenenet git commit: Fix more sbyte -> byte conversion remnants, making more tests green
Date Tue, 06 Jan 2015 03:46:21 GMT
Fix more sbyte -> byte conversion remnants, making more tests green


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

Branch: refs/heads/master
Commit: 4b6eafe3dc63378a9d584a753f2e9785288fa6e2
Parents: 4560053
Author: Itamar Syn-Hershko <itamar@code972.com>
Authored: Mon Jan 5 16:07:40 2015 +0200
Committer: Itamar Syn-Hershko <itamar@code972.com>
Committed: Mon Jan 5 16:07:40 2015 +0200

----------------------------------------------------------------------
 .../Codecs/Lucene42/Lucene42DocValuesProducer.cs    |  4 +---
 src/Lucene.Net.Core/Store/DataInput.cs              | 12 +++---------
 src/Lucene.Net.Core/Util/Fst/FST.cs                 | 16 ++++++++--------
 src/Lucene.Net.Core/Util/Fst/Util.cs                |  2 +-
 src/Lucene.Net.Tests/core/Store/TestCopyBytes.cs    |  2 +-
 src/Lucene.Net.Tests/core/Store/TestHugeRamFile.cs  |  4 ++--
 6 files changed, 16 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b6eafe3/src/Lucene.Net.Core/Codecs/Lucene42/Lucene42DocValuesProducer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene42/Lucene42DocValuesProducer.cs b/src/Lucene.Net.Core/Codecs/Lucene42/Lucene42DocValuesProducer.cs
index b635128..b3e7ca0 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene42/Lucene42DocValuesProducer.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene42/Lucene42DocValuesProducer.cs
@@ -167,9 +167,7 @@ namespace Lucene.Net.Codecs.Lucene42
                 int fieldType = meta.ReadByte();
                 if (fieldType == NUMBER)
                 {
-                    NumericEntry entry = new NumericEntry();
-                    entry.Offset = meta.ReadLong();
-                    entry.Format = meta.ReadSByte();
+                    var entry = new NumericEntry {Offset = meta.ReadLong(), Format = (sbyte)meta.ReadByte()};
                     switch (entry.Format)
                     {
                         case DELTA_COMPRESSED:

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b6eafe3/src/Lucene.Net.Core/Store/DataInput.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Store/DataInput.cs b/src/Lucene.Net.Core/Store/DataInput.cs
index 60e3b9f..58aef31 100644
--- a/src/Lucene.Net.Core/Store/DataInput.cs
+++ b/src/Lucene.Net.Core/Store/DataInput.cs
@@ -52,12 +52,6 @@ namespace Lucene.Net.Store
         /// <seealso cref= DataOutput#writeByte(byte) </seealso>
         public abstract byte ReadByte();
 
-        public sbyte ReadSByte()
-        {
-            // helper method to account for java's byte being signed
-            return (sbyte)ReadByte();
-        }
-
         /// <summary>
         /// Reads a specified number of bytes into an array at the specified offset. </summary>
         /// <param name="b"> the array to read bytes into </param>
@@ -247,8 +241,8 @@ namespace Lucene.Net.Store
         /// <seealso cref= DataOutput#writeString(String) </seealso>
         public virtual string ReadString()
         {
-            int length = ReadVInt();
-            byte[] bytes = new byte[length];
+            var length = ReadVInt();
+            var bytes = new byte[length];
             ReadBytes(bytes, 0, length);
 
             //return new string(bytes, 0, length, IOUtils.CHARSET_UTF_8);
@@ -323,7 +317,7 @@ namespace Lucene.Net.Store
             Debug.Assert(SkipBuffer.Length == SKIP_BUFFER_SIZE);
             for (long skipped = 0; skipped < numBytes; )
             {
-                int step = (int)Math.Min(SKIP_BUFFER_SIZE, numBytes - skipped);
+                var step = (int)Math.Min(SKIP_BUFFER_SIZE, numBytes - skipped);
                 ReadBytes(SkipBuffer, 0, step, false);
                 skipped += step;
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b6eafe3/src/Lucene.Net.Core/Util/Fst/FST.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Fst/FST.cs b/src/Lucene.Net.Core/Util/Fst/FST.cs
index 17ec300..f01f91a 100644
--- a/src/Lucene.Net.Core/Util/Fst/FST.cs
+++ b/src/Lucene.Net.Core/Util/Fst/FST.cs
@@ -271,7 +271,7 @@ namespace Lucene.Net.Util.Fst
             {
                 emptyOutput = default(T);
             }
-            sbyte t = @in.ReadSByte();
+            var t = @in.ReadByte();
             switch (t)
             {
                 case 0:
@@ -930,7 +930,7 @@ namespace Lucene.Net.Util.Fst
             {
                 @in.Position = GetNodeAddress(follow.Target);
                 arc.Node = follow.Target;
-                sbyte b = @in.ReadSByte();
+                var b = (sbyte)@in.ReadByte();
                 if (b == ARCS_AS_FIXED_ARRAY)
                 {
                     // array: jump straight to end
@@ -979,7 +979,7 @@ namespace Lucene.Net.Util.Fst
                         {
                             ReadUnpackedNodeTarget(@in);
                         }
-                        arc.Flags = @in.ReadSByte();
+                        arc.Flags = (sbyte)@in.ReadByte();
                     }
                     // Undo the byte flags we read:
                     @in.SkipBytes(-1);
@@ -1130,7 +1130,7 @@ namespace Lucene.Net.Util.Fst
                 long pos = GetNodeAddress(arc.NextArc);
                 @in.Position = pos;
 
-                sbyte b = @in.ReadSByte();
+                var b = (sbyte)@in.ReadByte();
                 if (b == ARCS_AS_FIXED_ARRAY)
                 {
                     //System.out.println("    nextArc fixed array");
@@ -1195,7 +1195,7 @@ namespace Lucene.Net.Util.Fst
                 // arcs are packed
                 @in.Position = arc.NextArc;
             }
-            arc.Flags = @in.ReadSByte();
+            arc.Flags = (sbyte)@in.ReadByte();
             arc.Label = ReadLabel(@in);
 
             if (arc.Flag(BIT_ARC_HAS_OUTPUT))
@@ -2166,17 +2166,17 @@ namespace Lucene.Net.Util.Fst
         internal const sbyte ARCS_AS_FIXED_ARRAY = BIT_ARC_HAS_FINAL_OUTPUT;
 
         /// <summary>
-        /// <see cref="UnCompiledNode"/>
+        /// <see cref="Builder{T}.UnCompiledNode{S}"/>
         /// </summary>
         public const int FIXED_ARRAY_SHALLOW_DISTANCE = 3;
 
         /// <summary>
-        /// <see cref="UnCompiledNode"/>
+        /// <see cref="Builder{T}.UnCompiledNode{S}"/>
         /// </summary>
         public const int FIXED_ARRAY_NUM_ARCS_SHALLOW = 5;
 
         /// <summary>
-        /// <see cref="UnCompiledNode"/>
+        /// <see cref="Builder{T}.UnCompiledNode{S}"/>
         /// </summary>
         public const int FIXED_ARRAY_NUM_ARCS_DEEP = 10;
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b6eafe3/src/Lucene.Net.Core/Util/Fst/Util.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Fst/Util.cs b/src/Lucene.Net.Core/Util/Fst/Util.cs
index 46260e9..96d97c3 100644
--- a/src/Lucene.Net.Core/Util/Fst/Util.cs
+++ b/src/Lucene.Net.Core/Util/Fst/Util.cs
@@ -189,7 +189,7 @@ namespace Lucene.Net.Util.Fst
                             mid = (int)((uint)(low + high) >> 1);
                             @in.Position = arc.PosArcsStart;
                             @in.SkipBytes(arc.BytesPerArc * mid);
-                            sbyte flags = @in.ReadSByte();
+                            var flags = (sbyte)@in.ReadByte();
                             fst.ReadLabel(@in);
                             long minArcOutput;
                             if ((flags & FST<long>.BIT_ARC_HAS_OUTPUT) != 0)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b6eafe3/src/Lucene.Net.Tests/core/Store/TestCopyBytes.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Store/TestCopyBytes.cs b/src/Lucene.Net.Tests/core/Store/TestCopyBytes.cs
index d8cd1df..34b5044 100644
--- a/src/Lucene.Net.Tests/core/Store/TestCopyBytes.cs
+++ b/src/Lucene.Net.Tests/core/Store/TestCopyBytes.cs
@@ -99,7 +99,7 @@ namespace Lucene.Net.Store
                 {
                     if (Random().NextBoolean())
                     {
-                        sbyte v = in2.ReadSByte();
+                        var v = in2.ReadByte();
                         Assert.AreEqual(Value(upto), v);
                         upto++;
                     }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b6eafe3/src/Lucene.Net.Tests/core/Store/TestHugeRamFile.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Store/TestHugeRamFile.cs b/src/Lucene.Net.Tests/core/Store/TestHugeRamFile.cs
index 12bb083..e5e405e 100644
--- a/src/Lucene.Net.Tests/core/Store/TestHugeRamFile.cs
+++ b/src/Lucene.Net.Tests/core/Store/TestHugeRamFile.cs
@@ -114,8 +114,8 @@ namespace Lucene.Net.Store
                 @in.Seek(loc);
                 for (int i = 0; i < m; i++)
                 {
-                    sbyte bt = @in.ReadSByte();
-                    sbyte expected = (sbyte)(1 + j + (i & 0x0003F));
+                    var bt = (sbyte)@in.ReadByte();
+                    var expected = (sbyte)(1 + j + (i & 0x0003F));
                     Assert.AreEqual(expected, bt, "must read same value that was written!
j=" + j + " i=" + i);
                 }
             }


Mime
View raw message