This is an automated email from the ASF dual-hosted git repository.

jakevin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 646f1ea087a [performance](Nereids): avoid use `getStringValue()` in 
getTimeFormatter() (#27625)
646f1ea087a is described below

commit 646f1ea087acf5153596e86ef49e84246a68af6c
Author: jakevin <[email protected]>
AuthorDate: Mon Nov 27 21:08:32 2023 +0800

    [performance](Nereids): avoid use `getStringValue()` in getTimeFormatter() 
(#27625)
    
    Original `getTimeFormatter()` will convert `long` to `string`, and then 
parse `string` to `int`.
---
 .../org/apache/doris/analysis/DateLiteral.java     | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/DateLiteral.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/DateLiteral.java
index 879795f8737..be72f5b0cff 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/DateLiteral.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/DateLiteral.java
@@ -1094,25 +1094,17 @@ public class DateLiteral extends LiteralExpr {
     }
 
     public LocalDateTime getTimeFormatter() {
-        TemporalAccessor accessor;
         if (type.equals(Type.DATE) || type.equals(Type.DATEV2)) {
-            accessor = DATE_FORMATTER.parse(getStringValue());
+            return LocalDateTime.of((int) this.year, (int) this.month, (int) 
this.day, 0, 0, 0);
         } else if (type.isDatetimeV2()) {
-            accessor = 
DATE_TIME_FORMATTER_TO_MICRO_SECOND.parse(getStringValue());
+            return LocalDateTime.of((int) this.year, (int) this.month, (int) 
this.day, (int) this.hour,
+                    (int) this.minute,
+                    (int) this.second, (int) this.microsecond * 1000);
         } else {
-            accessor = DATE_TIME_FORMATTER.parse(getStringValue());
+            return LocalDateTime.of((int) this.year, (int) this.month, (int) 
this.day, (int) this.hour,
+                    (int) this.minute,
+                    (int) this.second);
         }
-        final int year = accessor.get(ChronoField.YEAR);
-        final int month = accessor.get(ChronoField.MONTH_OF_YEAR);
-        final int dayOfMonth = accessor.get(ChronoField.DAY_OF_MONTH);
-        final int hour = getOrDefault(accessor, ChronoField.HOUR_OF_DAY, 0);
-        final int minute = getOrDefault(accessor, ChronoField.MINUTE_OF_HOUR, 
0);
-        final int second = getOrDefault(accessor, 
ChronoField.SECOND_OF_MINUTE, 0);
-        final int microSeconds = getOrDefault(accessor, 
ChronoField.MICRO_OF_SECOND, 0);
-
-        // LocalDateTime of(int year, int month, int dayOfMonth, int hour, int 
minute,
-        // int second, int nanoOfSecond)
-        return LocalDateTime.of(year, month, dayOfMonth, hour, minute, second, 
microSeconds * 1000);
     }
 
     public DateLiteral plusYears(long year) throws AnalysisException {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to