Skip to content

Commit 76f5254

Browse files
authored
IndexInput.isLoaded seems to return false for mmap index inputs on Windows apache#14050 (apache#14053)
1 parent a62e716 commit 76f5254

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

Diff for: lucene/core/src/java21/org/apache/lucene/store/MemorySegmentIndexInput.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.Optional;
2828
import org.apache.lucene.util.ArrayUtil;
2929
import org.apache.lucene.util.BitUtil;
30+
import org.apache.lucene.util.Constants;
3031
import org.apache.lucene.util.GroupVIntUtil;
3132
import org.apache.lucene.util.IOConsumer;
3233

@@ -422,12 +423,20 @@ void advise(long offset, long length, IOConsumer<MemorySegment> advice) throws I
422423

423424
@Override
424425
public Optional<Boolean> isLoaded() {
426+
boolean isLoaded = true;
425427
for (MemorySegment seg : segments) {
426428
if (seg.isLoaded() == false) {
427-
return Optional.of(Boolean.FALSE);
429+
isLoaded = false;
430+
break;
428431
}
429432
}
430-
return Optional.of(Boolean.TRUE);
433+
434+
if (Constants.WINDOWS && isLoaded == false) {
435+
// see https://github.com/apache/lucene/issues/14050
436+
return Optional.empty();
437+
}
438+
439+
return Optional.of(isLoaded);
431440
}
432441

433442
@Override

Diff for: lucene/test-framework/src/java/org/apache/lucene/tests/store/BaseDirectoryTestCase.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import org.apache.lucene.tests.util.TestUtil;
6464
import org.apache.lucene.util.ArrayUtil;
6565
import org.apache.lucene.util.BitUtil;
66+
import org.apache.lucene.util.Constants;
6667
import org.apache.lucene.util.GroupVIntUtil;
6768
import org.apache.lucene.util.IOUtils;
6869
import org.apache.lucene.util.packed.PackedInts;
@@ -1667,7 +1668,10 @@ private void testIsLoaded(int startOffset) throws IOException {
16671668
in = orig.slice("slice", startOffset, totalLength - startOffset);
16681669
}
16691670
var loaded = in.isLoaded();
1670-
if (FilterDirectory.unwrap(dir) instanceof MMapDirectory
1671+
1672+
if (Constants.WINDOWS) {
1673+
// On Windows, we temporarily don't care until this is fixed: #14050
1674+
} else if (FilterDirectory.unwrap(dir) instanceof MMapDirectory
16711675
// direct IO wraps MMap but does not support isLoaded
16721676
&& !(dir.getClass().getName().contains("DirectIO"))) {
16731677
assertTrue(loaded.isPresent());

0 commit comments

Comments
 (0)