com.ebay.erl.mobius.core.criterion
Class TupleCriterion

java.lang.Object
  extended by com.ebay.erl.mobius.core.criterion.TupleCriterion
All Implemented Interfaces:
java.io.Serializable, org.apache.hadoop.conf.Configurable
Direct Known Subclasses:
LogicalExpression

public abstract class TupleCriterion
extends java.lang.Object
implements org.apache.hadoop.conf.Configurable, java.io.Serializable

Evaluates a Tuple.

If the tuple is accepted after calling accept(Tuple, Configuration), then the tuple is populated.

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:
TupleRestrictions, Serialized Form

Constructor Summary
TupleCriterion()
           
 
Method Summary
 boolean accept(Tuple tuple, org.apache.hadoop.conf.Configuration configuration)
          Test if the tuple meet this TupleCriterion or not
 TupleCriterion and(TupleCriterion another)
          return a new TupleCriterion that represents this AND another
protected abstract  boolean evaluate(Tuple tuple, org.apache.hadoop.conf.Configuration configuration)
          Sub class shall override this method to verify if the tuple meet the the criteria or not.
 org.apache.hadoop.conf.Configuration getConf()
           
abstract  java.lang.String[] getInvolvedColumns()
          return an array of column names that are required by this criterion.
 TupleCriterion not()
          Return a new instance of TupleCriterion that is the complement of this one.
 TupleCriterion or(TupleCriterion another)
          return a new TupleCriterion that represents this OR another.
 void setConf(org.apache.hadoop.conf.Configuration conf)
           
static void validate(java.util.Set<java.lang.String> allAvailableColumns, TupleCriterion criteria)
          validate if the given criteria only use the columns in the allAvailableColumns
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TupleCriterion

public TupleCriterion()
Method Detail

accept

public boolean accept(Tuple tuple,
                      org.apache.hadoop.conf.Configuration configuration)
Test if the tuple meet this TupleCriterion or not

Parameters:
tuple - a tuple in a dataset to be tested
configuration -
Returns:
true if the tuple pass this TupleCriterion, false otherwise.

and

public TupleCriterion and(TupleCriterion another)
return a new TupleCriterion that represents this AND another

The another and this TupleCriterion doesn't change.


or

public TupleCriterion or(TupleCriterion another)
return a new TupleCriterion that represents this OR another.

The another and this TupleCriterion doesn't change.


not

public final TupleCriterion not()
Return a new instance of TupleCriterion that is the complement of this one.

The original TupleCriterion will not be changed.

Returns:
complement of this TupleCriterion

evaluate

protected abstract boolean evaluate(Tuple tuple,
                                    org.apache.hadoop.conf.Configuration configuration)
Sub class shall override this method to verify if the tuple meet the the criteria or not.

Parameters:
tuple - a tuple to be test
configuration - Hadoop configuration
Returns:
true if the tuple meets this criteria, false otherwise.

getInvolvedColumns

public abstract java.lang.String[] getInvolvedColumns()
return an array of column names that are required by this criterion.


setConf

public void setConf(org.apache.hadoop.conf.Configuration conf)
Specified by:
setConf in interface org.apache.hadoop.conf.Configurable

getConf

public org.apache.hadoop.conf.Configuration getConf()
Specified by:
getConf in interface org.apache.hadoop.conf.Configurable

validate

public static void validate(java.util.Set<java.lang.String> allAvailableColumns,
                            TupleCriterion criteria)
                     throws java.lang.IllegalArgumentException
validate if the given criteria only use the columns in the allAvailableColumns

Parameters:
allAvailableColumns -
criteria -
Throws:
java.lang.IllegalArgumentException - if the criteria use some column(s) that doesn't exist in the allAvailableColumns