You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by pa...@apache.org on 2025/03/19 13:24:57 UTC
(lucenenet) branch master updated: Remove adjust logic in MMapDirectory, #1090 (#1138)
This is an automated email from the ASF dual-hosted git repository.
paulirwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git
The following commit(s) were added to refs/heads/master by this push:
new 52ee6bb72 Remove adjust logic in MMapDirectory, #1090 (#1138)
52ee6bb72 is described below
commit 52ee6bb72db782ed3713ddefff3b3b99e3585e3f
Author: Paul Irwin <pa...@gmail.com>
AuthorDate: Wed Mar 19 07:24:51 2025 -0600
Remove adjust logic in MMapDirectory, #1090 (#1138)
---
src/Lucene.Net/Store/MMapDirectory.cs | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/Lucene.Net/Store/MMapDirectory.cs b/src/Lucene.Net/Store/MMapDirectory.cs
index 59e1cccf8..403f79047 100644
--- a/src/Lucene.Net/Store/MMapDirectory.cs
+++ b/src/Lucene.Net/Store/MMapDirectory.cs
@@ -330,15 +330,15 @@ internal virtual ByteBuffer[] Map(MMapIndexInput input, FileStream fc, long offs
// LUCENENET: We get an UnauthorizedAccessException if we create a 0 byte file at the end of the range.
// See: https://stackoverflow.com/a/5501331
- // We can fix this by moving back 1 byte on the offset if the bufSize is 0.
- int adjust = 0;
- if (bufSize == 0 && bufNr == (nrBuffers - 1) && (offset + bufferStart) > 0)
+ // We can fix this by using an empty ByteBuffer if the buffer size is 0.
+ if (bufSize == 0 && bufNr == (nrBuffers - 1))
{
- adjust = 1;
+ buffers[bufNr] = ByteBuffer.Allocate(0).AsReadOnlyBuffer();
+ break;
}
buffers[bufNr] = input.memoryMappedFile.CreateViewByteBuffer(
- offset: (offset + bufferStart) - adjust,
+ offset: offset + bufferStart,
size: bufSize,
access: MemoryMappedFileAccess.Read);
bufferStart += bufSize;