Interface BlockCache

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
SingleFilePerBlockCache

public interface BlockCache extends Closeable
Provides functionality necessary for caching blocks of data read from FileSystem.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the blocks in this cache.
    boolean
    containsBlock(int blockNumber)
    Indicates whether the given block is in this cache.
    void
    get(int blockNumber, ByteBuffer buffer)
    Gets the block having the given blockNumber.
    void
    put(int blockNumber, ByteBuffer buffer, Configuration conf, LocalDirAllocator localDirAllocator)
    Puts the given block in this cache.
    int
    Gets the number of blocks in this cache.

    Methods inherited from interface java.io.Closeable

    close
  • Method Details

    • containsBlock

      boolean containsBlock(int blockNumber)
      Indicates whether the given block is in this cache.
      Parameters:
      blockNumber - the id of the given block.
      Returns:
      true if the given block is in this cache, false otherwise.
    • blocks

      Iterable<Integer> blocks()
      Gets the blocks in this cache.
      Returns:
      the blocks in this cache.
    • size

      int size()
      Gets the number of blocks in this cache.
      Returns:
      the number of blocks in this cache.
    • get

      void get(int blockNumber, ByteBuffer buffer) throws IOException
      Gets the block having the given blockNumber.
      Parameters:
      blockNumber - the id of the desired block.
      buffer - contents of the desired block are copied to this buffer.
      Throws:
      IOException - if there is an error reading the given block.
    • put

      void put(int blockNumber, ByteBuffer buffer, Configuration conf, LocalDirAllocator localDirAllocator) throws IOException
      Puts the given block in this cache.
      Parameters:
      blockNumber - the id of the given block.
      buffer - contents of the given block to be added to this cache.
      conf - the configuration.
      localDirAllocator - the local dir allocator instance.
      Throws:
      IOException - if there is an error writing the given block.