IMPALA-4529: speed up parsing of identifiers Instead of using substring(), parseInt() and a try/catch, directly check the character.
Change-Id: Iebef43a6a2f7923ca0e9c158d83f5c06f26da0cd Reviewed-on: http://gerrit.cloudera.org:8080/5210 Reviewed-by: Alex Behm <[email protected]> Tested-by: Internal Jenkins Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/90ebecdd Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/90ebecdd Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/90ebecdd Branch: refs/heads/master Commit: 90ebecdd407708e28ff4ff234ee059dd2d3b190e Parents: a35eb2f Author: Tim Armstrong <[email protected]> Authored: Wed Nov 23 13:40:56 2016 -0800 Committer: Internal Jenkins <[email protected]> Committed: Thu Nov 24 08:03:28 2016 +0000 ---------------------------------------------------------------------- fe/src/main/java/org/apache/impala/analysis/ToSqlUtils.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/90ebecdd/fe/src/main/java/org/apache/impala/analysis/ToSqlUtils.java ---------------------------------------------------------------------- diff --git a/fe/src/main/java/org/apache/impala/analysis/ToSqlUtils.java b/fe/src/main/java/org/apache/impala/analysis/ToSqlUtils.java index f01a78c..3c0b850 100644 --- a/fe/src/main/java/org/apache/impala/analysis/ToSqlUtils.java +++ b/fe/src/main/java/org/apache/impala/analysis/ToSqlUtils.java @@ -91,12 +91,7 @@ public class ToSqlUtils { // are needed if this identifier will be preceded by a ".". boolean startsWithNumber = false; if (!hiveNeedsQuotes && !isImpalaKeyword) { - try { - Integer.parseInt(ident.substring(0, 1)); - startsWithNumber = true; - } catch (NumberFormatException e) { - // Ignore exception, identifier does not start with number. - } + startsWithNumber = Character.isDigit(ident.charAt(0)); } if (hiveNeedsQuotes || isImpalaKeyword || startsWithNumber) return "`" + ident + "`"; return ident;
