LUCENE-8467: RAMDirectory, RAMFile, RAMInputStream, RAMOutputStream are deprecated.

This commit is contained in:
Dawid Weiss 2018-08-28 08:49:17 +02:00
parent 04a50b6a2e
commit a452dd9ce3
6 changed files with 35 additions and 4 deletions

View File

@ -147,6 +147,9 @@ Optimizations
API 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. Instead

View File

@ -99,3 +99,10 @@ IndexSearcher's search and searchAfter methods were changed to only count hits
accurately up to 1,000, and Topdocs.totalHits was changed from a long to an
object that says whether the hit count is accurate or a lower bound of the
actual 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)

View File

@ -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.
*/
@Deprecated
public class RAMDirectory extends BaseDirectory implements Accountable {
protected final Map<String,RAMFile> fileMap = new ConcurrentHashMap<>();
protected final AtomicLong sizeInBytes = new AtomicLong();

View File

@ -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.
*/
@Deprecated
public class RAMFile implements Accountable {
protected final ArrayList<byte[]> buffers = new ArrayList<>();
long length;

View File

@ -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.
*/
@Deprecated
public class RAMInputStream extends IndexInput implements Cloneable {
private final RAMFile file;

View File

@ -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.
*/
@Deprecated
public class RAMOutputStream extends IndexOutput implements Accountable {
static final int BUFFER_SIZE = 1024;