@Override public int hashCode() { long seconds = getSeconds(); seconds <<= 30; // the nanosecond part fits in 30 bits seconds |= getNanos(); return (int) ((seconds >>> 32) ^ seconds); }
/** * * @return nanoseconds in this TimestampWritableV2 */ public int getNanos() { if (!timestampEmpty) { return timestamp.getNanos(); } else if (!bytesEmpty) { return hasDecimalOrSecondVInt() ? TimestampWritableV2.getNanos(currentBytes, offset + 4) : 0; } else { throw new IllegalStateException("Both timestamp and bytes are empty"); } }
private void populateTimestamp() { long seconds = getSeconds(); int nanos = getNanos(); timestamp.setTimeInSeconds(seconds, nanos); }
public BooleanWritable evaluate(TimestampWritableV2 i) { if (i == null) { return null; } else { booleanWritable.set(i.getSeconds() != 0 || i.getNanos() != 0); return booleanWritable; } }
public static void setTimestamp(Timestamp t, byte[] bytes, int offset) { long seconds = getSeconds(bytes, offset); int nanos; if (hasDecimalOrSecondVInt(bytes[offset])) { nanos = getNanos(bytes, offset + 4); } else { nanos = 0; } t.setTimeInSeconds(seconds, nanos); }
/** * @return byte[] representation of TimestampWritableV2 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; }
/** * * @return double representation of the timestamp, accurate to nanoseconds */ public double getDouble() { double seconds, nanos; if (bytesEmpty) { seconds = timestamp.toEpochSecond(); nanos = timestamp.getNanos(); } else { seconds = getSeconds(); nanos = getNanos(); } return seconds + nanos / 1000000000; }
Object row = rows.next(null); Timestamp tlistTimestamp = tslist.get(idx++); if (tlistTimestamp.getNanos() != ((TimestampWritableV2) row).getNanos()) { assertTrue(false);
@Override public int hashCode() { long seconds = getSeconds(); seconds <<= 30; // the nanosecond part fits in 30 bits seconds |= getNanos(); return (int) ((seconds >>> 32) ^ seconds); }
/** * * @return nanoseconds in this TimestampWritableV2 */ public int getNanos() { if (!timestampEmpty) { return timestamp.getNanos(); } else if (!bytesEmpty) { return hasDecimalOrSecondVInt() ? TimestampWritableV2.getNanos(currentBytes, offset + 4) : 0; } else { throw new IllegalStateException("Both timestamp and bytes are empty"); } }
private void populateTimestamp() { long seconds = getSeconds(); int nanos = getNanos(); timestamp.setTimeInSeconds(seconds, nanos); }
public static void setTimestamp(Timestamp t, byte[] bytes, int offset) { long seconds = getSeconds(bytes, offset); int nanos; if (hasDecimalOrSecondVInt(bytes[offset])) { nanos = getNanos(bytes, offset + 4); } else { nanos = 0; } t.setTimeInSeconds(seconds, nanos); }
/** * @return byte[] representation of TimestampWritableV2 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; }
/** * * @return double representation of the timestamp, accurate to nanoseconds */ public double getDouble() { double seconds, nanos; if (bytesEmpty) { seconds = timestamp.toEpochSecond(); nanos = timestamp.getNanos(); } else { seconds = getSeconds(); nanos = getNanos(); } return seconds + nanos / 1000000000; }