本文整理汇总了Java中org.apache.pig.data.DataType.isAtomic方法的典型用法代码示例。如果您正苦于以下问题:Java DataType.isAtomic方法的具体用法?Java DataType.isAtomic怎么用?Java DataType.isAtomic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.pig.data.DataType
的用法示例。
在下文中一共展示了DataType.isAtomic方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: containsByteArrayOrEmtpyInSchema
import org.apache.pig.data.DataType; //导入方法依赖的package包/类
/**
* @param fs
* @return true if fs is of complex type and contains a bytearray
* or empty inner schema
* @throws FrontendException
*/
private boolean containsByteArrayOrEmtpyInSchema(LogicalFieldSchema fs)
throws FrontendException {
if(fs.type == DataType.BYTEARRAY)
return true;
if(DataType.isAtomic(fs.type))
return false;
if(fs.schema == null || fs.schema.size() == 0)
return true;
for(LogicalFieldSchema inFs : fs.schema.getFields()){
if(containsByteArrayOrEmtpyInSchema(inFs))
return true;
}
return false;
}
示例2: getDescription
import org.apache.pig.data.DataType; //导入方法依赖的package包/类
private String getDescription(boolean printAlias) {
StringBuilder sb = new StringBuilder();
if (printAlias && this.name != null)
sb.append(this.name).append(":");
if (DataType.isAtomic(this.type)) {
sb.append(DataType.findTypeName(this.type));
} else {
//if (this.schema!=null)
stringifyResourceSchema(sb, this.schema, this.type, printAlias);
}
return sb.toString();
}
示例3: extractField
import org.apache.pig.data.DataType; //导入方法依赖的package包/类
@Override
protected Object extractField(Object target) {
List<String> fieldNames = getFieldNames();
for (int index = 0; index < fieldNames.size(); index++) {
String fieldName = fieldNames.get(index);
if (target instanceof PigTuple) {
PigTuple pt = (PigTuple) target;
ResourceFieldSchema[] fields = pt.getSchema().getSchema().getFields();
boolean foundField = false;
for (int i = 0; i < fields.length && !foundField; i++) {
ResourceFieldSchema field = fields[i];
if (fieldName.equals(field.getName())) {
foundField = true;
byte type = field.getType();
try {
Object object = pt.getTuple().get(i);
if (DataType.isAtomic(type)) {
target = object.toString();
}
else if (type == DataType.TUPLE) {
PigTuple rpt = new PigTuple(field.getSchema());
if (object instanceof PigTuple) {
rpt.setTuple(((PigTuple) object).getTuple());
}
else {
rpt.setTuple((Tuple) object);
}
target = rpt;
}
else {
Assert.isTrue(false, String.format("Unsupported data type [%s] for field [%s]; use only 'primitives' or 'tuples'", DataType.findTypeName(type), fieldName));
}
} catch (ExecException ex) {
throw new EsHadoopIllegalStateException(String.format("Cannot retrieve field [%s]", fieldName), ex);
}
}
}
}
else {
return NOT_FOUND;
}
}
return target;
}
示例4: stringifySchema
import org.apache.pig.data.DataType; //导入方法依赖的package包/类
public static void stringifySchema(StringBuilder sb,
Schema schema,
byte type,
int indentLevel)
throws FrontendException{
if (type == DataType.TUPLE) {
sb.append("(") ;
}
else if (type == DataType.BAG) {
sb.append("{") ;
}
indentLevel++;
if (schema != null) {
boolean isFirst = true ;
for (int i=0; i< schema.size() ;i++) {
if (!isFirst) {
sb.append(",") ;
}
else {
isFirst = false ;
}
indent(sb, indentLevel);
FieldSchema fs = schema.getField(i) ;
if(fs == null) {
continue;
}
if (fs.alias != null) {
sb.append(fs.alias);
sb.append(": ");
}
if (DataType.isAtomic(fs.type)) {
sb.append(DataType.findTypeName(fs.type)) ;
}
else if ( (fs.type == DataType.TUPLE) ||
(fs.type == DataType.BAG) ) {
// safety net
if (schema != fs.schema) {
stringifySchema(sb, fs.schema, fs.type, indentLevel) ;
}
else {
throw new AssertionError("Schema refers to itself "
+ "as inner schema") ;
}
} else if (fs.type == DataType.MAP) {
sb.append(DataType.findTypeName(fs.type) + "[");
if (fs.schema!=null)
stringifySchema(sb, fs.schema, fs.type, indentLevel);
sb.append("]");
} else {
sb.append(DataType.findTypeName(fs.type)) ;
}
}
}
indentLevel--;
indent(sb, indentLevel);
if (type == DataType.TUPLE) {
sb.append(")") ;
}
else if (type == DataType.BAG) {
sb.append("}") ;
}
}