Class ExpandAsColumns

java.lang.Object
ca.uqac.lif.cep.functions.Function
ca.uqac.lif.cep.functions.UnaryFunction<Tuple,Tuple>
ca.uqac.lif.cep.tuples.ExpandAsColumns
All Implemented Interfaces:
ca.uqac.lif.cep.Duplicable, ca.uqac.lif.cep.functions.DuplicableFunction

public class ExpandAsColumns extends ca.uqac.lif.cep.functions.UnaryFunction<Tuple,Tuple>
Transforms a tuple by replacing two key-value pairs by a single new key-value pair. The new pair is created by taking the value of a column as the key, and the value of another column as the value.

For example, with the tuple: {(foo,1), (bar,2), (baz,3)}, using "foo" as the "key" column and "baz" as the value column, the resulting tuple would be: {(1,3), (bar,2)}. The value of foo is the new key, and the value of baz is the new value.

If the value of the "key" pair is not a string, it is converted into a string by calling its toString() method (since the key of a tuple is always a string).

Author:
Sylvain Hallé
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected String
    The name of the column whose value will be used as a column header
    protected String
    The name of the column whose value will be used as a value for the newly created column

    Fields inherited from class ca.uqac.lif.cep.functions.Function

    s_maxInputArity
  • Constructor Summary

    Constructors
    Constructor
    Description
    ExpandAsColumns(String col_name, String col_value)
    Creates a new instance of the function.
  • Method Summary

    Modifier and Type
    Method
    Description
    duplicate(boolean with_state)
     
     

    Methods inherited from class ca.uqac.lif.cep.functions.UnaryFunction

    evaluate, getInputArity, getInputTypesFor, getOutputArity, getOutputTypeFor, reset

    Methods inherited from class ca.uqac.lif.cep.functions.Function

    duplicate, evaluate, evaluate, evaluateLazy, evaluatePartial, printState, readState

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • m_columnName

      protected String m_columnName
      The name of the column whose value will be used as a column header
    • m_columnValue

      protected String m_columnValue
      The name of the column whose value will be used as a value for the newly created column
  • Constructor Details

    • ExpandAsColumns

      public ExpandAsColumns(String col_name, String col_value)
      Creates a new instance of the function.
      Parameters:
      col_name - The name of the column whose value will be used as a column header
      col_value - The name of the column whose value will be used as a value for the newly created column
  • Method Details

    • getValue

      public Tuple getValue(Tuple x)
      Specified by:
      getValue in class ca.uqac.lif.cep.functions.UnaryFunction<Tuple,Tuple>
    • duplicate

      public ExpandAsColumns duplicate(boolean with_state)
      Specified by:
      duplicate in interface ca.uqac.lif.cep.Duplicable
      Overrides:
      duplicate in class ca.uqac.lif.cep.functions.UnaryFunction<Tuple,Tuple>