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


Java DataType.BIGDECIMAL属性代码示例

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


在下文中一共展示了DataType.BIGDECIMAL属性的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: subtract

protected Number subtract(Number a, Number b, byte dataType) throws ExecException {
    switch(dataType) {
    case DataType.DOUBLE:
        return Double.valueOf((Double) a - (Double) b);
    case DataType.INTEGER:
        return Integer.valueOf((Integer) a - (Integer) b);
    case DataType.LONG:
        return Long.valueOf((Long) a - (Long) b);
    case DataType.FLOAT:
        return Float.valueOf((Float) a - (Float) b);
    case DataType.BIGINTEGER:
        return ((BigInteger) a).subtract((BigInteger) b);
    case DataType.BIGDECIMAL:
        return ((BigDecimal) a).subtract((BigDecimal) b);
    default:
        throw new ExecException("called on unsupported Number class " + DataType.findTypeName(dataType));
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:18,代码来源:Subtract.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);
    case (DataType.TUPLE): return caster.bytesToTuple(bytes, fieldSchema);
    default: throw new IOException("Unknown type " + dataType);
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:28,代码来源:CastUtils.java

示例4: add

protected Number add(Number a, Number b, byte dataType) throws ExecException {
    switch(dataType) {
    case DataType.DOUBLE:
        return Double.valueOf((Double) a + (Double) b);
    case DataType.INTEGER:
        return Integer.valueOf((Integer) a + (Integer) b);
    case DataType.LONG:
        return Long.valueOf((Long) a + (Long) b);
    case DataType.FLOAT:
        return Float.valueOf((Float) a + (Float) b);
    case DataType.BIGINTEGER:
        return ((BigInteger) a).add((BigInteger) b);
    case DataType.BIGDECIMAL:
        return ((BigDecimal) a).add((BigDecimal) b);
    default:
        throw new ExecException("called on unsupported Number class " + DataType.findTypeName(dataType));
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:18,代码来源:Add.java

示例5: equalsZero

protected boolean equalsZero(Number a, byte dataType) throws ExecException {
    switch (dataType) {
    case DataType.DOUBLE:
        return ((Double) a).equals(0.0);
    case DataType.INTEGER:
        return ((Integer) a).equals(0);
    case DataType.LONG:
        return ((Long) a).equals(0L);
    case DataType.FLOAT:
        return ((Float) a).equals(0.0f);
    case DataType.BIGINTEGER:
        return BigInteger.ZERO.equals((BigInteger) a);
    case DataType.BIGDECIMAL:
        return BigDecimal.ZERO.equals((BigDecimal) a);
    default:
        throw new ExecException("Called on unsupported Number class " + DataType.findTypeName(dataType));
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:18,代码来源:Divide.java

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

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

示例8: getNextBoolean

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

    switch (operandType) {
    case DataType.BYTEARRAY:
    case DataType.DOUBLE:
    case DataType.FLOAT:
    case DataType.INTEGER:
    case DataType.BIGINTEGER:
    case DataType.BIGDECIMAL:
    case DataType.LONG:
    case DataType.DATETIME:
    case DataType.CHARARRAY: {
        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,代码行数:31,代码来源:LTOrEqualToExpr.java

示例9: findTypeFromNullableWritable

public static byte findTypeFromNullableWritable(PigNullableWritable o) throws ExecException {
    if (o instanceof NullableBooleanWritable)
        return DataType.BOOLEAN;
    else if (o instanceof NullableBytesWritable)
        return DataType.BYTEARRAY;
    else if (o instanceof NullableText)
        return DataType.CHARARRAY;
    else if (o instanceof NullableFloatWritable)
        return DataType.FLOAT;
    else if (o instanceof NullableDoubleWritable)
        return DataType.DOUBLE;
    else if (o instanceof NullableIntWritable)
        return DataType.INTEGER;
    else if (o instanceof NullableLongWritable)
        return DataType.LONG;
    else if (o instanceof NullableBigIntegerWritable)
        return DataType.BIGINTEGER;
    else if (o instanceof NullableBigDecimalWritable)
        return DataType.BIGDECIMAL;
    else if (o instanceof NullableDateTimeWritable)
        return DataType.DATETIME;
    else if (o instanceof NullableBag)
        return DataType.BAG;
    else if (o instanceof NullableTuple)
        return DataType.TUPLE;
    else {
        int errCode = 2044;
        String msg = "Cannot find Pig type for " + o.getClass().getName();
        throw new ExecException(msg, errCode, PigException.BUG);
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:31,代码来源:HDataType.java

示例10: getNext

/**
 * 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,代码行数:45,代码来源:PhysicalOperator.java

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

示例12: getNextBoolean

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

    switch (operandType) {
    case DataType.BYTEARRAY:
    case DataType.DOUBLE:
    case DataType.FLOAT:
    case DataType.INTEGER:
    case DataType.LONG:
    case DataType.BIGINTEGER:
    case DataType.BIGDECIMAL:
    case DataType.DATETIME:
    case DataType.CHARARRAY: {
        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-streaming,代码行数:31,代码来源:GreaterThanExpr.java

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

示例14: collectCastWarning

/***
 * Helper for collecting warning when casting is inserted
 * to the plan (implicit casting)
 *
 * @param node
 * @param originalType
 * @param toType
 */
static void collectCastWarning(Operator node,
        byte originalType,
        byte toType,
        CompilationMessageCollector msgCollector
) {
    String originalTypeName = DataType.findTypeName(originalType) ;
    String toTypeName = DataType.findTypeName(toType) ;
    String opName= node.getClass().getSimpleName() ;
    PigWarning kind = null;
    switch(toType) {
    case DataType.BAG:
        kind = PigWarning.IMPLICIT_CAST_TO_BAG;
        break;
    case DataType.CHARARRAY:
        kind = PigWarning.IMPLICIT_CAST_TO_CHARARRAY;
        break;
    case DataType.DOUBLE:
        kind = PigWarning.IMPLICIT_CAST_TO_DOUBLE;
        break;
    case DataType.FLOAT:
        kind = PigWarning.IMPLICIT_CAST_TO_FLOAT;
        break;
    case DataType.INTEGER:
        kind = PigWarning.IMPLICIT_CAST_TO_INT;
        break;
    case DataType.LONG:
        kind = PigWarning.IMPLICIT_CAST_TO_LONG;
        break;
    case DataType.BOOLEAN:
        kind = PigWarning.IMPLICIT_CAST_TO_BOOLEAN;
        break;
    case DataType.DATETIME:
        kind = PigWarning.IMPLICIT_CAST_TO_DATETIME;
        break;
    case DataType.MAP:
        kind = PigWarning.IMPLICIT_CAST_TO_MAP;
        break;
    case DataType.TUPLE:
        kind = PigWarning.IMPLICIT_CAST_TO_TUPLE;
        break;
    case DataType.BIGINTEGER:
        kind = PigWarning.IMPLICIT_CAST_TO_BIGINTEGER;
        break;
    case DataType.BIGDECIMAL:
        kind = PigWarning.IMPLICIT_CAST_TO_BIGDECIMAL;
        break;
    }
    msgCollector.collect(originalTypeName + " is implicitly cast to "
            + toTypeName +" under " + opName + " Operator",
            MessageType.Warning, kind) ;
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:59,代码来源:TypeCheckingExpVisitor.java

示例15: GetSmallerValue

Object GetSmallerValue(Object v) {
    byte type = DataType.findType(v);

    if (type == DataType.BAG || type == DataType.TUPLE
            || type == DataType.MAP)
        return null;

    switch (type) {
    case DataType.CHARARRAY:
        String str = (String) v;
        if (str.length() > 0)
            return str.substring(0, str.length() - 1);
        else
            return null;
    case DataType.BYTEARRAY:
        DataByteArray data = (DataByteArray) v;
        if (data.size() > 0)
            return new DataByteArray(data.get(), 0, data.size() - 1);
        else
            return null;
    case DataType.INTEGER:
        return Integer.valueOf((Integer) v - 1);
    case DataType.LONG:
        return Long.valueOf((Long) v - 1);
    case DataType.FLOAT:
        return Float.valueOf((Float) v - 1);
    case DataType.DOUBLE:
        return Double.valueOf((Double) v - 1);
    case DataType.BIGINTEGER:
        return ((BigInteger)v).subtract(BigInteger.ONE);
    case DataType.BIGDECIMAL:
        return ((BigDecimal)v).subtract(BigDecimal.ONE);
    case DataType.DATETIME:
        DateTime dt = (DateTime) v;
        if (dt.getMillisOfSecond() != 0) {
            return dt.minusMillis(1);
        } else if (dt.getSecondOfMinute() != 0) {
            return dt.minusSeconds(1);
        } else if (dt.getMinuteOfHour() != 0) {
            return dt.minusMinutes(1);
        } else if (dt.getHourOfDay() != 0) {
            return dt.minusHours(1);
        } else {
            return dt.minusDays(1);
        }
    default:
        return null;
    }

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


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