IndexInput.isLoaded seems to return false for mmap index inputs on Windows #14050 (#14053)

This commit is contained in:
Dawid Weiss 2024-12-10 19:26:18 +01:00 committed by GitHub
parent a62e716f21
commit 76f5254a75
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 3 deletions

View File

@ -27,6 +27,7 @@ import java.util.Objects;
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 @@ abstract class MemorySegmentIndexInput extends IndexInput
@Override
public Optional<Boolean> 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

View File

@ -63,6 +63,7 @@ import org.apache.lucene.tests.util.LuceneTestCase;
import org.apache.lucene.tests.util.TestUtil;
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.IOUtils;
import org.apache.lucene.util.packed.PackedInts;
@ -1667,7 +1668,10 @@ public abstract class BaseDirectoryTestCase extends LuceneTestCase {
in = orig.slice("slice", startOffset, totalLength - startOffset);
}
var loaded = in.isLoaded();
if (FilterDirectory.unwrap(dir) instanceof MMapDirectory
if (Constants.WINDOWS) {
// On Windows, we temporarily don't care until this is fixed: #14050
} else if (FilterDirectory.unwrap(dir) instanceof MMapDirectory
// direct IO wraps MMap but does not support isLoaded
&& !(dir.getClass().getName().contains("DirectIO"))) {
assertTrue(loaded.isPresent());