You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by mh...@apache.org on 2013/09/24 20:33:00 UTC

[24/50] [abbrv] Error Cleanup

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/25ec42a2/src/core/Util/CharsRef.cs
----------------------------------------------------------------------
diff --git a/src/core/Util/CharsRef.cs b/src/core/Util/CharsRef.cs
index c1fddeb..ebdc541 100644
--- a/src/core/Util/CharsRef.cs
+++ b/src/core/Util/CharsRef.cs
@@ -210,6 +210,71 @@ namespace Lucene.Net.Util
             return new CharsRef(chars, offset + start, end - start);
         }
 
+        private static readonly IComparer<CharsRef> utf16SortedAsUTF8SortOrder = new UTF16SortedAsUTF8ComparatorImpl();
+
+        public static IComparer<CharsRef> UTF16SortedAsUTF8Comparator
+        {
+            get { return utf16SortedAsUTF8SortOrder; }
+        }
+
+        private class UTF16SortedAsUTF8ComparatorImpl : Comparer<CharsRef>
+        {
+            public UTF16SortedAsUTF8ComparatorImpl()
+            {
+            }
+
+            public override int Compare(CharsRef a, CharsRef b)
+            {
+                if (a == b)
+                    return 0;
+
+                char[] aChars = a.chars;
+                int aUpto = a.offset;
+                char[] bChars = b.chars;
+                int bUpto = b.offset;
+
+                int aStop = aUpto + Math.Min(a.length, b.length);
+
+                while (aUpto < aStop)
+                {
+                    char aChar = aChars[aUpto++];
+                    char bChar = bChars[bUpto++];
+                    if (aChar != bChar)
+                    {
+                        // http://icu-project.org/docs/papers/utf16_code_point_order.html
+
+                        /* aChar != bChar, fix up each one if they're both in or above the surrogate range, then compare them */
+                        if (aChar >= 0xd800 && bChar >= 0xd800)
+                        {
+                            if (aChar >= 0xe000)
+                            {
+                                aChar -= (char)0x800;
+                            }
+                            else
+                            {
+                                aChar += (char)0x2000;
+                            }
+
+                            if (bChar >= 0xe000)
+                            {
+                                bChar -= (char)0x800;
+                            }
+                            else
+                            {
+                                bChar += (char)0x2000;
+                            }
+                        }
+
+                        /* now aChar and bChar are in code point order */
+                        return (int)aChar - (int)bChar; /* int must be 32 bits wide */
+                    }
+                }
+
+                // One is a prefix of the other, or, they are equal:
+                return a.length - b.length;
+            }
+        }
+
         [Obsolete("This comparer is only a transition mechanism")]
         private static readonly Comparer<CharsRef> utf8SortedAsUTF16SortOrder = new UTF8SortedAsUTF16ComparerImpl();
 
@@ -288,7 +353,7 @@ namespace Lucene.Net.Util
             return clone;
         }
 
-        public bool isValid()
+        public bool IsValid()
         {
             if (chars == null)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/25ec42a2/src/core/Util/FixedBitSet.cs
----------------------------------------------------------------------
diff --git a/src/core/Util/FixedBitSet.cs b/src/core/Util/FixedBitSet.cs
index 66da470..605bb8c 100644
--- a/src/core/Util/FixedBitSet.cs
+++ b/src/core/Util/FixedBitSet.cs
@@ -102,7 +102,7 @@ namespace Lucene.Net.Util
             }
         }
 
-        public bool Set(int index)
+        public void Set(int index)
         {
             //assert index >= 0 && index < numBits: "index=" + index + " numBits=" + numBits;
             int wordNum = index >> 6;      // div 64
@@ -192,7 +192,7 @@ namespace Lucene.Net.Util
 
         public void Or(DocIdSetIterator iter)
         {
-            if (iter is OpenBitSetIterator && iter.DocID() == -1)
+            if (iter is OpenBitSetIterator && iter.DocID == -1)
             {
                 OpenBitSetIterator obs = (OpenBitSetIterator)iter;
                 Or(obs.arr, obs.words);
@@ -227,7 +227,7 @@ namespace Lucene.Net.Util
 
         public void And(DocIdSetIterator iter)
         {
-            if (iter is OpenBitSetIterator && iter.DocID() == -1)
+            if (iter is OpenBitSetIterator && iter.DocID == -1)
             {
                 OpenBitSetIterator obs = (OpenBitSetIterator)iter;
                 And(obs.arr, obs.words);
@@ -273,7 +273,7 @@ namespace Lucene.Net.Util
 
         public void AndNot(DocIdSetIterator iter)
         {
-            if (iter is OpenBitSetIterator && iter.DocID() == -1)
+            if (iter is OpenBitSetIterator && iter.DocID == -1)
             {
                 OpenBitSetIterator obs = (OpenBitSetIterator)iter;
                 AndNot(obs.arr, obs.words);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/25ec42a2/src/core/Util/Fst/FST.cs
----------------------------------------------------------------------
diff --git a/src/core/Util/Fst/FST.cs b/src/core/Util/Fst/FST.cs
index 09a3849..96f0cf7 100644
--- a/src/core/Util/Fst/FST.cs
+++ b/src/core/Util/Fst/FST.cs
@@ -1009,7 +1009,7 @@ namespace Lucene.Net.Util.Fst
                     if (bottom == null)
                     {
                         q.Add(new NodeAndInCount(node, (int)InCounts.Get(node)));
-                        if (q.Size() == topN)
+                        if (q.Size == topN)
                             bottom = q.Top();
                     }
                     else if (InCounts.Get(node) > bottom.Count)
@@ -1022,7 +1022,7 @@ namespace Lucene.Net.Util.Fst
             // Free up RAM
             InCounts = null;
             var topNodeMap = new HashMap<long, long>();
-            for (var downTo = q.Size() - 1; downTo >= 0; downTo--)
+            for (var downTo = q.Size - 1; downTo >= 0; downTo--)
             {
                 var n = q.Pop();
                 topNodeMap.Add(n.Node, downTo);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/25ec42a2/src/core/Util/Fst/FSTEnum.cs
----------------------------------------------------------------------
diff --git a/src/core/Util/Fst/FSTEnum.cs b/src/core/Util/Fst/FSTEnum.cs
index 5c4839a..2475108 100644
--- a/src/core/Util/Fst/FSTEnum.cs
+++ b/src/core/Util/Fst/FSTEnum.cs
@@ -9,7 +9,7 @@ namespace Lucene.Net.Util.Fst
 
         protected FST<T>.Arc<T>[] arcs = new FST<T>.Arc<T>[10];
 
-        protected T[] output = (T[])new Object[10];
+        protected T[] output = new T[10];
 
         protected readonly T NO_OUTPUT;
         protected readonly FST.BytesReader fstReader;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/25ec42a2/src/core/Util/Fst/ForwardBytesReader.cs
----------------------------------------------------------------------
diff --git a/src/core/Util/Fst/ForwardBytesReader.cs b/src/core/Util/Fst/ForwardBytesReader.cs
index bcbb357..5d6e672 100644
--- a/src/core/Util/Fst/ForwardBytesReader.cs
+++ b/src/core/Util/Fst/ForwardBytesReader.cs
@@ -25,7 +25,7 @@ namespace Lucene.Net.Util.Fst
 
         public override byte ReadByte()
         {
-            return bytes[Position++];
+            return (byte)bytes[Position++];
         }
 
         public override void ReadBytes(byte[] bytes, int offset, int len)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/25ec42a2/src/core/Util/OpenBitSetIterator.cs
----------------------------------------------------------------------
diff --git a/src/core/Util/OpenBitSetIterator.cs b/src/core/Util/OpenBitSetIterator.cs
index febdd83..3e76978 100644
--- a/src/core/Util/OpenBitSetIterator.cs
+++ b/src/core/Util/OpenBitSetIterator.cs
@@ -86,8 +86,8 @@ namespace Lucene.Net.Util
         // for efficiency, or have a common root interface?  (or
         // maybe both?  could ask for a SetBitsIterator, etc...
 
-        private readonly long[] arr;
-        private readonly int words;
+        internal readonly long[] arr;
+        internal readonly int words;
         private int i = -1;
         private long word;
         private int wordShift;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/25ec42a2/src/core/Util/Packed/BulkOperationPacked.cs
----------------------------------------------------------------------
diff --git a/src/core/Util/Packed/BulkOperationPacked.cs b/src/core/Util/Packed/BulkOperationPacked.cs
index 5ea2438..67eda8d 100644
--- a/src/core/Util/Packed/BulkOperationPacked.cs
+++ b/src/core/Util/Packed/BulkOperationPacked.cs
@@ -232,7 +232,7 @@ namespace Lucene.Net.Util.Packed
 
         public override void Encode(long[] values, int valuesOffset, sbyte[] blocks, int blocksOffset, int iterations)
         {
-            int nextBlock = 0;
+            uint nextBlock = 0;
             int bitsLeft = 8;
             for (int i = 0; i < byteValueCount * iterations; ++i)
             {
@@ -256,7 +256,7 @@ namespace Lucene.Net.Util.Packed
                     }
                     // then buffer
                     bitsLeft = 8 - bits;
-                    nextBlock = (int)((v & ((1L << bits) - 1)) << bitsLeft);
+                    nextBlock = (uint)((v & ((1L << bits) - 1)) << bitsLeft);
                 }
             }
             //assert bitsLeft == 8;