From 1754ae319142d48654ad0e438dfd40f490295ab2 Mon Sep 17 00:00:00 2001 From: Dawid Weiss Date: Tue, 10 Dec 2024 14:30:34 +0100 Subject: [PATCH] IndexInput.isLoaded seems to return false for mmap index inputs on Windows #14050 --- .../lucene/store/MemorySegmentIndexInput.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lucene/core/src/java21/org/apache/lucene/store/MemorySegmentIndexInput.java b/lucene/core/src/java21/org/apache/lucene/store/MemorySegmentIndexInput.java index 2fc9f6369b72..2424b53645bd 100644 --- a/lucene/core/src/java21/org/apache/lucene/store/MemorySegmentIndexInput.java +++ b/lucene/core/src/java21/org/apache/lucene/store/MemorySegmentIndexInput.java @@ -27,6 +27,7 @@ import java.util.Optional; import org.apache.lucene.util.ArrayUtil; import org.apache.lucene.util.BitUtil; +import org.apache.lucene.util.Constants; import org.apache.lucene.util.GroupVIntUtil; import org.apache.lucene.util.IOConsumer; @@ -422,12 +423,20 @@ void advise(long offset, long length, IOConsumer advice) throws I @Override public Optional isLoaded() { + boolean isLoaded = true; for (MemorySegment seg : segments) { if (seg.isLoaded() == false) { - return Optional.of(Boolean.FALSE); + isLoaded = false; + break; } } - return Optional.of(Boolean.TRUE); + + if (Constants.WINDOWS && isLoaded == false) { + // see https://github.com/apache/lucene/issues/14050 + return Optional.empty(); + } + + return Optional.of(isLoaded); } @Override