NightOwl888 commented on code in PR #1138: URL: https://github.com/apache/lucenenet/pull/1138#discussion_r1987719691
########## 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: fc.Length, // use the full length of the file Review Comment: Lucene uses file locking to ensure that the `Map()` method is not called during a write operation, so the `length` is consistent during this operation. While you are correct that passing `0` is the equivalent operation as calling `FileChannel.map()` in Java, passing the `length` should be fine. More importantly, it has been tested very thoroughly using the `length` parameter and we haven't had any reports of problems. Also, since `length` is passed as a parameter to the method, we should be using it to ensure that the end chunk is calculated using the same value. This would fail in Java if there were a race condition here. We could use `0` on .NET Framework and .NET Core and pass `FileStream.Length` in all other cases, but it would require some messy platform detection code or additional assemblies for different platforms. Using `length` is the best way to ensure it is consistent. -- 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: dev-unsubscr...@lucenenet.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org