Class BlockCache

java.lang.Object
org.apache.solr.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 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
  • 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

    Modifier and Type
    Method
    Description
    boolean
    fetch(BlockCacheKey blockCacheKey, byte[] buffer)
     
    boolean
    fetch(BlockCacheKey blockCacheKey, byte[] buffer, int blockOffset, int off, int length)
     
    int
    returns the number of elements in the cache
    void
     
    boolean
    store(BlockCacheKey blockCacheKey, int blockOffset, byte[] data, int offset, int length)
    This is only best-effort...

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • 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 Details

    • 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 block
      blockOffset - the offset within the block
      data - source data to write to the block
      offset - offset within the source data array
      length - 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 block
      buffer - the target buffer for the read result
      blockOffset - offset within the block
      off - offset within the target buffer
      length - 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