lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [09/10] lucenenet git commit: Removing duplicated Verbose method and passing it in MergeThread.ctor
Date Tue, 24 May 2016 21:23:02 GMT
Removing duplicated Verbose method and passing it in MergeThread.ctor


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

Branch: refs/heads/analysis-work
Commit: 0af102e74c9ecc1035e9f5a5b69d3a8f592f040f
Parents: 2c8e4a9
Author: Connie Yau <conniey@microsoft.com>
Authored: Tue May 24 14:14:54 2016 -0700
Committer: Connie Yau <conniey@microsoft.com>
Committed: Tue May 24 14:14:54 2016 -0700

----------------------------------------------------------------------
 src/Lucene.Net.Core/Index/TaskMergeScheduler.cs | 21 ++++++++------------
 1 file changed, 8 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/0af102e7/src/Lucene.Net.Core/Index/TaskMergeScheduler.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/TaskMergeScheduler.cs b/src/Lucene.Net.Core/Index/TaskMergeScheduler.cs
index f43b243..dbc8e05 100644
--- a/src/Lucene.Net.Core/Index/TaskMergeScheduler.cs
+++ b/src/Lucene.Net.Core/Index/TaskMergeScheduler.cs
@@ -340,7 +340,7 @@ namespace Lucene.Net.Index
             var count = Interlocked.Increment(ref _mergeThreadCount);
             var name = string.Format("Lucene Merge Task #{0}", count);
 
-            return new MergeThread(name, writer, merge, writer.infoStream, _manualResetEvent,
HandleMergeException);
+            return new MergeThread(name, writer, merge, writer.infoStream, Verbose(), _manualResetEvent,
HandleMergeException);
         }
 
         /// <summary>
@@ -420,6 +420,7 @@ namespace Lucene.Net.Index
             private readonly InfoStream _logger;
             private readonly IndexWriter _writer;
             private readonly MergePolicy.OneMerge _startingMerge;
+            private readonly bool _isLoggingEnabled;
 
             private Task _task;
             private MergePolicy.OneMerge _runningMerge;
@@ -428,7 +429,8 @@ namespace Lucene.Net.Index
 
             /// <summary>
             /// Sole constructor. </summary>
-            public MergeThread(string name, IndexWriter writer, MergePolicy.OneMerge startMerge,
InfoStream logger,
+            public MergeThread(string name, IndexWriter writer, MergePolicy.OneMerge startMerge,
+                InfoStream logger, bool isLoggingEnabled,
                 ManualResetEventSlim resetEvent, Action<Exception> exceptionHandler)
             {
                 Name = name;
@@ -436,18 +438,11 @@ namespace Lucene.Net.Index
                 _writer = writer;
                 _startingMerge = startMerge;
                 _logger = logger;
+                _isLoggingEnabled = isLoggingEnabled;
                 _resetEvent = resetEvent;
                 _exceptionHandler = exceptionHandler;
             }
 
-            private bool IsLoggingEnabled
-            {
-                get
-                {
-                    return _logger != null && _logger.IsEnabled(COMPONENT_NAME);
-                }
-            }
-
             public string Name { get; private set; }
 
             public Task Instance
@@ -562,7 +557,7 @@ namespace Lucene.Net.Index
 
                 try
                 {
-                    if (IsLoggingEnabled)
+                    if (_isLoggingEnabled)
                     {
                         _logger.Message(COMPONENT_NAME, "  merge thread: start");
                     }
@@ -583,7 +578,7 @@ namespace Lucene.Net.Index
 
                         if (merge != null)
                         {
-                            if (IsLoggingEnabled)
+                            if (_isLoggingEnabled)
                             {
                                 _logger.Message(COMPONENT_NAME, "  merge thread: do another
merge " + _writer.SegString(merge.Segments));
                             }
@@ -594,7 +589,7 @@ namespace Lucene.Net.Index
                         }
                     }
 
-                    if (IsLoggingEnabled)
+                    if (_isLoggingEnabled)
                     {
                         _logger.Message(COMPONENT_NAME, "  merge thread: done");
                     }


Mime
View raw message