paulirwin commented on code in PR #1138:
URL: https://github.com/apache/lucenenet/pull/1138#discussion_r1986211452


##########
src/Lucene.Net/Store/MMapDirectory.cs:
##########
@@ -314,7 +314,7 @@ internal virtual ByteBuffer[] Map(MMapIndexInput input, 
FileStream fc, long offs
                 input.memoryMappedFile = MemoryMappedFile.CreateFromFile(
                     fileStream: fc,
                     mapName: null,
-                    capacity: length,
+                    capacity: 0, // use the full length of the file

Review Comment:
   We can't use `length` here because that is precisely what was causing the 
exception that this PR aims to fix. Somehow the `fc.Length` did not equal 
`length`. However, what the underlying code is doing on .NET Framework and 
modern .NET is that it is setting the capacity to `fileStream.Length` if it's 
zero, so we can just pass that to be on the safe side. That way it will always 
be valid.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to