Package org.apache.hadoop.hive.common.type

Examples of org.apache.hadoop.hive.common.type.HiveDecimal.unscaledValue()


      super.write(obj);
      if (obj != null) {
        HiveDecimal decimal = ((HiveDecimalObjectInspector) inspector).
            getPrimitiveJavaObject(obj);
        SerializationUtils.writeBigInteger(valueStream,
            decimal.unscaledValue());
        scaleStream.write(decimal.scale());
        indexStatistics.updateDecimal(decimal);
      }
    }
View Full Code Here


    int factor = dec.precision() - dec.scale();
    factor = sign == 1 ? factor : -factor;

        // convert the absolute big decimal to string
        dec.scaleByPowerOfTen(Math.abs(dec.scale()));
        String digits = dec.unscaledValue().toString();

        // finally write out the pieces (sign, scale, digits)
        buffer.write((byte) ( sign + 1), invert);
        buffer.write((byte) ((factor >> 24) ^ 0x80), invert);
        buffer.write((byte) ( factor >> 16), invert);
View Full Code Here

        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

        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

            getPrimitiveJavaObject(obj);
        if (decimal == null) {
          return;
        }
        SerializationUtils.writeBigInteger(valueStream,
            decimal.unscaledValue());
        scaleStream.write(decimal.scale());
        indexStatistics.updateDecimal(decimal);
      }
    }
View Full Code Here

  }

  public static void writeToByteStream(Decimal128 dec, Output byteStream) {
    HiveDecimal hd = HiveDecimal.create(dec.toBigDecimal());
    LazyBinaryUtils.writeVInt(byteStream, hd.scale());
    byte[] bytes = hd.unscaledValue().toByteArray();
    LazyBinaryUtils.writeVInt(byteStream, bytes.length);
    byteStream.write(bytes, 0, bytes.length);
  }

  public void writeToByteStream(RandomAccessOutput byteStream) {
View Full Code Here

        int factor = dec.precision() - dec.scale();
        factor = sign == 1 ? factor : -factor;

        // convert the absolute big decimal to string
        dec.scaleByPowerOfTen(Math.abs(dec.scale()));
        String digits = dec.unscaledValue().toString();

        // finally write out the pieces (sign, scale, digits)
        writeByte(buffer, (byte) ( sign + 1), invert);
        writeByte(buffer, (byte) ((factor >> 24) ^ 0x80), invert);
        writeByte(buffer, (byte) ( factor >> 16), invert);
View Full Code Here

            getPrimitiveJavaObject(obj);
        if (decimal == null) {
          return;
        }
        SerializationUtils.writeBigInteger(valueStream,
            decimal.unscaledValue());
        scaleStream.write(decimal.scale());
        indexStatistics.updateDecimal(decimal);
      }
    }
View Full Code Here

        int factor = dec.precision() - dec.scale();
        factor = sign == 1 ? factor : -factor;

        // convert the absolute big decimal to string
        dec.scaleByPowerOfTen(Math.abs(dec.scale()));
        String digits = dec.unscaledValue().toString();

        // finally write out the pieces (sign, scale, digits)
        buffer.write((byte) ( sign + 1), invert);
        buffer.write((byte) ((factor >> 24) ^ 0x80), invert);
        buffer.write((byte) ( factor >> 16), invert);
View Full Code Here

  }

  public static void writeToByteStream(Decimal128 dec, Output byteStream) {
    HiveDecimal hd = HiveDecimal.create(dec.toBigDecimal());
    LazyBinaryUtils.writeVInt(byteStream, hd.scale());
    byte[] bytes = hd.unscaledValue().toByteArray();
    LazyBinaryUtils.writeVInt(byteStream, bytes.length);
    byteStream.write(bytes, 0, bytes.length);
  }

  public void writeToByteStream(Output byteStream) {
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.