Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BigDataViewer_Core_Extension
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BioinformaticDataCompression
BigDataViewer_Core_Extension
Commits
0edd903f
Commit
0edd903f
authored
8 years ago
by
Tobias Pietzsch
Browse files
Options
Downloads
Patches
Plain Diff
Use revised caches
VolatileGlobalCellCache now builds on a WeakRefVolatileCache backed by a SoftRefCache.
parent
20b95000
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/bdv/img/cache/VolatileGlobalCellCache.java
+42
-21
42 additions, 21 deletions
src/main/java/bdv/img/cache/VolatileGlobalCellCache.java
with
42 additions
and
21 deletions
src/main/java/bdv/img/cache/VolatileGlobalCellCache.java
+
42
−
21
View file @
0edd903f
...
@@ -29,15 +29,20 @@
...
@@ -29,15 +29,20 @@
*/
*/
package
bdv.img.cache
;
package
bdv.img.cache
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.ExecutionException
;
import
bdv.cache.CacheControl
;
import
bdv.cache.CacheControl
;
import
bdv.cache.CacheHints
;
import
bdv.cache.CacheHints
;
import
bdv.cache.LoadingVolatileCache
;
import
bdv.cache.revised.Cache
;
import
bdv.cache.VolatileCacheValueLoader
;
import
bdv.cache.revised.SoftRefCache
;
import
bdv.cache.WeakSoftCache
;
import
bdv.cache.revised.VolatileCache
;
import
bdv.cache.revised.VolatileLoader
;
import
bdv.cache.revised.WeakRefVolatileCache
;
import
bdv.cache.util.BlockingFetchQueues
;
import
bdv.cache.util.BlockingFetchQueues
;
import
bdv.cache.util.FetcherThreads
;
import
bdv.img.cache.VolatileImgCells.CellCache
;
import
bdv.img.cache.VolatileImgCells.CellCache
;
import
net.imglib2.img.basictypeaccess.volatiles.VolatileAccess
;
import
net.imglib2.img.basictypeaccess.volatiles.VolatileAccess
;
import
net.imglib2.img.cell.CellImg
;
public
class
VolatileGlobalCellCache
implements
CacheControl
public
class
VolatileGlobalCellCache
implements
CacheControl
{
{
...
@@ -103,13 +108,13 @@ public class VolatileGlobalCellCache implements CacheControl
...
@@ -103,13 +108,13 @@ public class VolatileGlobalCellCache implements CacheControl
}
}
}
}
private
final
WeakSoftCacheFactory
cacheFactory
=
new
WeakSoftCacheFactory
();
private
final
BlockingFetchQueues
<
Callable
<
?
>
>
queue
;
private
final
BlockingFetchQueues
<
Loader
>
queue
;
private
final
FetcherThreads
fetchers
;
private
final
FetcherThreads
fetchers
;
protected
final
LoadingVolatileCache
<
Key
,
VolatileCell
<
?
>
>
volatileCache
;
// TODO rename
protected
final
Cache
<
Key
,
VolatileCell
<
?
>
>
backingCache
;
protected
final
VolatileCache
<
Key
,
VolatileCell
<
?
>
>
volatileCache
;
// TODO rename
/**
/**
* @param maxNumLevels
* @param maxNumLevels
...
@@ -120,7 +125,8 @@ public class VolatileGlobalCellCache implements CacheControl
...
@@ -120,7 +125,8 @@ public class VolatileGlobalCellCache implements CacheControl
{
{
queue
=
new
BlockingFetchQueues
<>(
maxNumLevels
);
queue
=
new
BlockingFetchQueues
<>(
maxNumLevels
);
fetchers
=
new
FetcherThreads
(
queue
,
numFetcherThreads
);
fetchers
=
new
FetcherThreads
(
queue
,
numFetcherThreads
);
volatileCache
=
new
LoadingVolatileCache
<>(
cacheFactory
,
queue
);
backingCache
=
new
SoftRefCache
<>();
volatileCache
=
new
WeakRefVolatileCache
<>(
backingCache
,
queue
);
}
}
/**
/**
...
@@ -147,7 +153,6 @@ public class VolatileGlobalCellCache implements CacheControl
...
@@ -147,7 +153,6 @@ public class VolatileGlobalCellCache implements CacheControl
public
void
prepareNextFrame
()
public
void
prepareNextFrame
()
{
{
queue
.
clearToPrefetch
();
queue
.
clearToPrefetch
();
cacheFactory
.
cleanUp
();
}
}
/**
/**
...
@@ -157,6 +162,7 @@ public class VolatileGlobalCellCache implements CacheControl
...
@@ -157,6 +162,7 @@ public class VolatileGlobalCellCache implements CacheControl
public
void
clearCache
()
public
void
clearCache
()
{
{
volatileCache
.
invalidateAll
();
volatileCache
.
invalidateAll
();
backingCache
.
invalidateAll
();
queue
.
clear
();
queue
.
clear
();
}
}
...
@@ -169,15 +175,16 @@ public class VolatileGlobalCellCache implements CacheControl
...
@@ -169,15 +175,16 @@ public class VolatileGlobalCellCache implements CacheControl
*
*
* @return the cache that handles cell loading
* @return the cache that handles cell loading
*/
*/
public
LoadingVolatileCache
<
Key
,
VolatileCell
<
?
>
>
getLoadingVolatileCache
()
// TODO
{
// public LoadingVolatileCache< Key, VolatileCell< ? > > getLoadingVolatileCache()
return
volatileCache
;
// {
}
// return volatileCache;
// }
/**
/**
* A {@link VolatileCacheValueLoader} for one specific {@link VolatileCell}.
* A {@link VolatileCacheValueLoader} for one specific {@link VolatileCell}.
*/
*/
public
static
class
VolatileCellLoader
<
A
extends
VolatileAccess
>
implements
Volatile
CacheValue
Loader
<
VolatileCell
<
A
>
>
public
static
class
VolatileCellLoader
<
A
extends
VolatileAccess
>
implements
VolatileLoader
<
VolatileCell
<
A
>
>
{
{
private
final
CacheArrayLoader
<
A
>
cacheArrayLoader
;
private
final
CacheArrayLoader
<
A
>
cacheArrayLoader
;
...
@@ -225,15 +232,15 @@ public class VolatileGlobalCellCache implements CacheControl
...
@@ -225,15 +232,15 @@ public class VolatileGlobalCellCache implements CacheControl
}
}
@Override
@Override
public
VolatileCell
<
A
>
c
reateEmptyValue
()
public
VolatileCell
<
A
>
c
all
()
throws
Exception
{
{
return
new
VolatileCell
<>(
cellDims
,
cellMin
,
cacheArrayLoader
.
empty
Array
(
cellDims
)
);
return
new
VolatileCell
<>(
cellDims
,
cellMin
,
cacheArrayLoader
.
load
Array
(
timepoint
,
setup
,
level
,
cellDims
,
cellMin
)
);
}
}
@Override
@Override
public
VolatileCell
<
A
>
load
()
throws
InterruptedException
public
VolatileCell
<
A
>
createInvalid
()
{
{
return
new
VolatileCell
<>(
cellDims
,
cellMin
,
cacheArrayLoader
.
load
Array
(
timepoint
,
setup
,
level
,
cellDims
,
cellMin
)
);
return
new
VolatileCell
<>(
cellDims
,
cellMin
,
cacheArrayLoader
.
empty
Array
(
cellDims
)
);
}
}
}
}
...
@@ -270,7 +277,14 @@ public class VolatileGlobalCellCache implements CacheControl
...
@@ -270,7 +277,14 @@ public class VolatileGlobalCellCache implements CacheControl
public
VolatileCell
<
A
>
get
(
final
long
index
)
public
VolatileCell
<
A
>
get
(
final
long
index
)
{
{
final
Key
key
=
new
Key
(
timepoint
,
setup
,
level
,
index
);
final
Key
key
=
new
Key
(
timepoint
,
setup
,
level
,
index
);
return
(
VolatileCell
<
A
>
)
volatileCache
.
getIfPresent
(
key
,
cacheHints
);
try
{
return
(
VolatileCell
<
A
>
)
volatileCache
.
getIfPresent
(
key
,
cacheHints
);
}
catch
(
final
ExecutionException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
...
@@ -279,7 +293,14 @@ public class VolatileGlobalCellCache implements CacheControl
...
@@ -279,7 +293,14 @@ public class VolatileGlobalCellCache implements CacheControl
{
{
final
Key
key
=
new
Key
(
timepoint
,
setup
,
level
,
index
);
final
Key
key
=
new
Key
(
timepoint
,
setup
,
level
,
index
);
final
VolatileCellLoader
<
A
>
loader
=
new
VolatileCellLoader
<>(
cacheArrayLoader
,
timepoint
,
setup
,
level
,
cellDims
,
cellMin
);
final
VolatileCellLoader
<
A
>
loader
=
new
VolatileCellLoader
<>(
cacheArrayLoader
,
timepoint
,
setup
,
level
,
cellDims
,
cellMin
);
return
(
VolatileCell
<
A
>
)
volatileCache
.
get
(
key
,
cacheHints
,
loader
);
try
{
return
(
VolatileCell
<
A
>
)
volatileCache
.
get
(
key
,
loader
,
cacheHints
);
}
catch
(
final
ExecutionException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
@Override
@Override
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment