Interface BlockCache
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
SingleFilePerBlockCache
Provides functionality necessary for caching blocks of data read from FileSystem.
-
Method Summary
Modifier and TypeMethodDescriptionblocks()Gets the blocks in this cache.booleancontainsBlock(int blockNumber) Indicates whether the given block is in this cache.voidget(int blockNumber, ByteBuffer buffer) Gets the block having the givenblockNumber.voidput(int blockNumber, ByteBuffer buffer, Configuration conf, LocalDirAllocator localDirAllocator) Puts the given block in this cache.intsize()Gets the number of blocks in this cache.
-
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
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
Gets the block having the givenblockNumber.- 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.
-