@Override public Object copyObject(Object o) { return o == null ? null : new TimestampLocalTZWritable((TimestampLocalTZWritable) o); } }
public void set(TimestampLocalTZWritable t) { if (t.bytesEmpty) { set(t.getTimestampTZ()); } else if (t.currentBytes == t.externalBytes) { set(t.currentBytes, t.offset, t.timeZone); } else { set(t.currentBytes, 0, t.timeZone); } }
public void fromBinarySortable(byte[] bytes, int binSortOffset, ZoneId timeZone) { // Flip the sign bit (and unused bits of the high-order byte) of the seven-byte long back. long seconds = readSevenByteLong(bytes, binSortOffset) ^ SEVEN_BYTE_LONG_SIGN_FLIP; int nanos = bytesToInt(bytes, binSortOffset + 7); timestampTZ.set(seconds, nanos, timeZone); timestampTZEmpty = false; bytesEmpty = true; }
/** * @return length of serialized TimestampTZWritable data. As a side effect, populates the internal * byte array if empty. */ private int getTotalLength() { checkBytes(); return getTotalLength(currentBytes, offset); }
@Override public int compareTo(TimestampLocalTZWritable o) { return getTimestampTZ().compareTo(o.getTimestampTZ()); }
final TimestampLocalTZWritable t = new TimestampLocalTZWritable( new TimestampTZ(Instant.ofEpochMilli(494243222000L).atZone(ZoneId.of("America/Los_Angeles")))); UDFDateFloor g; assertEquals( new TimestampTZ(Instant.ofEpochMilli(473414400000L).atZone(ZoneId.of("America/Los_Angeles"))), i1.getTimestampTZ()); assertEquals( new TimestampTZ(Instant.ofEpochMilli(489049200000L).atZone(ZoneId.of("America/Los_Angeles"))), i2.getTimestampTZ()); assertEquals( new TimestampTZ(Instant.ofEpochMilli(491727600000L).atZone(ZoneId.of("America/Los_Angeles"))), i3.getTimestampTZ()); assertEquals( new TimestampTZ(Instant.ofEpochMilli(493887600000L).atZone(ZoneId.of("America/Los_Angeles"))), i4.getTimestampTZ()); assertEquals( new TimestampTZ(Instant.ofEpochMilli(494233200000L).atZone(ZoneId.of("America/Los_Angeles"))), i5.getTimestampTZ()); assertEquals( new TimestampTZ(Instant.ofEpochMilli(494240400000L).atZone(ZoneId.of("America/Los_Angeles"))), i6.getTimestampTZ()); assertEquals(
@Override public TimestampTZ getPrimitiveJavaObject(Object o) { if (o == null) { return null; } TimestampLocalTZWritable t = (TimestampLocalTZWritable) o; TimestampLocalTZTypeInfo timestampTZTypeInfo = (TimestampLocalTZTypeInfo) typeInfo; if (!t.getTimestampTZ().getZonedDateTime().getZone().equals(timestampTZTypeInfo.timeZone())) { t.setTimeZone(timestampTZTypeInfo.timeZone()); } return t.getTimestampTZ(); }
return t; case TIMESTAMPLOCALTZ: TimestampLocalTZWritable tstz = (reuse == null ? new TimestampLocalTZWritable() : (TimestampLocalTZWritable) reuse); byte[] data = new byte[TimestampLocalTZWritable.BINARY_SORTABLE_LENGTH]; tstz.fromBinarySortable(data, 0, ((TimestampLocalTZTypeInfo) type).timeZone()); return tstz; case INTERVAL_YEAR_MONTH: {
public TimestampLocalTZWritable(byte[] bytes, int offset, ZoneId timeZone) { set(bytes, offset, timeZone); }
public TimestampLocalTZWritable(TimestampLocalTZWritable other) { this(other.getBytes(), 0, other.getTimestampTZ().getZonedDateTime().getZone()); }
public static long getSeconds(byte[] bytes, int offset) { int firstVInt = bytesToInt(bytes, offset); if (firstVInt >= 0 || !hasSecondVInt(bytes[offset + 4])) { return firstVInt & ~DECIMAL_OR_SECOND_VINT_FLAG; } return ((long) (firstVInt & ~DECIMAL_OR_SECOND_VINT_FLAG)) | (LazyBinaryUtils.readVLongFromByteArray(bytes, offset + 4 + WritableUtils.decodeVIntSize(bytes[offset + 4])) << 31); }
@Override public boolean equals(Object o) { if (o instanceof TimestampLocalTZWritable) { return compareTo((TimestampLocalTZWritable) o) == 0; } return false; }
return ((TimestampLocalTZObjectInspector) oi1).getPrimitiveWritableObject(o1).equals( ((TimestampLocalTZObjectInspector) oi2).getPrimitiveWritableObject(o2));
@Override public int hashCode() { return getTimestampTZ().hashCode(); }
@Override public TimestampLocalTZWritable getPrimitiveWritableObject(Object o) { if (o == null) { return null; } TimestampLocalTZWritable t = (TimestampLocalTZWritable) o; TimestampLocalTZTypeInfo timestampTZTypeInfo = (TimestampLocalTZTypeInfo) typeInfo; if (!t.getTimestampTZ().getZonedDateTime().getZone().equals(timestampTZTypeInfo.timeZone())) { t.setTimeZone(timestampTZTypeInfo.timeZone()); } return t; }
return t; case TIMESTAMPLOCALTZ: TimestampLocalTZWritable tstz = (reuse == null ? new TimestampLocalTZWritable() : (TimestampLocalTZWritable) reuse); byte[] data = new byte[TimestampLocalTZWritable.BINARY_SORTABLE_LENGTH]; tstz.fromBinarySortable(data, 0, ((TimestampLocalTZTypeInfo) type).timeZone()); return tstz; case INTERVAL_YEAR_MONTH: {
public TimestampLocalTZWritable(TimestampTZ tstz) { set(tstz); }
/** * Used to create copies of objects * * @return a copy of the internal TimestampTZWritable byte[] */ public byte[] getBytes() { checkBytes(); int len = getTotalLength(); byte[] b = new byte[len]; System.arraycopy(currentBytes, offset, b, 0, len); return b; }
public TimestampLocalTZWritable(TimestampLocalTZWritable other) { this(other.getBytes(), 0, other.getTimestampTZ().getZonedDateTime().getZone()); }
public static long getSeconds(byte[] bytes, int offset) { int firstVInt = bytesToInt(bytes, offset); if (firstVInt >= 0 || !hasSecondVInt(bytes[offset + 4])) { return firstVInt & ~DECIMAL_OR_SECOND_VINT_FLAG; } return ((long) (firstVInt & ~DECIMAL_OR_SECOND_VINT_FLAG)) | (LazyBinaryUtils.readVLongFromByteArray(bytes, offset + 4 + WritableUtils.decodeVIntSize(bytes[offset + 4])) << 31); }