Examples of HiveDecimalWritable


Examples of org.apache.hadoop.hive.serde2.io.HiveDecimalWritable

            target.setNull();
        } else if (primitive) {
            HiveDecimal entity = inspector.getPrimitiveJavaObject(value);
            ((DecimalOption) target).modify(entity.bigDecimalValue());
        } else {
            HiveDecimalWritable writable = inspector.getPrimitiveWritableObject(value);
            ((DecimalOption) target).modify(writable.getHiveDecimal().bigDecimalValue());
        }
    }
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.io.HiveDecimalWritable

    public HiveDecimalWritable getPrimitiveWritableObject(Object o) {
        HiveDecimal value = getPrimitiveJavaObject(o);
        if (value == null) {
            return null;
        }
        return new HiveDecimalWritable(value);
    }
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.io.HiveDecimalWritable

        assertThat(inspector.copyObject(option), is((Object) option));
        assertThat(inspector.copyObject(option), is(not(sameInstance((Object) option))));
        assertThat(inspector.copyObject(null), is(nullValue()));
        assertThat(inspector.getPrimitiveJavaObject(option), is(value));
        assertThat(inspector.getPrimitiveJavaObject(null), is(nullValue()));
        assertThat(inspector.getPrimitiveWritableObject(option), is(new HiveDecimalWritable(value)));
        assertThat(inspector.getPrimitiveWritableObject(null), is(nullValue()));

        ValueDriver driver = serde.getDriver(inspector);
        DecimalOption copy = new DecimalOption();
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.io.HiveDecimalWritable

    @Override
    public ObjectInspector init(Mode m, ObjectInspector[] parameters) throws HiveException {
      assert (parameters.length == 1);
      super.init(m, parameters);
      result = new HiveDecimalWritable(HiveDecimal.ZERO);
      inputOI = (PrimitiveObjectInspector) parameters[0];
      return PrimitiveObjectInspectorFactory.writableHiveDecimalObjectInspector;
    }
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.io.HiveDecimalWritable

    }

    @Override
    protected void doTerminatePartial(AverageAggregationBuffer<HiveDecimal> aggregation) {
      if(partialResult[1] == null && aggregation.sum != null) {
        partialResult[1] = new HiveDecimalWritable(HiveDecimal.ZERO);
      }
      ((LongWritable) partialResult[0]).set(aggregation.count);
      if (aggregation.sum != null) {
        ((HiveDecimalWritable) partialResult[1]).set(aggregation.sum);
      } else {
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.io.HiveDecimalWritable

    @Override
    protected Object doTerminate(AverageAggregationBuffer<HiveDecimal> aggregation) {
      if(aggregation.count == 0 || aggregation.sum == null) {
        return null;
      } else {
        HiveDecimalWritable result = new HiveDecimalWritable(HiveDecimal.ZERO);
        try {
          result.set(aggregation.sum.divide(new HiveDecimal(aggregation.count)));
        } catch (NumberFormatException e) {
          result = null;
        }
        return result;
      }
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.io.HiveDecimalWritable

        hiveTypeToJson(new MyHiveType(new TimestampWritable(new Timestamp(1407239910771l)), timestampTypeInfo));
    }

    @Test
    public void testDecimal() {
        hiveTypeToJson(new MyHiveType(new HiveDecimalWritable(HiveDecimal.create(BigDecimal.ONE)), decimalTypeInfo));
    }
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.io.HiveDecimalWritable

            continue;
          }

          // Decimals are stored as BigInteger, so convert and compare
          if (a instanceof HiveDecimal) {
            HiveDecimalWritable dec = (HiveDecimalWritable) b;
            Assert.assertEquals(a, dec.getHiveDecimal());
          }

          if (null == a) {
            Assert.assertEquals(true, (b == null || (b instanceof NullWritable)));
          } else {
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.io.HiveDecimalWritable

    case DataType.VARCHAR:
      HiveVarcharWritable hvw = new HiveVarcharWritable();
      hvw.readFields(in);
      return hvw.getHiveVarchar();
    case DataType.DECIMAL:
      HiveDecimalWritable hdw = new HiveDecimalWritable();
      hdw.readFields(in);
      return hdw.getHiveDecimal();
    case DataType.DATE:
      DateWritable dw = new DateWritable();
      dw.readFields(in);
      return dw.get();
    case DataType.TIMESTAMP:
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.io.HiveDecimalWritable

      return;
    case DataType.VARCHAR:
      new HiveVarcharWritable((HiveVarchar)val).write(out);
      return;
    case DataType.DECIMAL:
      new HiveDecimalWritable((HiveDecimal)val).write(out);
      return;
    case DataType.DATE:
      new DateWritable((Date)val).write(out);
      return;
    case DataType.TIMESTAMP:
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.