@Override public Date getPrimitiveJavaObject(Object o) { return o == null ? null : ((LazyDate) o).getWritableObject().get(); } }
@Override public Object copyObject(Object o) { return o == null ? null : new LazyDate((LazyDate) o); }
/** * Initializes LazyDate object by interpreting the input bytes as a SQL date string. * * @param bytes * @param start * @param length */ @Override public void init(ByteArrayRef bytes, int start, int length) { String s = null; if (!LazyUtils.isDateMaybe(bytes.getData(), start, length)) { isNull = true; return; } try { s = Text.decode(bytes.getData(), start, length); data.set(Date.valueOf(s)); isNull = false; } catch (Exception e) { isNull = true; logExceptionMessage(bytes, start, length, "DATE"); } }
@Override public void writeDate(int dateAsDays) throws IOException { beginPrimitive(); if (dateWritable == null) { dateWritable = new DateWritableV2(); } dateWritable.set(dateAsDays); LazyDate.writeUTF8(output, dateWritable); finishPrimitive(); }
@Override public void writeDate(Date date) throws IOException { beginPrimitive(); if (dateWritable == null) { dateWritable = new DateWritableV2(); } dateWritable.set(date); LazyDate.writeUTF8(output, dateWritable); finishPrimitive(); }
private static long formatDateAsLong(Object object, DateObjectInspector inspector) { if (object instanceof LazyDate) { return ((LazyDate) object).getWritableObject().getDays(); } if (object instanceof DateWritable) { return ((DateWritable) object).getDays(); } // Hive will return java.sql.Date at midnight in JVM time zone long millisLocal = inspector.getPrimitiveJavaObject(object).getTime(); // Convert it to midnight in UTC long millisUtc = DateTimeZone.getDefault().getMillisKeepLocal(DateTimeZone.UTC, millisLocal); // Convert midnight UTC to days return TimeUnit.MILLISECONDS.toDays(millisUtc); }
LazyDate.writeUTF8(out, ((DateObjectInspector) oi).getPrimitiveWritableObject(o)); break;
return new LazyHiveVarchar((LazyHiveVarcharObjectInspector) oi); case DATE: return new LazyDate((LazyDateObjectInspector) oi); case TIMESTAMP: return new LazyTimestamp((LazyTimestampObjectInspector) oi);
/** * Initializes LazyDate object by interpreting the input bytes as a SQL date string. * * @param bytes * @param start * @param length */ @Override public void init(ByteArrayRef bytes, int start, int length) { String s = null; try { s = Text.decode(bytes.getData(), start, length); data.set(Date.valueOf(s)); isNull = false; } catch (Exception e) { isNull = true; logExceptionMessage(bytes, start, length, "DATE"); } }
throw new RuntimeException("Expected LazyDate"); Date value = ((LazyDate) primitiveObject).getWritableObject().get(); Date expected = ((DateWritableV2) expectedObject).get(); if (!value.equals(expected)) {
@Override public void writeDate(int dateAsDays) throws IOException { if (index > 0) { output.write(separator); } if (dateWritable == null) { dateWritable = new DateWritable(); } dateWritable.set(dateAsDays); LazyDate.writeUTF8(output, dateWritable); index++; }
@Override public Object copyObject(Object o) { return o == null ? null : new LazyDate((LazyDate) o); }
/** * Initializes LazyDate object by interpreting the input bytes as a SQL date string. * * @param bytes * @param start * @param length */ @Override public void init(ByteArrayRef bytes, int start, int length) { String s = null; try { s = Text.decode(bytes.getData(), start, length); data.set(Date.valueOf(s)); isNull = false; } catch (Exception e) { isNull = true; logExceptionMessage(bytes, start, length, "DATE"); } }
@Override public Date getPrimitiveJavaObject(Object o) { return o == null ? null : ((LazyDate) o).getWritableObject().get(); } }
@Override public void writeDate(int dateAsDays) throws IOException { if (index > 0) { output.write(separator); } if (dateWritable == null) { dateWritable = new DateWritable(); } dateWritable.set(dateAsDays); LazyDate.writeUTF8(output, dateWritable); index++; }
@Override public Object copyObject(Object o) { return o == null ? null : new LazyDate((LazyDate) o); }
/** * Initializes LazyDate object by interpreting the input bytes as a SQL date string. * * @param bytes * @param start * @param length */ @Override public void init(ByteArrayRef bytes, int start, int length) { String s = null; try { s = Text.decode(bytes.getData(), start, length); data.set(Date.valueOf(s)); isNull = false; } catch (Exception e) { isNull = true; logExceptionMessage(bytes, start, length, "DATE"); } }
@Override public Date getPrimitiveJavaObject(Object o) { return o == null ? null : ((LazyDate) o).getWritableObject().get(); } }
@Override public void writeDate(Date date) throws IOException { if (index > 0) { output.write(separator); } if (dateWritable == null) { dateWritable = new DateWritable(); } dateWritable.set(date); LazyDate.writeUTF8(output, dateWritable); index++; }
@Override public Object copyObject(Object o) { return o == null ? null : new LazyDate((LazyDate) o); }