コード例 #1
0
  @Override
  public ByteWritable evaluate(ByteWritable a, ByteWritable b) {
    // LOG.info("Get input " + a.getClass() + ":" + a + " " + b.getClass() + ":"
    // + b);
    if ((a == null) || (b == null)) {
      return null;
    }

    byteWritable.set((byte) (a.get() + b.get()));
    return byteWritable;
  }
コード例 #2
0
ファイル: HiveUtils.java プロジェクト: naritta/hivemall
 public static double getAsConstDouble(@Nonnull final ObjectInspector numberOI)
     throws UDFArgumentException {
   final String typeName = numberOI.getTypeName();
   if (DOUBLE_TYPE_NAME.equals(typeName)) {
     DoubleWritable v = getConstValue(numberOI);
     return v.get();
   } else if (FLOAT_TYPE_NAME.equals(typeName)) {
     FloatWritable v = getConstValue(numberOI);
     return v.get();
   } else if (INT_TYPE_NAME.equals(typeName)) {
     IntWritable v = getConstValue(numberOI);
     return v.get();
   } else if (BIGINT_TYPE_NAME.equals(typeName)) {
     LongWritable v = getConstValue(numberOI);
     return v.get();
   } else if (SMALLINT_TYPE_NAME.equals(typeName)) {
     ShortWritable v = getConstValue(numberOI);
     return v.get();
   } else if (TINYINT_TYPE_NAME.equals(typeName)) {
     ByteWritable v = getConstValue(numberOI);
     return v.get();
   }
   throw new UDFArgumentException(
       "Unexpected argument type to cast as double: "
           + TypeInfoUtils.getTypeInfoFromObjectInspector(numberOI));
 }
コード例 #3
0
 @Override
 public int precision() {
   if (value == null) {
     return super.precision();
   }
   return BigDecimal.valueOf(value.get()).precision();
 }
コード例 #4
0
 /**
  * Convert from byte to an integer. This is called for CAST(... AS INT)
  *
  * @param i The byte value to convert
  * @return IntWritable
  */
 public IntWritable evaluate(ByteWritable i) {
   if (i == null) {
     return null;
   } else {
     intWritable.set(i.get());
     return intWritable;
   }
 }