public IntWritable evaluate(HiveDecimalWritable i) { if (i == null || !i.isSet() || !i.isInt()) { return null; } else { intWritable.set(i.intValue()); return intWritable; } }
public IntWritable evaluate(HiveDecimalWritable i) { if (i == null || !i.isSet() || !i.isInt()) { return null; } else { intWritable.set(i.intValue()); return intWritable; } }
break; case INT: outV.vector[i] = decWritable.intValue(); break; case LONG:
break; case INT: outV.vector[i] = decWritable.intValue(); break; case LONG:
/** * 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; }
return null; int nanos = nanosWritable.intValue(); if (nanos < 0) { nanos += 1000000000;
return null; int nanos = nanosWritable.intValue(); if (nanos < 0) { nanos += 1000000000;
return null; int nanos = nanosWritable.intValue(); if (nanos < 0) { nanos += 1000000000;
/** * 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 INT: vector[elementNum] = decWritable.intValue(); break; case LONG:
return null; int nanos = nanosWritable.intValue(); if (nanos < 0) { nanos += 1000000000;
return null; int nanos = nanosWritable.intValue(); if (nanos < 0) { nanos += 1000000000;
return null; int nanos = nanosWritable.intValue(); if (nanos < 0) { nanos += 1000000000;