You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by sy...@apache.org on 2016/10/02 14:36:07 UTC

[49/50] [abbrv] lucenenet git commit: Fixed equality checks in Core.Util.Fst.FST to account for generics. Updated some of the commented debug code to be .NETified in case it is required again.

Fixed equality checks in Core.Util.Fst.FST to account for generics. Updated some of the commented debug code to be .NETified in case it is required again.


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

Branch: refs/heads/master
Commit: c76e010217c5bb726c9cd72e84fdf9f04253205c
Parents: 6a61cfb
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Thu Sep 22 10:12:51 2016 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Sun Oct 2 17:45:16 2016 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Core/Util/Fst/FST.cs  | 15 +++++++--------
 src/Lucene.Net.Core/Util/Fst/Util.cs |  4 ++--
 2 files changed, 9 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c76e0102/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 c38f658..e68db5f 100644
--- a/src/Lucene.Net.Core/Util/Fst/FST.cs
+++ b/src/Lucene.Net.Core/Util/Fst/FST.cs
@@ -357,7 +357,7 @@ namespace Lucene.Net.Util.Fst
             {
                 throw new InvalidOperationException("already finished");
             }
-            if (newStartNode == FST.FINAL_END_NODE && emptyOutput != null)
+            if (newStartNode == FST.FINAL_END_NODE && !EqualityComparer<T>.Default.Equals(emptyOutput, default(T)))
             {
                 newStartNode = 0;
             }
@@ -504,7 +504,7 @@ namespace Lucene.Net.Util.Fst
             }
             // TODO: really we should encode this as an arc, arriving
             // to the root node, instead of special casing here:
-            if (emptyOutput != null)
+            if (!EqualityComparer<T>.Default.Equals(emptyOutput, default(T)))
             {
                 // Accepts empty string
                 @out.WriteByte(1);
@@ -866,7 +866,7 @@ namespace Lucene.Net.Util.Fst
         /// </summary>
         public FST.Arc<T> GetFirstArc(FST.Arc<T> arc)
         {
-            if (emptyOutput != null)
+            if (!EqualityComparer<T>.Default.Equals(emptyOutput, default(T)))
             {
                 arc.Flags = FST.BIT_FINAL_ARC | FST.BIT_LAST_ARC;
                 arc.NextFinalOutput = emptyOutput;
@@ -996,7 +996,7 @@ namespace Lucene.Net.Util.Fst
         public FST.Arc<T> ReadFirstTargetArc(FST.Arc<T> follow, FST.Arc<T> arc, FST.BytesReader @in)
         {
             //int pos = address;
-            //System.out.println("    readFirstTarget follow.target=" + follow.Target + " isFinal=" + follow.isFinal());
+            //Debug.WriteLine("    readFirstTarget follow.target=" + follow.Target + " isFinal=" + follow.IsFinal);
             if (follow.IsFinal)
             {
                 // Insert "fake" final first arc:
@@ -1014,7 +1014,7 @@ namespace Lucene.Net.Util.Fst
                     arc.NextArc = follow.Target;
                 }
                 arc.Target = FST.FINAL_END_NODE;
-                //System.out.println("    insert isFinal; nextArc=" + follow.Target + " isLast=" + arc.isLast() + " output=" + outputs.outputToString(arc.Output));
+                //Debug.WriteLine("    insert isFinal; nextArc=" + follow.Target + " isLast=" + arc.IsLast + " output=" + Outputs.OutputToString(arc.Output));
                 return arc;
             }
             else
@@ -1106,8 +1106,7 @@ namespace Lucene.Net.Util.Fst
 
             if (arc.Label == FST.END_LABEL)
             {
-                //System.out.println("    nextArc fake " +
-                //arc.nextArc);
+                //Debug.WriteLine("    nextArc fake " + arc.NextArc);
 
                 long pos = GetNodeAddress(arc.NextArc);
                 @in.Position = pos;
@@ -2046,7 +2045,7 @@ namespace Lucene.Net.Util.Fst
             fst.startNode = newNodeAddress.Get((int)startNode);
             //System.out.println("new startNode=" + fst.startNode + " old startNode=" + startNode);
 
-            if (emptyOutput != null)
+            if (!EqualityComparer<T>.Default.Equals(emptyOutput, default(T)))
             {
                 fst.EmptyOutput = emptyOutput;
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c76e0102/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 0419b78..c223505 100644
--- a/src/Lucene.Net.Core/Util/Fst/Util.cs
+++ b/src/Lucene.Net.Core/Util/Fst/Util.cs
@@ -610,11 +610,11 @@ namespace Lucene.Net.Util.Fst
                         if (path.Arc.Label == FST.END_LABEL)
                         {
                             // Add final output:
-                            //System.out.println("    done!: " + path);
+                            //Debug.WriteLine("    done!: " + path);
                             T finalOutput = fst.Outputs.Add(path.Cost, path.Arc.Output);
                             if (AcceptResult(path.Input, finalOutput))
                             {
-                                //System.out.println("    add result: " + path);
+                                //Debug.WriteLine("    add result: " + path);
                                 results.Add(new Result<T>(path.Input, finalOutput));
                             }
                             else