You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2016/10/23 13:02:08 UTC

[22/50] [abbrv] lucenenet git commit: Fixed accessibility/initial size bugs when opening Core.Store.MMapDirectory.

Fixed accessibility/initial size bugs when opening Core.Store.MMapDirectory.


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

Branch: refs/heads/master
Commit: d7bbc4abb1b7b914bf6d462eb34eb852530656ee
Parents: fac1be2
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Tue Oct 18 18:21:04 2016 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Thu Oct 20 18:20:57 2016 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Core/Store/MMapDirectory.cs | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d7bbc4ab/src/Lucene.Net.Core/Store/MMapDirectory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Store/MMapDirectory.cs b/src/Lucene.Net.Core/Store/MMapDirectory.cs
index b59ad88..4b8ec4b 100644
--- a/src/Lucene.Net.Core/Store/MMapDirectory.cs
+++ b/src/Lucene.Net.Core/Store/MMapDirectory.cs
@@ -137,7 +137,10 @@ namespace Lucene.Net.Store
         /// <summary>
         /// <code>true</code>, if this platform supports unmapping mmapped files.
         /// </summary>
-        public static readonly bool UNMAP_SUPPORTED;
+        // LUCENENET NOTE: Some JREs had a bug that didn't allow them to unmap.
+        // But according to MSDN, the MemoryMappedFile.Dispose() method will
+        // indeed "release all resources".
+        public static readonly bool UNMAP_SUPPORTED = true;
 
         /*static MMapDirectory()
         {
@@ -200,7 +203,7 @@ namespace Lucene.Net.Store
             EnsureOpen();
             var file = new FileInfo(Path.Combine(Directory.FullName, name));
 
-            var c = new FileStream(file.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
+            var c = new FileStream(file.FullName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
 
             return new MMapIndexInput(this, "MMapIndexInput(path=\"" + file + "\")", c);
         }
@@ -347,7 +350,7 @@ namespace Lucene.Net.Store
 
             if (input.memoryMappedFile == null)
             {
-                input.memoryMappedFile = MemoryMappedFile.CreateFromFile(fc, null, length == 0 ? 100 : length, MemoryMappedFileAccess.Read, null, HandleInheritability.Inheritable, false);
+                input.memoryMappedFile = MemoryMappedFile.CreateFromFile(fc, null, length == 0 ? 1024 : length, MemoryMappedFileAccess.ReadWrite, null, HandleInheritability.Inheritable, false);
             }
 
             long bufferStart = 0L;