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: outV.vector[i] = decWritable.longValue(); break; default:
break; case LONG: outV.vector[i] = decWritable.longValue(); 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; }
return null; long seconds = nanoInstant.longValue();
return null; long millis = nanoInstant.longValue() * 1000; return Timestamp.ofEpochMilli(millis, nanos); } catch (IllegalArgumentException | DateTimeException nfe) {
return null; long seconds = nanoInstant.longValue();
/** * 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: vector[elementNum] = decWritable.longValue(); break; default:
return null; long seconds = nanoInstant.longValue();
return null; long millis = nanoInstant.longValue() * 1000; return Timestamp.ofEpochMilli(millis, nanos); } catch (IllegalArgumentException | DateTimeException nfe) {
return null; long seconds = nanoInstant.longValue();