本文整理汇总了Java中org.apache.pig.PigException.ERROR属性的典型用法代码示例。如果您正苦于以下问题:Java PigException.ERROR属性的具体用法?Java PigException.ERROR怎么用?Java PigException.ERROR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.pig.PigException
的用法示例。
在下文中一共展示了PigException.ERROR属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exec
@Override
public String exec(Tuple input) throws IOException {
//
if (input == null || input.size() == 0 || input.get(0) == null) {
return null;
}
//
if (input.get(0) == "") {
return input.get(0).toString();
}
if (input.size() > 1)
throw new ExecException("Wrong number of arguments > 1", PigException.ERROR);
//
String url;
//Validating arguments
Object arg0 = input.get(0);
if (arg0 instanceof String)
url = (String) arg0;
else {
String msg = "Invalid data type for argument 0 " + DataType.findTypeName(arg0);
throw new ExecException(msg, PigException.ERROR);
}
//
try {
return URLEncoder.encode(url, this.encoding);
} catch (UnsupportedEncodingException e) {
// We overflowed. Give a warning, but do not throw an
// exception.
warn(e.toString(), PigWarning.UDF_WARNING_1);
// Returning null will indicate to Pig that we failed but
// we want to continue execution.
return null;
}
}
示例2: exec
@Override
public Boolean exec(Tuple input) throws IOException {
//
if (input == null || input.size() == 0 || input.get(0) == null) {
return false;
}
//
if (input.get(0) == "") {
return true;
}
if (input.size() > 1)
throw new ExecException("Wrong number of arguments > 1", PigException.ERROR);
//
String url;
//Validating arguments
Object arg0 = input.get(0);
if (arg0 instanceof String)
url = (String) arg0;
else {
String msg = "Invalid data type for argument 0 " + DataType.findTypeName(arg0);
throw new ExecException(msg, PigException.ERROR);
}
//
try {
URLDecoder.decode(url, this.encoding);
return true;
} catch (UnsupportedEncodingException e) {
return false;
}
}
示例3: exec
@Override
public String exec(Tuple input) throws IOException {
// validate input
if (input == null || input.size() == 0 || input.get(0) == null) {
return null;
}
//
if (input.get(0) == "") {
return input.get(0).toString();
}
if (input.size() > 1) {
throw new ExecException("Wrong number of arguments > 1", PigException.ERROR);
}
//
String str;
//Validating arguments
Object arg0 = input.get(0);
if (arg0 instanceof String)
str = (String) arg0;
else {
String msg = "Invalid data type for argument " + DataType.findTypeName(arg0);
throw new ExecException(msg, PigException.ERROR);
}
//decode
return new String(B64Code.encode(str.getBytes(StringUtil.__UTF8)));
}
示例4: exec
@Override
public String exec(Tuple input) throws IOException {
// validate input
if (input == null || input.size() == 0 || input.get(0) == null) {
return null;
}
//
if (input.get(0) == "") {
return input.get(0).toString();
}
if (input.size() > 1) {
throw new ExecException("Wrong number of arguments > 1", PigException.ERROR);
}
//
String str;
//Validating arguments
Object arg0 = input.get(0);
if (arg0 instanceof String)
str = (String) arg0;
else {
String msg = "Invalid data type for argument " + DataType.findTypeName(arg0);
throw new ExecException(msg, PigException.ERROR);
}
try {
String strDecoded = B64Code.decode(str, StringUtil.__UTF8);
return new String(strDecoded);
} catch (IllegalArgumentException iae) {
return null;
}
}
示例5: exec
@Override
public Boolean exec(Tuple input) throws IOException {
//
if (input == null || input.size() == 0 || input.get(0) == null) {
return false;
}
//
if (input.get(0) == "") {
return true;
}
if (input.size() > 1)
throw new ExecException("Wrong number of arguments > 1", PigException.ERROR);
//
String url;
//Validating arguments
Object arg0 = input.get(0);
if (arg0 instanceof String)
url = (String) arg0;
else {
String msg = "Invalid data type for argument 0 " + DataType.findTypeName(arg0);
throw new ExecException(msg, PigException.ERROR);
}
//
try {
URLEncoder.encode(url, this.encoding);
return true;
} catch (UnsupportedEncodingException e) {
return false;
}
}
示例6: exec
@Override
public String exec(Tuple input) throws IOException {
//
if (input == null || input.size() == 0 || input.get(0) == null) {
return null;
}
//
if (input.get(0) == "") {
return input.get(0).toString();
}
if (input.size() > 1)
throw new ExecException("Wrong number of arguments > 1", PigException.ERROR);
//
String url;
//Validating arguments
Object arg0 = input.get(0);
if (arg0 instanceof String)
url = (String) arg0;
else {
String msg = "Invalid data type for argument 0 " + DataType.findTypeName(arg0);
throw new ExecException(msg, PigException.ERROR);
}
//
try {
return URLDecoder.decode(url, this.encoding);
} catch (UnsupportedEncodingException e) {
// We overflowed. Give a warning, but do not throw an
// exception.
warn(e.toString(), PigWarning.UDF_WARNING_1);
// Returning null will indicate to Pig that we failed but
// we want to continue execution.
return null;
}
}
示例7: parseFieldIndex
protected static int parseFieldIndex(String inputFieldIndex)
throws ExecException {
// using a decrement to make sure that the subtraction happens correctly
int fieldIndex = Integer.valueOf(inputFieldIndex);
// to make fieldIndex 1-based instead of 0-based
--fieldIndex;
if (fieldIndex < 0) {
throw new ExecException("field index cannot be less than 1:"
+ inputFieldIndex, -1, PigException.ERROR, null);
}
return fieldIndex;
}
示例8: extreme
@SuppressWarnings("unchecked")
protected final static Tuple extreme(int pind, int psign, Tuple input,
PigProgressable reporter) throws ExecException {
DataBag values = (DataBag) input.get(0);
// if we were handed an empty bag, return NULL
// this is in compliance with SQL standard
if (values.size() == 0)
return null;
java.lang.Comparable curMax = null;
Tuple curMaxTuple = null;
int n = 0;
for (Tuple t : values) {
if (reporter != null && ++n % PROGRESS_FREQUENCY == 0)
reporter.progress();
if (t == null) {
// just in case.
continue;
}
try {
Object o = t.get(pind);
if (o == null) {
// if the comparison field is null it will never be
// returned, we won't even compare.
continue;
}
java.lang.Comparable d = (java.lang.Comparable) o;
if (curMax == null) {
curMax = d;
curMaxTuple = t;
} else {
/**
* <pre>
* c > 0 iff ((sign==1 && d>curMax) || (sign==-1 && d<curMax))
* </pre>
*
* In both case we want to replace curMax/curMaxTuple by the
* new values
*
**/
int c = psign * d.compareTo(curMax);
if (c > 0) {
curMax = d;
curMaxTuple = t;
}
}
} catch (ExecException ee) {
throw ee;
} catch (Exception e) {
int errCode = -1;
String msg = "Error while computing ExtremalTupleByNthField in ExtremalTupleByNthField,";
throw new ExecException(msg, errCode, PigException.ERROR, e);
}
}
return curMaxTuple;
}
示例9: extreme
@SuppressWarnings("unchecked")
protected final static Tuple extreme(int pind, int psign, Tuple input,
PigProgressable reporter) throws ExecException {
if (input == null || input.size() == 0 || input.get(0) == null) {
return null;
}
DataBag values = (DataBag) input.get(0);
// if we were handed an empty bag, return NULL
// this is in compliance with SQL standard
if (values.size() == 0)
return null;
java.lang.Comparable curMax = null;
Tuple curMaxTuple = null;
int n = 0;
for (Tuple t : values) {
if (reporter != null && ++n % PROGRESS_FREQUENCY == 0)
reporter.progress();
if (t == null) {
// just in case.
continue;
}
try {
Object o = t.get(pind);
if (o == null) {
// if the comparison field is null it will never be
// returned, we won't even compare.
continue;
}
java.lang.Comparable d = (java.lang.Comparable) o;
if (curMax == null) {
curMax = d;
curMaxTuple = t;
} else {
/**
* <pre>
* c > 0 iff ((sign==1 && d>curMax) || (sign==-1 && d<curMax))
* </pre>
*
* In both case we want to replace curMax/curMaxTuple by the
* new values
*
**/
int c = psign * d.compareTo(curMax);
if (c > 0) {
curMax = d;
curMaxTuple = t;
}
}
} catch (ExecException ee) {
throw ee;
} catch (Exception e) {
int errCode = -1;
String msg = "Error while computing ExtremalTupleByNthField in ExtremalTupleByNthField,";
throw new ExecException(msg, errCode, PigException.ERROR, e);
}
}
return curMaxTuple;
}