Apache Lucene open-source search software
LUCENE-8467: RAMDirectory, RAMFile, RAMInputStream, RAMOutputStream are deprecated.
Dawid Weissa452dd9ce305
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 3a062af560e..2dec765355b 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -147,6 +147,9 @@ OptimizationsAPI Changes:+* LUCENE-8467: RAMDirectory, RAMFile, RAMInputStream, RAMOutputStream are deprecated+ (Dawid Weiss)+* LUCENE-8356: StandardFilter is deprecated (Alan Woodward)* LUCENE-8373: ENGLISH_STOP_WORD_SET on StandardAnalyzer is deprecated. Insteaddiff --git a/lucene/MIGRATE.txt b/lucene/MIGRATE.txtindex 7dfe5c7e306..01e0baa3bc7 100644--- a/lucene/MIGRATE.txt+++ b/lucene/MIGRATE.txt@@ -99,3 +99,10 @@ IndexSearcher's search and searchAfter methods were changed to only count hitsaccurately up to 1,000, and Topdocs.totalHits was changed from a long to anobject that says whether the hit count is accurate or a lower bound of theactual hit count.++## RAMDirectory, RAMFile, RAMInputStream, RAMOutputStream are deprecated ##++This RAM-based directory implementation is an old piece of code that uses inefficient+thread synchronization primitives and can be confused as "faster" than the NIO-based+MMapDirectory. It is deprecated and scheduled for removal in future versions of+Lucene. (LUCENE-8467, LUCENE-8438)diff --git a/lucene/core/src/java/org/apache/lucene/store/RAMDirectory.java b/lucene/core/src/java/org/apache/lucene/store/RAMDirectory.javaindex 3c2bed28941..8d2dcf34dc1 100644--- a/lucene/core/src/java/org/apache/lucene/store/RAMDirectory.java+++ b/lucene/core/src/java/org/apache/lucene/store/RAMDirectory.java@@ -49,7 +49,12 @@ import org.apache.lucene.util.Accountables;* {@link MMapDirectory}, which is a high-performance directory* implementation working directly on the file system cache of the* operating system, so copying data to Java heap space is not useful.+ *+ * @deprecated This class uses inefficient synchronization and is discouraged+ * in favor of {@link MMapDirectory}. It will be removed in future versions+ * of Lucene.*/+@Deprecatedpublic class RAMDirectory extends BaseDirectory implements Accountable {protected final Map<String,RAMFile> fileMap = new ConcurrentHashMap<>();protected final AtomicLong sizeInBytes = new AtomicLong();diff --git a/lucene/core/src/java/org/apache/lucene/store/RAMFile.java b/lucene/core/src/java/org/apache/lucene/store/RAMFile.javaindex d8ae693519d..d4fd014e0a9 100644--- a/lucene/core/src/java/org/apache/lucene/store/RAMFile.java+++ b/lucene/core/src/java/org/apache/lucene/store/RAMFile.java@@ -24,7 +24,13 @@ import org.apache.lucene.util.Accountable;/*** Represents a file in RAM as a list of byte[] buffers.- * @lucene.internal */+ *+ * @lucene.internal+ * @deprecated This class uses inefficient synchronization and is discouraged+ * in favor of {@link MMapDirectory}. It will be removed in future versions+ * of Lucene.+ */+@Deprecatedpublic class RAMFile implements Accountable {protected final ArrayList<byte[]> buffers = new ArrayList<>();long length;diff --git a/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java b/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.javaindex 7c8c7a35643..cb07b6e42ca 100644--- a/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java+++ b/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java@@ -22,9 +22,15 @@ import java.io.IOException;import static org.apache.lucene.store.RAMOutputStream.BUFFER_SIZE;-/** A memory-resident {@link IndexInput} implementation.- *- * @lucene.internal */+/**+ * A memory-resident {@link IndexInput} implementation.+ *+ * @lucene.internal+ * @deprecated This class uses inefficient synchronization and is discouraged+ * in favor of {@link MMapDirectory}. It will be removed in future versions+ * of Lucene.+ */+@Deprecatedpublic class RAMInputStream extends IndexInput implements Cloneable {private final RAMFile file;diff --git a/lucene/core/src/java/org/apache/lucene/store/RAMOutputStream.java b/lucene/core/src/java/org/apache/lucene/store/RAMOutputStream.javaindex 3477fe449cd..02dc8439693 100644--- a/lucene/core/src/java/org/apache/lucene/store/RAMOutputStream.java+++ b/lucene/core/src/java/org/apache/lucene/store/RAMOutputStream.java@@ -30,7 +30,11 @@ import org.apache.lucene.util.Accountables;* A memory-resident {@link IndexOutput} implementation.** @lucene.internal+ * @deprecated This class uses inefficient synchronization and is discouraged+ * in favor of {@link MMapDirectory}. It will be removed in future versions+ * of Lucene.*/+@Deprecatedpublic class RAMOutputStream extends IndexOutput implements Accountable {static final int BUFFER_SIZE = 1024;