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.
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 theDiskCachedCellImgFactory
andDiskCachedCellImgOptions
to allow for better extensibility and reuse. Their external interface remains (nearly) unchanged.The two main (internal) changes are:
AbstractReadWriteCachedCellImgFactory
andAbstractReadWriteCachedCellImgOptions
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.DiskCachedCellImgOptions extends AbstractReadWriteCachedCellImgOptions extends ReadOnlyCachedCellImgOptions
API change:
DiskCachedCellImgOptions.values
is now private, use the new methodvalues()
instead to get access to the values.CacheType
has moved fromDiskCachedCellImgOptions
toReadOnlyCachedCellImgOptions
because that is its first usage in the inheritance hierarchy.Notes:
imglib2-cache-examples
to verify that the caches still work as expected.n5-imglib
provides aN5CellLoader
that we reuse instead of reimplementing it, butn5-imglib
at the same time depends onimglib2-cache
. To prevent cyclic dependencies, I have put theN5CachedCellImg
into its own maven project.IoSync
instance across multiple caches. I did not add an interface for this yet.Flushable
version of theGuardedStrongRefLoaderRemoverCache
to be able to trigger writing of all in-memory cache blocks to disk. This is not handled in this PR orimglib2-cache-n5
yet.