Search code examples
jakarta-eesolrlucenesearch-enginelucene.net

readerkey vs reader(solr 1.3) in FieldcacheImpl


It would great if some one letme know the difference between the reader(used in solr 1.3) vs the readerKey in solr 3.5, in FieldcacheImpl?

Thanks Jeyaprakash


Solution

  • In Lucene 2.4 (used by Solr 1.3), the fieldcache internally maintains a map (reader -> cache) meaning that two different readers will have two different cache instances.

    This works, but when an index reader is a view over an other index reader, these two instances could safely share the same fieldcache instance and save a lot of memory. This is why, in Lucene 3.5 (used by Solr 3.5), IndexReader now has a method to retrieve the cache key (getCoreCacheKey). By default, it returns this, leading to the same behavior as with Lucene 2.4, but some implementations override this method to share the field cache instances with other IndexReader instances. For example, it is safe to share the cache between a FilterIndexReader and the wrapped IndexReader. This is why FilterIndexReader#getCoreCacheKey returns the cache key of the wrapped IndexReader.