org.apache.sysds.runtime.compress.colgroup

## Class Dictionary

- java.lang.Object
- - org.apache.sysds.runtime.compress.colgroup.ADictionary
  - - org.apache.sysds.runtime.compress.colgroup.Dictionary

-     public class Dictionary
      extends ADictionary

  This dictionary class aims to encapsulate the storage and operations over unique floating point values of a column group. The primary reason for its introduction was to provide an entry point for specialization such as shared dictionaries, which require additional information.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Dictionary(double[] values)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `double` | `aggregate(double init, Builtin fn)` Aggregate all the contained values, useful in value only computations where the operation is iterating through all values contained in the dictionary.
    `Dictionary` | `apply(ScalarOperator op)` Applies the scalar operation on the dictionary.
    `Dictionary` | `applyScalarOp(ScalarOperator op, double newVal, int numCols)` Applies the scalar operation on the dictionary.
    `Dictionary` | `clone()` Returns a deep clone of the dictionary.
    `long` | `getExactSizeOnDisk()` Calculate the space consumption if the dictionary is stored on disk.
    `long` | `getInMemorySize()` Returns the memory usage of the dictionary.
    `int` | `getNumberOfValues(int ncol)` Get the number of values given that the column group has n columns
    `double` | `getValue(int i)` Get Specific value contained in the dictionary at index.
    `double[]` | `getValues()` Get all the values contained in the dictionary as a linearized double array.
    `int` | `getValuesLength()` returns the count of values contained in the dictionary.
    `int` | `hasZeroTuple(int ncol)` Determines if the content has a zero tuple.
    `static Dictionary` | `read(DataInput in)`
    `void` | `write(DataOutput out)` Write the dictionary to a DataOutput.

    - ### Methods inherited from class org.apache.sysds.runtime.compress.colgroup.ADictionary

      `aggregateCols, read`

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

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

- - ### Constructor Detail

    - #### Dictionary

          public Dictionary(double[] values)

  - ### Method Detail

    - #### getValues

          public double[] getValues()

      Description copied from class: `ADictionary`
      Get all the values contained in the dictionary as a linearized double array.
      Specified by:
        `getValues` in class `ADictionary`
      Returns:
        linearized double array

    - #### getValue

          public double getValue(int i)

      Description copied from class: `ADictionary`
      Get Specific value contained in the dictionary at index.
      Specified by:
        `getValue` in class `ADictionary`
      Parameters:
        `i` - The index to extract the value from
      Returns:
        The value contained at the index

    - #### getInMemorySize

          public long getInMemorySize()

      Description copied from class: `ADictionary`
      Returns the memory usage of the dictionary.
      Specified by:
        `getInMemorySize` in class `ADictionary`
      Returns:
        a long value in number of bytes for the dictionary.

    - #### hasZeroTuple

          public int hasZeroTuple(int ncol)

      Description copied from class: `ADictionary`
      Determines if the content has a zero tuple. meaning all values at a specific row are zero value. This is useful information to find out if the dictionary is used in a dense context. To improve some specific operations.
      Specified by:
        `hasZeroTuple` in class `ADictionary`
      Parameters:
        `ncol` - The number of columns in the dictionary.
      Returns:
        The index at which the zero tuple is located.

    - #### aggregate

          public double aggregate(double init,
                                  Builtin fn)

      Description copied from class: `ADictionary`
      Aggregate all the contained values, useful in value only computations where the operation is iterating through all values contained in the dictionary.
      Specified by:
        `aggregate` in class `ADictionary`
      Parameters:
        `init` - The initial Value, in cases such as Max value, this could be -infinity
        `fn` - The Function to apply to values
      Returns:
        The aggregated value as a double.

    - #### apply

          public Dictionary apply(ScalarOperator op)

      Description copied from class: `ADictionary`
      Applies the scalar operation on the dictionary. Note that this operation modifies the underlying data, and normally require a copy of the original Dictionary to preserve old objects.
      Specified by:
        `apply` in class `ADictionary`
      Parameters:
        `op` - The operator to apply to the dictionary values.
      Returns:
        this dictionary with modified values.

    - #### applyScalarOp

          public Dictionary applyScalarOp(ScalarOperator op,
                                          double newVal,
                                          int numCols)

      Description copied from class: `ADictionary`
      Applies the scalar operation on the dictionary. The returned dictionary should contain a new instance of the underlying data. Therefore it will not modify the previous object.
      Specified by:
        `applyScalarOp` in class `ADictionary`
      Parameters:
        `op` - The operator to apply to the dictionary values.
        `newVal` - The value to append to the dictionary.
        `numCols` - The number of columns stored in the dictionary.
      Returns:
        Another dictionary with modified values.

    - #### clone

          public Dictionary clone()

      Description copied from class: `ADictionary`
      Returns a deep clone of the dictionary.
      Specified by:
        `clone` in class `ADictionary`

    - #### getValuesLength

          public int getValuesLength()

      Description copied from class: `ADictionary`
      returns the count of values contained in the dictionary.
      Specified by:
        `getValuesLength` in class `ADictionary`
      Returns:
        an integer of count of values.

    - #### read

          public static Dictionary read(DataInput in)
                                 throws IOException

      Throws:
        `IOException`

    - #### write

          public void write(DataOutput out)
                     throws IOException

      Description copied from class: `ADictionary`
      Write the dictionary to a DataOutput.
      Specified by:
        `write` in class `ADictionary`
      Parameters:
        `out` - the output sink to write the dictionary to.
      Throws:
        `IOException` - if the sink fails.

    - #### getExactSizeOnDisk

          public long getExactSizeOnDisk()

      Description copied from class: `ADictionary`
      Calculate the space consumption if the dictionary is stored on disk.
      Specified by:
        `getExactSizeOnDisk` in class `ADictionary`
      Returns:
        the long count of bytes to store the dictionary.

    - #### getNumberOfValues

          public int getNumberOfValues(int ncol)

      Description copied from class: `ADictionary`
      Get the number of values given that the column group has n columns
      Specified by:
        `getNumberOfValues` in class `ADictionary`
      Parameters:
        `ncol` - The number of Columns in the ColumnGroup.
      Returns:
        the number of value tuples contained in the dictionary.

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