Search code examples
javalucene

Lucene RAMDirectory deprecated - how to keep Directory RAM-only anyway?


I'm currently using the class org.apache.lucene.store.RAMDirectory for a fast RAM-based index without the requirement of hard disk write permissions. RAM size & persistence is not a limiting factor. However, RAMDirectory is marked as deprecated and also seems to be problematic for large indexes according to its API.

So my question is, what is a RAM-only alternative for the deprecated RAMDirectory?

Anything writing on hard disk is out of the question for me (read only) & also seems to be quite a bit slower on my own systems. I was thinking about using FSDDirectory with a RAMDisk but couldn't find a way to create said RAMDisk using java / the jar only (again requires changing the system).


Solution

  • ByteBuffersDirectory is the replacement for RAMDirectory.

    The chart below makes it crystal clear why RAMDiretory was depreciated and then removed. BBDIR is ByteBuffersDirectory and RAMDIR is RAMDirectory.

    enter image description here Chart by Dawid Weiss. Source: LUCENE-8438 and shown under Apache 2.0 License.