rmuir commented on code in PR #13381: URL: https://github.com/apache/lucene/pull/13381#discussion_r1605799608
########## lucene/core/src/java21/org/apache/lucene/store/PosixNativeAccess.java: ########## @@ -165,6 +181,44 @@ private Integer mapReadAdvice(ReadAdvice readAdvice) { }; } + @Override + public boolean mincore(MemorySegment segment) throws IOException { + final long numPages = (segment.byteSize() + getPageSize() - 1) / getPageSize(); + try (Arena arena = Arena.ofConfined()) { + MemorySegment vec = arena.allocate(numPages); + mincore(segment, vec); + for (long i = 0; i < numPages; ++i) { + byte b = vec.get(ValueLayout.JAVA_BYTE, i); + if (b == 0) { + return false; + } + } + return true; + } + } Review Comment: this can be replaced with `MemorySegment.isLoaded()` which does the exact same thing in the openJDK via C code? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org