mirror of https://github.com/apache/lucene.git
Add a sysprop "org.apache.lucene.store.MMapDirectory.enableMemorySegments" (#12062)
This commit is contained in:
parent
19cc6cdf66
commit
2f602c01dd
|
@ -162,7 +162,9 @@ New Features
|
|||
* GITHUB#12033: Support for Java 19 foreign memory support is now enabled by default,
|
||||
no need to pass "--enable-preview" on the command line. If exactly Java 19 is used,
|
||||
MMapDirectory will mmap Lucene indexes in chunks of 16 GiB (instead of 1 GiB) and
|
||||
indexes closed while queries are running can no longer crash the JVM. (Uwe Schindler)
|
||||
indexes closed while queries are running can no longer crash the JVM.
|
||||
To disable this feature, pass the following sysprop on Java command line:
|
||||
"-Dorg.apache.lucene.store.MMapDirectory.enableMemorySegments=false" (Uwe Schindler)
|
||||
|
||||
* GITHUB#11869: RangeOnRangeFacetCounts added, supporting numeric range "relationship" faceting over docvalue-stored
|
||||
ranges. (Marc D'Mello)
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.lang.invoke.MethodType;
|
|||
import java.nio.channels.ClosedChannelException; // javadoc @link
|
||||
import java.nio.file.Path;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.logging.Logger;
|
||||
|
@ -113,6 +114,17 @@ public class MMapDirectory extends FSDirectory {
|
|||
*/
|
||||
public static final long DEFAULT_MAX_CHUNK_SIZE;
|
||||
|
||||
/**
|
||||
* This sysprop allows to control if {@code MemorySegment} API should be used on supported Java
|
||||
* versions. By default it is enabled; set to {@code false} to use legacy {@code ByteBuffer}
|
||||
* implementation. On command line pass {@code
|
||||
* -Dorg.apache.lucene.store.MMapDirectory.enableMemorySegments=false} to disable.
|
||||
*
|
||||
* @lucene.internal
|
||||
*/
|
||||
public static final String ENABLE_MEMORY_SEGMENTS_SYSPROP =
|
||||
"org.apache.lucene.store.MMapDirectory.enableMemorySegments";
|
||||
|
||||
final int chunkSizePower;
|
||||
|
||||
/**
|
||||
|
@ -347,7 +359,22 @@ public class MMapDirectory extends FSDirectory {
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean checkMemorySegmentsSysprop() {
|
||||
try {
|
||||
return Optional.ofNullable(System.getProperty(ENABLE_MEMORY_SEGMENTS_SYSPROP))
|
||||
.map(Boolean::valueOf)
|
||||
.orElse(Boolean.TRUE);
|
||||
} catch (
|
||||
@SuppressWarnings("unused")
|
||||
SecurityException ignored) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static MMapIndexInputProvider lookupProvider() {
|
||||
if (checkMemorySegmentsSysprop() == false) {
|
||||
return new MappedByteBufferIndexInputProvider();
|
||||
}
|
||||
final var lookup = MethodHandles.lookup();
|
||||
final int runtimeVersion = Runtime.version().feature();
|
||||
if (runtimeVersion == 19) {
|
||||
|
|
Loading…
Reference in New Issue