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


Java DataType.findTypeName方法代码示例

本文整理汇总了Java中org.apache.pig.data.DataType.findTypeName方法的典型用法代码示例。如果您正苦于以下问题:Java DataType.findTypeName方法的具体用法?Java DataType.findTypeName怎么用?Java DataType.findTypeName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.pig.data.DataType的用法示例。


在下文中一共展示了DataType.findTypeName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertPrimitiveType

import org.apache.pig.data.DataType; //导入方法依赖的package包/类
/**
 * Convert Pig primitive type to Avro type
 * 
 */
protected static Schema convertPrimitiveType(byte pigType) throws IOException {

    if (pigType == DataType.BOOLEAN) {
        return AvroStorageUtils.BooleanSchema;
    } else if (pigType == DataType.BYTEARRAY) {
        return AvroStorageUtils.BytesSchema;
    } else if (pigType == DataType.CHARARRAY
                                    || pigType == DataType.BIGCHARARRAY) {
        return AvroStorageUtils.StringSchema;
    } else if (pigType == DataType.DOUBLE) {
        return AvroStorageUtils.DoubleSchema;
    } else if (pigType == DataType.FLOAT) {
        return AvroStorageUtils.FloatSchema;
    } else if (pigType == DataType.INTEGER) {
        return AvroStorageUtils.IntSchema;
    } else if (pigType == DataType.LONG) {
        return AvroStorageUtils.LongSchema;
    } else
        throw new IOException("unsupported pig type:"
                                        + DataType.findTypeName(pigType));

}
 
开发者ID:linkedin,项目名称:Cubert,代码行数:27,代码来源:PigSchema2Avro.java

示例2: generateIncompatibleTypesMessage

import org.apache.pig.data.DataType; //导入方法依赖的package包/类
private String generateIncompatibleTypesMessage(BinaryExpression binOp)
throws FrontendException {
    String msg = binOp.toString();
    if (currentRelOp.getAlias()!=null){
        msg = "In alias " + currentRelOp.getAlias() + ", ";
    }
    LogicalFieldSchema lhsFs = binOp.getLhs().getFieldSchema();
    LogicalFieldSchema rhsFs = binOp.getRhs().getFieldSchema();

    msg = msg + "incompatible types in " + binOp.getName() + " Operator"
    + " left hand side:" + DataType.findTypeName(lhsFs.type)
    + (lhsFs.schema == null ? "" : " " + lhsFs.schema.toString(false) + " ")
    + " right hand side:" + DataType.findTypeName(rhsFs.type)
    + (rhsFs.schema == null ? "" : " " + rhsFs.schema.toString(false) + " ") ;
    return msg;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:17,代码来源:TypeCheckingExpVisitor.java

示例3: ShortenField

import org.apache.pig.data.DataType; //导入方法依赖的package包/类
static String ShortenField(Object d) throws ExecException {
    if (d instanceof Tuple)
        return ShortenField((Tuple) d);
    else if (d instanceof DataBag)
        return ShortenField((DataBag) d);
    else {
        // System.out.println("Unrecognized data-type received!!!");
        // return null;
        if (DataType.findTypeName(d) != null) {
            if (d == null)
                return "";
            else
                return d.toString();
        }
    }
    System.out.println("Unrecognized data-type received!!!");
    return null;
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:19,代码来源:DisplayExamples.java

示例4: outputSchema

import org.apache.pig.data.DataType; //导入方法依赖的package包/类
public Schema outputSchema(Schema input) {
	// Check that we were passed one field
	if ( input.size() != 1 )
		throw new RuntimeException("Excpeted input (String), input need only one field");
	try{
		// Get the types for column and check it.
		// If they are wring, figure out what types were passed and give a good error message.
		if (input.getField(0).type != DataType.CHARARRAY){
			String msg = "Excepted input (String), received schema (";
			msg += DataType.findTypeName(input.getField(0).type);
			msg += ")";
			throw new RuntimeException(msg);
		}
	} catch ( Exception e) {
		throw new RuntimeException(e);
	}
	// Assemble output schema
	Schema output = new Schema();
	FieldSchema paramMap = new FieldSchema("urlparams", DataType.MAP);
	output.add(paramMap);
	return output;
}
 
开发者ID:caesar0301,项目名称:piggybox,代码行数:23,代码来源:ExtractUrlParams.java

示例5: exec

import org.apache.pig.data.DataType; //导入方法依赖的package包/类
@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,代码行数:41,代码来源:Encode.java

示例6: exec

import org.apache.pig.data.DataType; //导入方法依赖的package包/类
@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,代码行数:37,代码来源:IsDecodable.java

示例7: exec

import org.apache.pig.data.DataType; //导入方法依赖的package包/类
@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,代码行数:33,代码来源:Base64Encode.java

示例8: exec

import org.apache.pig.data.DataType; //导入方法依赖的package包/类
@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,代码行数:38,代码来源:Base64Decode.java

示例9: exec

import org.apache.pig.data.DataType; //导入方法依赖的package包/类
@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,代码行数:37,代码来源:IsEncodable.java

示例10: exec

import org.apache.pig.data.DataType; //导入方法依赖的package包/类
@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,代码行数:41,代码来源:Decode.java

示例11: getNextBoolean

import org.apache.pig.data.DataType; //导入方法依赖的package包/类
@Override
public Result getNextBoolean() throws ExecException {

    Result res = null;
    switch(operandType) {
    case DataType.BYTEARRAY:
    case DataType.DOUBLE:
    case DataType.INTEGER:
    case DataType.BIGINTEGER:
    case DataType.BIGDECIMAL:
    case DataType.CHARARRAY:
    case DataType.BOOLEAN:
    case DataType.LONG:
    case DataType.FLOAT:
    case DataType.DATETIME:
    case DataType.MAP:
    case DataType.TUPLE:
    case DataType.BAG:
        res = expr.getNext(operandType);
        if(res.returnStatus == POStatus.STATUS_OK) {
            if (res.result == null) {
                res.result = true;
            } else {
                res.result = false;
            }
            illustratorMarkup(null, res.result, (Boolean) res.result ? 0 : 1);
        }
        return res;
    default: {
        int errCode = 2067;
        String msg = this.getClass().getSimpleName() + " does not know how to " +
        "handle type: " + DataType.findTypeName(operandType);
        throw new ExecException(msg, errCode, PigException.BUG);
    }

    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:38,代码来源:POIsNull.java

示例12: toString

import org.apache.pig.data.DataType; //导入方法依赖的package包/类
public String toString(boolean verbose) {
    String uidString = "";
    if (verbose)
        uidString="#" + uid;
    
    String aliasToPrint = "";
    if (alias!=null)
        aliasToPrint = alias;
    
    if( type == DataType.BAG ) {
        if( schema == null ) {
            return ( aliasToPrint + uidString + ":bag{}" );
        }
        return ( aliasToPrint + uidString + ":bag{" + schema.toString(verbose) + "}" );
    } else if( type == DataType.TUPLE ) {
        if( schema == null ) {
            return ( aliasToPrint + uidString + ":tuple()" );
        }
        return ( aliasToPrint + uidString + ":tuple(" + schema.toString(verbose) + ")" );
    } else if (type == DataType.MAP) {
        if (schema == null ) {
            return (aliasToPrint + uidString + ":map");
        } else {
            return (aliasToPrint + uidString + ":map(" + schema.toString(verbose) + ")");
        }
    }
    return ( aliasToPrint + uidString + ":" + DataType.findTypeName(type) );
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:29,代码来源:LogicalSchema.java

示例13: mod

import org.apache.pig.data.DataType; //导入方法依赖的package包/类
protected Number mod(Number a, Number b, byte dataType) throws ExecException {
    switch(dataType) {
    case DataType.INTEGER:
        return Integer.valueOf((Integer) a % (Integer) b);
    case DataType.LONG:
        return Long.valueOf((Long) a % (Long) b);
    case DataType.BIGINTEGER:
        return ((BigInteger)a).mod((BigInteger)b);
    default:
        throw new ExecException("called on unsupported Number class " + DataType.findTypeName(dataType));
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:13,代码来源:Mod.java

示例14: name

import org.apache.pig.data.DataType; //导入方法依赖的package包/类
@Override
public String name() {
    if (DataType.isSchemaType(resultType))
        return "Cast" + "[" + DataType.findTypeName(resultType)+":"
        + fieldSchema.calcCastString() + "]" + " - "
        + mKey.toString();
    else
        return "Cast" + "[" + DataType.findTypeName(resultType) + "]" + " - "
            + mKey.toString();
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:11,代码来源:POCast.java

示例15: getNext

import org.apache.pig.data.DataType; //导入方法依赖的package包/类
/**
 * Implementations that call into the different versions of getNext are often
 * identical, differing only in the signature of the getNext() call they make.
 * This method allows to cut down on some of the copy-and-paste.
 * @param dataType Describes the type of obj; a byte from DataType.
 *
 * @return result Result of applying this Operator to the Object.
 * @throws ExecException
 */
public Result getNext(byte dataType) throws ExecException {
    try {
        switch (dataType) {
        case DataType.BAG:
            return getNextDataBag();
        case DataType.BOOLEAN:
            return getNextBoolean();
        case DataType.BYTEARRAY:
            return getNextDataByteArray();
        case DataType.CHARARRAY:
            return getNextString();
        case DataType.DOUBLE:
            return getNextDouble();
        case DataType.FLOAT:
            return getNextFloat();
        case DataType.INTEGER:
            return getNextInteger();
        case DataType.LONG:
            return getNextLong();
        case DataType.BIGINTEGER:
            return getNextBigInteger();
        case DataType.BIGDECIMAL:
            return getNextBigDecimal();
        case DataType.DATETIME:
            return getNextDateTime();
        case DataType.MAP:
            return getNextMap();
        case DataType.TUPLE:
            return getNextTuple();
        default:
            throw new ExecException("Unsupported type for getNext: " + DataType.findTypeName(dataType));
        }
    } catch (RuntimeException e) {
        throw new ExecException("Exception while executing " + this.toString() + ": " + e.toString(), e);
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:46,代码来源:PhysicalOperator.java


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