package

org.apache.lucene.store.instantiated

InstantiatedIndex, alternative RAM store for small corpora.

@lucene.experimental

Abstract

Represented as a coupled graph of class instances, this all-in-memory index store implementation delivers search results up to a 100 times faster than the file-centric RAMDirectory at the cost of greater RAM consumption.

API

Just as the default store implementation, InstantiatedIndex comes with an IndexReader and IndexWriter. The latter share many method signatures with the file-centric IndexWriter.

It is also possible to load the content of another index by passing an IndexReader to the InstantiatedIndex constructor.

Performance

At a few thousand ~160 characters long documents InstantiatedIndex outperforms RAMDirectory some 50x, 15x at 100 documents of 2000 characters length, and is linear to RAMDirectory at 10,000 documents of 2000 characters length.

Mileage may vary depending on term saturation.

benchmark

Populated with a single document InstantiatedIndex is almost, but not quite, as fast as MemoryIndex.

It takes more or less the same time to populate an InstantiatedIndex as it takes to populate a RAMDirectory. Hardly any effort has been put in to optimizing the InstantiatedIndexWriter, only minimizing the amount of time needed to write-lock the index has been considered.

Caveats

  • No locks! Consider using InstantiatedIndex as if it was immutable.
  • No documents with fields containing readers.
  • No field selection when retrieving documents, as all stored field are available in memory.
  • Any document returned must cloned if they are to be touched.
  • Norms array returned must not be touched.

Use cases

Could replace any small index that could do with greater response time. spell check a priori index, the index of new documents exposed to user search agent queries, to compile classifiers in machine learning environments, etc.

Class diagram

class diagram
Diagram rendered using UMLet 7.1.

Classes

InstantiatedDocument A document in the instantiated index object graph, optionally coupled to the vector space view. 
InstantiatedIndex Represented as a coupled graph of class instances, this all-in-memory index store implementation delivers search results up to a 100 times faster than the file-centric RAMDirectory at the cost of greater RAM consumption. 
InstantiatedIndexReader An InstantiatedIndexReader is not a snapshot in time, it is completely in sync with the latest commit to the store!

Consider using InstantiatedIndex as if it was immutable. 

InstantiatedIndexWriter This class, similar to IndexWriter, has no locking mechanism. 
InstantiatedTerm A term in the inverted index, coupled to the documents it occurs in. 
InstantiatedTermDocs A TermDocs navigating an InstantiatedIndexReader
InstantiatedTermDocumentInformation There is one instance of this class per indexed term in a document and it contains the meta data about each occurrence of a term in a document. 
InstantiatedTermEnum A TermEnum navigating an InstantiatedIndexReader
InstantiatedTermFreqVector Vector space view of a document in an InstantiatedIndexReader
InstantiatedTermPositions A TermPositions navigating an InstantiatedIndexReader
InstantiatedTermPositionVector Extended vector space view of a document in an InstantiatedIndexReader