Interface CacheBlock<T>

All Superinterfaces:
org.apache.hadoop.io.Writable
All Known Implementing Classes:
CompressedMatrixBlock, FrameBlock, MatrixBlock, TensorBlock

public interface CacheBlock<T> extends org.apache.hadoop.io.Writable
Interface for all blocks handled by lazy write buffer. This abstraction allows us to keep the buffer pool independent of matrix and frame blocks.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Free unnecessarily allocated empty block.
     
    double
    getDouble(int r, int c)
    Returns the double value at the passed row and column.
    double
    getDoubleNaN(int r, int c)
    Returns the double value at the passed row and column.
    long
    Get the exact serialized size in bytes of the cache block.
    long
    Get the in-memory size in bytes of the cache block.
    int
     
    int
     
    getString(int r, int c)
    Returns the string of the value at the passed row and column.
    boolean
    Indicates if the cache block is subject to shallow serialized, which is generally true if in-memory size and serialized size are almost identical allowing to avoid unnecessary deep serialize.
    boolean
    isShallowSerialize(boolean inclConvert)
    Indicates if the cache block is subject to shallow serialized, which is generally true if in-memory size and serialized size are almost identical allowing to avoid unnecessary deep serialize.
    merge(T that, boolean appendOnly)
    Merge disjoint: merges all non-zero values of the given input into the current block.
    slice(int rl, int ru)
    Slice a sub block out of the current block and write into the given output block.
    slice(int rl, int ru, boolean deep)
    Slice a sub block out of the current block and write into the given output block.
    slice(int rl, int ru, int cl, int cu)
    Slice a sub block out of the current block and write into the given output block.
    slice(int rl, int ru, int cl, int cu, boolean deep)
    Slice a sub block out of the current block and write into the given output block.
    slice(int rl, int ru, int cl, int cu, boolean deep, T block)
    Slice a sub block out of the current block and write into the given output block.
    slice(int rl, int ru, int cl, int cu, T block)
    Slice a sub block out of the current block and write into the given output block.
    slice(IndexRange ixrange, T ret)
    Slice a sub block out of the current block and write into the given output block.
    void
    Converts a cache block that is not shallow serializable into a form that is shallow serializable.

    Methods inherited from interface org.apache.hadoop.io.Writable

    readFields, write
  • Method Details

    • getNumRows

      int getNumRows()
    • getNumColumns

      int getNumColumns()
    • getDataCharacteristics

      DataCharacteristics getDataCharacteristics()
    • getInMemorySize

      long getInMemorySize()
      Get the in-memory size in bytes of the cache block.
      Returns:
      in-memory size in bytes of cache block
    • getExactSerializedSize

      long getExactSerializedSize()
      Get the exact serialized size in bytes of the cache block.
      Returns:
      exact serialized size in bytes of cache block
    • isShallowSerialize

      boolean isShallowSerialize()
      Indicates if the cache block is subject to shallow serialized, which is generally true if in-memory size and serialized size are almost identical allowing to avoid unnecessary deep serialize.
      Returns:
      true if shallow serialized
    • isShallowSerialize

      boolean isShallowSerialize(boolean inclConvert)
      Indicates if the cache block is subject to shallow serialized, which is generally true if in-memory size and serialized size are almost identical allowing to avoid unnecessary deep serialize.
      Parameters:
      inclConvert - if true report blocks as shallow serialize that are currently not amenable but can be brought into an amenable form via toShallowSerializeBlock.
      Returns:
      true if shallow serialized
    • toShallowSerializeBlock

      void toShallowSerializeBlock()
      Converts a cache block that is not shallow serializable into a form that is shallow serializable. This methods has no affect if the given cache block is not amenable.
    • compactEmptyBlock

      void compactEmptyBlock()
      Free unnecessarily allocated empty block.
    • slice

      CacheBlock<T> slice(IndexRange ixrange, T ret)
      Slice a sub block out of the current block and write into the given output block. This method returns the passed instance if not null.
      Parameters:
      ixrange - index range inclusive
      ret - outputBlock
      Returns:
      sub-block of cache block
    • slice

      CacheBlock<T> slice(int rl, int ru)
      Slice a sub block out of the current block and write into the given output block. This method returns the passed instance if not null.
      Parameters:
      rl - row lower
      ru - row upper inclusive
      Returns:
      sub-block of cache block
    • slice

      CacheBlock<T> slice(int rl, int ru, boolean deep)
      Slice a sub block out of the current block and write into the given output block. This method returns the passed instance if not null.
      Parameters:
      rl - row lower
      ru - row upper inclusive
      deep - enforce deep-copy
      Returns:
      sub-block of cache block
    • slice

      CacheBlock<T> slice(int rl, int ru, int cl, int cu)
      Slice a sub block out of the current block and write into the given output block. This method returns the passed instance if not null.
      Parameters:
      rl - row lower
      ru - row upper inclusive
      cl - column lower
      cu - column upper inclusive
      Returns:
      sub-block of cache block
    • slice

      CacheBlock<T> slice(int rl, int ru, int cl, int cu, T block)
      Slice a sub block out of the current block and write into the given output block. This method returns the passed instance if not null.
      Parameters:
      rl - row lower
      ru - row upper inclusive
      cl - column lower
      cu - column upper inclusive
      block - cache block
      Returns:
      sub-block of cache block
    • slice

      CacheBlock<T> slice(int rl, int ru, int cl, int cu, boolean deep)
      Slice a sub block out of the current block and write into the given output block. This method returns the passed instance if not null.
      Parameters:
      rl - row lower
      ru - row upper inclusive
      cl - column lower
      cu - column upper inclusive
      deep - enforce deep-copy
      Returns:
      sub-block of cache block
    • slice

      CacheBlock<T> slice(int rl, int ru, int cl, int cu, boolean deep, T block)
      Slice a sub block out of the current block and write into the given output block. This method returns the passed instance if not null.
      Parameters:
      rl - row lower
      ru - row upper inclusive
      cl - column lower
      cu - column upper inclusive
      deep - enforce deep-copy
      block - cache block
      Returns:
      sub-block of cache block
    • merge

      CacheBlock<T> merge(T that, boolean appendOnly)
      Merge disjoint: merges all non-zero values of the given input into the current block. Note that this method does NOT check for overlapping entries; it's the callers responsibility of ensuring disjoint blocks. The appendOnly parameter is only relevant for sparse target blocks; if true, we only append values and do not sort sparse rows for each call; this is useful whenever we merge iterators of matrix blocks into one target block.
      Parameters:
      that - cache block
      appendOnly - Indicate if the merger can be append only on sparse rows.
      Returns:
      the merged group, in most implementations 'this' is modified.
    • getDouble

      double getDouble(int r, int c)
      Returns the double value at the passed row and column. If the value is missing 0 is returned.
      Parameters:
      r - row of the value
      c - column of the value
      Returns:
      double value at the passed row and column
    • getDoubleNaN

      double getDoubleNaN(int r, int c)
      Returns the double value at the passed row and column. If the value is missing NaN is returned.
      Parameters:
      r - row of the value
      c - column of the value
      Returns:
      double value at the passed row and column
    • getString

      String getString(int r, int c)
      Returns the string of the value at the passed row and column. If the value is missing or NaN, null is returned.
      Parameters:
      r - row of the value
      c - column of the value
      Returns:
      string of the value at the passed row and column