Skip to content

Commit

Permalink
IndexInput.isLoaded seems to return false for mmap index inputs on Wi…
Browse files Browse the repository at this point in the history
…ndows apache#14050
  • Loading branch information
dweiss committed Dec 10, 2024
1 parent 44556cf commit 1754ae3
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

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

@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
Expand Down

0 comments on commit 1754ae3

Please sign in to comment.