当前位置: 首页>>代码示例>>Java>>正文


Java PigException.ERROR属性代码示例

本文整理汇总了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;
    }
}
 
开发者ID:christiangda,项目名称:pigiptools,代码行数:40,代码来源:Encode.java

示例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;
    }
}
 
开发者ID:christiangda,项目名称:pigiptools,代码行数:36,代码来源:IsDecodable.java

示例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)));
}
 
开发者ID:christiangda,项目名称:pigiptools,代码行数:32,代码来源:Base64Encode.java

示例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;
    }
}
 
开发者ID:christiangda,项目名称:pigiptools,代码行数:37,代码来源:Base64Decode.java

示例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;
    }
}
 
开发者ID:christiangda,项目名称:pigiptools,代码行数:36,代码来源:IsEncodable.java

示例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;
    }
}
 
开发者ID:christiangda,项目名称:pigiptools,代码行数:40,代码来源:Decode.java

示例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;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:13,代码来源:ExtremalTupleByNthField.java

示例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;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:60,代码来源:ExtremalTupleByNthField.java

示例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;
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:63,代码来源:ExtremalTupleByNthField.java


注:本文中的org.apache.pig.PigException.ERROR属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。