Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disk cache refactoring #7

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

chaubold
Copy link

@chaubold chaubold commented Jan 4, 2019

As discussed in Dresden in December 2018, we've been working on a N5 backend for the DiskCachedCellImg. To prepare for that, I have refactored the DiskCachedCellImgFactory and DiskCachedCellImgOptions to allow for better extensibility and reuse. Their external interface remains (nearly) unchanged.

The two main (internal) changes are:

  • I have introduced an AbstractReadWriteCachedCellImgFactory and AbstractReadWriteCachedCellImgOptions that hold the code that can be shared by different read-write-cache implementations. Concrete subclasses must implement abstract methods that encapsulate backend-specific things like CellCache creation.
  • Options (and their Values) now inherit from each other to remove code duplication, as DiskCached options were a strict superset of the ReadOnlyCached options: DiskCachedCellImgOptions extends AbstractReadWriteCachedCellImgOptions extends ReadOnlyCachedCellImgOptions

API change:

  • DiskCachedCellImgOptions.values is now private, use the new method values() instead to get access to the values.
  • CacheType has moved from DiskCachedCellImgOptions to ReadOnlyCachedCellImgOptions because that is its first usage in the inheritance hierarchy.

Notes:

  • As there are no tests in this repository, I have run all examples from imglib2-cache-examples to verify that the caches still work as expected.
  • The N5 backend that makes use of this refactoring is currently located in https://github.com/chaubold/imglib2-cache-n5. The reason is that n5-imglib provides a N5CellLoader that we reuse instead of reimplementing it, but n5-imglib at the same time depends on imglib2-cache. To prevent cyclic dependencies, I have put the N5CachedCellImg into its own maven project.
  • We also talked about maybe sharing an IoSync instance across multiple caches. I did not add an interface for this yet.
  • For KNIME, we actually implemented a Flushable version of the GuardedStrongRefLoaderRemoverCache to be able to trigger writing of all in-memory cache blocks to disk. This is not handled in this PR or imglib2-cache-n5 yet.

@chaubold
Copy link
Author

chaubold commented Jan 4, 2019

@dietzc dietzc requested a review from tpietzsch January 7, 2019 13:33
@chaubold chaubold force-pushed the feature/disk-cache-refactoring branch from 28b1faf to 4679f12 Compare January 17, 2019 08:02
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.

1 participant