public interface DfsBlockCacheTable
Block cache table.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceProvides methods used with Block Cache statistics. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(DfsStreamKey key, long position) Check if the block cache contains an object identified by (key, position).<T> Tget(DfsStreamKey key, long position) Get the object identified by (key, position) from the block cache.Get the list ofDfsBlockCacheTable.BlockCacheStatsheld by this cache.getName()Get the name of the table.org.eclipse.jgit.internal.storage.dfs.DfsBlockgetOrLoad(org.eclipse.jgit.internal.storage.dfs.BlockBasedFile file, long position, DfsReader dfsReader, org.eclipse.jgit.internal.storage.dfs.DfsBlockCache.ReadableChannelSupplier fileChannel) Look up a cached object, creating and loading it if it doesn't exist.<T> org.eclipse.jgit.internal.storage.dfs.DfsBlockCache.Ref<T>getOrLoadRef(DfsStreamKey key, long position, org.eclipse.jgit.internal.storage.dfs.DfsBlockCache.RefLoader<T> loader) Look up a cached object, creating and loading it if it doesn't exist.booleanhasBlock0(DfsStreamKey key) Quickly check if the cache contains block 0 of the given stream.voidput(org.eclipse.jgit.internal.storage.dfs.DfsBlock v) Put a block in the block cache.<T> org.eclipse.jgit.internal.storage.dfs.DfsBlockCache.Ref<T>put(DfsStreamKey key, long pos, long size, T v) Put a block in the block cache.<T> org.eclipse.jgit.internal.storage.dfs.DfsBlockCache.Ref<T>putRef(DfsStreamKey key, long size, T v) Put an object in the block cache.
-
Method Details
-
hasBlock0
Quickly check if the cache contains block 0 of the given stream.This can be useful for sophisticated pre-read algorithms to quickly determine if a file is likely already in cache, especially small reftables which may be smaller than a typical DFS block size.
- Parameters:
key- the file to check.- Returns:
- true if block 0 (the first block) is in the cache.
-
getOrLoad
org.eclipse.jgit.internal.storage.dfs.DfsBlock getOrLoad(org.eclipse.jgit.internal.storage.dfs.BlockBasedFile file, long position, DfsReader dfsReader, org.eclipse.jgit.internal.storage.dfs.DfsBlockCache.ReadableChannelSupplier fileChannel) throws IOException Look up a cached object, creating and loading it if it doesn't exist.- Parameters:
file- the pack that "contains" the cached object.position- offset withinpackof the object.dfsReader- current thread's reader.fileChannel- supplier for channel to readpack.- Returns:
- the object reference.
- Throws:
IOException- the reference was not in the cache and could not be loaded.
-
getOrLoadRef
<T> org.eclipse.jgit.internal.storage.dfs.DfsBlockCache.Ref<T> getOrLoadRef(DfsStreamKey key, long position, org.eclipse.jgit.internal.storage.dfs.DfsBlockCache.RefLoader<T> loader) throws IOException Look up a cached object, creating and loading it if it doesn't exist.- Parameters:
key- the stream key of the pack.position- the position in the key. The default should be 0.loader- the function to load the reference.- Returns:
- the object reference.
- Throws:
IOException- the reference was not in the cache and could not be loaded.
-
put
void put(org.eclipse.jgit.internal.storage.dfs.DfsBlock v) Put a block in the block cache.- Parameters:
v- the block to put in the cache.
-
put
<T> org.eclipse.jgit.internal.storage.dfs.DfsBlockCache.Ref<T> put(DfsStreamKey key, long pos, long size, T v) Put a block in the block cache.- Parameters:
key- the stream key of the pack.pos- the position in the key.size- the size of the object.v- the object to put in the block cache.- Returns:
- the object reference.
-
putRef
<T> org.eclipse.jgit.internal.storage.dfs.DfsBlockCache.Ref<T> putRef(DfsStreamKey key, long size, T v) Put an object in the block cache.- Parameters:
key- the stream key of the pack.size- the size of the object.v- the object to put in the block cache.- Returns:
- the object reference.
-
contains
Check if the block cache contains an object identified by (key, position).- Parameters:
key- the stream key of the pack.position- the position in the key.- Returns:
- if the block cache contains the object identified by (key, position).
-
get
Get the object identified by (key, position) from the block cache.- Parameters:
key- the stream key of the pack.position- the position in the key.- Returns:
- the object identified by (key, position).
-
getBlockCacheStats
List<DfsBlockCacheTable.BlockCacheStats> getBlockCacheStats()Get the list ofDfsBlockCacheTable.BlockCacheStatsheld by this cache.The returned list has a
DfsBlockCacheTable.BlockCacheStatsper configured cache table, with a minimum of 1DfsBlockCacheTable.BlockCacheStatsobject returned. UseAggregatedBlockCacheStatsto combine the results of the stats in the list for an aggregated view of the cache's stats.- Returns:
- the list of
DfsBlockCacheTable.BlockCacheStatsheld by this cache.
-
getName
String getName()Get the name of the table.- Returns:
- this table's name.
-