org.apache.sysds.runtime.transform.encode

## Class Encoder

- java.lang.Object
- - org.apache.sysds.runtime.transform.encode.Encoder

- All Implemented Interfaces:
    Serializable
  Direct Known Subclasses:
    EncoderBin, EncoderComposite, EncoderDummycode, EncoderFeatureHash, EncoderMVImpute, EncoderOmit, EncoderPassThrough, EncoderRecode

      public abstract class Encoder
      extends Object
      implements Serializable

  Base class for all transform encoders providing both a row and block interface for decoding frames to matrices.
  See Also:
    Serialized Form

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract MatrixBlock` | `apply(FrameBlock in, MatrixBlock out)` Encode input data blockwise according to existing transform meta data (transform apply).
    `abstract void` | `build(FrameBlock in)` Build the transform meta data for the given block input.
    `abstract MatrixBlock` | `encode(FrameBlock in, MatrixBlock out)` Block encode: build and apply (transform encode).
    `int[]` | `getColList()`
    `MatrixBlock` | `getColMapping(FrameBlock meta, MatrixBlock out)` Obtain the column mapping of encoded frames based on the passed meta data frame.
    `abstract FrameBlock` | `getMetaData(FrameBlock out)` Construct a frame block out of the transform meta data.
    `int` | `getNumCols()`
    `int` | `initColList(int[] colList)`
    `int` | `initColList(org.apache.wink.json4j.JSONArray attrs)`
    `abstract void` | `initMetaData(FrameBlock meta)` Sets up the required meta data for a subsequent call to apply.
    `boolean` | `isApplicable()` Indicates if this encoder is applicable, i.e, if there is at least one column to encode.
    `int` | `isApplicable(int colID)` Indicates if this encoder is applicable for the given column ID, i.e., if it is subject to this transformation.
    `void` | `mergeAt(Encoder other, int row, int col)` Merges another encoder, of a compatible type, in after a certain position.
    `void` | `setColList(int[] colList)`
    `Encoder` | `subRangeEncoder(IndexRange ixRange)` Returns a new Encoder that only handles a sub range of columns.
    `void` | `updateIndexRanges(long[] beginDims, long[] endDims)` Update index-ranges to after encoding.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### getColList

          public int[] getColList()

    - #### setColList

          public void setColList(int[] colList)

    - #### getNumCols

          public int getNumCols()

    - #### initColList

          public int initColList(org.apache.wink.json4j.JSONArray attrs)

    - #### initColList

          public int initColList(int[] colList)

    - #### isApplicable

          public boolean isApplicable()

      Indicates if this encoder is applicable, i.e, if there is at least one column to encode.
      Returns:
        true if at least one column to encode

    - #### isApplicable

          public int isApplicable(int colID)

      Indicates if this encoder is applicable for the given column ID, i.e., if it is subject to this transformation.
      Parameters:
        `colID` - column ID
      Returns:
        true if encoder is applicable for given column

    - #### encode

          public abstract MatrixBlock encode(FrameBlock in,
                                             MatrixBlock out)

      Block encode: build and apply (transform encode).
      Parameters:
        `in` - input frame block
        `out` - output matrix block
      Returns:
        output matrix block

    - #### build

          public abstract void build(FrameBlock in)

      Build the transform meta data for the given block input. This call modifies and keeps meta data as encoder state.
      Parameters:
        `in` - input frame block

    - #### apply

          public abstract MatrixBlock apply(FrameBlock in,
                                            MatrixBlock out)

      Encode input data blockwise according to existing transform meta data (transform apply).
      Parameters:
        `in` - input frame block
        `out` - output matrix block
      Returns:
        output matrix block

    - #### subRangeEncoder

          public Encoder subRangeEncoder(IndexRange ixRange)

      Returns a new Encoder that only handles a sub range of columns.
      Parameters:
        `ixRange` - the range (1-based, begin inclusive, end exclusive)
      Returns:
        an encoder of the same type, just for the sub-range

    - #### mergeAt

          public void mergeAt(Encoder other,
                              int row,
                              int col)

      Merges another encoder, of a compatible type, in after a certain position. Resizes as necessary. `Encoders` are compatible with themselves and `EncoderComposite` is compatible with every other `Encoder`.
      Parameters:
        `other` - the encoder that should be merged in
        `row` - the row where it should be placed (1-based)
        `col` - the col where it should be placed (1-based)

    - #### updateIndexRanges

          public void updateIndexRanges(long[] beginDims,
                                        long[] endDims)

      Update index-ranges to after encoding. Note that only Dummycoding changes the ranges.
      Parameters:
        `beginDims` - begin dimensions of range
        `endDims` - end dimensions of range

    - #### getMetaData

          public abstract FrameBlock getMetaData(FrameBlock out)

      Construct a frame block out of the transform meta data.
      Parameters:
        `out` - output frame block
      Returns:
        output frame block?

    - #### initMetaData

          public abstract void initMetaData(FrameBlock meta)

      Sets up the required meta data for a subsequent call to apply.
      Parameters:
        `meta` - frame block

    - #### getColMapping

          public MatrixBlock getColMapping(FrameBlock meta,
                                           MatrixBlock out)

      Obtain the column mapping of encoded frames based on the passed meta data frame.
      Parameters:
        `meta` - meta data frame block
        `out` - output matrix
      Returns:
        matrix with column mapping (one row per attribute)

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