public class Cache extends Object
append(ini.trakem2.persistence.Cache.Pyramid)
,
but in the current setup this overhead is just not necessary.
This Cache self-regulates the size to stay always at or below max_bytes.
If the smallest image added is larger than max_bytes, then that image will be the only
one in the cache, and will be thrown out when adding a new image.
That is, the max_bytes is an indication for a desired maximum. The usual is that
the cache will stay below max_bytes, unless when a single image is larger than max_bytes.
Also, momentarily when adding an image, max_bytes may be overflown by maximum the
size of the newly added image. Take that into account when choosing a value for max_bytes.
When an image is removed, either directly or out of house-keeping to stay under max_bytes,
that image is flushed. ImagePlus instances are not flushed, but if they point to an Image,
then that image is flushed.Constructor and Description |
---|
Cache(long max_bytes) |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(long id) |
boolean |
contains(long id,
int level) |
void |
debug() |
long |
ensureFree(long min_free_bytes)
Remove and flush the minimal amount of images to ensure there are at least min_free_bytes free.
|
ij.ImagePlus |
get(long id) |
Image |
get(long id,
int level) |
ij.ImagePlus |
get(String path) |
Map<Integer,Image> |
getAll(long id) |
long |
getBytes()
Current estimated space occupied by the images in this cache.
|
MipMapImage |
getClosestAbove(long id,
int level) |
MipMapImage |
getClosestBelow(long id,
int level) |
long |
getMaxBytes()
Maximum desired space for this cache.
|
static String |
getPath(ij.ImagePlus imp)
Returns null if the ImagePlus was preprocessed or doesn't have an original FileInfo
(which means the image does not come from a file).
|
void |
put(long id,
Image image,
int level) |
void |
put(long id,
ij.ImagePlus imp,
int maxdim) |
void |
remove(long id) |
Image |
remove(long id,
int level)
Remove one mipmap level, if there.
|
void |
removeAndFlushAll()
Flush all mipmaps, and forget all mipmaps and imps.
|
void |
removeAndFlushPyramid(long id)
Does not alter the ImagePlus.
|
long |
removeAndFlushSome(int n) |
long |
removeAndFlushSome(long min_bytes)
Returns the number of released bytes.
|
ij.ImagePlus |
removeImagePlus(long id)
Remove only the ImagePlus, if there.
|
long |
seqFindId(ij.ImagePlus imp) |
void |
setMaxBytes(long max_bytes) |
int |
size() |
void |
updateImagePlusPath(String oldPath,
String newPath) |
public void setMaxBytes(long max_bytes)
public final long ensureFree(long min_free_bytes)
public long getMaxBytes()
public long getBytes()
public final boolean contains(long id)
public final boolean contains(long id, int level)
public final Image get(long id, int level)
public final ij.ImagePlus get(String path)
public final ij.ImagePlus get(long id)
public final MipMapImage getClosestAbove(long id, int level)
public final MipMapImage getClosestBelow(long id, int level)
public final void put(long id, Image image, int level)
public static final String getPath(ij.ImagePlus imp)
public final void put(long id, ij.ImagePlus imp, int maxdim)
maxdim
- is max(width, height) of the Patch wrapping @param imp;
that is, the dimensions of the mipmap image.public final Image remove(long id, int level)
public final ij.ImagePlus removeImagePlus(long id)
public final void remove(long id)
public final void removeAndFlushAll()
public final void removeAndFlushPyramid(long id)
public final long removeAndFlushSome(long min_bytes)
public final long removeAndFlushSome(int n)
public final int size()
public void debug()
public final long seqFindId(ij.ImagePlus imp)
Copyright © 2015–2021 Fiji. All rights reserved.