Top Description Fields Constructors Methods
org.eclipse.jgit.internal.storage.dfs

pack-priv Class PackExtBlockCacheTable

extends Object
implements DfsBlockCacheTable
Class Inheritance
All Implemented Interfaces
org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable
Imports
java.io.IOException, java.text.MessageFormat, java.util.HashMap, .HashSet, .List, .Map, .Set, java.util.stream.Collectors, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.internal.storage.dfs.DfsBlockCache.ReadableChannelSupplier, .DfsBlockCache.Ref, .DfsBlockCache.RefLoader, .DfsBlockCacheConfig.DfsBlockCachePackExtConfig, org.eclipse.jgit.internal.storage.pack.PackExt

A table that holds multiple cache tables accessed by PackExt types.

Allows the separation of entries from different PackExt types to limit churn in cache caused by entries of differing sizes.

Separating these tables enables the fine-tuning of cache tables per extension type.

Field Summary

Modifier and TypeField and Description
private final List<DfsBlockCacheTable>
private final DfsBlockCacheTable
private final Map<PackExt, DfsBlockCacheTable>
private final String
name

Table name.

Constructor Summary

AccessConstructor and Description
private
PackExtBlockCacheTable(String name, DfsBlockCacheTable defaultBlockCacheTable, List<DfsBlockCacheTable> blockCacheTableList, Map<PackExt, DfsBlockCacheTable> extBlockCacheTables)

Method Summary

Modifier and TypeMethod and Description
public boolean
contains(DfsStreamKey
the stream key of the pack.
key
,
long
the position in the key.
position
)

Implements org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.contains.

Check if the block cache contains an object identified by (key, position).

pack-priv static PackExtBlockCacheTable

Returns:

the cache table built from the given configs.
fromBlockCacheConfigs
(DfsBlockCacheConfig
DfsBlockCacheConfig containing DfsBlockCachePackExtConfigs used to configure PackExtBlockCacheTable. The DfsBlockCacheConfig holds the configuration for the default cache table.
cacheConfig
)

Builds the PackExtBlockCacheTable from a list of DfsBlockCachePackExtConfigs.

pack-priv static PackExtBlockCacheTable

Returns:

the PackExtBlockCacheTable created from the defaultBlockCacheTable and packExtsCacheTablePairs mapping.
fromCacheTables
(DfsBlockCacheTable
the default table used when a handling a PackExt type that does not map to a DfsBlockCacheTable mapped by packExtsCacheTablePairs.
defaultBlockCacheTable
,
Map<PackExt, DfsBlockCacheTable>
the mapping of PackExts to DfsBlockCacheTables. A single DfsBlockCacheTable can be defined for multiple PackExts in a many-to-one relationship.
packExtBlockCacheTables
)

Creates a new PackExtBlockCacheTable from the combination of a default DfsBlockCacheTable and a map of PackExts to DfsBlockCacheTables.

public <T> T
get(DfsStreamKey
the stream key of the pack.
key
,
long
the position in the key.
position
)

Implements org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.get.

Get the object identified by (key, position) from the block cache.

public List<DfsBlockCacheTable.BlockCacheStats>
public String
public DfsBlock
getOrLoad(BlockBasedFile
the pack that "contains" the cached object.
file
,
long
offset within pack of the object.
position
,
DfsReader
current thread's reader.
dfsReader
,
DfsBlockCache.ReadableChannelSupplier
supplier for channel to read pack.
fileChannel
)

Implements org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.getOrLoad.

Look up a cached object, creating and loading it if it doesn't exist.

public <T> DfsBlockCache.Ref<T>
getOrLoadRef(DfsStreamKey
the stream key of the pack.
key
,
long
the position in the key. The default should be 0.
position
,
DfsBlockCache.RefLoader<T>
the function to load the reference.
loader
)

Implements org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.getOrLoadRef.

Look up a cached object, creating and loading it if it doesn't exist.

private static PackExt
private DfsBlockCacheTable
getTable(PackExt packExt)

private DfsBlockCacheTable
public boolean
hasBlock0(DfsStreamKey
the file to check.
key
)

Implements org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.hasBlock0.

Quickly check if the cache contains block 0 of the given stream.

public void
put(DfsBlock
the block to put in the cache.
v
)

Implements org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.put.

Put a block in the block cache.

public <T> DfsBlockCache.Ref<T>
put(DfsStreamKey
the stream key of the pack.
key
,
long
the position in the key.
pos
,
long
the size of the object.
size
,
T
the object to put in the block cache.
v
)

Implements org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.put.

Put a block in the block cache.

public <T> DfsBlockCache.Ref<T>
putRef(DfsStreamKey
the stream key of the pack.
key
,
long
the size of the object.
size
,
T
the object to put in the block cache.
v
)

Implements org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.putRef.

Put an object in the block cache.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

blockCacheTableListback to summary
private final List<DfsBlockCacheTable> blockCacheTableList
defaultBlockCacheTableback to summary
private final DfsBlockCacheTable defaultBlockCacheTable
extBlockCacheTablesback to summary
private final Map<PackExt, DfsBlockCacheTable> extBlockCacheTables
nameback to summary
private final String name

Table name.

Constructor Detail

PackExtBlockCacheTableback to summary
private PackExtBlockCacheTable(String name, DfsBlockCacheTable defaultBlockCacheTable, List<DfsBlockCacheTable> blockCacheTableList, Map<PackExt, DfsBlockCacheTable> extBlockCacheTables)

Method Detail

containsback to summary
public boolean contains(DfsStreamKey key, long position)

Implements org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.contains.

Doc from org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.contains.

Check if the block cache contains an object identified by (key, position).

Parameters
key:DfsStreamKey

the stream key of the pack.

position:long

the position in the key.

Returns:boolean

if the block cache contains the object identified by (key, position).

Annotations
@Override
fromBlockCacheConfigsback to summary
pack-priv static PackExtBlockCacheTable fromBlockCacheConfigs(DfsBlockCacheConfig cacheConfig)

Builds the PackExtBlockCacheTable from a list of DfsBlockCachePackExtConfigs.

Parameters
cacheConfig:DfsBlockCacheConfig

DfsBlockCacheConfig containing DfsBlockCachePackExtConfigs used to configure PackExtBlockCacheTable. The DfsBlockCacheConfig holds the configuration for the default cache table.

Returns:PackExtBlockCacheTable

the cache table built from the given configs.

Exceptions
IllegalArgumentException:
when no DfsBlockCachePackExtConfig exists in the DfsBlockCacheConfig.
fromCacheTablesback to summary
pack-priv static PackExtBlockCacheTable fromCacheTables(DfsBlockCacheTable defaultBlockCacheTable, Map<PackExt, DfsBlockCacheTable> packExtBlockCacheTables)

Creates a new PackExtBlockCacheTable from the combination of a default DfsBlockCacheTable and a map of PackExts to DfsBlockCacheTables.

This method allows for the PackExtBlockCacheTable to handle a mapping of PackExts to arbitrarily defined DfsBlockCacheTable implementations. This is especially useful for users wishing to implement custom cache tables.

This is currently made visible for testing.

Parameters
defaultBlockCacheTable:DfsBlockCacheTable

the default table used when a handling a PackExt type that does not map to a DfsBlockCacheTable mapped by packExtsCacheTablePairs.

packExtBlockCacheTables:Map<PackExt, DfsBlockCacheTable>

the mapping of PackExts to DfsBlockCacheTables. A single DfsBlockCacheTable can be defined for multiple PackExts in a many-to-one relationship.

Returns:PackExtBlockCacheTable

the PackExtBlockCacheTable created from the defaultBlockCacheTable and packExtsCacheTablePairs mapping.

Exceptions
IllegalArgumentException:
when a PackExt is defined for multiple DfsBlockCacheTables.
getback to summary
public <T> T get(DfsStreamKey key, long position)

Implements org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.get.

Doc from org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.get.

Get the object identified by (key, position) from the block cache.

Parameters
key:DfsStreamKey

the stream key of the pack.

position:long

the position in the key.

Returns:T

the object identified by (key, position).

Annotations
@Override
getBlockCacheStatsback to summary
public List<DfsBlockCacheTable.BlockCacheStats> getBlockCacheStats()

Implements org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.getBlockCacheStats.

Doc from org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.getBlockCacheStats.

Get the list of BlockCacheStats held by this cache.

The returned list has a BlockCacheStats per configured cache table, with a minimum of 1 BlockCacheStats object returned. Use AggregatedBlockCacheStats to combine the results of the stats in the list for an aggregated view of the cache's stats.

Returns:List<DfsBlockCacheTable.BlockCacheStats>

the list of BlockCacheStats held by this cache.

Annotations
@Override
getNameback to summary
public String getName()

Implements org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.getName.

Doc from org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.getName.

Get the name of the table.

Returns:String

this table's name.

Annotations
@Override
getOrLoadback to summary
public DfsBlock getOrLoad(BlockBasedFile file, long position, DfsReader dfsReader, DfsBlockCache.ReadableChannelSupplier fileChannel) throws IOException

Implements org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.getOrLoad.

Doc from org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.getOrLoad.

Look up a cached object, creating and loading it if it doesn't exist.

Parameters
file:BlockBasedFile

the pack that "contains" the cached object.

position:long

offset within pack of the object.

dfsReader:DfsReader

current thread's reader.

fileChannel:DfsBlockCache.ReadableChannelSupplier

supplier for channel to read pack.

Returns:DfsBlock

the object reference.

Annotations
@Override
Exceptions
IOException:
the reference was not in the cache and could not be loaded.
getOrLoadRefback to summary
public <T> DfsBlockCache.Ref<T> getOrLoadRef(DfsStreamKey key, long position, DfsBlockCache.RefLoader<T> loader) throws IOException

Implements org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.getOrLoadRef.

Doc from org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.getOrLoadRef.

Look up a cached object, creating and loading it if it doesn't exist.

Parameters
key:DfsStreamKey

the stream key of the pack.

position:long

the position in the key. The default should be 0.

loader:DfsBlockCache.RefLoader<T>

the function to load the reference.

Returns:DfsBlockCache.Ref<T>

the object reference.

Annotations
@Override
Exceptions
IOException:
the reference was not in the cache and could not be loaded.
getPackExtback to summary
private static PackExt getPackExt(DfsStreamKey key)
getTableback to summary
private DfsBlockCacheTable getTable(PackExt packExt)
getTableback to summary
private DfsBlockCacheTable getTable(DfsStreamKey key)
hasBlock0back to summary
public boolean hasBlock0(DfsStreamKey key)

Implements org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.hasBlock0.

Doc from org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.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:DfsStreamKey

the file to check.

Returns:boolean

true if block 0 (the first block) is in the cache.

Annotations
@Override
putback to summary
public void put(DfsBlock v)

Implements org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.put.

Doc from org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.put.

Put a block in the block cache.

Parameters
v:DfsBlock

the block to put in the cache.

Annotations
@Override
putback to summary
public <T> DfsBlockCache.Ref<T> put(DfsStreamKey key, long pos, long size, T v)

Implements org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.put.

Doc from org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.put.

Put a block in the block cache.

Parameters
key:DfsStreamKey

the stream key of the pack.

pos:long

the position in the key.

size:long

the size of the object.

v:T

the object to put in the block cache.

Returns:DfsBlockCache.Ref<T>

the object reference.

Annotations
@Override
putRefback to summary
public <T> DfsBlockCache.Ref<T> putRef(DfsStreamKey key, long size, T v)

Implements org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.putRef.

Doc from org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.putRef.

Put an object in the block cache.

Parameters
key:DfsStreamKey

the stream key of the pack.

size:long

the size of the object.

v:T

the object to put in the block cache.

Returns:DfsBlockCache.Ref<T>

the object reference.

Annotations
@Override