[
https://issues.apache.org/jira/browse/HADOOP-17101?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17157465#comment-17157465
]
Jonathan Turner Eagles commented on HADOOP-17101:
-------------------------------------------------
Thanks for the updated patch, [~ahussein].
{code:title=HostSet.java}
String sep = "";
while (iter.hasNext()) {
InetSocketAddress addr = iter.next();
sb.append(sep + addr.getAddress().getHostAddress()
+ ":" + addr.getPort());
sep = ",";
}
{code}
I wasn't clear in my comment from before regarding unrolling this loop, but
this is very close. By unrolling this loop, we can add each substring
individually and prevent intermediate string creation. Also making the
separator and ":" a char (not string) is slightly more efficient in general,
but probably won't make a huge difference in this code.
{code:title=suggestion}
sb.append(sep);
sb.append(addr.getAddress().getHostAddress());
// Notice single quote below for slightly more efficient char add
sb.append(':');
sb.append(addr.getPort());
{code}
Everything else looks great.
> Replace Guava Function with Java8+ Function
> -------------------------------------------
>
> Key: HADOOP-17101
> URL: https://issues.apache.org/jira/browse/HADOOP-17101
> Project: Hadoop Common
> Issue Type: Sub-task
> Reporter: Ahmed Hussein
> Assignee: Ahmed Hussein
> Priority: Major
> Attachments: HADOOP-17101.005.patch
>
>
> {code:java}
> Targets
> Occurrences of 'com.google.common.base.Function'
> Found Occurrences (7 usages found)
> hadoop-hdfs-project/hadoop-hdfs/dev-support/jdiff (1 usage found)
> Apache_Hadoop_HDFS_2.6.0.xml (1 usage found)
> 13603 <field name="GET_START_TXID"
> type="com.google.common.base.Function"
> org.apache.hadoop.hdfs.server.blockmanagement (1 usage found)
> HostSet.java (1 usage found)
> 20 import com.google.common.base.Function;
> org.apache.hadoop.hdfs.server.datanode.checker (1 usage found)
> AbstractFuture.java (1 usage found)
> 58 * (ListenableFuture, com.google.common.base.Function)
> Futures.transform}
> org.apache.hadoop.hdfs.server.namenode.ha (1 usage found)
> HATestUtil.java (1 usage found)
> 40 import com.google.common.base.Function;
> org.apache.hadoop.hdfs.server.protocol (1 usage found)
> RemoteEditLog.java (1 usage found)
> 20 import com.google.common.base.Function;
> org.apache.hadoop.mapreduce.lib.input (1 usage found)
> TestFileInputFormat.java (1 usage found)
> 58 import com.google.common.base.Function;
> org.apache.hadoop.yarn.api.protocolrecords.impl.pb (1 usage found)
> GetApplicationsRequestPBImpl.java (1 usage found)
> 38 import com.google.common.base.Function;
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]