public LongWritable evaluate(HiveDecimalWritable i) { if (i == null || !i.isSet() || !i.isLong()) { return null; } else { longWritable.set(i.longValue()); return longWritable; } }
public LongWritable evaluate(HiveDecimalWritable i) { if (i == null || !i.isSet() || !i.isLong()) { return null; } else { longWritable.set(i.longValue()); return longWritable; } }
break; case LONG: isInRange = decWritable.isLong(); break; default:
break; case LONG: isInRange = decWritable.isLong(); break; default:
/** * Take a HiveDecimal and return the timestamp representation where the fraction part is the * nanoseconds and integer part is the number of seconds. * @param dec * @return */ public static Timestamp decimalToTimestamp(HiveDecimal dec) { HiveDecimalWritable nanosWritable = new HiveDecimalWritable(dec); nanosWritable.mutateFractionPortion(); // Clip off seconds portion. nanosWritable.mutateScaleByPowerOfTen(9); // Bring nanoseconds into integer portion. if (!nanosWritable.isSet() || !nanosWritable.isInt()) { return null; } int nanos = nanosWritable.intValue(); if (nanos < 0) { nanos += 1000000000; } nanosWritable.setFromLong(nanos); HiveDecimalWritable nanoInstant = new HiveDecimalWritable(dec); nanoInstant.mutateScaleByPowerOfTen(9); nanoInstant.mutateSubtract(nanosWritable); nanoInstant.mutateScaleByPowerOfTen(-9); // Back to seconds. if (!nanoInstant.isSet() || !nanoInstant.isLong()) { return null; } long seconds = nanoInstant.longValue(); Timestamp t = new Timestamp(seconds * 1000); t.setNanos(nanos); return t; }
if (!nanoInstant.isSet() || !nanoInstant.isLong()) { return null;
if (!nanoInstant.isSet() || !nanoInstant.isLong()) { return null;
if (!nanoInstant.isSet() || !nanoInstant.isLong()) { return null;
/** * Take a HiveDecimal and return the timestamp representation where the fraction part is the * nanoseconds and integer part is the number of seconds. * @param dec * @return */ public static Timestamp decimalToTimestamp(HiveDecimal dec) { HiveDecimalWritable nanosWritable = new HiveDecimalWritable(dec); nanosWritable.mutateFractionPortion(); // Clip off seconds portion. nanosWritable.mutateScaleByPowerOfTen(9); // Bring nanoseconds into integer portion. if (!nanosWritable.isSet() || !nanosWritable.isInt()) { return null; } int nanos = nanosWritable.intValue(); if (nanos < 0) { nanos += 1000000000; } nanosWritable.setFromLong(nanos); HiveDecimalWritable nanoInstant = new HiveDecimalWritable(dec); nanoInstant.mutateScaleByPowerOfTen(9); nanoInstant.mutateSubtract(nanosWritable); nanoInstant.mutateScaleByPowerOfTen(-9); // Back to seconds. if (!nanoInstant.isSet() || !nanoInstant.isLong()) { return null; } long seconds = nanoInstant.longValue(); Timestamp t = new Timestamp(seconds * 1000); t.setNanos(nanos); return t; }
break; case LONG: isInRange = decWritable.isLong(); break; default:
if (!nanoInstant.isSet() || !nanoInstant.isLong()) { return null;
if (!nanoInstant.isSet() || !nanoInstant.isLong()) { return null;
if (!nanoInstant.isSet() || !nanoInstant.isLong()) { return null;