imay commented on a change in pull request #1644: Refactor DateLiteral class in
FE
URL: https://github.com/apache/incubator-doris/pull/1644#discussion_r315654711
##########
File path: fe/src/main/java/org/apache/doris/analysis/DateLiteral.java
##########
@@ -187,18 +222,266 @@ protected Expr uncheckedCastTo(Type targetType) throws
AnalysisException {
@Override
public void write(DataOutput out) throws IOException {
super.write(out);
- out.writeLong(date.getTime());
+ long ymd = ((year * 13 + month) << 5) | day;
+ long hms = (hour << 12) | (minute << 6) | second;
+ long packed_datetime = ((ymd << 17) | hms) << 24 + microsecond;
+ out.writeLong(packed_datetime);
}
@Override
public void readFields(DataInput in) throws IOException {
super.readFields(in);
- date = new Date(in.readLong());
+ if (Catalog.getCurrentCatalogJournalVersion() >=
FeMetaVersion.VERSION_59) {
+ long packed_time = in.readLong();
+ microsecond = (packed_time % (1L << 24));
+ long ymdhms = (packed_time >> 24);
+ long ymd = ymdhms >> 17;
+ long hms = ymdhms % (1 << 17);
+
+ day = ymd % (1 << 5);
+ long ym = ymd >> 5;
+ month = ym % 13;
+ year = ym / 13;
+ year %= 10000;
+ second = hms % (1 << 6);
+ minute = (hms >> 6) % (1 << 6);
+ hour = (hms >> 12);
+ this.type = Type.DATETIME;
Review comment:
why DATETIME? I think it may be DATE
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]