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


Java DataType.MAP属性代码示例

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


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

示例1: findPigDataType

/**
    * Returns the pig DataType for the hive type
    * 
    * @param hiveType
    * @return byte from DataType
    */
   public static byte findPigDataType(String hiveType) {
hiveType = hiveType.toLowerCase();

if (hiveType.equals("string"))
    return DataType.CHARARRAY;
else if (hiveType.equals("int"))
    return DataType.INTEGER;
else if (hiveType.equals("bigint") || hiveType.equals("long"))
    return DataType.LONG;
else if (hiveType.equals("float"))
    return DataType.FLOAT;
else if (hiveType.equals("double"))
    return DataType.DOUBLE;
else if (hiveType.equals("boolean"))
    return DataType.BOOLEAN;
else if (hiveType.equals("byte"))
    return DataType.INTEGER;
else if (hiveType.contains("array"))
    return DataType.TUPLE;
else if (hiveType.contains("map"))
    return DataType.MAP;
else
    return DataType.ERROR;
   }
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:30,代码来源:HiveRCSchemaUtil.java

示例2: typeName

public String typeName(byte type) {
    switch(type) {
        case (DataType.INTEGER): return "int";
        case (DataType.LONG): return "long";
        case (DataType.FLOAT): return "float";
        case (DataType.DOUBLE): return "double";
        case (DataType.BYTEARRAY): return "byte[]";
        case (DataType.CHARARRAY): return "String";
        case (DataType.BOOLEAN): return "boolean";
        case (DataType.DATETIME): return "DateTime";
        case (DataType.BIGDECIMAL): return "BigDecimal";
        case (DataType.BIGINTEGER): return "BigInteger";
        case (DataType.TUPLE): return "Tuple";
        case (DataType.BAG): return "DataBag";
        case (DataType.MAP): return "Map";
        default: throw new RuntimeException("Can't return String for given type " + DataType.findTypeName(type));
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:18,代码来源:SchemaTupleClassGenerator.java

示例3: consumeComplexType

private Object consumeComplexType(PushbackInputStream in, ResourceFieldSchema complexFieldSchema) throws IOException {
    Object field;
    switch (complexFieldSchema.getType()) {
    case DataType.BAG:
        field = consumeBag(in, complexFieldSchema);
        break;
    case DataType.TUPLE:
        field = consumeTuple(in, complexFieldSchema);
        break;
    case DataType.MAP:
        field = consumeMap(in, complexFieldSchema);
        break;
    default:
        throw new IOException("Unknown complex data type");
    }
    return field;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:17,代码来源:Utf8StorageConverter.java

示例4: toCanonicalType

private Type toCanonicalType(final LogicalSchema.LogicalFieldSchema field) {
    if (PigTypeMapping.getPIG_TO_CANONICAL().containsKey(field.type)) {
        return PigTypeMapping.getPIG_TO_CANONICAL().get(field.type);
    }
    switch (field.type) {
        case DataType.MAP:
            return toCanonicalMapType(field);
        case DataType.BAG:
            return toCanonicalArrayType(field);
        case DataType.TUPLE:
            return toCanonicalRowType(field);
        default:
    }
    throw new IllegalArgumentException(String.format("Invalid for Pig converter: '%s'", field.toString()));
}
 
开发者ID:Netflix,项目名称:metacat,代码行数:15,代码来源:PigTypeConverter.java

示例5: visit

@Override
public void visit(MapLookupExpression map)
throws FrontendException{
    if(map.getMap().getType() != DataType.MAP) {
        // insert cast if the predecessor does not
        // return map
        insertCast(map, DataType.MAP, map.getMap());
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:9,代码来源:TypeCheckingExpVisitor.java

示例6: outputSchema

public Schema outputSchema(Schema input) {
	try{
           Schema mapSchema = new Schema();
           mapSchema.add(new Schema.FieldSchema("value", DataType.CHARARRAY));

           return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input),
                                                  mapSchema, DataType.MAP));
       }catch (Exception e){
          return null;
       }
}
 
开发者ID:JamesLampton,项目名称:piggybank-squeal,代码行数:11,代码来源:JSONPath.java

示例7: getNextBoolean

@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,代码行数:37,代码来源:POIsNull.java

示例8: ResourceFieldSchema

/**
 * Construct using a {@link org.apache.pig.impl.logicalLayer.schema.Schema.FieldSchema} as the template.
 * @param fieldSchema fieldSchema to copy from
 */
public ResourceFieldSchema(FieldSchema fieldSchema) {
    type = fieldSchema.type;
    name = fieldSchema.alias;
    description = "autogenerated from Pig Field Schema";
    Schema inner = fieldSchema.schema;
    
    // allow partial schema 
    if ((type == DataType.BAG || type == DataType.TUPLE || type == DataType.MAP)
            && inner != null) {
        schema = new ResourceSchema(inner);
    } else {
        schema = null;
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:18,代码来源:ResourceSchema.java

示例9: TOBAG

public TOBAG(String bagColName, String tupleColName, String fieldType) {

        if ( bagColName== null || tupleColName == null  || fieldType == null)  {
	    throw new RuntimeException("The bagColName  and fieldType cannot be null");
        }

    	this.bagColName   = bagColName;	
    	this.tupleColName = tupleColName;	

        if ( fieldType.equalsIgnoreCase( "CHARARRAY" )){ 
             this.fieldType = DataType.CHARARRAY;

        } else if ( fieldType.equalsIgnoreCase( "DOUBLE" )){ 
            this.fieldType = DataType.DOUBLE;

        } else if ( fieldType.equalsIgnoreCase( "FLOAT" )){ 
            this.fieldType = DataType.FLOAT; 

        } else if ( fieldType.equalsIgnoreCase( "BOOLEAN" )){ 
            this.fieldType = DataType.BOOLEAN; 

        } else if ( fieldType.equalsIgnoreCase( "INTEGER" )){ 
            this.fieldType = DataType.INTEGER;

        } else if ( fieldType.equalsIgnoreCase( "LONG" )){ 
            this.fieldType = DataType.LONG; 

        } else if ( fieldType.equalsIgnoreCase( "MAP" )){ 
            this.fieldType = DataType.MAP; 
        } else {
	    throw new RuntimeException("This type"+ fieldType +"is not supported in TOBAG");
        }

    }
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:34,代码来源:TOBAG.java

示例10: jsToPigTuple

private Tuple jsToPigTuple(Scriptable object, Schema schema, int depth) throws FrontendException, ExecException {
    debugConvertJSToPig(depth, "Tuple", object, schema);
    Tuple t = TupleFactory.getInstance().newTuple(schema.size());
    for (int i = 0; i < schema.size(); i++) {
        FieldSchema field = schema.getField(i);
        if (object.has(field.alias, jsScriptEngine.getScope())) {
            Object attr = object.get(field.alias, object);
            Object value;
            if (field.type == DataType.BAG) {
                value = jsToPigBag((Scriptable)attr, field.schema, depth + 1);
            } else if (field.type == DataType.TUPLE) {
                value = jsToPigTuple((Scriptable)attr, field.schema, depth + 1);
            } else if (field.type == DataType.MAP) {
                value = jsToPigMap((Scriptable)attr, field.schema, depth + 1);
            } else if (attr instanceof NativeJavaObject) {
                value = ((NativeJavaObject)attr).unwrap();
            } else if (attr instanceof Undefined) {
                value = null;
            } else {
                value = attr;
            }
            t.set(i, value);
        } else {
            if (LOG.isDebugEnabled()) {
                LOG.debug("X( "+field.alias+" NOT FOUND");
            }
        }
    }
    debugReturn(depth, t);
    return t;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:31,代码来源:JsFunction.java

示例11: toString

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,代码行数:28,代码来源:LogicalSchema.java

示例12: getNextBoolean

@Override
public Result getNextBoolean() throws ExecException {
  try {
    Result left, right;

    switch (operandType) {
    case DataType.BYTEARRAY:
    case DataType.DOUBLE:
    case DataType.FLOAT:
    case DataType.BOOLEAN:
    case DataType.INTEGER:
    case DataType.BIGINTEGER:
    case DataType.BIGDECIMAL:
    case DataType.LONG:
    case DataType.DATETIME:
    case DataType.CHARARRAY:
    case DataType.TUPLE:
    case DataType.MAP: {
        Result r = accumChild(null, operandType);
        if (r != null) {
            return r;
        }
        left = lhs.getNext(operandType);
        right = rhs.getNext(operandType);
        return doComparison(left, right);
    }

    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);
    }

    }
  } catch (RuntimeException e) {
      throw new ExecException("exception while executing " + this.toString() + ": " + e.toString(), 2067, PigException.BUG, e);
  }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:39,代码来源:EqualToExpr.java

示例13: outputSchema

@Override
public Schema outputSchema(Schema input) {
    return new Schema(
        new Schema.FieldSchema("object", DataType.MAP)
    );
}
 
开发者ID:mortardata,项目名称:pig-json,代码行数:6,代码来源:FromJsonInferSchema.java

示例14: getPigType

/**
 * Defines a mapping of HCatalog type to Pig type; not every mapping is exact, 
 * see {@link #extractPigObject(Object,
 * com.cloudera.recordservice.core.Schema.TypeDesc)}
 * See http://pig.apache.org/docs/r0.12.0/basic.html#data-types
 * See {@link org.apache.hive.hcatalog.pig.HCatBaseStorer#validateSchema(
 * Schema.FieldSchema, HCatFieldSchema, Schema, HCatSchema, int)}
 * for Pig->Hive type mapping.
 */ 
static public byte getPigType(Type type) throws IOException {
  if (type == Type.STRING || type == Type.CHAR || type == Type.VARCHAR) {
    //CHARARRAY is unbounded so Hive->Pig is lossless
    return DataType.CHARARRAY;
  }

  if ((type == Type.INT) || (type == Type.SMALLINT) || (type == Type.TINYINT)) {
    return DataType.INTEGER;
  }

  if (type == Type.ARRAY) {
    return DataType.BAG;
  }

  if (type == Type.STRUCT) {
    return DataType.TUPLE;
  }

  if (type == Type.MAP) {
    return DataType.MAP;
  }

  if (type == Type.BIGINT) {
    return DataType.LONG;
  }

  if (type == Type.FLOAT) {
    return DataType.FLOAT;
  }

  if (type == Type.DOUBLE) {
    return DataType.DOUBLE;
  }

  if (type == Type.BINARY) {
    return DataType.BYTEARRAY;
  }

  if (type == Type.BOOLEAN && pigHasBooleanSupport) {
    return DataType.BOOLEAN;
  }
  if(type == Type.DECIMAL) {
    //Hive is more restrictive, so Hive->Pig works
    return DataType.BIGDECIMAL;
  }
  if(type == Type.DATE || type == Type.TIMESTAMP) {
    //Hive Date is representable as Pig DATETIME
    return DataType.DATETIME;
  }

  throw new PigException("HCatalog column type '" + type.toString()
      + "' is not supported in Pig as a column type", PIG_EXCEPTION_CODE);
}
 
开发者ID:cloudera,项目名称:RecordServiceClient,代码行数:62,代码来源:PigHCatUtil.java

示例15: pickTest

/**
 * To show that it does not have any type specific
 * code
 */
private void pickTest(byte t, boolean[] inner) throws ExecException, IOException {
    Random r = new Random();
    switch (t) {
    case DataType.BAG:
        runTest(GenRandomData.genRandSmallTupDataBag(r, 10, 100), inner, DataType.BAG);
        break;
    case DataType.BOOLEAN:
        runTest(r.nextBoolean(), inner, DataType.BOOLEAN);
        break;
    case DataType.BYTEARRAY:
        runTest(GenRandomData.genRandDBA(r), inner, DataType.BYTEARRAY);
        break;
    case DataType.BIGCHARARRAY: {
        String s = GenRandomData.genRandString(r);
        for (; s.length() < 65535;) {
            s += GenRandomData.genRandString(r);
        }
        runTest(s, inner, DataType.CHARARRAY);
        break;
    }
    case DataType.CHARARRAY:
        runTest(GenRandomData.genRandString(r), inner, DataType.CHARARRAY);
        break;
    case DataType.DOUBLE:
        runTest(r.nextDouble(), inner, DataType.DOUBLE);
        break;
    case DataType.FLOAT:
        runTest(r.nextFloat(), inner, DataType.FLOAT);
        break;
    case DataType.INTEGER:
        runTest(r.nextInt(), inner, DataType.INTEGER);
        break;
    case DataType.LONG:
        runTest(r.nextLong(), inner, DataType.LONG);
        break;
    case DataType.DATETIME:
        runTest(new DateTime(r.nextLong()), inner, DataType.DATETIME);
        break;
    case DataType.MAP:
    case DataType.INTERNALMAP:
    case DataType.BYTE:
        return; // map not key type
    case DataType.TUPLE:
        runTest(GenRandomData.genRandSmallBagTuple(r, 10, 100), inner, DataType.TUPLE);
        break;
    case DataType.BIGINTEGER:
        runTest(new BigInteger(256, r), inner, DataType.BIGINTEGER);
        break;
    case DataType.BIGDECIMAL:
        runTest(new BigDecimal(r.nextDouble()), inner, DataType.BIGDECIMAL);
        break;
    default:
        fail("No test case for type " + DataType.findTypeName(t));
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:59,代码来源:TestPackage.java


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