Package org.apache.solr.store.blockcache
Class BlockCache
- java.lang.Object
-
- org.apache.solr.store.blockcache.BlockCache
-
public class BlockCache extends Object
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
BlockCache.OnRelease
-
Constructor Summary
Constructors Constructor Description BlockCache(Metrics metrics, boolean directAllocation, long totalMemory)
BlockCache(Metrics metrics, boolean directAllocation, long totalMemory, int slabSize)
BlockCache(Metrics metrics, boolean directAllocation, long totalMemory, int slabSize, int blockSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
fetch(BlockCacheKey blockCacheKey, byte[] buffer)
boolean
fetch(BlockCacheKey blockCacheKey, byte[] buffer, int blockOffset, int off, int length)
int
getSize()
returns the number of elements in the cachevoid
release(BlockCacheKey key)
boolean
store(BlockCacheKey blockCacheKey, int blockOffset, byte[] data, int offset, int length)
This is only best-effort...
-
-
-
Field Detail
-
_128M
public static final int _128M
- See Also:
- Constant Field Values
-
_32K
public static final int _32K
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BlockCache
public BlockCache(Metrics metrics, boolean directAllocation, long totalMemory)
-
BlockCache
public BlockCache(Metrics metrics, boolean directAllocation, long totalMemory, int slabSize)
-
BlockCache
public BlockCache(Metrics metrics, boolean directAllocation, long totalMemory, int slabSize, int blockSize)
-
-
Method Detail
-
release
public void release(BlockCacheKey key)
-
store
public boolean store(BlockCacheKey blockCacheKey, int blockOffset, byte[] data, int offset, int length)
This is only best-effort... it's possible for false to be returned, meaning the block was not able to be cached. NOTE: blocks may not currently be updated (false will be returned if the block is already cached) The blockCacheKey is cloned before it is inserted into the map, so it may be reused by clients if desired.- Parameters:
blockCacheKey
- the key for the blockblockOffset
- the offset within the blockdata
- source data to write to the blockoffset
- offset within the source data arraylength
- the number of bytes to write.- Returns:
- true if the block was cached/updated
-
fetch
public boolean fetch(BlockCacheKey blockCacheKey, byte[] buffer, int blockOffset, int off, int length)
- Parameters:
blockCacheKey
- the key for the blockbuffer
- the target buffer for the read resultblockOffset
- offset within the blockoff
- offset within the target bufferlength
- the number of bytes to read- Returns:
- true if the block was cached and the bytes were read
-
fetch
public boolean fetch(BlockCacheKey blockCacheKey, byte[] buffer)
-
getSize
public int getSize()
returns the number of elements in the cache
-
-