[ https://issues.apache.org/jira/browse/MAPREDUCE-2380?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15283290#comment-15283290 ]
Thiago Pinto commented on MAPREDUCE-2380: ----------------------------------------- Duplicated issue. > Multiple replace function call can be replaced with a single for loop to > improve performance > --------------------------------------------------------------------------------------------- > > Key: MAPREDUCE-2380 > URL: https://issues.apache.org/jira/browse/MAPREDUCE-2380 > Project: Hadoop Map/Reduce > Issue Type: Bug > Components: tools/rumen > Affects Versions: 0.21.0 > Reporter: Xiaoming Shi > > {noformat} > ./hadoop-0.21.0/mapred/src/tools/org/apache/hadoop/tools/rumen/LoggedTaskAttempt.java > line:362 > ./chukwa-0.4.0/src/java/org/apache/hadoop/chukwa/datacollection/writer/localfs/LocalWriter.java > line:249 > {noformat} > 4 consecutive replace() is called to remove the special characters. It's 3+ > times slower than using a for loop > replace them all. > {noformat} > e.g. > - str.replace('a', '#'); > - str.replace('b', '%'); > + StringBuilder sb = new StringBuilder( str.length() ); > + for (int i=0; i < str.length(); i++) > + { > + char c = str.charAt(i); > + if ( c == 'a' ) > + sb.append('#'); > + else if ( c== 'b' ) > + sb.append('%'); > + else > + sb.append(c); > + } > + str = sb.toString(); > {noformat} > This bug has the same problem as the MySQL bug : > http://bugs.mysql.com/bug.php?id=45699 -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: mapreduce-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: mapreduce-issues-h...@hadoop.apache.org