lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [13/49] lucenenet git commit: Moved BytesRefFSTEnum<T>.InputOutput<T> and IntsRefFSTEnum<T>.InputOutput<T> classes into non-generic classes with the same name so we don't need to specify the generic type twice.
Date Sun, 02 Oct 2016 10:16:44 GMT
Moved BytesRefFSTEnum<T>.InputOutput<T> and IntsRefFSTEnum<T>.InputOutput<T>
classes into non-generic classes with the same name so we don't need to specify the generic
type twice.


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

Branch: refs/heads/master
Commit: 3994051b243f9e4a39cdda107ac8c6d1d68a78e2
Parents: 18f8443
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Wed Sep 7 18:07:43 2016 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Thu Sep 8 06:40:55 2016 +0700

----------------------------------------------------------------------
 .../BlockTerms/VariableGapTermsIndexReader.cs   |  4 +-
 .../Memory/FSTOrdTermsReader.cs                 |  2 +-
 src/Lucene.Net.Codecs/Memory/FSTTermsReader.cs  |  2 +-
 .../Memory/MemoryPostingsFormat.cs              |  2 +-
 .../Codecs/BlockTreeTermsWriter.cs              |  2 +-
 .../Lucene42/Lucene42DocValuesProducer.cs       |  2 +-
 src/Lucene.Net.Core/Util/Fst/BytesRefFSTEnum.cs | 41 +++++++++++++-------
 src/Lucene.Net.Core/Util/Fst/IntsRefFSTEnum.cs  | 41 +++++++++++++-------
 .../Util/fst/FSTTester.cs                       |  8 ++--
 src/Lucene.Net.Tests/core/Util/Fst/Test2BFST.cs |  6 +--
 src/Lucene.Net.Tests/core/Util/Fst/TestFSTs.cs  |  6 +--
 11 files changed, 71 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/3994051b/src/Lucene.Net.Codecs/BlockTerms/VariableGapTermsIndexReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/BlockTerms/VariableGapTermsIndexReader.cs b/src/Lucene.Net.Codecs/BlockTerms/VariableGapTermsIndexReader.cs
index 654ad34..17b808f 100644
--- a/src/Lucene.Net.Codecs/BlockTerms/VariableGapTermsIndexReader.cs
+++ b/src/Lucene.Net.Codecs/BlockTerms/VariableGapTermsIndexReader.cs
@@ -202,7 +202,7 @@ namespace Lucene.Net.Codecs.BlockTerms
                     var fstEnum = new BytesRefFSTEnum<long?>(Fst);
                     var count = _vgtir._indexDivisor;
                         
-                    BytesRefFSTEnum<long?>.InputOutput<long?> result;
+                    BytesRefFSTEnum.InputOutput<long?> result;
                     while ((result = fstEnum.Next()) != null)
                     {
                         if (count == _vgtir._indexDivisor)
@@ -226,7 +226,7 @@ namespace Lucene.Net.Codecs.BlockTerms
         protected class IndexEnum : FieldIndexEnum
         {
             private readonly BytesRefFSTEnum<long?> _fstEnum;
-            private BytesRefFSTEnum<long?>.InputOutput<long?> _current;
+            private BytesRefFSTEnum.InputOutput<long?> _current;
 
             public IndexEnum(FST<long?> fst)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/3994051b/src/Lucene.Net.Codecs/Memory/FSTOrdTermsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Memory/FSTOrdTermsReader.cs b/src/Lucene.Net.Codecs/Memory/FSTOrdTermsReader.cs
index 7f3f35b..86afc3e 100644
--- a/src/Lucene.Net.Codecs/Memory/FSTOrdTermsReader.cs
+++ b/src/Lucene.Net.Codecs/Memory/FSTOrdTermsReader.cs
@@ -531,7 +531,7 @@ namespace Lucene.Net.Codecs.Memory
                 }
 
                 // Update current enum according to FSTEnum
-                private void UpdateEnum(BytesRefFSTEnum<long?>.InputOutput<long?>
pair)
+                private void UpdateEnum(BytesRefFSTEnum.InputOutput<long?> pair)
                 {
                     if (pair == null)
                     {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/3994051b/src/Lucene.Net.Codecs/Memory/FSTTermsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Memory/FSTTermsReader.cs b/src/Lucene.Net.Codecs/Memory/FSTTermsReader.cs
index 79e0365..0077054 100644
--- a/src/Lucene.Net.Codecs/Memory/FSTTermsReader.cs
+++ b/src/Lucene.Net.Codecs/Memory/FSTTermsReader.cs
@@ -396,7 +396,7 @@ namespace Lucene.Net.Codecs.Memory
                 }
 
                 // Update current enum according to FSTEnum
-                internal void UpdateEnum(BytesRefFSTEnum<FSTTermOutputs.TermData>.InputOutput<FSTTermOutputs.TermData>
pair)
+                internal void UpdateEnum(BytesRefFSTEnum.InputOutput<FSTTermOutputs.TermData>
pair)
                 {
                     if (pair == null)
                     {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/3994051b/src/Lucene.Net.Codecs/Memory/MemoryPostingsFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Memory/MemoryPostingsFormat.cs b/src/Lucene.Net.Codecs/Memory/MemoryPostingsFormat.cs
index ebf7456..88aea52 100644
--- a/src/Lucene.Net.Codecs/Memory/MemoryPostingsFormat.cs
+++ b/src/Lucene.Net.Codecs/Memory/MemoryPostingsFormat.cs
@@ -788,7 +788,7 @@ namespace Lucene.Net.Codecs.Memory
 
             internal int docFreq_Renamed;
             internal long totalTermFreq_Renamed;
-            internal BytesRefFSTEnum<BytesRef>.InputOutput<BytesRef> current;
+            internal BytesRefFSTEnum.InputOutput<BytesRef> current;
             internal BytesRef postingsSpare = new BytesRef();
 
             public FSTTermsEnum(FieldInfo field, FST<BytesRef> fst)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/3994051b/src/Lucene.Net.Core/Codecs/BlockTreeTermsWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/BlockTreeTermsWriter.cs b/src/Lucene.Net.Core/Codecs/BlockTreeTermsWriter.cs
index e339aa3..0c32f3b 100644
--- a/src/Lucene.Net.Core/Codecs/BlockTreeTermsWriter.cs
+++ b/src/Lucene.Net.Core/Codecs/BlockTreeTermsWriter.cs
@@ -501,7 +501,7 @@ namespace Lucene.Net.Codecs
             internal void Append(Builder<BytesRef> builder, FST<BytesRef> subIndex)
             {
                 BytesRefFSTEnum<BytesRef> subIndexEnum = new BytesRefFSTEnum<BytesRef>(subIndex);
-                BytesRefFSTEnum<BytesRef>.InputOutput<BytesRef> indexEnt;
+                BytesRefFSTEnum.InputOutput<BytesRef> indexEnt;
                 while ((indexEnt = subIndexEnum.Next()) != null)
                 {
                     //if (DEBUG) {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/3994051b/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 802ed53..5977d18 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene42/Lucene42DocValuesProducer.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene42/Lucene42DocValuesProducer.cs
@@ -489,7 +489,7 @@ namespace Lucene.Net.Codecs.Lucene42
             {
                 try
                 {
-                    BytesRefFSTEnum<long?>.InputOutput<long?> o = FstEnum.SeekCeil(key);
+                    BytesRefFSTEnum.InputOutput<long?> o = FstEnum.SeekCeil(key);
                     if (o == null)
                     {
                         return -ValueCount - 1;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/3994051b/src/Lucene.Net.Core/Util/Fst/BytesRefFSTEnum.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Fst/BytesRefFSTEnum.cs b/src/Lucene.Net.Core/Util/Fst/BytesRefFSTEnum.cs
index 6774b21..8bd5028 100644
--- a/src/Lucene.Net.Core/Util/Fst/BytesRefFSTEnum.cs
+++ b/src/Lucene.Net.Core/Util/Fst/BytesRefFSTEnum.cs
@@ -29,16 +29,10 @@ namespace Lucene.Net.Util.Fst
     public sealed class BytesRefFSTEnum<T> : FSTEnum<T>
     {
         private readonly BytesRef current = new BytesRef(10);
-        private readonly InputOutput<T> result = new InputOutput<T>();
+        private readonly BytesRefFSTEnum.InputOutput<T> result = new BytesRefFSTEnum.InputOutput<T>();
         private BytesRef target;
 
-        /// <summary>
-        /// Holds a single input (BytesRef) + output pair. </summary>
-        public class InputOutput<T>
-        {
-            public BytesRef Input;
-            public T Output;
-        }
+        // LUCENENET NOTE: InputOutput<T> was moved to the BytesRefFSTEnum class
 
         /// <summary>
         /// doFloor controls the behavior of advance: if it's true
@@ -52,12 +46,12 @@ namespace Lucene.Net.Util.Fst
             current.Offset = 1;
         }
 
-        public InputOutput<T> Current()
+        public BytesRefFSTEnum.InputOutput<T> Current()
         {
             return result;
         }
 
-        public InputOutput<T> Next()
+        public BytesRefFSTEnum.InputOutput<T> Next()
         {
             //System.out.println("  enum.next");
             DoNext();
@@ -66,7 +60,7 @@ namespace Lucene.Net.Util.Fst
 
         /// <summary>
         /// Seeks to smallest term that's >= target. </summary>
-        public InputOutput<T> SeekCeil(BytesRef target)
+        public BytesRefFSTEnum.InputOutput<T> SeekCeil(BytesRef target)
         {
             this.target = target;
             targetLength = target.Length;
@@ -76,7 +70,7 @@ namespace Lucene.Net.Util.Fst
 
         /// <summary>
         /// Seeks to biggest term that's <= target. </summary>
-        public InputOutput<T> SeekFloor(BytesRef target)
+        public BytesRefFSTEnum.InputOutput<T> SeekFloor(BytesRef target)
         {
             this.target = target;
             targetLength = target.Length;
@@ -90,7 +84,7 @@ namespace Lucene.Net.Util.Fst
         ///  #seekFloor} or <seealso cref="#seekCeil"/> because it
         ///  short-circuits as soon the match is not found.
         /// </summary>
-        public InputOutput<T> SeekExact(BytesRef target)
+        public BytesRefFSTEnum.InputOutput<T> SeekExact(BytesRef target)
         {
             this.target = target;
             targetLength = target.Length;
@@ -138,7 +132,7 @@ namespace Lucene.Net.Util.Fst
             current.Bytes = ArrayUtil.Grow(current.Bytes, upto + 1);
         }
 
-        private InputOutput<T> SetResult()
+        private BytesRefFSTEnum.InputOutput<T> SetResult()
         {
             if (upto == 0)
             {
@@ -152,4 +146,23 @@ namespace Lucene.Net.Util.Fst
             }
         }
     }
+
+    /// <summary>
+    /// LUCENENET specific. This class is to mimic Java's ability to specify
+    /// nested classes of Generics without having to specify the generic type
+    /// (i.e. BytesRefFSTEnum.InputOutput{T} rather than BytesRefFSTEnum{T}.InputOutput{T})
+    /// </summary>
+    public sealed class BytesRefFSTEnum
+    {
+        private BytesRefFSTEnum()
+        { }
+
+        /// <summary>
+        /// Holds a single input (BytesRef) + output pair. </summary>
+        public class InputOutput<T>
+        {
+            public BytesRef Input;
+            public T Output;
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/3994051b/src/Lucene.Net.Core/Util/Fst/IntsRefFSTEnum.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Fst/IntsRefFSTEnum.cs b/src/Lucene.Net.Core/Util/Fst/IntsRefFSTEnum.cs
index b70d8c4..f679a6f 100644
--- a/src/Lucene.Net.Core/Util/Fst/IntsRefFSTEnum.cs
+++ b/src/Lucene.Net.Core/Util/Fst/IntsRefFSTEnum.cs
@@ -29,16 +29,10 @@ namespace Lucene.Net.Util.Fst
     public sealed class IntsRefFSTEnum<T> : FSTEnum<T>
     {
         private readonly IntsRef current = new IntsRef(10);
-        private readonly InputOutput<T> result = new InputOutput<T>();
+        private readonly IntsRefFSTEnum.InputOutput<T> result = new IntsRefFSTEnum.InputOutput<T>();
         private IntsRef target;
 
-        /// <summary>
-        /// Holds a single input (IntsRef) + output pair. </summary>
-        public class InputOutput<T>
-        {
-            public IntsRef Input;
-            public T Output;
-        }
+        // LUCENENET NOTE: The InputOutput<T> class was moved into the IntsRefFSTEnum
class
 
         /// <summary>
         /// doFloor controls the behavior of advance: if it's true
@@ -52,12 +46,12 @@ namespace Lucene.Net.Util.Fst
             current.Offset = 1;
         }
 
-        public InputOutput<T> Current()
+        public IntsRefFSTEnum.InputOutput<T> Current()
         {
             return result;
         }
 
-        public InputOutput<T> Next()
+        public IntsRefFSTEnum.InputOutput<T> Next()
         {
             //System.out.println("  enum.next");
             DoNext();
@@ -66,7 +60,7 @@ namespace Lucene.Net.Util.Fst
 
         /// <summary>
         /// Seeks to smallest term that's >= target. </summary>
-        public InputOutput<T> SeekCeil(IntsRef target)
+        public IntsRefFSTEnum.InputOutput<T> SeekCeil(IntsRef target)
         {
             this.target = target;
             targetLength = target.Length;
@@ -76,7 +70,7 @@ namespace Lucene.Net.Util.Fst
 
         /// <summary>
         /// Seeks to biggest term that's <= target. </summary>
-        public InputOutput<T> SeekFloor(IntsRef target)
+        public IntsRefFSTEnum.InputOutput<T> SeekFloor(IntsRef target)
         {
             this.target = target;
             targetLength = target.Length;
@@ -90,7 +84,7 @@ namespace Lucene.Net.Util.Fst
         ///  #seekFloor} or <seealso cref="#seekCeil"/> because it
         ///  short-circuits as soon the match is not found.
         /// </summary>
-        public InputOutput<T> SeekExact(IntsRef target)
+        public IntsRefFSTEnum.InputOutput<T> SeekExact(IntsRef target)
         {
             this.target = target;
             targetLength = target.Length;
@@ -138,7 +132,7 @@ namespace Lucene.Net.Util.Fst
             current.Ints = ArrayUtil.Grow(current.Ints, upto + 1);
         }
 
-        private InputOutput<T> SetResult()
+        private IntsRefFSTEnum.InputOutput<T> SetResult()
         {
             if (upto == 0)
             {
@@ -152,4 +146,23 @@ namespace Lucene.Net.Util.Fst
             }
         }
     }
+
+    /// <summary>
+    /// LUCENENET specific. This class is to mimic Java's ability to specify
+    /// nested classes of Generics without having to specify the generic type
+    /// (i.e. IntsRefFSTEnum.InputOutput{T} rather than IntsRefFSTEnum{T}.InputOutput{T})
+    /// </summary>
+    public sealed class IntsRefFSTEnum
+    {
+        private IntsRefFSTEnum()
+        { }
+
+        /// <summary>
+        /// Holds a single input (IntsRef) + output pair. </summary>
+        public class InputOutput<T>
+        {
+            public IntsRef Input;
+            public T Output;
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/3994051b/src/Lucene.Net.TestFramework/Util/fst/FSTTester.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Util/fst/FSTTester.cs b/src/Lucene.Net.TestFramework/Util/fst/FSTTester.cs
index e5d6f84..cb5f44d 100644
--- a/src/Lucene.Net.TestFramework/Util/fst/FSTTester.cs
+++ b/src/Lucene.Net.TestFramework/Util/fst/FSTTester.cs
@@ -486,7 +486,7 @@ namespace Lucene.Net.Util.Fst
                     Assert.IsTrue(OutputsEqual(pair.Output, output));
 
                     // verify enum's next
-                    IntsRefFSTEnum<T>.InputOutput<T> t = fstEnum.Next();
+                    IntsRefFSTEnum.InputOutput<T> t = fstEnum.Next();
                     Assert.IsNotNull(t);
                     Assert.AreEqual(term, t.Input, "expected input=" + InputToString(inputMode,
term) + " but fstEnum returned " + InputToString(inputMode, t.Input));
                     Assert.IsTrue(OutputsEqual(pair.Output, t.Output));
@@ -564,7 +564,7 @@ namespace Lucene.Net.Util.Fst
                             pos = -(pos + 1);
                             // ok doesn't exist
                             //System.out.println("  seek " + inputToString(inputMode, term));
-                            IntsRefFSTEnum<T>.InputOutput<T> seekResult;
+                            IntsRefFSTEnum.InputOutput<T> seekResult;
                             if (Random.Next(3) == 0)
                             {
                                 if (LuceneTestCase.VERBOSE)
@@ -622,7 +622,7 @@ namespace Lucene.Net.Util.Fst
                 {
                     // seek to term that does exist:
                     InputOutput<T> pair = Pairs[Random.Next(Pairs.Count)];
-                    IntsRefFSTEnum<T>.InputOutput<T> seekResult;
+                    IntsRefFSTEnum.InputOutput<T> seekResult;
                     if (Random.Next(3) == 2)
                     {
                         if (LuceneTestCase.VERBOSE)
@@ -960,7 +960,7 @@ namespace Lucene.Net.Util.Fst
                 Console.WriteLine("TEST: check pruned enum");
             }
             IntsRefFSTEnum<T> fstEnum = new IntsRefFSTEnum<T>(fst);
-            IntsRefFSTEnum<T>.InputOutput<T> current;
+            IntsRefFSTEnum.InputOutput<T> current;
             while ((current = fstEnum.Next()) != null)
             {
                 if (LuceneTestCase.VERBOSE)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/3994051b/src/Lucene.Net.Tests/core/Util/Fst/Test2BFST.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/Fst/Test2BFST.cs b/src/Lucene.Net.Tests/core/Util/Fst/Test2BFST.cs
index ad2f968..7127487 100644
--- a/src/Lucene.Net.Tests/core/Util/Fst/Test2BFST.cs
+++ b/src/Lucene.Net.Tests/core/Util/Fst/Test2BFST.cs
@@ -111,7 +111,7 @@ namespace Lucene.Net.Util.Fst
                         int upto = 0;
                         while (true)
                         {
-                            IntsRefFSTEnum<object>.InputOutput<object> pair =
fstEnum.Next();
+                            IntsRefFSTEnum.InputOutput<object> pair = fstEnum.Next();
                             if (pair == null)
                             {
                                 break;
@@ -200,7 +200,7 @@ namespace Lucene.Net.Util.Fst
                         int upto = 0;
                         while (true)
                         {
-                            IntsRefFSTEnum<BytesRef>.InputOutput<BytesRef> pair
= fstEnum.Next();
+                            IntsRefFSTEnum.InputOutput<BytesRef> pair = fstEnum.Next();
                             if (pair == null)
                             {
                                 break;
@@ -293,7 +293,7 @@ namespace Lucene.Net.Util.Fst
                         output = 1;
                         while (true)
                         {
-                            IntsRefFSTEnum<long?>.InputOutput<long?> pair = fstEnum.Next();
+                            IntsRefFSTEnum.InputOutput<long?> pair = fstEnum.Next();
                             if (pair == null)
                             {
                                 break;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/3994051b/src/Lucene.Net.Tests/core/Util/Fst/TestFSTs.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/Fst/TestFSTs.cs b/src/Lucene.Net.Tests/core/Util/Fst/TestFSTs.cs
index 2e972ad..bb4d206 100644
--- a/src/Lucene.Net.Tests/core/Util/Fst/TestFSTs.cs
+++ b/src/Lucene.Net.Tests/core/Util/Fst/TestFSTs.cs
@@ -438,7 +438,7 @@ namespace Lucene.Net.Util.Fst
                         }
 
                         TermsEnum.SeekStatus seekResult = termsEnum.SeekCeil(randomTerm);
-                        BytesRefFSTEnum<long?>.InputOutput<long?> fstSeekResult
= fstEnum.SeekCeil(randomTerm);
+                        BytesRefFSTEnum.InputOutput<long?> fstSeekResult = fstEnum.SeekCeil(randomTerm);
 
                         if (seekResult == TermsEnum.SeekStatus.END)
                         {
@@ -472,7 +472,7 @@ namespace Lucene.Net.Util.Fst
                                     {
                                         Console.WriteLine("  end!");
                                     }
-                                    BytesRefFSTEnum<long?>.InputOutput<long?>
nextResult = fstEnum.Next();
+                                    BytesRefFSTEnum.InputOutput<long?> nextResult =
fstEnum.Next();
                                     if (nextResult != null)
                                     {
                                         Console.WriteLine("expected null but got: input="
+ nextResult.Input.Utf8ToString() + " output=" + outputs.OutputToString(nextResult.Output));
@@ -985,7 +985,7 @@ namespace Lucene.Net.Util.Fst
             Assert.AreEqual(17, Util.Get(fst, a));
 
             BytesRefFSTEnum<long?> fstEnum = new BytesRefFSTEnum<long?>(fst);
-            BytesRefFSTEnum<long?>.InputOutput<long?> seekResult;
+            BytesRefFSTEnum.InputOutput<long?> seekResult;
             seekResult = fstEnum.SeekFloor(a);
             Assert.IsNotNull(seekResult);
             Assert.AreEqual(17, seekResult.Output);


Mime
View raw message