@Override public int hashCode() { long seconds = getSeconds(); seconds <<= 30; // the nanosecond part fits in 30 bits seconds |= getNanos(); return (int) ((seconds >>> 32) ^ seconds); }
/** * * @return seconds corresponding to this TimestampWritable */ public long getSeconds() { if (!timestampEmpty) { return TimestampUtils.millisToSeconds(timestamp.getTime()); } else if (!bytesEmpty) { return TimestampWritable.getSeconds(currentBytes, offset); } else { throw new IllegalStateException("Both timestamp and bytes are empty"); } }
public ByteWritable evaluate(TimestampWritable i) { if (i == null) { return null; } else { byteWritable.set((byte)i.getSeconds()); return byteWritable; } }
public ShortWritable evaluate(TimestampWritable i) { if (i == null) { return null; } else { shortWritable.set((short) i.getSeconds()); return shortWritable; } }
public LongWritable evaluate(TimestampWritable i) { if (i == null) { return null; } else { longWritable.set(i.getSeconds()); return longWritable; } }
/** * Convert from Timestamp to an integer. This is called for CAST(... AS INT) * * @param i * The Timestamp value to convert * @return IntWritable */ public IntWritable evaluate(TimestampWritable i) { if (i == null) { return null; } else { intWritable.set((int) i.getSeconds()); return intWritable; } }
private void populateTimestamp() { long seconds = getSeconds(); int nanos = getNanos(); timestamp.setTime(seconds * 1000); timestamp.setNanos(nanos); }
public int compareTo(TimestampWritable t) { checkBytes(); long s1 = this.getSeconds(); long s2 = t.getSeconds(); if (s1 == s2) { int n1 = this.getNanos(); int n2 = t.getNanos(); if (n1 == n2) { return 0; } return n1 - n2; } else { return s1 < s2 ? -1 : 1; } }
/** * * @return double representation of the timestamp, accurate to nanoseconds */ public double getDouble() { double seconds, nanos; if (bytesEmpty) { seconds = TimestampUtils.millisToSeconds(timestamp.getTime()); nanos = timestamp.getNanos(); } else { seconds = getSeconds(); nanos = getNanos(); } return seconds + nanos / 1000000000; }
public static void setTimestamp(Timestamp t, byte[] bytes, int offset) { long seconds = getSeconds(bytes, offset); t.setTime(seconds * 1000); if (hasDecimalOrSecondVInt(bytes[offset])) { t.setNanos(getNanos(bytes, offset + 4)); } else { t.setNanos(0); } }
public BooleanWritable evaluate(TimestampWritable i) { if (i == null) { return null; } else { booleanWritable.set(i.getSeconds() != 0 || i.getNanos() != 0); return booleanWritable; } }
/** * @return byte[] representation of TimestampWritable that is binary * sortable (7 bytes for seconds, 4 bytes for nanoseconds) */ public byte[] getBinarySortable() { byte[] b = new byte[BINARY_SORTABLE_LENGTH]; int nanos = getNanos(); // We flip the highest-order bit of the seven-byte representation of seconds to make negative // values come before positive ones. long seconds = getSeconds() ^ SEVEN_BYTE_LONG_SIGN_FLIP; sevenByteLongToBytes(seconds, b, 0); intToBytes(nanos, b, 7); return b; }
actualValue = sqlTimestampOf((timestamp.getSeconds() * 1000) + (timestamp.getNanos() / 1000000L), SESSION);
TimestampWritable timestamp = (TimestampWritable) actualValue; if (SESSION.isLegacyTimestamp()) { actualValue = new SqlTimestamp((timestamp.getSeconds() * 1000) + (timestamp.getNanos() / 1000000L), UTC_KEY); actualValue = new SqlTimestamp((timestamp.getSeconds() * 1000) + (timestamp.getNanos() / 1000000L));
public LongWritable evaluate(TimestampWritable i) { if (i == null) { return null; } else { longWritable.set(i.getSeconds()); return longWritable; } }
@Override public int hashCode() { long seconds = getSeconds(); seconds <<= 30; // the nanosecond part fits in 30 bits seconds |= getNanos(); return (int) ((seconds >>> 32) ^ seconds); }
public ByteWritable evaluate(TimestampWritable i) { if (i == null) { return null; } else { byteWritable.set((byte)i.getSeconds()); return byteWritable; } }
public ShortWritable evaluate(TimestampWritable i) { if (i == null) { return null; } else { shortWritable.set((short) i.getSeconds()); return shortWritable; } }
public BooleanWritable evaluate(TimestampWritable i) { if (i == null) { return null; } else { booleanWritable.set(i.getSeconds() != 0 || i.getNanos() != 0); return booleanWritable; } }
@Override public void setSafeValue(ObjectInspector oi, Object hiveFieldValue, ValueVector outputVV, int outputIndex) { final TimestampWritable value = ((TimestampObjectInspector)oi).getPrimitiveWritableObject(hiveFieldValue); long seconds = value.getSeconds(); long nanos = value.getNanos(); long millis = seconds * 1000 + nanos/1000/1000; ((TimeStampMilliVector) outputVV).setSafe(outputIndex, millis); } }