a refector to improve performance, this api is in hot path
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/6294427a Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/6294427a Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/6294427a Branch: refs/heads/master Commit: 6294427aa603be970e740332fee032af01e5009c Parents: 5e00f87 Author: Liu Ming <[email protected]> Authored: Tue Apr 5 13:18:36 2016 +0000 Committer: Liu Ming <[email protected]> Committed: Tue Apr 5 13:18:36 2016 +0000 ---------------------------------------------------------------------- core/sql/executor/ExHdfsScan.h | 59 +++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6294427a/core/sql/executor/ExHdfsScan.h ---------------------------------------------------------------------- diff --git a/core/sql/executor/ExHdfsScan.h b/core/sql/executor/ExHdfsScan.h index 1a88a64..0a1dc62 100644 --- a/core/sql/executor/ExHdfsScan.h +++ b/core/sql/executor/ExHdfsScan.h @@ -473,30 +473,51 @@ inline char *hdfs_strchr(char *s, int rd, int cd, const char *end, NABoolean che { char *curr = (char *)s; int count = 0; - while (curr < end) { - if (*curr == rd) { - if( (mode & HIVE_MODE_DOSFORMAT)>0 ) //convert DOS format by replace the \r with space if it is \r\n here - { + if( (mode & HIVE_MODE_DOSFORMAT)>0 ) //check outside the while loop to make it faster + { + while (curr < end) { + if (*curr == rd) { if(count>0 && rd == '\n') { - if(s[count-1] == '\r') s[count-1] = ' '; + if(s[count-1] == '\r') s[count-1] = ' '; } - } - *rdSeen = TRUE; - return curr; - } - else - if (*curr == cd) { - *rdSeen = FALSE; - return curr; + *rdSeen = TRUE; + return curr; + } + else + if (*curr == cd) { + *rdSeen = FALSE; + return curr; + } + else + if (checkRangeDelimiter && *curr == RANGE_DELIMITER) { + *rdSeen = TRUE; + return NULL; + } + curr++; + count++; } - else - if (checkRangeDelimiter && *curr == RANGE_DELIMITER) { - *rdSeen = TRUE; - return NULL; + } + else + { + while (curr < end) { + if (*curr == rd) { + *rdSeen = TRUE; + return curr; + } + else + if (*curr == cd) { + *rdSeen = FALSE; + return curr; + } + else + if (checkRangeDelimiter && *curr == RANGE_DELIMITER) { + *rdSeen = TRUE; + return NULL; + } + curr++; + count++; } - curr++; - count++; } *rdSeen = FALSE; return NULL;
