From b80feabb97c4ac0548c594b3edb12303b4608c28 Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Wed, 30 Jun 2021 23:43:46 +0200 Subject: [PATCH] Use NIOFSDirectory --- .../cavallium/dbengine/database/disk/LLLocalLuceneIndex.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/it/cavallium/dbengine/database/disk/LLLocalLuceneIndex.java b/src/main/java/it/cavallium/dbengine/database/disk/LLLocalLuceneIndex.java index bb37032..379bea8 100644 --- a/src/main/java/it/cavallium/dbengine/database/disk/LLLocalLuceneIndex.java +++ b/src/main/java/it/cavallium/dbengine/database/disk/LLLocalLuceneIndex.java @@ -67,6 +67,7 @@ import org.apache.lucene.search.similarities.TFIDFSimilarity; import org.apache.lucene.store.ByteBuffersDirectory; import org.apache.lucene.store.Directory; import org.apache.lucene.store.FSDirectory; +import org.apache.lucene.store.FSLockFactory; import org.apache.lucene.store.IOContext; import org.apache.lucene.store.MMapDirectory; import org.apache.lucene.store.NIOFSDirectory; @@ -87,6 +88,8 @@ import reactor.util.function.Tuples; public class LLLocalLuceneIndex implements LLLuceneIndex { + private static final boolean ALLOW_MMAP = false; + protected static final Logger logger = LoggerFactory.getLogger(LLLocalLuceneIndex.class); private static final LuceneStreamSearcher streamSearcher = new AdaptiveStreamSearcher(); private static final AllowOnlyQueryParsingCollectorStreamSearcher allowOnlyQueryParsingCollectorStreamSearcher @@ -147,7 +150,7 @@ public class LLLocalLuceneIndex implements LLLuceneIndex { } else { Directory directory; { - FSDirectory fsDirectory = FSDirectory.open(directoryPath); + FSDirectory fsDirectory = ALLOW_MMAP ? FSDirectory.open(directoryPath) : new NIOFSDirectory(directoryPath); if (Constants.LINUX || Constants.MAC_OS_X) { if (!lowMemory) { directory = new DirectIODirectory(fsDirectory, 5 * 1024 * 1024, 60 * 1024 * 1024);