Interface CacheBlock

  • All Superinterfaces:
    org.apache.hadoop.io.Writable
    All Known Implementing Classes:
    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 Description
      void compactEmptyBlock()
      Free unnecessarily allocated empty block.
      DataCharacteristics getDataCharacteristics()  
      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 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()  
      String getString​(int r, int c)
      Returns the string of the value at the passed row and column.
      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, boolean deep, CacheBlock block)
      Slice a sub block out of the current block and write into the given output 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
      • slice

        CacheBlock slice​(int rl,
                         int ru,
                         int cl,
                         int cu,
                         boolean deep,
                         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
        deep - enforce deep-copy
        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 - ?
      • 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