Replace ConcurrentLRUCache and Cache interface with Caffeine#4516
Open
dsmiley wants to merge 4 commits into
Open
Replace ConcurrentLRUCache and Cache interface with Caffeine#4516dsmiley wants to merge 4 commits into
dsmiley wants to merge 4 commits into
Conversation
This change removes the custom ConcurrentLRUCache implementation and replaces its usages in IndexSchema and TemplateUpdateProcessorFactory with Caffeine's Cache. Additionally: - The org.apache.solr.common.util.Cache interface and MapBackedCache have been removed. - JavaBinCodec.StringCache has been refactored into an abstract class to allow implementers to provide their own caching mechanism without introducing a Caffeine dependency to solr-solrj. - ObjectCache has been updated to use ConcurrentHashMap directly instead of implementing the removed Cache interface. - Tests have been updated to use simple Map-based caches where appropriate. Co-authored-by: dsmiley <377295+dsmiley@users.noreply.github.com>
This change removes the custom ConcurrentLRUCache implementation and replaces its usages in IndexSchema and TemplateUpdateProcessorFactory with Caffeine's Cache. Additionally: - The org.apache.solr.common.util.Cache interface and MapBackedCache have been removed. - JavaBinCodec.StringCache has been refactored into an abstract class to allow implementers to provide their own caching mechanism without introducing a Caffeine dependency to solr-solrj. - ObjectCache has been updated to use ConcurrentHashMap directly instead of implementing the removed Cache interface. - Tests have been updated to use simple Map-based caches where appropriate. - Fixed compilation and spotless check issues from previous attempts. Co-authored-by: dsmiley <377295+dsmiley@users.noreply.github.com>
- IndexSchema: Added initialCapacity(100) to Caffeine builder to match original ConcurrentLRUCache configuration. - ObjectCache: Simplified type-safe computeIfAbsent to call the generic one and cast. - Elaborated on mapping between ConcurrentLRUCache watermarks and Caffeine maximumSize in PR comments. Co-authored-by: dsmiley <377295+dsmiley@users.noreply.github.com>
- Match original initial sizes in Caffeine builders. - Add @lucene.internal to StringCache. - Refactor ObjectCache to be more efficient. - Ensure all CI issues (compilation, spotless) are resolved. Co-authored-by: dsmiley <377295+dsmiley@users.noreply.github.com>
Contributor
Author
|
Changelog or not is debatable. This is an internal change intended to reduce Solr project maintenance by removing things we don't need. I don't imagine a user will be impacted. Even though JavaBinCodec.StringCache is technically public... it's very internal. And users shouldn't assume that all utilities in SolrJ are also for their use as well. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have replaced the custom
ConcurrentLRUCacheimplementation and theorg.apache.solr.common.util.Cacheinterface with Caffeine'sCacheinsolr-core.Key changes:
solr-solrj:JavaBinCodec.StringCacheinto an abstract class withgetFromCacheandputIntoCachemethods. This keepssolrjindependent of Caffeine.ObjectCacheto useConcurrentHashMapdirectly and fixed itscomputeIfAbsentmethods to ensure compatibility with existing call-sites (likeIndexSchemaFactory).org.apache.solr.common.util.CacheandMapBackedCache.solr-core:ConcurrentLRUCachewith Caffeine'sCacheinIndexSchemaandTemplateUpdateProcessorFactory.org.apache.solr.util.ConcurrentLRUCache.TestJavaBinCodecto use aHashMap-based implementation of the now-abstractStringCache.I verified the changes by ensuring both
solrjandcoremodules compile and by running relevant tests includingTestJavaBinCodec,IndexSchemaTest,TemplateUpdateProcessorTest,ObjectCacheTest, andTestJavaBinResponseWriter.PR created automatically by Jules for task 10202347838202579826 started by @dsmiley
Fork PR: dsmiley#28