I tried to analyse the FieldCacheImpl in Solr 3.5.0, can any one explain me or give me pointer to know what does the abstract Class Cache is performing upfront?
Thanks and Regards,
Jeyaprakash.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As you can see in
FieldCache.java, there are several different methods to load the fieldcache (getBytes, getInts, getStringIndex, getStrings, …). This is whyFieldCacheImplmaintains amap (type -> cache).Lucene segments are write-once and then read-only, so you want to load the field cache only once, and then always re-use the same instance. Cache is a helper class that helps achieve this: it is a wrapper around a
map (segment -> map (field -> fieldcache instance)). (By fieldcache instance, I mean abyte[]for thegetBytesmethod, aString[]for thegetStringsmethod, …)When a segment is not used anymore (if there is no more open reader using it), you want the GC to be able to reclaim the fieldcache, which is why this map is a WeakHashMap.
There are different
Cacheimplementations because the logic is not the same when loading (for example) a String cache and a StringIndex cache (seeCache#createValue(AtomicReader, Entry, boolean)).