Examples of HiveDecimal


Examples of org.apache.hadoop.hive.common.type.HiveDecimal

      int bufferUsed = d.fastSerializeForHiveDecimal(scratch);
      HiveDecimalWritable hdw = new HiveDecimalWritable();
      hdw.set(scratch.getBytes(bufferUsed), d.getScale());

      HiveDecimal hd = hdw.getHiveDecimal();

      BigDecimal readValue = hd.bigDecimalValue();

      Assert.assertEquals(d.toBigDecimal().stripTrailingZeros(),
          readValue.stripTrailingZeros());
    }
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveDecimal

        Long l = randField > 3 ? null : Long.valueOf(r.nextLong());
        Float f = randField > 4 ? null : Float.valueOf(r.nextFloat());
        Double d = randField > 5 ? null : Double.valueOf(r.nextDouble());
        String st = randField > 6 ? null : TestBinarySortableSerDe
            .getRandString(r);
  HiveDecimal bd = randField > 7 ? null : TestBinarySortableSerDe.getRandHiveDecimal(r);
        Date date = randField > 8 ? null : TestBinarySortableSerDe.getRandDate(r);
        MyTestInnerStruct is = randField > 9 ? null : new MyTestInnerStruct(r
            .nextInt(5) - 2, r.nextInt(5) - 2);
        List<Integer> li = randField > 10 ? null : TestBinarySortableSerDe
            .getRandIntegerArray(r);
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveDecimal

      Long l = randField > 3 ? null : Long.valueOf(r.nextLong());
      Float f = randField > 4 ? null : Float.valueOf(r.nextFloat());
      Double d = randField > 5 ? null : Double.valueOf(r.nextDouble());
      String st = randField > 6 ? null : TestBinarySortableSerDe
          .getRandString(r);
      HiveDecimal bd = randField > 7 ? null : TestBinarySortableSerDe.getRandHiveDecimal(r);
      Date date = randField > 8 ? null : TestBinarySortableSerDe.getRandDate(r);
      MyTestInnerStruct is = randField > 9 ? null : new MyTestInnerStruct(r
          .nextInt(5) - 2, r.nextInt(5) - 2);
      List<Integer> li = randField > 10 ? null : TestBinarySortableSerDe
          .getRandIntegerArray(r);
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveDecimal

      Long l = randField > 3 ? null : Long.valueOf(r.nextLong());
      Float f = randField > 4 ? null : Float.valueOf(r.nextFloat());
      Double d = randField > 5 ? null : Double.valueOf(r.nextDouble());
      String st = randField > 6 ? null : TestBinarySortableSerDe
          .getRandString(r);
      HiveDecimal bd = randField > 7 ? null : TestBinarySortableSerDe.getRandHiveDecimal(r);
      Date date = randField > 8 ? null : TestBinarySortableSerDe.getRandDate(r);
      MyTestInnerStruct is = randField > 9 ? null : new MyTestInnerStruct(r
          .nextInt(5) - 2, r.nextInt(5) - 2);
      List<Integer> li = randField > 10 ? null : TestBinarySortableSerDe
          .getRandIntegerArray(r);
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveDecimal

      Long l = randField > 3 ? null : Long.valueOf(r.nextLong());
      Float f = randField > 4 ? null : Float.valueOf(r.nextFloat());
      Double d = randField > 5 ? null : Double.valueOf(r.nextDouble());
      String st = randField > 6 ? null : TestBinarySortableSerDe
          .getRandString(r);
      HiveDecimal bd = randField > 7 ? null : TestBinarySortableSerDe.getRandHiveDecimal(r);
      Date date = randField > 8 ? null : TestBinarySortableSerDe.getRandDate(r);
      MyTestInnerStruct is = randField > 9 ? null : new MyTestInnerStruct(r
          .nextInt(5) - 2, r.nextInt(5) - 2);
      List<Integer> li = randField > 10 ? null : TestBinarySortableSerDe
          .getRandIntegerArray(r);
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveDecimal

      Long l = randField > 3 ? null : Long.valueOf(r.nextLong());
      Float f = randField > 4 ? null : Float.valueOf(r.nextFloat());
      Double d = randField > 5 ? null : Double.valueOf(r.nextDouble());
      String st = randField > 6 ? null : TestBinarySortableSerDe
          .getRandString(r);
      HiveDecimal bd = randField > 7 ? null : TestBinarySortableSerDe.getRandHiveDecimal(r);
      Date date = randField > 7 ? null : TestBinarySortableSerDe.getRandDate(r);
      MyTestInnerStruct is = randField > 7 ? null : new MyTestInnerStruct(r
          .nextInt(5) - 2, r.nextInt(5) - 2);

      MyTestClassSmaller input = new MyTestClassSmaller(b, s, n, l, f, d, st, bd, date,
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveDecimal

        Long l = randField > 3 ? null : Long.valueOf(r.nextLong());
        Float f = randField > 4 ? null : Float.valueOf(r.nextFloat());
        Double d = randField > 5 ? null : Double.valueOf(r.nextDouble());
        String st = randField > 6 ? null : TestBinarySortableSerDe
            .getRandString(r);
        HiveDecimal bd = randField > 7 ? null : TestBinarySortableSerDe.getRandHiveDecimal(r);
        Date date = randField > 8 ? null : TestBinarySortableSerDe.getRandDate(r);
        MyTestInnerStruct is = randField > 9 ? null : new MyTestInnerStruct(r
            .nextInt(5) - 2, r.nextInt(5) - 2);
        List<Integer> li = randField > 10 ? null : TestBinarySortableSerDe
            .getRandIntegerArray(r);
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveDecimal

        return 1;
      } else {
        return 0;
      }
    } else if (decimalTypePattern.matcher(constDesc.getTypeString()).matches()) {
      HiveDecimal hd = (HiveDecimal) constDesc.getValue();
      Decimal128 dvalue = new Decimal128();
      dvalue.update(hd.unscaledValue(), (short) hd.scale());
      return dvalue;
    } else {
      return constDesc.getValue();
    }
  }
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveDecimal

    return doubleWritable;
  }

  @Override
  protected HiveDecimalWritable evaluate(HiveDecimal left, HiveDecimal right) {
    HiveDecimal dec = left.multiply(right);

    if (dec == null) {
      return null;
    }
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveDecimal

      case LONG:
        long longVal = ((Long) scalar).longValue();
        d.update(longVal, (short) scale);
        break;
      case DECIMAL:
        HiveDecimal decimalVal = (HiveDecimal) scalar;
        d.update(decimalVal.unscaledValue(), (short) scale);
        break;
      default:
        throw new HiveException("Unsupported type "+typename+" for cast to Decimal128");
    }
    return d;
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.