org.apache.sysds.runtime.compress.colgroup.offset

## Class OffsetFactory

- java.lang.Object
- - org.apache.sysds.runtime.compress.colgroup.offset.OffsetFactory

-     public class OffsetFactory
      extends Object

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `OffsetFactory.OFF_TYPE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `OffsetFactory()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static AOffset` | `create(int[] indexes, int nRows)` Main factory pattern creator for Offsets.
    `static long` | `estimateInMemorySize(int size, int nRows)` Avg diff only works assuming a normal distribution of the offsets.
    `static AOffset` | `readIn(DataInput in)` Read in AOffset from the DataInput.

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

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

- - ### Constructor Detail

    - #### OffsetFactory

          public OffsetFactory()

  - ### Method Detail

    - #### create

          public static AOffset create(int[] indexes,
                                       int nRows)

      Main factory pattern creator for Offsets.
      Parameters:
        `indexes` - List of indexes, that is assumed to be sorted and have no duplicates
        `nRows` - The number of rows that should be possible in the encoding.
      Returns:
        AOffset object containing offsets to the next value.

    - #### readIn

          public static AOffset readIn(DataInput in)
                                throws IOException

      Read in AOffset from the DataInput.
      Parameters:
        `in` - DataInput to read from
      Returns:
        The AOffset data instance
      Throws:
        `IOException` - If the DataInput fails reading in the variables

    - #### estimateInMemorySize

          public static long estimateInMemorySize(int size,
                                                  int nRows)

      Avg diff only works assuming a normal distribution of the offsets. This means that if we have 1000 rows and 100 offsets, it is assumed that on average the distance between elements is 10. Optionally todo is to add some number of size if the average distance is almost the same as the max value of the OffsetLists. this would add to the estimated size and approximate better the real compression size. It would also then handle edge cases better.
      Parameters:
        `size` - The estimated number of offsets
        `nRows` - The number of rows.
      Returns:
        The estimated size of an offset given the number of offsets and rows.

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