lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [02/10] lucenenet git commit: Adding IMergeScheduler and IConcurrentMergeScheduler
Date Tue, 24 May 2016 21:22:55 GMT
Adding IMergeScheduler and IConcurrentMergeScheduler


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

Branch: refs/heads/analysis-work
Commit: 17515ff51c017cb533b6c610e582be0b2c7f62f1
Parents: 9185b0a
Author: Connie Yau <conniey@microsoft.com>
Authored: Mon Apr 18 15:22:23 2016 -0700
Committer: Connie Yau <conniey@microsoft.com>
Committed: Tue May 3 11:34:17 2016 -0700

----------------------------------------------------------------------
 .../Index/ConcurrentMergeScheduler.cs                |  4 ++--
 .../Index/IConcurrentMergeScheduler.cs               | 15 +++++++++++++++
 src/Lucene.Net.Core/Index/IMergeScheduler.cs         | 11 +++++++++++
 src/Lucene.Net.Core/Index/IndexWriter.cs             |  2 +-
 src/Lucene.Net.Core/Index/IndexWriterConfig.cs       |  6 +++---
 src/Lucene.Net.Core/Index/LiveIndexWriterConfig.cs   |  6 ++++--
 src/Lucene.Net.Core/Index/MergeScheduler.cs          |  4 ++--
 src/Lucene.Net.Core/Index/NoMergeScheduler.cs        |  2 +-
 src/Lucene.Net.Core/Lucene.Net.csproj                |  2 ++
 src/Lucene.Net.TestFramework/Util/TestUtil.cs        | 12 ++++++------
 .../core/Index/TestIndexWriterConfig.cs              |  4 ++--
 .../core/Index/TestIndexWriterExceptions.cs          |  6 +++---
 .../core/Index/TestIndexWriterOnDiskFull.cs          | 14 +++++++-------
 .../Index/TestIndexWriterOutOfFileDescriptors.cs     |  6 +++---
 14 files changed, 62 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/17515ff5/src/Lucene.Net.Core/Index/ConcurrentMergeScheduler.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/ConcurrentMergeScheduler.cs b/src/Lucene.Net.Core/Index/ConcurrentMergeScheduler.cs
index eeb3231..7f09844 100644
--- a/src/Lucene.Net.Core/Index/ConcurrentMergeScheduler.cs
+++ b/src/Lucene.Net.Core/Index/ConcurrentMergeScheduler.cs
@@ -44,7 +44,7 @@ namespace Lucene.Net.Index
     ///  incoming threads by pausing until one more more merges
     ///  complete.</p>
     /// </summary>
-    public class ConcurrentMergeScheduler : MergeScheduler
+    public class ConcurrentMergeScheduler : MergeScheduler, IConcurrentMergeScheduler
     {
         private int MergeThreadPriority_Renamed = -1;
 
@@ -743,7 +743,7 @@ namespace Lucene.Net.Index
             return sb.ToString();
         }
 
-        public override object Clone()
+        public override IMergeScheduler Clone()
         {
             ConcurrentMergeScheduler clone = (ConcurrentMergeScheduler)base.Clone();
             clone.Writer = null;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/17515ff5/src/Lucene.Net.Core/Index/IConcurrentMergeScheduler.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/IConcurrentMergeScheduler.cs b/src/Lucene.Net.Core/Index/IConcurrentMergeScheduler.cs
new file mode 100644
index 0000000..bbf205f
--- /dev/null
+++ b/src/Lucene.Net.Core/Index/IConcurrentMergeScheduler.cs
@@ -0,0 +1,15 @@
+´╗┐namespace Lucene.Net.Index
+{
+    public interface IConcurrentMergeScheduler : IMergeScheduler
+    {
+        int MaxThreadCount { get; }
+        int MaxMergeCount { get; }
+        int MergeThreadPriority { get; set; }
+
+        void Sync();
+        void SetMaxMergesAndThreads(int maxMergeCount, int maxThreadCount);
+
+        void SetSuppressExceptions();
+        void ClearSuppressExceptions();
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/17515ff5/src/Lucene.Net.Core/Index/IMergeScheduler.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/IMergeScheduler.cs b/src/Lucene.Net.Core/Index/IMergeScheduler.cs
new file mode 100644
index 0000000..36347b5
--- /dev/null
+++ b/src/Lucene.Net.Core/Index/IMergeScheduler.cs
@@ -0,0 +1,11 @@
+´╗┐using System;
+
+namespace Lucene.Net.Index
+{
+    public interface IMergeScheduler : IDisposable
+    {
+        void Merge(IndexWriter writer, MergeTrigger trigger, bool newMergesFound);
+
+        IMergeScheduler Clone();
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/17515ff5/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 2cb6c0a..2c759e0 100644
--- a/src/Lucene.Net.Core/Index/IndexWriter.cs
+++ b/src/Lucene.Net.Core/Index/IndexWriter.cs
@@ -260,7 +260,7 @@ namespace Lucene.Net.Index
         private readonly HashSet<SegmentCommitInfo> mergingSegments = new HashSet<SegmentCommitInfo>();
 
         private readonly MergePolicy mergePolicy;
-        private readonly MergeScheduler mergeScheduler;
+        private readonly IMergeScheduler mergeScheduler;
         private readonly LinkedList<MergePolicy.OneMerge> PendingMerges = new LinkedList<MergePolicy.OneMerge>();
         private readonly HashSet<MergePolicy.OneMerge> RunningMerges = new HashSet<MergePolicy.OneMerge>();
         private IList<MergePolicy.OneMerge> MergeExceptions = new List<MergePolicy.OneMerge>();

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/17515ff5/src/Lucene.Net.Core/Index/IndexWriterConfig.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/IndexWriterConfig.cs b/src/Lucene.Net.Core/Index/IndexWriterConfig.cs
index aaf160b..33f31a0 100644
--- a/src/Lucene.Net.Core/Index/IndexWriterConfig.cs
+++ b/src/Lucene.Net.Core/Index/IndexWriterConfig.cs
@@ -201,7 +201,7 @@ namespace Lucene.Net.Index
                 // such as line numbers, message throughput, ...
                 clone.infoStream = (InfoStream)infoStream.Clone();
                 clone.mergePolicy = (MergePolicy)mergePolicy.Clone();
-                clone.mergeScheduler = (MergeScheduler)mergeScheduler.Clone();
+                clone.mergeScheduler = mergeScheduler.Clone();
 
                 return clone;
             }
@@ -322,7 +322,7 @@ namespace Lucene.Net.Index
         ///
         /// <p>Only takes effect when IndexWriter is first created.
         /// </summary>
-        public IndexWriterConfig SetMergeScheduler(MergeScheduler mergeScheduler)
+        public IndexWriterConfig SetMergeScheduler(IMergeScheduler mergeScheduler)
         {
             if (mergeScheduler == null)
             {
@@ -332,7 +332,7 @@ namespace Lucene.Net.Index
             return this;
         }
 
-        public override MergeScheduler MergeScheduler
+        public override IMergeScheduler MergeScheduler
         {
             get
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/17515ff5/src/Lucene.Net.Core/Index/LiveIndexWriterConfig.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/LiveIndexWriterConfig.cs b/src/Lucene.Net.Core/Index/LiveIndexWriterConfig.cs
index 7d90819..c2961f9 100644
--- a/src/Lucene.Net.Core/Index/LiveIndexWriterConfig.cs
+++ b/src/Lucene.Net.Core/Index/LiveIndexWriterConfig.cs
@@ -75,7 +75,7 @@ namespace Lucene.Net.Index
 
         /// <summary>
         /// <seealso cref="MergeScheduler"/> to use for running merges. </summary>
-        protected internal volatile MergeScheduler mergeScheduler;
+        protected internal volatile IMergeScheduler mergeScheduler;
 
         /// <summary>
         /// Timeout when trying to obtain the write lock on init. </summary>
@@ -149,7 +149,9 @@ namespace Lucene.Net.Index
             useCompoundFile = IndexWriterConfig.DEFAULT_USE_COMPOUND_FILE_SYSTEM;
             openMode = OpenMode_e.CREATE_OR_APPEND;
             similarity = IndexSearcher.DefaultSimilarity;
+
             mergeScheduler = new ConcurrentMergeScheduler();
+
             writeLockTimeout = IndexWriterConfig.WRITE_LOCK_TIMEOUT;
             indexingChain = DocumentsWriterPerThread.defaultIndexingChain;
             codec = Codec.Default;
@@ -547,7 +549,7 @@ namespace Lucene.Net.Index
         /// Returns the <seealso cref="MergeScheduler"/> that was set by
         /// <seealso cref="IndexWriterConfig#setMergeScheduler(MergeScheduler)"/>.
         /// </summary>
-        public virtual MergeScheduler MergeScheduler
+        public virtual IMergeScheduler MergeScheduler
         {
             get
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/17515ff5/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 fc80f60..780f17e 100644
--- a/src/Lucene.Net.Core/Index/MergeScheduler.cs
+++ b/src/Lucene.Net.Core/Index/MergeScheduler.cs
@@ -29,7 +29,7 @@ namespace Lucene.Net.Index
     ///  instance.</p>
     /// @lucene.experimental
     /// </summary>
-    public abstract class MergeScheduler : IDisposable, ICloneable
+    public abstract class MergeScheduler : IDisposable, IMergeScheduler
     {
         /// <summary>
         /// Sole constructor. (For invocation by subclass
@@ -51,7 +51,7 @@ namespace Lucene.Net.Index
         /// Close this MergeScheduler. </summary>
         public abstract void Dispose();
 
-        public virtual object Clone()
+        public virtual IMergeScheduler Clone()
         {
             return (MergeScheduler)base.MemberwiseClone();
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/17515ff5/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 2369197..51dabe2 100644
--- a/src/Lucene.Net.Core/Index/NoMergeScheduler.cs
+++ b/src/Lucene.Net.Core/Index/NoMergeScheduler.cs
@@ -46,7 +46,7 @@ namespace Lucene.Net.Index
         {
         }
 
-        public override object Clone()
+        public override IMergeScheduler Clone()
         {
             return this;
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/17515ff5/src/Lucene.Net.Core/Lucene.Net.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Lucene.Net.csproj b/src/Lucene.Net.Core/Lucene.Net.csproj
index 0d08a91..97ef348 100644
--- a/src/Lucene.Net.Core/Lucene.Net.csproj
+++ b/src/Lucene.Net.Core/Lucene.Net.csproj
@@ -286,6 +286,8 @@
     <Compile Include="Index\FreqProxTermsWriter.cs" />
     <Compile Include="Index\FreqProxTermsWriterPerField.cs" />
     <Compile Include="Index\FrozenBufferedUpdates.cs" />
+    <Compile Include="Index\IConcurrentMergeScheduler.cs" />
+    <Compile Include="Index\IMergeScheduler.cs" />
     <Compile Include="Index\IndexableField.cs" />
     <Compile Include="Index\IndexableFieldType.cs" />
     <Compile Include="Index\IndexCommit.cs" />

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/17515ff5/src/Lucene.Net.TestFramework/Util/TestUtil.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Util/TestUtil.cs b/src/Lucene.Net.TestFramework/Util/TestUtil.cs
index 1afcf67..c0db864 100644
--- a/src/Lucene.Net.TestFramework/Util/TestUtil.cs
+++ b/src/Lucene.Net.TestFramework/Util/TestUtil.cs
@@ -128,11 +128,11 @@ namespace Lucene.Net.Util
             SyncConcurrentMerges(writer.Config.MergeScheduler);
         }
 
-        public static void SyncConcurrentMerges(MergeScheduler ms)
+        public static void SyncConcurrentMerges(IMergeScheduler ms)
         {
-            if (ms is ConcurrentMergeScheduler)
+            if (ms is IConcurrentMergeScheduler)
             {
-                ((ConcurrentMergeScheduler)ms).Sync();
+                ((IConcurrentMergeScheduler)ms).Sync();
             }
         }
 
@@ -916,11 +916,11 @@ namespace Lucene.Net.Util
                 tmp.SegmentsPerTier = Math.Min(5, tmp.SegmentsPerTier);
                 tmp.NoCFSRatio = 1.0;
             }
-            MergeScheduler ms = w.Config.MergeScheduler;
-            if (ms is ConcurrentMergeScheduler)
+            IMergeScheduler ms = w.Config.MergeScheduler;
+            if (ms is IConcurrentMergeScheduler)
             {
                 // wtf... shouldnt it be even lower since its 1 by default?!?!
-                ((ConcurrentMergeScheduler)ms).SetMaxMergesAndThreads(3, 2);
+                ((IConcurrentMergeScheduler)ms).SetMaxMergesAndThreads(3, 2);
             }
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/17515ff5/src/Lucene.Net.Tests/core/Index/TestIndexWriterConfig.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestIndexWriterConfig.cs b/src/Lucene.Net.Tests/core/Index/TestIndexWriterConfig.cs
index 215d1d4..954d323 100644
--- a/src/Lucene.Net.Tests/core/Index/TestIndexWriterConfig.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestIndexWriterConfig.cs
@@ -279,8 +279,8 @@ namespace Lucene.Net.Index
             MergePolicy mergePolicyClone = clone.MergePolicy;
             Assert.IsTrue(mergePolicy.GetType() == mergePolicyClone.GetType() &&
(mergePolicy != mergePolicyClone || mergePolicy.Clone() == mergePolicyClone.Clone()));
 
-            MergeScheduler mergeSched = conf.MergeScheduler;
-            MergeScheduler mergeSchedClone = clone.MergeScheduler;
+            IMergeScheduler mergeSched = conf.MergeScheduler;
+            IMergeScheduler mergeSchedClone = clone.MergeScheduler;
             Assert.IsTrue(mergeSched.GetType() == mergeSchedClone.GetType() && (mergeSched
!= mergeSchedClone || mergeSched.Clone() == mergeSchedClone.Clone()));
 
             conf.SetMergeScheduler(new SerialMergeScheduler());

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/17515ff5/src/Lucene.Net.Tests/core/Index/TestIndexWriterExceptions.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestIndexWriterExceptions.cs b/src/Lucene.Net.Tests/core/Index/TestIndexWriterExceptions.cs
index 51eb668..34bba74 100644
--- a/src/Lucene.Net.Tests/core/Index/TestIndexWriterExceptions.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestIndexWriterExceptions.cs
@@ -2150,11 +2150,11 @@ namespace Lucene.Net.Index
                 if (w == null)
                 {
                     IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, new
MockAnalyzer(Random()));
-                    MergeScheduler ms = iwc.MergeScheduler;
-                    if (ms is ConcurrentMergeScheduler)
+                    IMergeScheduler ms = iwc.MergeScheduler;
+                    if (ms is IConcurrentMergeScheduler)
                     {
                         ConcurrentMergeScheduler suppressFakeIOE = new ConcurrentMergeSchedulerAnonymousInnerClassHelper(this);
-                        ConcurrentMergeScheduler cms = (ConcurrentMergeScheduler)ms;
+                        IConcurrentMergeScheduler cms = (IConcurrentMergeScheduler)ms;
                         suppressFakeIOE.SetMaxMergesAndThreads(cms.MaxMergeCount, cms.MaxThreadCount);
                         suppressFakeIOE.MergeThreadPriority = cms.MergeThreadPriority;
                         iwc.SetMergeScheduler(suppressFakeIOE);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/17515ff5/src/Lucene.Net.Tests/core/Index/TestIndexWriterOnDiskFull.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestIndexWriterOnDiskFull.cs b/src/Lucene.Net.Tests/core/Index/TestIndexWriterOnDiskFull.cs
index 306cc3c..75aeb19 100644
--- a/src/Lucene.Net.Tests/core/Index/TestIndexWriterOnDiskFull.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestIndexWriterOnDiskFull.cs
@@ -72,13 +72,13 @@ namespace Lucene.Net.Index
                     MockDirectoryWrapper dir = new MockDirectoryWrapper(Random(), new RAMDirectory());
                     dir.MaxSizeInBytes = diskFree;
                     IndexWriter writer = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer(Random())));
-                    MergeScheduler ms = writer.Config.MergeScheduler;
-                    if (ms is ConcurrentMergeScheduler)
+                    IMergeScheduler ms = writer.Config.MergeScheduler;
+                    if (ms is IConcurrentMergeScheduler)
                     {
                         // this test intentionally produces exceptions
                         // in the threads that CMS launches; we don't
                         // want to pollute test output with these.
-                        ((ConcurrentMergeScheduler)ms).SetSuppressExceptions();
+                        ((IConcurrentMergeScheduler)ms).SetSuppressExceptions();
                     }
 
                     bool hitError = false;
@@ -297,21 +297,21 @@ namespace Lucene.Net.Index
                     indWriter = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer(Random())).SetOpenMode(OpenMode_e.APPEND).SetMergePolicy(NewLogMergePolicy(false)));
                     IOException err = null;
 
-                    MergeScheduler ms = indWriter.Config.MergeScheduler;
+                    IMergeScheduler ms = indWriter.Config.MergeScheduler;
                     for (int x = 0; x < 2; x++)
                     {
-                        if (ms is ConcurrentMergeScheduler)
+                        if (ms is IConcurrentMergeScheduler)
                         // this test intentionally produces exceptions
                         // in the threads that CMS launches; we don't
                         // want to pollute test output with these.
                         {
                             if (0 == x)
                             {
-                                ((ConcurrentMergeScheduler)ms).SetSuppressExceptions();
+                                ((IConcurrentMergeScheduler)ms).SetSuppressExceptions();
                             }
                             else
                             {
-                                ((ConcurrentMergeScheduler)ms).ClearSuppressExceptions();
+                                ((IConcurrentMergeScheduler)ms).ClearSuppressExceptions();
                             }
                         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/17515ff5/src/Lucene.Net.Tests/core/Index/TestIndexWriterOutOfFileDescriptors.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestIndexWriterOutOfFileDescriptors.cs b/src/Lucene.Net.Tests/core/Index/TestIndexWriterOutOfFileDescriptors.cs
index b65a77f..24a3726 100644
--- a/src/Lucene.Net.Tests/core/Index/TestIndexWriterOutOfFileDescriptors.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestIndexWriterOutOfFileDescriptors.cs
@@ -70,10 +70,10 @@ namespace Lucene.Net.Index
                         // we see incrementing messageID:
                         iwc.InfoStream = new PrintStreamInfoStream(Console.Out);
                     }
-                    MergeScheduler ms = iwc.MergeScheduler;
-                    if (ms is ConcurrentMergeScheduler)
+                    var ms = iwc.MergeScheduler;
+                    if (ms is IConcurrentMergeScheduler)
                     {
-                        ((ConcurrentMergeScheduler)ms).SetSuppressExceptions();
+                        ((IConcurrentMergeScheduler)ms).SetSuppressExceptions();
                     }
                     w = new IndexWriter(dir, iwc);
                     if (r != null && Random().Next(5) == 3)


Mime
View raw message