org.apache.sysds.runtime.controlprogram.caching

## Interface CacheBlock

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

      public interface CacheBlock
      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

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `compactEmptyBlock()` Free unnecessarily allocated empty block.
    `long` | `getExactSerializedSize()` Get the exact serialized size in bytes of the cache block.
    `long` | `getInMemorySize()` Get the in-memory size in bytes of the cache block.
    `int` | `getNumColumns()`
    `int` | `getNumRows()`
    `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.
    `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.
    `void` | `merge(CacheBlock that, boolean appendOnly)` Merge the given block into the current block.
    `CacheBlock` | `slice(int rl, int ru, int cl, int cu, CacheBlock block)` Slice a sub block out of the current block and write into the given output block.
    `void` | `toShallowSerializeBlock()` 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 Detail

    - #### getNumRows

          int getNumRows()

    - #### getNumColumns

          int getNumColumns()

    - #### 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 slice(int rl,
                           int ru,
                           int cl,
                           int cu,
                           CacheBlock 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
        `cl` - column lower
        `cu` - column upper
        `block` - cache block
      Returns:
        sub-block of cache block

    - #### merge

          void merge(CacheBlock that,
                     boolean appendOnly)

      Merge the given block into the current block. Both blocks needs to be of equal dimensions and contain disjoint non-zero cells.
      Parameters:
        `that` - cache block
        `appendOnly` - ?

Copyright © 2020 The Apache Software Foundation. All rights reserved.