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


Java DataType.FLOAT属性代码示例

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


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

示例1: process

public void process(int fieldPos, Schema.FieldSchema fs) {
    add("public "+typeName()+" getDummy_"+fieldPos+"() {");
    switch (fs.type) {
    case (DataType.INTEGER): add("    return 0;"); break;
    case (DataType.LONG): add("    return 0L;"); break;
    case (DataType.FLOAT): add("    return 0.0f;"); break;
    case (DataType.DOUBLE): add("    return 0.0;"); break;
    case (DataType.BOOLEAN): add("    return true;"); break;
    case (DataType.DATETIME): add("    return new DateTime();"); break;
    case (DataType.BIGDECIMAL): add("    return (BigDecimal)null;"); break;
    case (DataType.BIGINTEGER): add("    return (BigInteger)null;"); break;
    case (DataType.BYTEARRAY): add("    return (byte[])null;"); break;
    case (DataType.CHARARRAY): add("    return (String)null;"); break;
    case (DataType.TUPLE): add("    return (Tuple)null;"); break;
    case (DataType.BAG): add("    return (DataBag)null;"); break;
    case (DataType.MAP): add("    return (Map<String,Object>)null;"); break;
    default: throw new RuntimeException("Unsupported type");
    }
    add("}");
    addBreak();
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:21,代码来源:SchemaTupleClassGenerator.java

示例2: process

@Override
public void process(int fieldPos, Schema.FieldSchema fs) {
    add("public "+typeName()+" getDummy_"+fieldPos+"() {");
    switch (fs.type) {
    case (DataType.INTEGER): add("    return 0;"); break;
    case (DataType.LONG): add("    return 0L;"); break;
    case (DataType.FLOAT): add("    return 0.0f;"); break;
    case (DataType.DOUBLE): add("    return 0.0;"); break;
    case (DataType.BOOLEAN): add("    return true;"); break;
    case (DataType.DATETIME): add("    return new DateTime();"); break;
    case (DataType.BIGDECIMAL): add("    return (BigDecimal)null;"); break;
    case (DataType.BIGINTEGER): add("    return (BigInteger)null;"); break;
    case (DataType.BYTEARRAY): add("    return (byte[])null;"); break;
    case (DataType.CHARARRAY): add("    return (String)null;"); break;
    case (DataType.TUPLE): add("    return (Tuple)null;"); break;
    case (DataType.BAG): add("    return (DataBag)null;"); break;
    case (DataType.MAP): add("    return (Map<String,Object>)null;"); break;
    default: throw new RuntimeException("Unsupported type");
    }
    add("}");
    addBreak();
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:22,代码来源:SchemaTupleClassGenerator.java

示例3: convertToType

/**
 *
 * @param caster LoadCaster to be used to convert the bytes into a field.
 * @param bytes
 * @param fieldSchema schema of Bag or Tuple; pass in null if a simple type.
 * @param dataType type from DataType
 * @return converted object.
 * @throws IOException
 */
public static Object convertToType(LoadCaster caster, byte[] bytes,
        ResourceFieldSchema fieldSchema, byte dataType) throws IOException {
    switch (dataType) {
    case (DataType.BAG): return caster.bytesToBag(bytes, fieldSchema);
    case (DataType.BYTEARRAY): return new DataByteArray(bytes);
    case (DataType.CHARARRAY): return caster.bytesToCharArray(bytes);
    case (DataType.DOUBLE): return caster.bytesToDouble(bytes);
    case (DataType.FLOAT): return caster.bytesToFloat(bytes);
    case (DataType.INTEGER): return caster.bytesToInteger(bytes);
    case (DataType.BIGINTEGER): return caster.bytesToBigInteger(bytes);
    case (DataType.BIGDECIMAL): return caster.bytesToBigDecimal(bytes);
    case (DataType.LONG): return caster.bytesToLong(bytes);
    case (DataType.BOOLEAN): return caster.bytesToBoolean(bytes);
    case (DataType.DATETIME): return caster.bytesToDateTime(bytes);
    case (DataType.MAP): return caster.bytesToMap(bytes, fieldSchema);
    case (DataType.TUPLE): return caster.bytesToTuple(bytes, fieldSchema);
    default: throw new IOException("Unknown type " + dataType);
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:28,代码来源:CastUtils.java

示例4: getTypedObject

private TypedObject getTypedObject(Object data, FieldDetail detail) throws ExecException {
    if (data == null) {
        return null;
    }
    byte type = detail.type;
    switch (type) {
        case DataType.BOOLEAN:
            return TypeSystem.asTypedObject(DataType.toBoolean(data, type));
        case DataType.INTEGER:
        case DataType.LONG:
            return TypeSystem.asTypedObject(DataType.toLong(data, type));
        case DataType.FLOAT:
        case DataType.DOUBLE:
            return TypeSystem.asTypedObject(DataType.toDouble(data, type));
        case DataType.DATETIME:
            return TypeSystem.asTypedObject(new Timestamp(DataType.toDateTime(data, type).getMillis()));
        case DataType.BYTE:
        case DataType.BYTEARRAY:
        case DataType.CHARARRAY:
            return TypeSystem.asTypedObject(DataType.toString(data, type));
        case DataType.BIGINTEGER:
        case DataType.BIGDECIMAL:
            return TypeSystem.asTypedObject(DataType.toBigDecimal(data, type));
        default:
            //TUPLE, BAG, MAP, INTERNALMAP, GENERIC_WRITABLECOMPARABLE, ERROR, UNKNOWN, NULL and anything else
            return null;
    }
}
 
开发者ID:yahoo,项目名称:validatar,代码行数:28,代码来源:Sty.java

示例5: outputSchema

@Override
public Schema outputSchema(final Schema input) {
  try {
    if (input == null || input.size() == 0) {
      throw new IllegalArgumentException("Degenerate input schema to VarOptSampling");
    }

    // first element must be a bag, weightIdx_ element of tuples must be a float or double
    if (input.getField(0).type != DataType.BAG) {
      throw new IllegalArgumentException("VarOpt input must be a data bag: "
              + input.toString());
    }

    final Schema record = input.getField(0).schema; // record has a tuple in field 0
    final Schema fields = record.getField(0).schema;
    if (fields.getField(weightIdx_).type != DataType.DOUBLE
            && fields.getField(weightIdx_).type != DataType.FLOAT) {
      throw new IllegalArgumentException("weightIndex item of VarOpt tuple must be a "
              + "weight (double/float), found " + fields.getField(0).type
              + ": " + fields.toString());
    }

    final Schema weightedSampleSchema = new Schema();
    weightedSampleSchema.add(new Schema.FieldSchema(WEIGHT_ALIAS, DataType.DOUBLE));
    weightedSampleSchema.add(new Schema.FieldSchema(RECORD_ALIAS, record, DataType.TUPLE));

    return new Schema(new Schema.FieldSchema(getSchemaName(this
            .getClass().getName().toLowerCase(), record), weightedSampleSchema, DataType.BAG));
  }
  catch (final FrontendException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:DataSketches,项目名称:sketches-pig,代码行数:33,代码来源:VarOptSampling.java

示例6: outputSchema

@Override
public Schema outputSchema(final Schema input) {
  try {
    if (input == null || input.size() == 0) {
      throw new IllegalArgumentException("Degenerate input schema to VarOptSampling");
    }

    // first element must be a bag
    if (input.getField(0).type != DataType.BAG) {
      throw new IllegalArgumentException("VarOpt input must be a data bag: "
              + input.toString());
    }

    final Schema record = input.getField(0).schema; // record has a tuple in field 0
    final Schema fields = record.getField(0).schema;
    if (fields.getField(weightIdx_).type != DataType.DOUBLE
            && fields.getField(weightIdx_).type != DataType.FLOAT) {
      throw new IllegalArgumentException("weightIndex item of VarOpt tuple must be a "
              + "weight (double/float), found " + fields.getField(0).type
              + ": " + fields.toString());
    }

    return new Schema(new Schema.FieldSchema(getSchemaName(this
            .getClass().getName().toLowerCase(), input), DataType.BYTEARRAY));
  }
  catch (final FrontendException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:DataSketches,项目名称:sketches-pig,代码行数:29,代码来源:DataToVarOptSketch.java

示例7: testQuery86

@Test
public void testQuery86() throws Exception {
    LogicalPlan lp;
    String query = "a = load 'myfile' as (name:Chararray, age:Int, gpa:Float);" +
                   "b = group a by (name, age);" +
                   "store b into 'output';";
    lp = buildPlan( query );
    Operator store = lp.getSinks().get(0);
    LOCogroup cogroup = (LOCogroup) lp.getPredecessors(store).get(0);

    Schema.FieldSchema nameFs = new Schema.FieldSchema("name", DataType.CHARARRAY);
    Schema.FieldSchema ageFs = new Schema.FieldSchema("age", DataType.INTEGER);
    Schema.FieldSchema gpaFs = new Schema.FieldSchema("gpa", DataType.FLOAT);

    Schema groupSchema = new Schema(nameFs);
    groupSchema.add(ageFs);
    Schema.FieldSchema groupFs = new Schema.FieldSchema("group", groupSchema, DataType.TUPLE);

    Schema loadSchema = new Schema(nameFs);
    loadSchema.add(ageFs);
    loadSchema.add(gpaFs);

    Schema.FieldSchema bagFs = new Schema.FieldSchema("a", loadSchema, DataType.BAG);

    Schema cogroupExpectedSchema = new Schema(groupFs);
    cogroupExpectedSchema.add(bagFs);
    Assert.assertTrue(cogroup.getSchema().toString(false).equals("group:tuple(name:chararray,age:int),a:bag{:tuple(name:chararray,age:int,gpa:float)}"));
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:28,代码来源:TestLogicalPlanBuilder.java

示例8: getBagWithNulls

private DataBag getBagWithNulls(byte type) {
    DataBag bag = DefaultBagFactory.getInstance().newDefaultBag();
    for(int i = 0; i < 10; i ++) {
        Tuple t = TupleFactory.getInstance().newTuple();
        if (r.nextInt(4)%3 == 0){
            t.append(null);
        }else{
            switch(type) {
                case DataType.BOOLEAN:
                    t.append(r.nextBoolean());
                    break;
                case DataType.INTEGER:
                    t.append(r.nextInt(2));
                    break;
                case DataType.LONG:
                    t.append(r.nextLong() % 2L);
                    break;
                case DataType.FLOAT:
                    t.append( (i % 2 == 0 ? 1.0f : 0.0f));
                    break;
                case DataType.DOUBLE:
                    t.append( (i % 2 == 0 ? 1.0 : 0.0));
                    break;
                case DataType.DATETIME:
                    t.append(new DateTime(r.nextLong() % 2L));
                    break;
            }
        }
        t.append(1);
        t.append(0);
        bag.add(t);
    }
    return bag;
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:34,代码来源:TestPOBinCond.java

示例9: convertWithName

private Type convertWithName(FieldSchema fieldSchema, String name) {
  try {
    switch (fieldSchema.type) {
    case DataType.BAG:
      return convertBag(name, fieldSchema);
    case DataType.TUPLE:
      return convertTuple(name, fieldSchema, Repetition.OPTIONAL);
    case DataType.MAP:
      return convertMap(name, fieldSchema);
    case DataType.BOOLEAN:
      return primitive(name, PrimitiveTypeName.BOOLEAN);
    case DataType.CHARARRAY:
      return primitive(name, PrimitiveTypeName.BINARY, OriginalType.UTF8);
    case DataType.INTEGER:
      return primitive(name, PrimitiveTypeName.INT32);
    case DataType.LONG:
      return primitive(name, PrimitiveTypeName.INT64);
    case DataType.FLOAT:
      return primitive(name, PrimitiveTypeName.FLOAT);
    case DataType.DOUBLE:
      return primitive(name, PrimitiveTypeName.DOUBLE);
    case DataType.DATETIME:
      throw new UnsupportedOperationException();
    case DataType.BYTEARRAY:
      return primitive(name, PrimitiveTypeName.BINARY);
    default:
      throw new SchemaConversionException("Unknown type " + fieldSchema.type + " " + DataType.findTypeName(fieldSchema.type));
    }
  } catch (FrontendException e) {
    throw new SchemaConversionException("can't convert "+fieldSchema, e);
  }
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:32,代码来源:PigSchemaConverter.java

示例10: getResult

private Result getResult(PhysicalPlan plan, byte resultType) throws ExecException {
	ExpressionOperator Op = (ExpressionOperator) plan.getLeaves().get(0);
	Result res = null;

	switch (resultType) {
          case DataType.BYTEARRAY:
          case DataType.CHARARRAY:
          case DataType.DOUBLE:
          case DataType.FLOAT:
          case DataType.BOOLEAN:
          case DataType.INTEGER:
          case DataType.LONG:
          case DataType.BIGINTEGER:
          case DataType.BIGDECIMAL:
          case DataType.DATETIME:
          case DataType.TUPLE:
              res = Op.getNext(resultType);
              break;

          default: {
              int errCode = 2082;
              String msg = "Did not expect result of type: " +
                      DataType.findTypeName(resultType);
                  throw new ExecException(msg, errCode, PigException.BUG);
          }

          }
	return res;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:29,代码来源:POSort.java

示例11: translateWritableToPigDataType

protected Object translateWritableToPigDataType(Writable w, byte dataType) {
  switch(dataType) {
    case DataType.CHARARRAY: return ((Text) w).toString();
    case DataType.BYTEARRAY: return((DataByteArray) w).get();
    case DataType.BOOLEAN: return ((BooleanWritable) w).get();
    case DataType.INTEGER: return ((IntWritable) w).get();
    case DataType.LONG: return ((LongWritable) w).get();
    case DataType.FLOAT: return ((FloatWritable) w).get();
    case DataType.DOUBLE: return ((DoubleWritable) w).get();
    case DataType.BYTE: return ((ByteWritable) w).get();
    case DataType.DATETIME: return ((DateTimeWritable) w).get();
  }
  
  return null;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:15,代码来源:SequenceFileLoader.java

示例12: getNextBoolean

@Override
public Result getNextBoolean() throws ExecException {
    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);
    }

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

示例13: 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

示例14: generateData

Object generateData(byte type, String data) {
    switch (type) {
    case DataType.BOOLEAN:
        if (data.equalsIgnoreCase("true")) {
            return Boolean.TRUE;
        } else if (data.equalsIgnoreCase("false")) {
            return Boolean.FALSE;
        } else {
            return null;
        }
    case DataType.BYTEARRAY:
        return new DataByteArray(data.getBytes());
    case DataType.DOUBLE:
        return Double.valueOf(data);
    case DataType.FLOAT:
        return Float.valueOf(data);
    case DataType.INTEGER:
        return Integer.valueOf(data);
    case DataType.LONG:
        return Long.valueOf(data);
    case DataType.BIGINTEGER:
        return new BigInteger(data);
    case DataType.BIGDECIMAL:
        return new BigDecimal(data);
    case DataType.DATETIME:
        return new DateTime(data);
    case DataType.CHARARRAY:
        return data;
    default:
        return null;
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:32,代码来源:AugmentBaseDataVisitor.java

示例15: buildTuple

public Tuple buildTuple(int rank, JsonNode hit) {
    Tuple tuple = TupleFactory.getInstance().newTuple();

    for (VespaQuerySchema.AliasTypePair tupleElement : tupleSchema) {
        String alias = tupleElement.getAlias();
        Byte type = DataType.findTypeByName(tupleElement.getType());

        // reserved word
        if ("rank".equals(alias)) {
            tuple.append(rank);
        } else {
            JsonNode field = hit;
            String[] path = alias.split("/"); // move outside
            for (String p : path) {
                field = field.get(p);
                if (field == null) {
                    type = DataType.NULL; // effectively skip field as it is not found
                    break;
                }
            }
            switch (type) {
                case DataType.BOOLEAN:
                    tuple.append(field.asBoolean());
                    break;
                case DataType.INTEGER:
                    tuple.append(field.asInt());
                    break;
                case DataType.LONG:
                    tuple.append(field.asLong());
                    break;
                case DataType.FLOAT:
                case DataType.DOUBLE:
                    tuple.append(field.asDouble());
                    break;
                case DataType.DATETIME:
                    tuple.append(field.asText());
                    break;
                case DataType.CHARARRAY:
                    tuple.append(field.asText());
                    break;
                default:
                    // the rest of the data types are currently not supported
            }
        }
    }
    return tuple;
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:47,代码来源:VespaQuerySchema.java


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