datafu.pig.util
Class ASSERT
java.lang.Object
org.apache.pig.EvalFunc<java.lang.Boolean>
org.apache.pig.FilterFunc
datafu.pig.util.ASSERT
public class ASSERT
- extends org.apache.pig.FilterFunc
Asserts some boolean. There is a unary and a binary version.
The unary version just takes a boolean, and throws out a generic exception message when the
assertion is violated.
The binary version takes a String as a second argument and throws that out when the assertion
is violated.
Unfortunately, the pig interpreter doesn't recognize boolean expressions nested as function
arguments, so this has reverted to C-style booleans. That is, the first argument should be
an integer. 0 for false, anything else for true.
Example:
FILTER members BY ASSERT( (member_id < 0 ? 1 : 0), 'This should always fail, as nobody has a negative member_id' );
Fields inherited from class org.apache.pig.EvalFunc |
log, pigLogger, reporter, returnType |
Method Summary |
java.lang.Boolean |
exec(org.apache.pig.data.Tuple tuple)
|
Methods inherited from class org.apache.pig.FilterFunc |
finish |
Methods inherited from class org.apache.pig.EvalFunc |
getArgToFuncMapping, getCacheFiles, getLogger, getPigLogger, getReporter, getReturnType, getSchemaName, isAsynchronous, outputSchema, progress, setPigLogger, setReporter, warn |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ASSERT
public ASSERT()
exec
public java.lang.Boolean exec(org.apache.pig.data.Tuple tuple)
throws java.io.IOException
- Specified by:
exec
in class org.apache.pig.EvalFunc<java.lang.Boolean>
- Throws:
java.io.IOException
Matthew Hayes, Sam Shah