lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [15/33] lucenenet git commit: Lucene.Net.Core.MergePolicy refactor: Changed MergeTrigger enum argument of FindMerges to be non-nullable. For the edge cases that were passing null in Lucene, we are just passing int.MinValue.
Date Fri, 17 Mar 2017 22:28:45 GMT
Lucene.Net.Core.MergePolicy refactor: Changed MergeTrigger enum argument of FindMerges to be
non-nullable. For the edge cases that were passing null in Lucene, we are just passing int.MinValue.


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

Branch: refs/heads/api-work
Commit: 51f56d5c8b98dd2ec935d30c1d85488cac8b8141
Parents: 0e6ad0d
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Fri Mar 17 09:43:52 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Fri Mar 17 09:43:52 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Core/Index/IndexWriter.cs                |  4 ++--
 src/Lucene.Net.Core/Index/LogMergePolicy.cs             |  2 +-
 src/Lucene.Net.Core/Index/MergePolicy.cs                | 12 ++++++------
 src/Lucene.Net.Core/Index/MergeScheduler.cs             |  8 ++++----
 src/Lucene.Net.Core/Index/MergeTrigger.cs               |  2 +-
 src/Lucene.Net.Core/Index/NoMergePolicy.cs              |  2 +-
 src/Lucene.Net.Core/Index/NoMergeScheduler.cs           |  6 +++---
 src/Lucene.Net.Core/Index/TieredMergePolicy.cs          |  8 ++++----
 src/Lucene.Net.Core/Index/UpgradeIndexMergePolicy.cs    |  5 +++--
 src/Lucene.Net.Misc/Index/Sorter/SortingMergePolicy.cs  |  3 +--
 .../Index/MockRandomMergePolicy.cs                      |  5 +++--
 src/Lucene.Net.Tests/Index/TestNoMergePolicy.cs         |  2 +-
 src/Lucene.Net.Tests/Index/TestPerSegmentDeletes.cs     |  2 +-
 13 files changed, 31 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/51f56d5c/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 c6b51fa..710761d 100644
--- a/src/Lucene.Net.Core/Index/IndexWriter.cs
+++ b/src/Lucene.Net.Core/Index/IndexWriter.cs
@@ -2364,8 +2364,8 @@ namespace Lucene.Net.Index
         /// necessary. The most common case is when merge policy
         /// parameters have changed.
         ///
-        /// this method will call the <seealso cref="mergePolicy"/> with
-        /// <seealso cref="MergeTrigger#EXPLICIT"/>.
+        /// this method will call the <see cref="mergePolicy"/> with
+        /// <see cref="MergeTrigger.EXPLICIT"/>.
         ///
         /// <p><b>NOTE</b>: if this method hits an OutOfMemoryError
         /// you should immediately close the writer.  See <a

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/51f56d5c/src/Lucene.Net.Core/Index/LogMergePolicy.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/LogMergePolicy.cs b/src/Lucene.Net.Core/Index/LogMergePolicy.cs
index a8cb5fa..581da8b 100644
--- a/src/Lucene.Net.Core/Index/LogMergePolicy.cs
+++ b/src/Lucene.Net.Core/Index/LogMergePolicy.cs
@@ -559,7 +559,7 @@ namespace Lucene.Net.Index
         ///  will return multiple merges, allowing the {@link
         ///  MergeScheduler} to use concurrency.
         /// </summary>
-        public override MergeSpecification FindMerges(MergeTrigger? mergeTrigger, SegmentInfos
infos)
+        public override MergeSpecification FindMerges(MergeTrigger mergeTrigger, SegmentInfos
infos)
         {
             int numSegments = infos.Count;
             if (IsVerbose)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/51f56d5c/src/Lucene.Net.Core/Index/MergePolicy.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/MergePolicy.cs b/src/Lucene.Net.Core/Index/MergePolicy.cs
index 16ff3bd..e6e5de1 100644
--- a/src/Lucene.Net.Core/Index/MergePolicy.cs
+++ b/src/Lucene.Net.Core/Index/MergePolicy.cs
@@ -610,19 +610,19 @@ namespace Lucene.Net.Index
 
         /// <summary>
         /// Determine what set of merge operations are now necessary on the index.
-        /// <seealso cref="IndexWriter"/> calls this whenever there is a change to
the segments.
-        /// this call is always synchronized on the <seealso cref="IndexWriter"/> instance
so
+        /// <see cref="IndexWriter"/> calls this whenever there is a change to the
segments.
+        /// this call is always synchronized on the <see cref="IndexWriter"/> instance
so
         /// only one thread at a time will call this method. </summary>
         /// <param name="mergeTrigger"> the event that triggered the merge </param>
         /// <param name="segmentInfos">
         ///          the total set of segments in the index </param>
-        public abstract MergeSpecification FindMerges(MergeTrigger? mergeTrigger, SegmentInfos
segmentInfos);
+        public abstract MergeSpecification FindMerges(MergeTrigger mergeTrigger, SegmentInfos
segmentInfos);
 
         /// <summary>
         /// Determine what set of merge operations is necessary in
-        /// order to merge to <= the specified segment count. <seealso cref="IndexWriter"/>
calls this when its
-        /// <seealso cref="IndexWriter#forceMerge"/> method is called. this call is
always
-        /// synchronized on the <seealso cref="IndexWriter"/> instance so only one
thread at a
+        /// order to merge to &lt;= the specified segment count. <see cref="IndexWriter"/>
calls this when its
+        /// <see cref="IndexWriter.ForceMerge"/> method is called. this call is always
+        /// synchronized on the <see cref="IndexWriter"/> instance so only one thread
at a
         /// time will call this method.
         /// </summary>
         /// <param name="segmentInfos">

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/51f56d5c/src/Lucene.Net.Core/Index/MergeScheduler.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/MergeScheduler.cs b/src/Lucene.Net.Core/Index/MergeScheduler.cs
index 8646cc7..7def836 100644
--- a/src/Lucene.Net.Core/Index/MergeScheduler.cs
+++ b/src/Lucene.Net.Core/Index/MergeScheduler.cs
@@ -40,10 +40,10 @@ namespace Lucene.Net.Index
         }
 
         /// <summary>
-        /// Run the merges provided by <seealso cref="IndexWriter#getNextMerge()"/>.
</summary>
-        /// <param name="writer"> the <seealso cref="IndexWriter"/> to obtain
the merges from. </param>
-        /// <param name="trigger"> the <seealso cref="MergeTrigger"/> that caused
this merge to happen </param>
-        /// <param name="newMergesFound"> <code>true</code> iff any new
merges were found by the caller otherwise <code>false</code>
+        /// Run the merges provided by <see cref="IndexWriter.NextMerge()"/>. </summary>
+        /// <param name="writer"> the <see cref="IndexWriter"/> to obtain the
merges from. </param>
+        /// <param name="trigger"> the <see cref="MergeTrigger"/> that caused
this merge to happen </param>
+        /// <param name="newMergesFound"> <c>true</c> iff any new merges
were found by the caller; otherwise <c>false</c>
         ///  </param>
         public abstract void Merge(IndexWriter writer, MergeTrigger trigger, bool newMergesFound);
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/51f56d5c/src/Lucene.Net.Core/Index/MergeTrigger.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/MergeTrigger.cs b/src/Lucene.Net.Core/Index/MergeTrigger.cs
index 70cd63f..113be31 100644
--- a/src/Lucene.Net.Core/Index/MergeTrigger.cs
+++ b/src/Lucene.Net.Core/Index/MergeTrigger.cs
@@ -19,7 +19,7 @@ namespace Lucene.Net.Index
 
     /// <summary>
     /// MergeTrigger is passed to
-    /// <seealso cref="Lucene.Net.Index.MergePolicy#findMerges(MergeTrigger, Lucene.Net.Index.SegmentInfos)"/>
to indicate the
+    /// <see cref="MergePolicy.FindMerges(MergeTrigger, SegmentInfos)"/> to indicate
the
     /// event that triggered the merge.
     /// </summary>
     public enum MergeTrigger

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/51f56d5c/src/Lucene.Net.Core/Index/NoMergePolicy.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/NoMergePolicy.cs b/src/Lucene.Net.Core/Index/NoMergePolicy.cs
index 67b2c79..b044007 100644
--- a/src/Lucene.Net.Core/Index/NoMergePolicy.cs
+++ b/src/Lucene.Net.Core/Index/NoMergePolicy.cs
@@ -55,7 +55,7 @@ namespace Lucene.Net.Index
         {
         }
 
-        public override MergeSpecification FindMerges(MergeTrigger? mergeTrigger, SegmentInfos
segmentInfos)
+        public override MergeSpecification FindMerges(MergeTrigger mergeTrigger, SegmentInfos
segmentInfos)
         {
             return null;
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/51f56d5c/src/Lucene.Net.Core/Index/NoMergeScheduler.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/NoMergeScheduler.cs b/src/Lucene.Net.Core/Index/NoMergeScheduler.cs
index a25fa6c..9ab5da2 100644
--- a/src/Lucene.Net.Core/Index/NoMergeScheduler.cs
+++ b/src/Lucene.Net.Core/Index/NoMergeScheduler.cs
@@ -18,9 +18,9 @@ namespace Lucene.Net.Index
      */
 
     /// <summary>
-    /// A <seealso cref="MergeScheduler"/> which never executes any merges. It is also
a
-    /// singleton and can be accessed through <seealso cref="NoMergeScheduler#INSTANCE"/>.
Use
-    /// it if you want to prevent an <seealso cref="IndexWriter"/> from ever executing
merges,
+    /// A <see cref="MergeScheduler"/> which never executes any merges. It is also
a
+    /// singleton and can be accessed through <see cref="NoMergeScheduler.INSTANCE"/>.
Use
+    /// it if you want to prevent an <see cref="IndexWriter"/> from ever executing
merges,
     /// regardless of the <seealso cref="MergePolicy"/> used. Note that you can achieve
the
     /// same thing by using <seealso cref="NoMergePolicy"/>, however with
     /// <seealso cref="NoMergeScheduler"/> you also ensure that no unnecessary code
of any

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/51f56d5c/src/Lucene.Net.Core/Index/TieredMergePolicy.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/TieredMergePolicy.cs b/src/Lucene.Net.Core/Index/TieredMergePolicy.cs
index b13ecaa..40fba9f 100644
--- a/src/Lucene.Net.Core/Index/TieredMergePolicy.cs
+++ b/src/Lucene.Net.Core/Index/TieredMergePolicy.cs
@@ -323,7 +323,7 @@ namespace Lucene.Net.Index
             public abstract string Explanation { get; }
         }
 
-        public override MergeSpecification FindMerges(MergeTrigger? mergeTrigger, SegmentInfos
infos)
+        public override MergeSpecification FindMerges(MergeTrigger mergeTrigger, SegmentInfos
infos)
         {
             if (Verbose())
             {
@@ -356,7 +356,7 @@ namespace Lucene.Net.Index
                     {
                         extra += " [floored]";
                     }
-                    Message("  seg=" + m_writer.Get().SegString(info) + " size=" + String.Format(CultureInfo.InvariantCulture,
"{0:0.00}", segBytes / 1024 / 1024.0) + " MB" + extra);
+                    Message("  seg=" + m_writer.Get().SegString(info) + " size=" + string.Format("{0:0.000}",
segBytes / 1024 / 1024.0) + " MB" + extra);
                 }
 
                 minSegmentBytes = Math.Min(segBytes, minSegmentBytes);
@@ -467,7 +467,7 @@ namespace Lucene.Net.Index
                         MergeScore score = Score(candidate, hitTooLarge, mergingBytes);
                         if (Verbose())
                         {
-                            Message("  maybe=" + m_writer.Get().SegString(candidate) + "
score=" + score.Score + " " + score.Explanation + " tooLarge=" + hitTooLarge + " size=" +
string.Format(CultureInfo.InvariantCulture, "%.3f MB", totAfterMergeBytes / 1024.0 / 1024.0));
+                            Message("  maybe=" + m_writer.Get().SegString(candidate) + "
score=" + score.Score + " " + score.Explanation + " tooLarge=" + hitTooLarge + " size=" +
string.Format("{0:0.000} MB", totAfterMergeBytes / 1024.0 / 1024.0));
                         }
 
                         // If we are already running a max sized merge
@@ -497,7 +497,7 @@ namespace Lucene.Net.Index
 
                         if (Verbose())
                         {
-                            Message("  add merge=" + m_writer.Get().SegString(merge.Segments)
+ " size=" + string.Format(CultureInfo.InvariantCulture, "%.3f MB", bestMergeBytes / 1024.0
/ 1024.0) + " score=" + string.Format(CultureInfo.InvariantCulture, "%.3f", bestScore.Score)
+ " " + bestScore.Explanation + (bestTooLarge ? " [max merge]" : ""));
+                            Message("  add merge=" + m_writer.Get().SegString(merge.Segments)
+ " size=" + string.Format("{0:0.000} MB", bestMergeBytes / 1024.0 / 1024.0) + " score=" +
string.Format("{0:0.000}", bestScore.Score) + " " + bestScore.Explanation + (bestTooLarge
? " [max merge]" : ""));
                         }
                     }
                     else

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/51f56d5c/src/Lucene.Net.Core/Index/UpgradeIndexMergePolicy.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/UpgradeIndexMergePolicy.cs b/src/Lucene.Net.Core/Index/UpgradeIndexMergePolicy.cs
index 9e02b0c..b490686 100644
--- a/src/Lucene.Net.Core/Index/UpgradeIndexMergePolicy.cs
+++ b/src/Lucene.Net.Core/Index/UpgradeIndexMergePolicy.cs
@@ -77,9 +77,10 @@ namespace Lucene.Net.Index
             m_base.SetIndexWriter(writer);
         }
 
-        public override MergeSpecification FindMerges(MergeTrigger? mergeTrigger, SegmentInfos
segmentInfos)
+        public override MergeSpecification FindMerges(MergeTrigger mergeTrigger, SegmentInfos
segmentInfos)
         {
-            return m_base.FindMerges(null, segmentInfos);
+            // LUCENENET specific - just use min value to indicate "null" for merge trigger
+            return m_base.FindMerges((MergeTrigger)int.MinValue, segmentInfos);
         }
 
         public override MergeSpecification FindForcedMerges(SegmentInfos segmentInfos, int
maxSegmentCount, IDictionary<SegmentCommitInfo, bool?> segmentsToMerge)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/51f56d5c/src/Lucene.Net.Misc/Index/Sorter/SortingMergePolicy.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Misc/Index/Sorter/SortingMergePolicy.cs b/src/Lucene.Net.Misc/Index/Sorter/SortingMergePolicy.cs
index a70a5f1..770c00b 100644
--- a/src/Lucene.Net.Misc/Index/Sorter/SortingMergePolicy.cs
+++ b/src/Lucene.Net.Misc/Index/Sorter/SortingMergePolicy.cs
@@ -235,8 +235,7 @@ namespace Lucene.Net.Index.Sorter
             this.sort = sort;
         }
 
-        [ExceptionToNullableEnumConvention]
-        public override MergeSpecification FindMerges(MergeTrigger? mergeTrigger, SegmentInfos
segmentInfos)
+        public override MergeSpecification FindMerges(MergeTrigger mergeTrigger, SegmentInfos
segmentInfos)
         {
             return SortedMergeSpecification(@in.FindMerges(mergeTrigger, segmentInfos));
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/51f56d5c/src/Lucene.Net.TestFramework/Index/MockRandomMergePolicy.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Index/MockRandomMergePolicy.cs b/src/Lucene.Net.TestFramework/Index/MockRandomMergePolicy.cs
index 8c69e69..820bd3e 100644
--- a/src/Lucene.Net.TestFramework/Index/MockRandomMergePolicy.cs
+++ b/src/Lucene.Net.TestFramework/Index/MockRandomMergePolicy.cs
@@ -38,7 +38,7 @@ namespace Lucene.Net.Index
             this.Random = new Random(random.Next());
         }
 
-        public override MergeSpecification FindMerges(MergeTrigger? mergeTrigger, SegmentInfos
segmentInfos)
+        public override MergeSpecification FindMerges(MergeTrigger mergeTrigger, SegmentInfos
segmentInfos)
         {
             MergeSpecification mergeSpec = null;
             //System.out.println("MRMP: findMerges sis=" + segmentInfos);
@@ -115,7 +115,8 @@ namespace Lucene.Net.Index
 
         public override MergeSpecification FindForcedDeletesMerges(SegmentInfos segmentInfos)
         {
-            return FindMerges(null, segmentInfos);
+            // LUCENENET specific - just use int.MinValue to indicate "null"
+            return FindMerges((MergeTrigger)int.MinValue, segmentInfos);
         }
 
         public override void Dispose()

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/51f56d5c/src/Lucene.Net.Tests/Index/TestNoMergePolicy.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Index/TestNoMergePolicy.cs b/src/Lucene.Net.Tests/Index/TestNoMergePolicy.cs
index 694126b..98b9b4f 100644
--- a/src/Lucene.Net.Tests/Index/TestNoMergePolicy.cs
+++ b/src/Lucene.Net.Tests/Index/TestNoMergePolicy.cs
@@ -30,7 +30,7 @@ namespace Lucene.Net.Index
         public virtual void TestNoMergePolicy_Mem()
         {
             MergePolicy mp = NoMergePolicy.NO_COMPOUND_FILES;
-            Assert.IsNull(mp.FindMerges(null, (SegmentInfos)null));
+            Assert.IsNull(mp.FindMerges(/*null*/ (MergeTrigger)int.MinValue, (SegmentInfos)null));
             Assert.IsNull(mp.FindForcedMerges(null, 0, null));
             Assert.IsNull(mp.FindForcedDeletesMerges(null));
             Assert.IsFalse(mp.UseCompoundFile(null, null));

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/51f56d5c/src/Lucene.Net.Tests/Index/TestPerSegmentDeletes.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Index/TestPerSegmentDeletes.cs b/src/Lucene.Net.Tests/Index/TestPerSegmentDeletes.cs
index f928cb3..5855138 100644
--- a/src/Lucene.Net.Tests/Index/TestPerSegmentDeletes.cs
+++ b/src/Lucene.Net.Tests/Index/TestPerSegmentDeletes.cs
@@ -286,7 +286,7 @@ namespace Lucene.Net.Index
             {
             }
 
-            public override MergeSpecification FindMerges(MergeTrigger? mergeTrigger, SegmentInfos
segmentInfos)
+            public override MergeSpecification FindMerges(MergeTrigger mergeTrigger, SegmentInfos
segmentInfos)
             {
                 MergeSpecification ms = new MergeSpecification();
                 if (DoMerge)


Mime
View raw message