Skip to content

LUCENE-10369: Move DelegatingCacheHelper to FilterDirectoryReader#596

Merged
jpountz merged 12 commits intoapache:mainfrom
grcevski:feature/lasting_readers
Jan 11, 2022
Merged

LUCENE-10369: Move DelegatingCacheHelper to FilterDirectoryReader#596
jpountz merged 12 commits intoapache:mainfrom
grcevski:feature/lasting_readers

Conversation

@grcevski
Copy link
Copy Markdown
Contributor

@grcevski grcevski commented Jan 10, 2022

Description

To support building long-lived readers without IndexReader to delegate caching to, it would be beneficial to refactor SoftDeletesDirectoryReaderWrapper, such that its caching behaviour (DelegatingCacheHelper) is moved into the superclass FilterDirectoryReader.

With this change, external implementations of such readers, e.g. LazySoftDeletesDirectoryReaderWrapper in Elasticsearch could properly modularize their codebase and remove split packages.

Solution

The solution proposed here moves the delegating CacheHelper implementation from SoftDeletesDirectoryReaderWrapper to the superclass, so that it can be used by other subclasses.

An alternative approach could possibly be a new public class specialization of the FilterDirectoryReader class, which brings in the DelegatingCacheHelper and enforces the caching behaviour.

Tests

I added the following unit tests for the moved DelegatingCacheHelper class:

  • Tests that ensure the DelegatingCacheHelper is using unique CacheKey
  • Tests that ensure that, when the onClose listener is invoked on the delegate, the correct CacheKey is used to invalidate the cache.

Checklist

Please review the following and check all that apply:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Lucene maintainers access to contribute to my PR branch. (optional but recommended)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants