Class SimpleWriteableTuple<T extends WriteableTuple<T>>

java.lang.Object
com.linkedin.feathr.common.ColumnUtils
com.linkedin.feathr.common.tensor.SimpleWriteableTuple<T>
Type Parameters:
T -
All Implemented Interfaces:
ReadableTuple, WriteableTuple<T>

public class SimpleWriteableTuple<T extends WriteableTuple<T>> extends ColumnUtils implements WriteableTuple<T>, ReadableTuple
An implementation of WriteableTuple which keeps all values in primitive arrays. This can be used as a scratch space for a single row in a tensor.
  • Constructor Details

    • SimpleWriteableTuple

      public SimpleWriteableTuple(Representable[] types)
  • Method Details

    • getTypes

      public Representable[] getTypes()
      Specified by:
      getTypes in interface ReadableTuple
      Specified by:
      getTypes in interface WriteableTuple<T extends WriteableTuple<T>>
      Returns:
      the types of all dimensions and the value as a single array.
    • getInt

      public int getInt(int column)
      Specified by:
      getInt in interface ReadableTuple
      Returns:
      an int at given column.
    • getLong

      public long getLong(int column)
      Specified by:
      getLong in interface ReadableTuple
      Returns:
      a long at given column.
    • getFloat

      public float getFloat(int column)
      Specified by:
      getFloat in interface ReadableTuple
      Returns:
      a float at given column.
    • getDouble

      public double getDouble(int column)
      Specified by:
      getDouble in interface ReadableTuple
      Returns:
      a double at given column.
    • getBoolean

      public boolean getBoolean(int column)
      Specified by:
      getBoolean in interface ReadableTuple
      Returns:
      a boolean at given column.
    • getString

      public String getString(int column)
      Specified by:
      getString in interface ReadableTuple
      Returns:
      a string at given column.
    • getBytes

      public byte[] getBytes(int column)
      Specified by:
      getBytes in interface ReadableTuple
      Returns:
      a byte array at given column.
    • getCopy

      public ReadableTuple getCopy()
      Specified by:
      getCopy in interface ReadableTuple
      Returns:
      a copy of this tuple, so that changes to the original tuple will not affect the new one.
    • setInt

      public T setInt(int column, int value)
      Description copied from interface: WriteableTuple
      Sets the specified column to a given `int`
      Specified by:
      setInt in interface WriteableTuple<T extends WriteableTuple<T>>
      Parameters:
      column - The column in the tuple to write to
      value - The int value to be written
      Returns:
      A reference to this object (`this`)
    • setLong

      public T setLong(int column, long value)
      Description copied from interface: WriteableTuple
      Sets the specified column to a given `long`
      Specified by:
      setLong in interface WriteableTuple<T extends WriteableTuple<T>>
      Parameters:
      column - The column in the tuple to write to
      value - The long value to be written
      Returns:
      A reference to this object (`this`)
    • setFloat

      public T setFloat(int column, float value)
      Description copied from interface: WriteableTuple
      Sets the specified column to a given `float`
      Specified by:
      setFloat in interface WriteableTuple<T extends WriteableTuple<T>>
      Parameters:
      column - The column in the tuple to write to
      value - The float value to be written
      Returns:
      A reference to this object (`this`)
    • setDouble

      public T setDouble(int column, double value)
      Description copied from interface: WriteableTuple
      Sets the specified column to a given `double`
      Specified by:
      setDouble in interface WriteableTuple<T extends WriteableTuple<T>>
      Parameters:
      column - The column in the tuple to write to
      value - The double value to be written
      Returns:
      A reference to this object (`this`)
    • setBoolean

      public T setBoolean(int column, boolean value)
      Description copied from interface: WriteableTuple
      Sets the specified column to a given `boolean`
      Specified by:
      setBoolean in interface WriteableTuple<T extends WriteableTuple<T>>
      Parameters:
      column - The column in the tuple to write to
      value - The double value to be written
      Returns:
      A reference to this object (`this`)
    • setString

      public T setString(int column, String value)
      Description copied from interface: WriteableTuple
      Sets the specified column to a given `String`
      Specified by:
      setString in interface WriteableTuple<T extends WriteableTuple<T>>
      Parameters:
      column - The column in the tuple to write to
      value - The String value to be written
      Returns:
      A reference to this object (`this`)
    • setBytes

      public T setBytes(int column, byte[] value)
      Description copied from interface: WriteableTuple
      Sets the specified column to a given `byte array`
      Specified by:
      setBytes in interface WriteableTuple<T extends WriteableTuple<T>>
      Parameters:
      column - The column in the tuple to write to
      value - The byte array value to be written
      Returns:
      A reference to this object (`this`)
    • resetColumns

      public void resetColumns()
      Resets all values to 0 (for primitives) and null for Strings
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object