lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [4/7] lucenenet git commit: Lucene.Net.Core.Search.SearcherLifetimeManager: Fixed math to calculate seconds correctly
Date Fri, 24 Mar 2017 11:47:52 GMT
Lucene.Net.Core.Search.SearcherLifetimeManager: Fixed math to calculate seconds correctly


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

Branch: refs/heads/api-work
Commit: d284bd03b031306f1c7d7409c5f521caab0fe323
Parents: 0d4619a
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Fri Mar 24 18:13:47 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Fri Mar 24 18:13:47 2017 +0700

----------------------------------------------------------------------
 .../Search/SearcherLifetimeManager.cs              | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d284bd03/src/Lucene.Net.Core/Search/SearcherLifetimeManager.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/SearcherLifetimeManager.cs b/src/Lucene.Net.Core/Search/SearcherLifetimeManager.cs
index c6e6f07..4f0e2cd 100644
--- a/src/Lucene.Net.Core/Search/SearcherLifetimeManager.cs
+++ b/src/Lucene.Net.Core/Search/SearcherLifetimeManager.cs
@@ -95,7 +95,10 @@ namespace Lucene.Net.Search
 
     public class SearcherLifetimeManager : IDisposable
     {
-        internal const double NANOS_PER_SEC = 1000000000.0;
+        // LUCENENET specific - adjust scale to account for the fact that we
+        // are using milliseconds instead of nanoseconds in .NET.
+        private const double MILLISECONDS_PER_SECOND = 1000;
+        //internal const double NANOS_PER_SEC = 1000000000.0;
 
         private sealed class SearcherTracker : IComparable<SearcherTracker>, IDisposable
         {
@@ -108,9 +111,11 @@ namespace Lucene.Net.Search
                 Searcher = searcher;
                 Version = ((DirectoryReader)searcher.IndexReader).Version;
                 searcher.IndexReader.IncRef();
-                // Use nanoTime not currentTimeMillis since it [in
-                // theory] reduces risk from clock shift
-                RecordTimeSec = DateTime.Now.ToFileTime() / 100.0d / NANOS_PER_SEC;
+                //// Use nanoTime not currentTimeMillis since it [in
+                //// theory] reduces risk from clock shift
+                //RecordTimeSec = DateTime.Now.ToFileTime() / 100.0d / NANOS_PER_SEC;
+                // LUCENENET specific - adjust calculation for milliseconds
+                RecordTimeSec = Environment.TickCount / MILLISECONDS_PER_SECOND;
             }
 
             // Newer searchers are sort before older ones:
@@ -268,7 +273,9 @@ namespace Lucene.Net.Search
                 var trackers = _searchers.Values.ToList();
                 trackers.Sort();
                 var lastRecordTimeSec = 0.0;
-                var now = DateTime.Now.ToFileTime() / 100.0d / NANOS_PER_SEC;
+                //var now = DateTime.Now.ToFileTime() / 100.0d / NANOS_PER_SEC;
+                // LUCENENET specific - adjust calculation for milliseconds
+                double now = Environment.TickCount / MILLISECONDS_PER_SECOND;
                 foreach (var tracker in trackers)
                 {
                     double ageSec;


Mime
View raw message