Interface DfsBlockCacheTable


public interface DfsBlockCacheTable
Block cache table.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Provides methods used with Block Cache statistics.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(DfsStreamKey key, long position)
    Check if the block cache contains an object identified by (key, position).
    <T> T
    get(DfsStreamKey key, long position)
    Get the object identified by (key, position) from the block cache.
    Get the list of DfsBlockCacheTable.BlockCacheStats held by this cache.
    Get the name of the table.
    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)
    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.
    boolean
    Quickly check if the cache contains block 0 of the given stream.
    void
    put(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

      boolean hasBlock0(DfsStreamKey key)
      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 within pack of the object.
      dfsReader - current thread's reader.
      fileChannel - supplier for channel to read pack.
      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

      boolean contains(DfsStreamKey key, long position)
      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

      <T> T get(DfsStreamKey key, long position)
      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

      Get the list of DfsBlockCacheTable.BlockCacheStats held by this cache.

      The returned list has a DfsBlockCacheTable.BlockCacheStats per configured cache table, with a minimum of 1 DfsBlockCacheTable.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:
      the list of DfsBlockCacheTable.BlockCacheStats held by this cache.
    • getName

      String getName()
      Get the name of the table.
      Returns:
      this table's name.