/** * Set a decimal writable's value to a doubles value. * <p> * Afterwards, the isSet() method will return true if the double to decimal conversion was successful. * */ @HiveDecimalWritableVersionV2 public void setFromDouble(double doubleValue) { fastReset(); isSet = fastSetFromDouble(doubleValue); if (!isSet) { fastReset(); } }
/** * Set the writable's current value to the decimal in a UTF-8 byte slice. * <p> * Afterwards, the isSet() method will return true, unless byte slice could not be converted. * */ @HiveDecimalWritableVersionV2 public void setFromBytes(byte[] bytes, int offset, int length) { fastReset(); isSet = fastSetFromBytes(bytes, offset, length, false); if (!isSet) { fastReset(); } }
/** * Set the writable's current value to the signed value from BigInteger bytes and a specified * scale. * <p> * Afterwards, the isSet() method will return true, unless conversion failed. * */ @HiveDecimalWritableVersionV2 public void setFromBigIntegerBytesAndScale(byte[] bigIntegerBytes, int scale) { fastReset(); isSet = fastSetFromBigIntegerBytesAndScale(bigIntegerBytes, 0, bigIntegerBytes.length, scale); if (!isSet) { fastReset(); } }
/** * Set the writable's current value to the long's value at a specified * scale. * <p> * Afterwards, the isSet() method will return true, unless conversion failed. * */ @HiveDecimalWritableVersionV2 public void setFromLongAndScale(long longValue, int scale) { fastReset(); isSet = fastSetFromLongAndScale(longValue, scale); if (!isSet) { fastReset(); } }
/** * Set the writable's current value to the decimal digits only in a UTF-8 byte slice, a sign * flag, and a scale. * <p> * Afterwards, the isSet() method will return true, unless byte slice etc could not be converted. * */ @HiveDecimalWritableVersionV2 public void setFromDigitsOnlyBytesWithScale( boolean isNegative, byte[] bytes, int offset, int length, int scale) { fastReset(); isSet = fastSetFromDigitsOnlyBytesAndScale(isNegative, bytes, offset, length, scale); if (!isSet) { fastReset(); } }
/** * Set a decimal writable's value to a long's value with scale 0. * <p> * Afterwards, the isSet() method will return true since all long values fit in a decimal. * */ @HiveDecimalWritableVersionV2 public void setFromLong(long longValue) { fastReset(); fastSetFromLong(longValue); isSet = true; }
@HiveDecimalWritableVersionV2 public void mutateSetScale(int roundingPoint, int roundingMode) { if (!isSet) { return; } isSet = fastRound(roundingPoint, roundingMode, this); if (!isSet) { fastReset(); } }
@HiveDecimalWritableVersionV2 public boolean mutateEnforcePrecisionScale(int precision, int scale) { if (!isSet) { return false; } isSet = fastEnforcePrecisionScale(precision, scale); if (!isSet) { fastReset(); } return isSet; }
/** * Create a decimal writable with an initial value from a String. * <p> * If the conversion from String to decimal is successful, isSet() will return true. * */ @HiveDecimalWritableVersionV1 public HiveDecimalWritable(String string) { super(); isSet = fastSetFromString(string, false); if (!isSet) { fastReset(); } }
/** * Set the writable's current value to a HiveDecimal's value. * <p> * Afterwards, the isSet() method will return true, unless value is null. * */ @HiveDecimalWritableVersionV1 public void set(HiveDecimal value) { if (value == null) { fastReset(); isSet = false; } else { fastSet(value); isSet = true; } }
/** * See the comments for HiveDecimal.serializationUtilsRead. */ @HiveDecimalWritableVersionV2 public boolean serializationUtilsRead( InputStream inputStream, int scale, byte[] scratchBytes) throws IOException { fastReset(); isSet = fastSerializationUtilsRead( inputStream, scale, scratchBytes); return isSet; }
/** * Standard Writable method that deserialize the fields of this object from a DataInput. * */ @HiveDecimalWritableVersionV1 @Override public void readFields(DataInput in) throws IOException { int scale = WritableUtils.readVInt(in); int byteArrayLen = WritableUtils.readVInt(in); byte[] bytes = new byte[byteArrayLen]; in.readFully(bytes); fastReset(); if (!fastSetFromBigIntegerBytesAndScale(bytes, 0, bytes.length, scale)) { throw new IOException("Couldn't convert decimal"); } isSet = true; }
/** * Set the writable's current value to the value in a another decimal writable. * <p> * If the supplied writable has a value, isSet() will return true. * */ @HiveDecimalWritableVersionV1 public void set(HiveDecimalWritable writable) { if (writable == null || !writable.isSet()) { fastReset(); isSet = false; } else { fastSet(writable); isSet = true; } }
/** * Set the writable's current value to a HiveDecimal's value with a specified precision / scale * enforced. * <p> * Afterwards, the isSet() method will return true, unless value is null or value didn't fit within * maxPrecision / maxScale. * */ @HiveDecimalWritableVersionV1 public void set(HiveDecimal value, int maxPrecision, int maxScale) { set(value); if (isSet) { isSet = fastEnforcePrecisionScale(maxPrecision, maxScale); if (!isSet) { fastReset(); } } }
/** * Set the writable's current value to a writable's value with a specified precision / scale * enforced. * <p> * The isSet() method will return true, unless value is null or value didn't fit within * maxPrecision / maxScale. * */ @HiveDecimalWritableVersionV2 public void set(HiveDecimalWritable writable, int maxPrecision, int maxScale) { set(writable); if (isSet) { isSet = fastEnforcePrecisionScale(maxPrecision, maxScale); if (!isSet) { fastReset(); } } }
@HiveDecimalWritableVersionV2 public void mutateSetScale(int roundingPoint, int roundingMode) { if (!isSet) { return; } isSet = fastRound(roundingPoint, roundingMode, this); if (!isSet) { fastReset(); } }
@HiveDecimalWritableVersionV2 public boolean mutateEnforcePrecisionScale(int precision, int scale) { if (!isSet) { return false; } isSet = fastEnforcePrecisionScale(precision, scale); if (!isSet) { fastReset(); } return isSet; }