morningman commented on a change in pull request #1644: Refactor DateLiteral 
class in FE
URL: https://github.com/apache/incubator-doris/pull/1644#discussion_r316160623
 
 

 ##########
 File path: fe/src/main/java/org/apache/doris/analysis/DateLiteral.java
 ##########
 @@ -169,36 +238,252 @@ protected void toThrift(TExprNode msg) {
         msg.date_literal = new TDateLiteral(getStringValue());
     }
 
-    public Date getValue() {
-        return date;
-    }
-
     @Override
     protected Expr uncheckedCastTo(Type targetType) throws AnalysisException {
         if (targetType.isDateType()) {
             return this;
         } else if (targetType.isStringType()) {
-            return new StringLiteral(getStringValue()); 
+            return new StringLiteral(getStringValue());
         }
         Preconditions.checkState(false);
         return this;
     }
 
+
+    private long make_packed_datetime () {
+        long ymd = ((year * 13 + month) << 5) | day;
+        long hms = (hour << 12) | (minute << 6) | second;
+        long packed_datetime = ((ymd << 17) | hms) << 24 + microsecond;
+        return packed_datetime;
+    }
+
     @Override
     public void write(DataOutput out) throws IOException {
         super.write(out);
-        out.writeLong(date.getTime());
+        out.writeLong(make_packed_datetime());
+    }
+
+    private void from_packed_datetime (long packed_time) {
+        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;
     }
 
     @Override
     public void readFields(DataInput in) throws IOException {
         super.readFields(in);
-        date = new Date(in.readLong());
+        if (Catalog.getCurrentCatalogJournalVersion() >= 
FeMetaVersion.VERSION_59) {
 
 Review comment:
   VERSION_59  is used by `support strict mode`, change to VERSION_60

----------------------------------------------------------------
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]

Reply via email to