lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [1/2] lucenenet git commit: Various
Date Wed, 28 Jan 2015 11:11:50 GMT
Repository: lucenenet
Updated Branches:
  refs/heads/master b5be9c0b8 -> 67af7e4e9


Various


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

Branch: refs/heads/master
Commit: 4513c521802861b3c3ebe4e33647a4670f035727
Parents: b5be9c0
Author: Itamar Syn-Hershko <itamar@code972.com>
Authored: Wed Jan 28 13:10:59 2015 +0200
Committer: Itamar Syn-Hershko <itamar@code972.com>
Committed: Wed Jan 28 13:11:33 2015 +0200

----------------------------------------------------------------------
 src/Lucene.Net.Core/Analysis/Analyzer.cs        | 28 +++-----
 .../Analysis/NumericTokenStream.cs              | 67 ++++++++------------
 .../Analysis/ReusableStringReader.cs            | 34 +++++-----
 src/Lucene.Net.Core/Analysis/Token.cs           | 31 +++++----
 src/Lucene.Net.Core/Analysis/TokenStream.cs     |  4 +-
 src/Lucene.Net.Core/Analysis/Tokenizer.cs       | 12 ++--
 src/Lucene.Net.Core/Support/WeakDictionary.cs   |  4 +-
 7 files changed, 79 insertions(+), 101 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4513c521/src/Lucene.Net.Core/Analysis/Analyzer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Analysis/Analyzer.cs b/src/Lucene.Net.Core/Analysis/Analyzer.cs
index 9c9ab97..ce6d98e 100644
--- a/src/Lucene.Net.Core/Analysis/Analyzer.cs
+++ b/src/Lucene.Net.Core/Analysis/Analyzer.cs
@@ -68,7 +68,7 @@ namespace Lucene.Net.Analysis
     /// </summary>
     public abstract class Analyzer : IDisposable
     {
-        private readonly ReuseStrategy ReuseStrategy_Renamed;
+        private readonly ReuseStrategy _reuseStrategy;
 
         // non final as it gets nulled if closed; pkg private for access by ReuseStrategy's
final helper methods:
         internal IDisposableThreadLocal<object> StoredValue = new IDisposableThreadLocal<object>();
@@ -77,7 +77,7 @@ namespace Lucene.Net.Analysis
         /// Create a new Analyzer, reusing the same set of components per-thread
         /// across calls to <seealso cref="#tokenStream(String, Reader)"/>.
         /// </summary>
-        public Analyzer()
+        protected Analyzer()
             : this(GLOBAL_REUSE_STRATEGY)
         {
         }
@@ -90,9 +90,9 @@ namespace Lucene.Net.Analysis
         /// <a href="{@docRoot}/../analyzers-common/Lucene.Net.Analysis/miscellaneous/PerFieldAnalyzerWrapper.html">
         /// PerFieldAnalyerWrapper</a> instead.
         /// </summary>
-        public Analyzer(ReuseStrategy reuseStrategy)
+        protected Analyzer(ReuseStrategy reuseStrategy)
         {
-            this.ReuseStrategy_Renamed = reuseStrategy;
+            this._reuseStrategy = reuseStrategy;
         }
 
         /// <summary>
@@ -129,16 +129,16 @@ namespace Lucene.Net.Analysis
         /// <seealso cref= #tokenStream(String, Reader) </seealso>
         public TokenStream TokenStream(string fieldName, TextReader reader)
         {
-            TokenStreamComponents components = ReuseStrategy_Renamed.GetReusableComponents(this,
fieldName);
+            TokenStreamComponents components = _reuseStrategy.GetReusableComponents(this,
fieldName);
             TextReader r = InitReader(fieldName, reader);
             if (components == null)
             {
                 components = CreateComponents(fieldName, r);
-                ReuseStrategy_Renamed.SetReusableComponents(this, fieldName, components);
+                _reuseStrategy.SetReusableComponents(this, fieldName, components);
             }
             else
             {
-                components.Reader = r;//new TextReaderWrapper(r);
+                components.Reader = r;// LUCENENET TODO new TextReaderWrapper(r);
             }
             return components.TokenStream;
         }
@@ -196,7 +196,7 @@ namespace Lucene.Net.Analysis
         {
             get
             {
-                return ReuseStrategy_Renamed;
+                return _reuseStrategy;
             }
         }
 
@@ -308,12 +308,6 @@ namespace Lucene.Net.Analysis
         public abstract class ReuseStrategy
         {
             /// <summary>
-            /// Sole constructor. (For invocation by subclass constructors, typically implicit.)
</summary>
-            public ReuseStrategy()
-            {
-            }
-
-            /// <summary>
             /// Gets the reusable TokenStreamComponents for the field with the given name.
             /// </summary>
             /// <param name="analyzer"> Analyzer from which to get the reused components.
Use
@@ -379,10 +373,6 @@ namespace Lucene.Net.Analysis
         /// Sole constructor. (For invocation by subclass constructors, typically implicit.)
</summary>
         /// @deprecated Don't create instances of this class, use <seealso cref="Analyzer#GLOBAL_REUSE_STRATEGY"/>
         {
-            public GlobalReuseStrategy()
-            {
-            }
-
             public override TokenStreamComponents GetReusableComponents(Analyzer analyzer,
string fieldName)
             {
                 return (TokenStreamComponents)GetStoredValue(analyzer);
@@ -418,9 +408,9 @@ namespace Lucene.Net.Analysis
             public override TokenStreamComponents GetReusableComponents(Analyzer analyzer,
string fieldName)
             {
                 var componentsPerField = (IDictionary<string, TokenStreamComponents>)GetStoredValue(analyzer);
-                TokenStreamComponents ret;
                 if (componentsPerField != null)
                 {
+                    TokenStreamComponents ret;
                     componentsPerField.TryGetValue(fieldName, out ret);
                     return ret;
                 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4513c521/src/Lucene.Net.Core/Analysis/NumericTokenStream.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Analysis/NumericTokenStream.cs b/src/Lucene.Net.Core/Analysis/NumericTokenStream.cs
index 1b218cb..fcb1e6d 100644
--- a/src/Lucene.Net.Core/Analysis/NumericTokenStream.cs
+++ b/src/Lucene.Net.Core/Analysis/NumericTokenStream.cs
@@ -1,4 +1,7 @@
+using System.Diagnostics;
 using Lucene.Net.Analysis.Tokenattributes;
+using Lucene.Net.Documents;
+using Lucene.Net.Search;
 using Lucene.Net.Util;
 using System;
 
@@ -136,7 +139,7 @@ namespace Lucene.Net.Analysis
         // just a wrapper to prevent adding CTA
         private sealed class NumericAttributeFactory : AttributeSource.AttributeFactory
         {
-            internal readonly AttributeSource.AttributeFactory @delegate;
+            private readonly AttributeSource.AttributeFactory @delegate;
 
             internal NumericAttributeFactory(AttributeSource.AttributeFactory @delegate)
             {
@@ -161,77 +164,59 @@ namespace Lucene.Net.Analysis
         /// </summary>
         public sealed class NumericTermAttribute : Util.Attribute, INumericTermAttribute,
ITermToBytesRefAttribute
         {
-            internal long Value = 0L;
-            internal int ValueSize_Renamed = 0, Shift_Renamed = 0, PrecisionStep = 0;
-            internal BytesRef Bytes = new BytesRef();
+            private long _value = 0L;
+            private int _precisionStep = 0;
+            private readonly BytesRef _bytes = new BytesRef();
 
-            /// <summary>
-            /// Creates, but does not yet initialize this attribute instance </summary>
-            /// <seealso> cref= #init(long, int, int, int) </seealso>
             public NumericTermAttribute()
             {
+                ValueSize = 0;
             }
 
             public BytesRef BytesRef
             {
                 get
                 {
-                    return Bytes;
+                    return _bytes;
                 }
             }
 
             public void FillBytesRef()
             {
-                //Debug.Assert(ValueSize_Renamed == 64 || ValueSize_Renamed == 32);
-                if (ValueSize_Renamed == 64)
+                Debug.Assert(ValueSize == 64 || ValueSize == 32);
+                if (ValueSize == 64)
                 {
-                    NumericUtils.LongToPrefixCoded(Value, Shift_Renamed, Bytes);
+                    NumericUtils.LongToPrefixCoded(_value, Shift, _bytes);
                 }
                 else
                 {
-                    NumericUtils.IntToPrefixCoded((int)Value, Shift_Renamed, Bytes);
+                    NumericUtils.IntToPrefixCoded((int)_value, Shift, _bytes);
                 }
             }
 
-            public int Shift
-            {
-                get
-                {
-                    return Shift_Renamed;
-                }
-                set
-                {
-                    this.Shift_Renamed = value;
-                }
-            }
+            public int Shift { get; set; }
 
             public int IncShift()
             {
-                return (Shift_Renamed += PrecisionStep);
+                return (Shift += _precisionStep);
             }
 
             public long RawValue
             {
                 get
                 {
-                    return Value & ~((1L << Shift_Renamed) - 1L);
+                    return _value & ~((1L << Shift) - 1L);
                 }
             }
 
-            public int ValueSize
-            {
-                get
-                {
-                    return ValueSize_Renamed;
-                }
-            }
+            public int ValueSize { get; private set; }
 
             public void Init(long value, int valueSize, int precisionStep, int shift)
             {
-                this.Value = value;
-                this.ValueSize_Renamed = valueSize;
-                this.PrecisionStep = precisionStep;
-                this.Shift_Renamed = shift;
+                this._value = value;
+                this.ValueSize = valueSize;
+                this._precisionStep = precisionStep;
+                this.Shift = shift;
             }
 
             public override void Clear()
@@ -243,16 +228,16 @@ namespace Lucene.Net.Analysis
             public override void ReflectWith(IAttributeReflector reflector)
             {
                 FillBytesRef();
-                reflector.Reflect(typeof(ITermToBytesRefAttribute), "bytes", BytesRef.DeepCopyOf(Bytes));
-                reflector.Reflect(typeof(INumericTermAttribute), "shift", Shift_Renamed);
+                reflector.Reflect(typeof(ITermToBytesRefAttribute), "bytes", BytesRef.DeepCopyOf(_bytes));
+                reflector.Reflect(typeof(INumericTermAttribute), "shift", _shift);
                 reflector.Reflect(typeof(INumericTermAttribute), "rawValue", RawValue);
-                reflector.Reflect(typeof(INumericTermAttribute), "valueSize", ValueSize_Renamed);
+                reflector.Reflect(typeof(INumericTermAttribute), "valueSize", ValueSize);
             }
 
             public override void CopyTo(Util.Attribute target)
             {
-                NumericTermAttribute a = (NumericTermAttribute)target;
-                a.Init(Value, ValueSize_Renamed, PrecisionStep, Shift_Renamed);
+                var a = (NumericTermAttribute)target;
+                a.Init(_value, ValueSize, _precisionStep, _shift);
             }
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4513c521/src/Lucene.Net.Core/Analysis/ReusableStringReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Analysis/ReusableStringReader.cs b/src/Lucene.Net.Core/Analysis/ReusableStringReader.cs
index 71b910a..76bb651 100644
--- a/src/Lucene.Net.Core/Analysis/ReusableStringReader.cs
+++ b/src/Lucene.Net.Core/Analysis/ReusableStringReader.cs
@@ -23,56 +23,52 @@ namespace Lucene.Net.Analysis
     /// Internal class to enable reuse of the string reader by <seealso cref="Analyzer#tokenStream(String,String)"/>
</summary>
     public sealed class ReusableStringReader : System.IO.TextReader
     {
-        private int Pos = 0, Size = 0;
-        private string s = null;
-
-        public ReusableStringReader()
-        {
-        }
+        private int _pos = 0, _size = 0;
+        private string _s = null;
 
         public string Value
         {
             set
             {
-                this.s = value;
-                this.Size = value.Length;
-                this.Pos = 0;
+                this._s = value;
+                this._size = value.Length;
+                this._pos = 0;
             }
         }
 
         public override int Read()
         {
-            if (Pos < Size)
+            if (_pos < _size)
             {
-                return s[Pos++];
+                return _s[_pos++];
             }
             else
             {
-                s = null;
+                _s = null;
                 return -1;
             }
         }
 
         public override int Read(char[] c, int off, int len)
         {
-            if (Pos < Size)
+            if (_pos < _size)
             {
-                len = Math.Min(len, Size - Pos);
-                s.CopyTo(Pos, c, off, Pos + len - Pos);
-                Pos += len;
+                len = Math.Min(len, _size - _pos);
+                _s.CopyTo(_pos, c, off, _pos + len - _pos);
+                _pos += len;
                 return len;
             }
             else
             {
-                s = null;
+                _s = null;
                 return -1;
             }
         }
 
         public override void Close()
         {
-            Pos = Size; // this prevents NPE when reading after close!
-            s = null;
+            _pos = _size; // this prevents NPE when reading after close!
+            _s = null;
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4513c521/src/Lucene.Net.Core/Analysis/Token.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Analysis/Token.cs b/src/Lucene.Net.Core/Analysis/Token.cs
index b26f423..2a234b2 100644
--- a/src/Lucene.Net.Core/Analysis/Token.cs
+++ b/src/Lucene.Net.Core/Analysis/Token.cs
@@ -1,8 +1,8 @@
+using Lucene.Net.Index;
+
 namespace Lucene.Net.Analysis
 {
     using Lucene.Net.Analysis.Tokenattributes;
-
-    // for javadoc
     using Attribute = Lucene.Net.Util.Attribute;
     using AttributeSource = Lucene.Net.Util.AttributeSource;
     using BytesRef = Lucene.Net.Util.BytesRef;
@@ -67,7 +67,7 @@ namespace Lucene.Net.Analysis
     ///  if you know that your text is shorter than the capacity of the termBuffer
     ///  or <seealso cref="#resizeBuffer(int)"/>, if there is any possibility
     ///  that you may need to grow the buffer. Fill in the characters of your term into this
-    ///  buffer, with <seealso cref="String#getChars(int, int, char[], int)"/> if loading
from a string,
+    ///  buffer, with <seealso cref="string#getChars(int, int, char[], int)"/> if loading
from a string,
     ///  or with <seealso cref="System#arraycopy(Object, int, Object, int, int)"/>,
and finally call <seealso cref="#setLength(int)"/> to
     ///  set the length of the term text.  See <a target="_top"
     ///  href="https://issues.apache.org/jira/browse/LUCENE-969">LUCENE-969</a>
@@ -353,7 +353,7 @@ namespace Lucene.Net.Analysis
 
         public override object Clone()
         {
-            Token t = (Token)base.Clone();
+            var t = (Token)base.Clone();
             // Do a deep clone
             if (payload != null)
             {
@@ -371,10 +371,12 @@ namespace Lucene.Net.Analysis
         /// </summary>
         public virtual Token Clone(char[] newTermBuffer, int newTermOffset, int newTermLength,
int newStartOffset, int newEndOffset)
         {
-            Token t = new Token(newTermBuffer, newTermOffset, newTermLength, newStartOffset,
newEndOffset);
-            t.positionIncrement = positionIncrement;
-            t.flags = flags;
-            t.type = type;
+            var t = new Token(newTermBuffer, newTermOffset, newTermLength, newStartOffset,
newEndOffset)
+            {
+                positionIncrement = positionIncrement,
+                flags = flags,
+                type = type
+            };
             if (payload != null)
             {
                 t.payload = (BytesRef)payload.Clone();
@@ -389,9 +391,9 @@ namespace Lucene.Net.Analysis
                 return true;
             }
 
-            if (obj is Token)
+            var other = obj as Token;
+            if (other != null)
             {
-                Token other = (Token)obj;
                 return (startOffset == other.startOffset && endOffset == other.endOffset
&& flags == other.flags && positionIncrement == other.positionIncrement &&
(type == null ? other.type == null : type.Equals(other.type)) && (payload == null
? other.payload == null : payload.Equals(other.payload)) && base.Equals(obj));
             }
             else
@@ -580,9 +582,9 @@ namespace Lucene.Net.Analysis
 
         public override void CopyTo(Attribute target)
         {
-            if (target is Token)
+            var to = target as Token;
+            if (to != null)
             {
-                Token to = (Token)target;
                 to.Reinit(this);
                 // reinit shares the payload, so clone it:
                 if (payload != null)
@@ -658,9 +660,10 @@ namespace Lucene.Net.Analysis
                 {
                     return true;
                 }
-                if (other is TokenAttributeFactory)
+
+                var af = other as TokenAttributeFactory;
+                if (af != null)
                 {
-                    TokenAttributeFactory af = (TokenAttributeFactory)other;
                     return this.@delegate.Equals(af.@delegate);
                 }
                 return false;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4513c521/src/Lucene.Net.Core/Analysis/TokenStream.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Analysis/TokenStream.cs b/src/Lucene.Net.Core/Analysis/TokenStream.cs
index ccaed6b..c1c9d98 100644
--- a/src/Lucene.Net.Core/Analysis/TokenStream.cs
+++ b/src/Lucene.Net.Core/Analysis/TokenStream.cs
@@ -1,6 +1,8 @@
+using System.Diagnostics;
 using Lucene.Net.Analysis.Tokenattributes;
 using System;
 using Lucene.Net.Documents;
+using Lucene.Net.Index;
 using Lucene.Net.Util;
 
 namespace Lucene.Net.Analysis
@@ -107,7 +109,7 @@ namespace Lucene.Net.Analysis
             //Debug.Assert(AssertFinal());
         }
 
-        /* LUCENE TO-DO
+        /* LUCENENET TO-DO
         private bool AssertFinal()
         {
           try

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4513c521/src/Lucene.Net.Core/Analysis/Tokenizer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Analysis/Tokenizer.cs b/src/Lucene.Net.Core/Analysis/Tokenizer.cs
index b63da43..b0215be 100644
--- a/src/Lucene.Net.Core/Analysis/Tokenizer.cs
+++ b/src/Lucene.Net.Core/Analysis/Tokenizer.cs
@@ -47,7 +47,7 @@ namespace Lucene.Net.Analysis
         {
             if (input == null)
             {
-                throw new System.NullReferenceException("input must not be null");
+                throw new System.ArgumentNullException("input", "input must not be null");
             }
             this.InputPending = input;
         }
@@ -59,7 +59,7 @@ namespace Lucene.Net.Analysis
         {
             if (input == null)
             {
-                throw new System.NullReferenceException("input must not be null");
+                throw new System.ArgumentNullException("input", "input must not be null");
             }
             this.InputPending = input;
         }
@@ -102,11 +102,11 @@ namespace Lucene.Net.Analysis
             {
                 if (value == null)
                 {
-                    throw new System.NullReferenceException("input must not be null");
+                    throw new System.ArgumentNullException("value", "input must not be null");
                 }
                 else if (this.input != ILLEGAL_STATE_READER)
                 {
-                    //throw new Exception("TokenStream contract violation: close() call missing");
+                    throw new InvalidOperationException("TokenStream contract violation:
close() call missing");
                 }
                 this.InputPending = value;
                 Debug.Assert(SetReaderTestPoint());
@@ -132,7 +132,9 @@ namespace Lucene.Net.Analysis
         {
             public override int Read(char[] cbuf, int off, int len)
             {
-                throw new InvalidOperationException("TokenStream contract violation: reset()/close()
call missing, " + "reset() called multiple times, or subclass does not call super.reset().
" + "Please see Javadocs of TokenStream class for more information about the correct consuming
workflow.");
+                throw new InvalidOperationException("TokenStream contract violation: reset()/close()
call missing, " 
+                    + "reset() called multiple times, or subclass does not call super.reset().
"
+                    + "Please see Javadocs of TokenStream class for more information about
the correct consuming workflow.");
             }
 
             public override void Close()

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4513c521/src/Lucene.Net.Core/Support/WeakDictionary.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/WeakDictionary.cs b/src/Lucene.Net.Core/Support/WeakDictionary.cs
index a29a0bf..c8b07de 100644
--- a/src/Lucene.Net.Core/Support/WeakDictionary.cs
+++ b/src/Lucene.Net.Core/Support/WeakDictionary.cs
@@ -26,7 +26,7 @@ using System.Linq;
 
 namespace Lucene.Net.Support
 {
-    public sealed class WeakDictionary<TKey, TValue> : IDictionary<TKey, TValue>
+    public sealed class WeakDictionary<TKey, TValue> : IDictionary<TKey, TValue>
where TKey : class 
     {
         private HashMap<WeakKey<TKey>, TValue> _hm;
         private int _gcCollections = 0;
@@ -249,7 +249,7 @@ namespace Lucene.Net.Support
         /// is added to the hashtable, the key is wrapped using a WeakKey. WeakKey saves
the
         /// value of the original object hashcode for fast comparison.
         /// </summary>
-        private class WeakKey<T>
+        private class WeakKey<T> where T : class
         {
             private readonly WeakReference reference;
             private readonly int hashCode;


Mime
View raw message