com.ebay.erl.mobius.core.model
Class Column

java.lang.Object
  extended by com.ebay.erl.mobius.core.function.base.Projectable
      extended by com.ebay.erl.mobius.core.function.base.ExtendFunction
          extended by com.ebay.erl.mobius.core.model.Column
All Implemented Interfaces:
java.io.Serializable, org.apache.hadoop.conf.Configurable

public class Column
extends ExtendFunction

Represents a single column of a Dataset. An instance of Column can be used as projection in the list, join, grouping, or sorting jobs.

This product is licensed under the Apache License, Version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0. This product contains portions derived from Apache hadoop which is licensed under the Apache License, Version 2.0, available at http://hadoop.apache.org. © 2007 – 2012 eBay Inc., Evan Chiu, Woody Zhou, Neel Sundaresan

See Also:
Serialized Form

Field Summary
protected  java.lang.String columnName
          the name of this column
protected  Dataset dataset
          the Dataset this column belongs to.
protected  java.lang.String newName
          the new name of this column, specified by user via setNewName(String)
 
Fields inherited from class com.ebay.erl.mobius.core.function.base.Projectable
conf, inputs, outputSchema, reporter, requireDataFromMultiDatasets
 
Constructor Summary
Column(Dataset dataset, java.lang.String columnName)
          Create a column instance that represents a column named columnName in the dataset .
 
Method Summary
static Column[] columns(Dataset dataset, java.lang.String... columns)
          Select multiple columns from a dataset
 boolean equals(java.lang.Object obj)
          Two columns are equal only if their dataset are the same (specified by Dataset.equals(Object)), columnName are the same, and their getOutputName() also the same.
 Dataset getDataset()
          Get the Dataset this column belongs to.
 java.lang.String getInputColumnName()
          Return the original name of this column
 java.lang.String getOutputName()
          Get the output name of this column, by default, it's the same as it's original name.
 java.lang.String[] getOutputSchema()
          Always return a size 1 array which contains the result of getOutputName().
 Tuple getResult(Tuple inputRow)
          Return a Tuple which contains one single column with the name of getOutputName() and its value is from the column named getInputColumnName() in the inputRow.
 int hashCode()
           
 Column setNewName(java.lang.String newName)
          Change the output schema name of this column.
 Projectable setOutputSchema(java.lang.String... schema)
          Deprecated. use setNewName(String) instead.
static java.lang.String[] toSchemaArray(Column... columns)
          Get the getOutputName() from the columns and store then in the returned string array.
static java.lang.String toSchemaString(Column... columns)
          Concatenate the getOutputName() from the columns together and separated by comma.
 java.lang.String toString()
           
 
Methods inherited from class com.ebay.erl.mobius.core.function.base.ExtendFunction
getNoMatchResult
 
Methods inherited from class com.ebay.erl.mobius.core.function.base.Projectable
calledByCombiner, getConf, getInputColumns, getParticipatedDataset, init, isCombinable, requireDataFromMultiDatasets, setCalledByCombiner, setConf, setReporter, useGroupKeyOnly
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

dataset

protected Dataset dataset
the Dataset this column belongs to.


columnName

protected java.lang.String columnName
the name of this column


newName

protected java.lang.String newName
the new name of this column, specified by user via setNewName(String)

Constructor Detail

Column

public Column(Dataset dataset,
              java.lang.String columnName)
Create a column instance that represents a column named columnName in the dataset .

Parameters:
dataset - a Dataset contains the specified column.
columnName - name of the column
Throws:
java.lang.IllegalArgumentException - if the specified columnName doesn't exist in the dataset.
Method Detail

setOutputSchema

public final Projectable setOutputSchema(java.lang.String... schema)
Deprecated. use setNewName(String) instead.

Description copied from class: Projectable
Set the output schema of the result of this function.

Overrides:
setOutputSchema in class Projectable

getOutputSchema

public final java.lang.String[] getOutputSchema()
Always return a size 1 array which contains the result of getOutputName().

Overrides:
getOutputSchema in class Projectable

setNewName

public final Column setNewName(java.lang.String newName)
Change the output schema name of this column.

By default, the output schema of this column is the name specified in the constructor, in the case of select two different columns from two different datasets, and the name of these two columns are the same, one can use this method to change the name of one of the columns to remove ambiguous.

Returns:
the column it self.

getDataset

public final Dataset getDataset()
Get the Dataset this column belongs to.


toString

public java.lang.String toString()
Overrides:
toString in class Projectable

hashCode

public int hashCode()
Overrides:
hashCode in class Projectable

equals

public boolean equals(java.lang.Object obj)
Two columns are equal only if their dataset are the same (specified by Dataset.equals(Object)), columnName are the same, and their getOutputName() also the same.

Overrides:
equals in class Projectable

columns

public static Column[] columns(Dataset dataset,
                               java.lang.String... columns)
Select multiple columns from a dataset


getInputColumnName

public final java.lang.String getInputColumnName()
Return the original name of this column


getOutputName

public final java.lang.String getOutputName()
Get the output name of this column, by default, it's the same as it's original name.


toSchemaString

public static java.lang.String toSchemaString(Column... columns)
Concatenate the getOutputName() from the columns together and separated by comma.


toSchemaArray

public static java.lang.String[] toSchemaArray(Column... columns)
Get the getOutputName() from the columns and store then in the returned string array.


getResult

public Tuple getResult(Tuple inputRow)
Return a Tuple which contains one single column with the name of getOutputName() and its value is from the column named getInputColumnName() in the inputRow.

Specified by:
getResult in class ExtendFunction