hbase-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "stack (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (HBASE-17512) Optimize ServerName.parsePort() to reduce objects creation
Date Thu, 26 Jan 2017 00:01:26 GMT

     [ https://issues.apache.org/jira/browse/HBASE-17512?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

stack updated HBASE-17512:
--------------------------
    Assignee: Samuel David Glover

> Optimize ServerName.parsePort() to reduce objects creation
> ----------------------------------------------------------
>
>                 Key: HBASE-17512
>                 URL: https://issues.apache.org/jira/browse/HBASE-17512
>             Project: HBase
>          Issue Type: Bug
>    Affects Versions: 1.2.4
>            Reporter: Jean-Marc Spaggiari
>            Assignee: Samuel David Glover
>            Priority: Minor
>              Labels: beginner
>
> ServerName.parsePort() calls the split method on a string. This string format is like
"www.example.org,1234,1212121212" where we try to get only 1234. Each time the split() method
is called, it creates 4 objets. 3 strings and an array. And we just us one of those strings.
> This this method is called in a single place. In the constructor:
> {code}
>   private ServerName(final String serverName) {
>     this(parseHostname(serverName), parsePort(serverName),
>       parseStartcode(serverName));
>   }
> {code}
> So parsePort creates 3 string. Te hostname, the port, the startcode, but returns only
the port, while we call 2 other methods to redo the exact same work.
> This constructor is called only there:
> {code}
>   /**
>    * Retrieve an instance of ServerName.
>    * Callers should use the equals method to compare returned instances, though we may
return
>    * a shared immutable object as an internal optimization.
>    */
>   public static ServerName valueOf(final String serverName) {
>     return new ServerName(serverName);
>   }
> {code}
> and this is called here and there. Not intensively, but still, should be cleaned.
> Instead of using split, something like this might do better:
> {code}
>   public static int parsePort(final String serverName) {
>     int indexStart = serverName.indexOf(SERVERNAME_SEPARATOR);
>     int indexStop = serverName.lastIndexOf(SERVERNAME_SEPARATOR);
>     return Integer.parseInt(serverName.substring(indexStart + 1, indexStop));
>   }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message