lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [22/27] lucenenet git commit: Lucene.Net.Core: reviewed and removed some unnecessary TODOs
Date Sun, 05 Feb 2017 16:51:57 GMT
Lucene.Net.Core: reviewed and removed some unnecessary TODOs


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

Branch: refs/heads/api-work
Commit: 3ec3e794e6d4622c4bdeb2fa3c71a011fedcc170
Parents: efd894b
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sun Feb 5 18:33:58 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Sun Feb 5 18:33:58 2017 +0700

----------------------------------------------------------------------
 .../Codecs/BlockTreeTermsReader.cs              | 146 ++++++++-----------
 .../Index/AtomicReaderContext.cs                |   2 +-
 src/Lucene.Net.Core/Index/IndexWriter.cs        |  12 +-
 src/Lucene.Net.Core/Index/Term.cs               |  13 +-
 src/Lucene.Net.Core/Search/PhraseQuery.cs       |   1 -
 src/Lucene.Net.Core/Search/ReqExclScorer.cs     |   2 -
 .../Search/ScoreCachingWrappingScorer.cs        |   2 -
 .../Search/Spans/NearSpansOrdered.cs            |   1 -
 src/Lucene.Net.Core/Search/Spans/TermSpans.cs   |   2 -
 src/Lucene.Net.Core/Util/CollectionUtil.cs      |  21 +--
 src/Lucene.Net.Core/Util/WeakIdentityMap.cs     |   2 -
 11 files changed, 83 insertions(+), 121 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/3ec3e794/src/Lucene.Net.Core/Codecs/BlockTreeTermsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/BlockTreeTermsReader.cs b/src/Lucene.Net.Core/Codecs/BlockTreeTermsReader.cs
index 0a9fc2d..be4641d 100644
--- a/src/Lucene.Net.Core/Codecs/BlockTreeTermsReader.cs
+++ b/src/Lucene.Net.Core/Codecs/BlockTreeTermsReader.cs
@@ -492,16 +492,6 @@ namespace Lucene.Net.Codecs
             {
                 StringBuilder @out = new StringBuilder();
 
-                /* LUCENE TO-DO I don't think this is neccesary
-                try
-                {
-                  @out = new PrintStream(bos, false, IOUtils.UTF_8);
-                }
-                catch (UnsupportedEncodingException bogus)
-                {
-                  throw new Exception(bogus);
-                }*/
-
                 @out.AppendLine("  index FST:");
                 @out.AppendLine("    " + IndexNodeCount + " nodes");
                 @out.AppendLine("    " + IndexArcCount + " arcs");
@@ -536,15 +526,6 @@ namespace Lucene.Net.Codecs
                     Debug.Assert(TotalBlockCount == total);
                 }
                 return @out.ToString();
-                /* LUCENE TO-DO I dont think this is neccesary
-                try
-                {
-                  return bos.ToString(IOUtils.UTF_8);
-                }
-                catch (UnsupportedEncodingException bogus)
-                {
-                  throw new Exception(bogus);
-                }*/
             }
         }
 
@@ -2416,69 +2397,70 @@ namespace Lucene.Net.Codecs
                     }
                 }
 
-                /*LUCENE TO-DO Not in use
-                private void PrintSeekState(PrintStream @out)
-                {
-                  if (CurrentFrame == StaticFrame)
-                  {
-                    @out.println("  no prior seek");
-                  }
-                  else
-                  {
-                    @out.println("  prior seek state:");
-                    int ord = 0;
-                    bool isSeekFrame = true;
-                    while (true)
-                    {
-                      Frame f = GetFrame(ord);
-                      Debug.Assert(f != null);
-                      BytesRef prefix = new BytesRef(Term_Renamed.Bytes, 0, f.Prefix);
-                      if (f.NextEnt == -1)
-                      {
-                        @out.println("    frame " + (isSeekFrame ? "(seek)" : "(next)") +
" ord=" + ord + " fp=" + f.Fp + (f.IsFloor ? (" (fpOrig=" + f.FpOrig + ")") : "") + " prefixLen="
+ f.Prefix + " prefix=" + prefix + (f.NextEnt == -1 ? "" : (" (of " + f.EntCount + ")")) +
" hasTerms=" + f.HasTerms + " isFloor=" + f.IsFloor + " code=" + ((f.Fp << BlockTreeTermsWriter.OUTPUT_FLAGS_NUM_BITS)
+ (f.HasTerms ? BlockTreeTermsWriter.OUTPUT_FLAG_HAS_TERMS:0) + (f.IsFloor ? BlockTreeTermsWriter.OUTPUT_FLAG_IS_FLOOR:0))
+ " isLastInFloor=" + f.IsLastInFloor + " mdUpto=" + f.MetaDataUpto + " tbOrd=" + f.TermBlockOrd);
-                      }
-                      else
-                      {
-                        @out.println("    frame " + (isSeekFrame ? "(seek, loaded)" : "(next,
loaded)") + " ord=" + ord + " fp=" + f.Fp + (f.IsFloor ? (" (fpOrig=" + f.FpOrig + ")") :
"") + " prefixLen=" + f.Prefix + " prefix=" + prefix + " nextEnt=" + f.NextEnt + (f.NextEnt
== -1 ? "" : (" (of " + f.EntCount + ")")) + " hasTerms=" + f.HasTerms + " isFloor=" + f.IsFloor
+ " code=" + ((f.Fp << BlockTreeTermsWriter.OUTPUT_FLAGS_NUM_BITS) + (f.HasTerms ? BlockTreeTermsWriter.OUTPUT_FLAG_HAS_TERMS:0)
+ (f.IsFloor ? BlockTreeTermsWriter.OUTPUT_FLAG_IS_FLOOR:0)) + " lastSubFP=" + f.LastSubFP
+ " isLastInFloor=" + f.IsLastInFloor + " mdUpto=" + f.MetaDataUpto + " tbOrd=" + f.TermBlockOrd);
-                      }
-                      if (OuterInstance.Index != null)
-                      {
-                        Debug.Assert(!isSeekFrame || f.Arc != null, "isSeekFrame=" + isSeekFrame
+ " f.arc=" + f.Arc);
-                        if (f.Prefix > 0 && isSeekFrame && f.Arc.Label
!= (Term_Renamed.Bytes[f.Prefix - 1] & 0xFF))
-                        {
-                          @out.println("      broken seek state: arc.label=" + (char) f.Arc.Label
+ " vs term byte=" + (char)(Term_Renamed.Bytes[f.Prefix - 1] & 0xFF));
-                          throw new Exception("seek state is broken");
-                        }
-                        BytesRef output = Util.Get(OuterInstance.Index, prefix);
-                        if (output == null)
-                        {
-                          @out.println("      broken seek state: prefix is not final in index");
-                          throw new Exception("seek state is broken");
-                        }
-                        else if (isSeekFrame && !f.IsFloor)
-                        {
-                          ByteArrayDataInput reader = new ByteArrayDataInput(output.Bytes,
output.Offset, output.Length);
-                          long codeOrig = reader.ReadVLong();
-                          long code = (f.Fp << BlockTreeTermsWriter.OUTPUT_FLAGS_NUM_BITS)
| (f.HasTerms ? BlockTreeTermsWriter.OUTPUT_FLAG_HAS_TERMS:0) | (f.IsFloor ? BlockTreeTermsWriter.OUTPUT_FLAG_IS_FLOOR:0);
-                          if (codeOrig != code)
-                          {
-                            @out.println("      broken seek state: output code=" + codeOrig
+ " doesn't match frame code=" + code);
-                            throw new Exception("seek state is broken");
-                          }
-                        }
-                      }
-                      if (f == CurrentFrame)
-                      {
-                        break;
-                      }
-                      if (f.Prefix == ValidIndexPrefix)
-                      {
-                        isSeekFrame = false;
-                      }
-                      ord++;
-                    }
-                  }
-                }*/
+                // LUCENENET NOTE: Not in use
+
+                //private void PrintSeekState(PrintStream @out)
+                //{
+                //    if (CurrentFrame == StaticFrame)
+                //    {
+                //        @out.println("  no prior seek");
+                //    }
+                //    else
+                //    {
+                //        @out.println("  prior seek state:");
+                //        int ord = 0;
+                //        bool isSeekFrame = true;
+                //        while (true)
+                //        {
+                //            Frame f = GetFrame(ord);
+                //            Debug.Assert(f != null);
+                //            BytesRef prefix = new BytesRef(Term_Renamed.Bytes, 0, f.Prefix);
+                //            if (f.NextEnt == -1)
+                //            {
+                //                @out.println("    frame " + (isSeekFrame ? "(seek)" : "(next)")
+ " ord=" + ord + " fp=" + f.Fp + (f.IsFloor ? (" (fpOrig=" + f.FpOrig + ")") : "") + " prefixLen="
+ f.Prefix + " prefix=" + prefix + (f.NextEnt == -1 ? "" : (" (of " + f.EntCount + ")")) +
" hasTerms=" + f.HasTerms + " isFloor=" + f.IsFloor + " code=" + ((f.Fp << BlockTreeTermsWriter.OUTPUT_FLAGS_NUM_BITS)
+ (f.HasTerms ? BlockTreeTermsWriter.OUTPUT_FLAG_HAS_TERMS : 0) + (f.IsFloor ? BlockTreeTermsWriter.OUTPUT_FLAG_IS_FLOOR
: 0)) + " isLastInFloor=" + f.IsLastInFloor + " mdUpto=" + f.MetaDataUpto + " tbOrd=" + f.TermBlockOrd);
+                //            }
+                //            else
+                //            {
+                //                @out.println("    frame " + (isSeekFrame ? "(seek, loaded)"
: "(next, loaded)") + " ord=" + ord + " fp=" + f.Fp + (f.IsFloor ? (" (fpOrig=" + f.FpOrig
+ ")") : "") + " prefixLen=" + f.Prefix + " prefix=" + prefix + " nextEnt=" + f.NextEnt +
(f.NextEnt == -1 ? "" : (" (of " + f.EntCount + ")")) + " hasTerms=" + f.HasTerms + " isFloor="
+ f.IsFloor + " code=" + ((f.Fp << BlockTreeTermsWriter.OUTPUT_FLAGS_NUM_BITS) + (f.HasTerms
? BlockTreeTermsWriter.OUTPUT_FLAG_HAS_TERMS : 0) + (f.IsFloor ? BlockTreeTermsWriter.OUTPUT_FLAG_IS_FLOOR
: 0)) + " lastSubFP=" + f.LastSubFP + " isLastInFloor=" + f.IsLastInFloor + " mdUpto=" + f.MetaDataUpto
+ " tbOrd=" + f.TermBlockOrd);
+                //            }
+                //            if (OuterInstance.Index != null)
+                //            {
+                //                Debug.Assert(!isSeekFrame || f.Arc != null, "isSeekFrame="
+ isSeekFrame + " f.arc=" + f.Arc);
+                //                if (f.Prefix > 0 && isSeekFrame && f.Arc.Label
!= (Term_Renamed.Bytes[f.Prefix - 1] & 0xFF))
+                //                {
+                //                    @out.println("      broken seek state: arc.label="
+ (char)f.Arc.Label + " vs term byte=" + (char)(Term_Renamed.Bytes[f.Prefix - 1] & 0xFF));
+                //                    throw new Exception("seek state is broken");
+                //                }
+                //                BytesRef output = Util.Get(OuterInstance.Index, prefix);
+                //                if (output == null)
+                //                {
+                //                    @out.println("      broken seek state: prefix is not
final in index");
+                //                    throw new Exception("seek state is broken");
+                //                }
+                //                else if (isSeekFrame && !f.IsFloor)
+                //                {
+                //                    ByteArrayDataInput reader = new ByteArrayDataInput(output.Bytes,
output.Offset, output.Length);
+                //                    long codeOrig = reader.ReadVLong();
+                //                    long code = (f.Fp << BlockTreeTermsWriter.OUTPUT_FLAGS_NUM_BITS)
| (f.HasTerms ? BlockTreeTermsWriter.OUTPUT_FLAG_HAS_TERMS : 0) | (f.IsFloor ? BlockTreeTermsWriter.OUTPUT_FLAG_IS_FLOOR
: 0);
+                //                    if (codeOrig != code)
+                //                    {
+                //                        @out.println("      broken seek state: output code="
+ codeOrig + " doesn't match frame code=" + code);
+                //                        throw new Exception("seek state is broken");
+                //                    }
+                //                }
+                //            }
+                //            if (f == CurrentFrame)
+                //            {
+                //                break;
+                //            }
+                //            if (f.Prefix == ValidIndexPrefix)
+                //            {
+                //                isSeekFrame = false;
+                //            }
+                //            ord++;
+                //        }
+                //    }
+                //}
 
                 /* Decodes only the term bytes of the next term.  If caller then asks for
                    metadata, ie docFreq, totalTermFreq or pulls a D/&PEnum, we then (lazily)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/3ec3e794/src/Lucene.Net.Core/Index/AtomicReaderContext.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/AtomicReaderContext.cs b/src/Lucene.Net.Core/Index/AtomicReaderContext.cs
index edbf05e..8f7d2eb 100644
--- a/src/Lucene.Net.Core/Index/AtomicReaderContext.cs
+++ b/src/Lucene.Net.Core/Index/AtomicReaderContext.cs
@@ -45,7 +45,7 @@ namespace Lucene.Net.Index
             this.Ord = leafOrd;
             this.DocBase = leafDocBase;
             this.reader = reader;
-            this.leaves = IsTopLevel ? new[] { this } : null; //LUCENE TO-DO suspicous
+            this.leaves = IsTopLevel ? new[] { this } : null;
         }
 
         internal AtomicReaderContext(AtomicReader atomicReader)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/3ec3e794/src/Lucene.Net.Core/Index/IndexWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/IndexWriter.cs b/src/Lucene.Net.Core/Index/IndexWriter.cs
index 0897287..99a9381 100644
--- a/src/Lucene.Net.Core/Index/IndexWriter.cs
+++ b/src/Lucene.Net.Core/Index/IndexWriter.cs
@@ -3820,12 +3820,12 @@ namespace Lucene.Net.Index
         // at a time:
         private readonly object fullFlushLock = new object();
 
-        //LUCENE TO-DO Not possible in .NET
-        /*// for assert
-        internal virtual bool HoldsFullFlushLock()
-        {
-          return Thread.holdsLock(FullFlushLock);
-        }*/
+        // LUCENENET NOTE: Not possible in .NET
+        //// for assert
+        //internal virtual bool HoldsFullFlushLock()
+        //{
+        //  return Thread.holdsLock(FullFlushLock);
+        //}
 
         /// <summary>
         /// Flush all in-memory buffered updates (adds and deletes)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/3ec3e794/src/Lucene.Net.Core/Index/Term.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/Term.cs b/src/Lucene.Net.Core/Index/Term.cs
index ebc6522..26e5b35 100644
--- a/src/Lucene.Net.Core/Index/Term.cs
+++ b/src/Lucene.Net.Core/Index/Term.cs
@@ -91,20 +91,9 @@ namespace Lucene.Net.Index
         /// </summary>
         public static string ToString(BytesRef termText)
         {
-            // LUCENENET TODO
-            /*// the term might not be text, but usually is. so we make a best effort
-            CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder().onMalformedInput(CodingErrorAction.REPORT).onUnmappableCharacter(CodingErrorAction.REPORT);
             try
             {
-              return decoder.decode(ByteBuffer.wrap(termText.Bytes, termText.Offset, termText.Length)).ToString();
-            }
-            catch (CharacterCodingException e)
-            {
-              return termText.ToString();
-            }*/
-            try
-            {
-                // .Net port: termText already has this handy UTF8ToString method, so we're
using that instead
+                // LUCENENET specific: termText already has this handy UTF8ToString method,
so we're using that instead of Encoding.UTF8.GetBytes()
                 return termText.Utf8ToString();
             }
             catch

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/3ec3e794/src/Lucene.Net.Core/Search/PhraseQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/PhraseQuery.cs b/src/Lucene.Net.Core/Search/PhraseQuery.cs
index 64140f1..10d660b 100644
--- a/src/Lucene.Net.Core/Search/PhraseQuery.cs
+++ b/src/Lucene.Net.Core/Search/PhraseQuery.cs
@@ -431,7 +431,6 @@ namespace Lucene.Net.Search
         /// <seealso cref= Lucene.Net.Search.Query#extractTerms(Set) </seealso>
         public override void ExtractTerms(ISet<Term> queryTerms)
         {
-            //LUCENE TO-DO Normal conundrum
             queryTerms.UnionWith(terms);
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/3ec3e794/src/Lucene.Net.Core/Search/ReqExclScorer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/ReqExclScorer.cs b/src/Lucene.Net.Core/Search/ReqExclScorer.cs
index b4f4ab3..8af838d 100644
--- a/src/Lucene.Net.Core/Search/ReqExclScorer.cs
+++ b/src/Lucene.Net.Core/Search/ReqExclScorer.cs
@@ -122,9 +122,7 @@ namespace Lucene.Net.Search
 
         public override ICollection<ChildScorer> GetChildren()
         {
-            //LUCENE TO-DO
             return new[] { new ChildScorer(reqScorer, "FILTERED") };
-            //return Collections.singleton(new ChildScorer(ReqScorer, "FILTERED"));
         }
 
         public override int Advance(int target)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/3ec3e794/src/Lucene.Net.Core/Search/ScoreCachingWrappingScorer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/ScoreCachingWrappingScorer.cs b/src/Lucene.Net.Core/Search/ScoreCachingWrappingScorer.cs
index c7216d0..a6c4a47 100644
--- a/src/Lucene.Net.Core/Search/ScoreCachingWrappingScorer.cs
+++ b/src/Lucene.Net.Core/Search/ScoreCachingWrappingScorer.cs
@@ -78,9 +78,7 @@ namespace Lucene.Net.Search
 
         public override ICollection<ChildScorer> GetChildren()
         {
-            //LUCENE TO-DO
             return new[] { new ChildScorer(scorer, "CACHED") };
-            //return Collections.singleton(new ChildScorer(Scorer, "CACHED"));
         }
 
         public override long GetCost()

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/3ec3e794/src/Lucene.Net.Core/Search/Spans/NearSpansOrdered.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/Spans/NearSpansOrdered.cs b/src/Lucene.Net.Core/Search/Spans/NearSpansOrdered.cs
index 3906b3d..a9232a9 100644
--- a/src/Lucene.Net.Core/Search/Spans/NearSpansOrdered.cs
+++ b/src/Lucene.Net.Core/Search/Spans/NearSpansOrdered.cs
@@ -343,7 +343,6 @@ namespace Lucene.Net.Search.Spans
             var possibleMatchPayloads = new HashSet<byte[]>();
             if (subSpans[subSpans.Length - 1].IsPayloadAvailable)
             {
-                //LUCENE TO-DO UnionWith or AddAll(Set<>, IEnumerable<>)
                 possibleMatchPayloads.UnionWith(subSpans[subSpans.Length - 1].GetPayload());
             }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/3ec3e794/src/Lucene.Net.Core/Search/Spans/TermSpans.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/Spans/TermSpans.cs b/src/Lucene.Net.Core/Search/Spans/TermSpans.cs
index f72f7bb..6fc28c9 100644
--- a/src/Lucene.Net.Core/Search/Spans/TermSpans.cs
+++ b/src/Lucene.Net.Core/Search/Spans/TermSpans.cs
@@ -126,9 +126,7 @@ namespace Lucene.Net.Search.Spans
             {
                 bytes = null;
             }
-            //LUCENE TO-DO
             return new[] { bytes };
-            //return Collections.singletonList(bytes);
         }
 
         // TODO: Remove warning after API has been finalized

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/3ec3e794/src/Lucene.Net.Core/Util/CollectionUtil.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/CollectionUtil.cs b/src/Lucene.Net.Core/Util/CollectionUtil.cs
index e1142f9..7f8cf95 100644
--- a/src/Lucene.Net.Core/Util/CollectionUtil.cs
+++ b/src/Lucene.Net.Core/Util/CollectionUtil.cs
@@ -44,11 +44,12 @@ namespace Lucene.Net.Util
             internal ListIntroSorter(IList<T> list, IComparer<T> comp)
                 : base()
             {
-                /* LUCENE TO-DO I believe all ILists are RA
-                if (!(list is RandomAccess))
-                {
-                  throw new System.ArgumentException("CollectionUtil can only sort random
access lists in-place.");
-                }*/
+                // LUCENENET NOTE: All ILists in .NET are random access (only IEnumerable
is forward-only)
+                //if (!(list is RandomAccess))
+                //{
+                //  throw new System.ArgumentException("CollectionUtil can only sort random
access lists in-place.");
+                //}
+                
                 this.list = list;
                 this.comp = comp;
             }
@@ -83,11 +84,11 @@ namespace Lucene.Net.Util
             internal ListTimSorter(IList<T> list, IComparer<T> comp, int maxTempSlots)
                 : base(maxTempSlots)
             {
-                /* LUCENE TO-DO I believe all ILists are RA
-                if (!(list is RandomAccess))
-                {
-                  throw new System.ArgumentException("CollectionUtil can only sort random
access lists in-place.");
-                }*/
+                // LUCENENET NOTE: All ILists in .NET are random access (only IEnumerable
is forward-only)
+                //if (!(list is RandomAccess))
+                //{
+                //  throw new System.ArgumentException("CollectionUtil can only sort random
access lists in-place.");
+                //}
                 this.list = list;
                 this.comp = comp;
                 if (maxTempSlots > 0)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/3ec3e794/src/Lucene.Net.Core/Util/WeakIdentityMap.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/WeakIdentityMap.cs b/src/Lucene.Net.Core/Util/WeakIdentityMap.cs
index 9cb1bef..c6c35c4 100644
--- a/src/Lucene.Net.Core/Util/WeakIdentityMap.cs
+++ b/src/Lucene.Net.Core/Util/WeakIdentityMap.cs
@@ -63,8 +63,6 @@ namespace Lucene.Net.Util
     public sealed class WeakIdentityMap<TKey, TValue>
         where TKey : class
     {
-        // LUCENENET TODO: Make this class internal as it isn't required anywhere; need to
have it exposed to tests though
-
         //private readonly ReferenceQueue<object> queue = new ReferenceQueue<object>();
         private readonly IDictionary<IdentityWeakReference, TValue> backingStore;
 


Mime
View raw message