impala-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Ho (Code Review)" <ger...@cloudera.org>
Subject [Impala-ASF-CR] IMPALA-4055: Speed up to date() with custom implementation.
Date Wed, 25 Jan 2017 07:28:03 GMT
Michael Ho has posted comments on this change.

Change subject: IMPALA-4055: Speed up to_date() with custom implementation.
......................................................................


Patch Set 1:

(1 comment)

Nice change. A suggestion below.

http://gerrit.cloudera.org:8080/#/c/5791/1/be/src/exprs/timestamp-functions-ir.cc
File be/src/exprs/timestamp-functions-ir.cc:

PS1, Line 344:   // Fill in year.
             :   const int year = ts_value.date().year();
             :   result.ptr[3] = '0' + year % 10;
             :   result.ptr[2] = '0' + (year / 10) % 10;
             :   result.ptr[1] = '0' + (year / 100) % 10;
             :   result.ptr[0] = '0' + (year / 1000) % 10;
             : 
             :   // Fill in month, day, and dashes.
             :   result.ptr[4] = '-';
             :   TwoDigitZeroPaddedItoa(result.ptr + 5, ts_value.date().month());
             :   result.ptr[7] = '-';
             :   TwoDigitZeroPaddedItoa(result.ptr + 8, ts_value.date().day());
             :   return result;
Appears that the int to string conversion can be factored into a function like the following:

static inline void IntToChar(char* dst, int num, int len) {
   DCHECK_GT(len, 0);
   for (int i = len-1; i >= 0; --i) {
       *(dst + i) = '0' + (num % 10);
       num /= 10;
   }
}

IntToChar(result.ptr, year, 4);
IntToChar(result.ptr + 5, month, 2);
IntToChar(result.ptr + 8, date, 2);


-- 
To view, visit http://gerrit.cloudera.org:8080/5791
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I5713b3e0c27b739aae597a6911cf3b2ddd01f822
Gerrit-PatchSet: 1
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-Owner: Alex Behm <alex.behm@cloudera.com>
Gerrit-Reviewer: Michael Ho <kwho@cloudera.com>
Gerrit-HasComments: Yes

Mime
View raw message