Package org.apache.solr.blockcache
Class BlockCache
java.lang.Object
org.apache.solr.blockcache.BlockCache
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBlockCache(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
Modifier and TypeMethodDescriptionbooleanfetch(BlockCacheKey blockCacheKey, byte[] buffer) booleanfetch(BlockCacheKey blockCacheKey, byte[] buffer, int blockOffset, int off, int length) intgetSize()returns the number of elements in the cachevoidrelease(BlockCacheKey key) booleanstore(BlockCacheKey blockCacheKey, int blockOffset, byte[] data, int offset, int length) This is only best-effort...
-
Field Details
-
_128M
public static final int _128M- See Also:
-
_32K
public static final int _32K- See Also:
-
-
Constructor Details
-
BlockCache
-
BlockCache
-
BlockCache
public BlockCache(Metrics metrics, boolean directAllocation, long totalMemory, int slabSize, int blockSize)
-
-
Method Details
-
release
-
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
-
getSize
public int getSize()returns the number of elements in the cache
-