You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "Ted Yu (JIRA)" <ji...@apache.org> on 2014/06/08 06:17:01 UTC

[jira] [Commented] (HBASE-11308) Reuse NameStringPair#Builder instances in loops

    [ https://issues.apache.org/jira/browse/HBASE-11308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14021088#comment-14021088 ] 

Ted Yu commented on HBASE-11308:
--------------------------------

Creating NameStringPair#Builder instances within loop occurs in ProtobufUtil#toProtoNamespaceDescriptor() which is called by the following methods:
ZKNamespaceManager#writeNamespace()
TableNamespaceManager#upsert()
MasterRpcServices#listNamespaceDescriptors()

The above methods are frequently called.

> Reuse NameStringPair#Builder instances in loops
> -----------------------------------------------
>
>                 Key: HBASE-11308
>                 URL: https://issues.apache.org/jira/browse/HBASE-11308
>             Project: HBase
>          Issue Type: Task
>            Reporter: Ted Yu
>            Priority: Trivial
>
> The following code is from HColumnDescriptor#convert() but the pattern can be found in other classes, such as HBaseAdmin:
> {code}
>     for (Map.Entry<String, String> e : this.configuration.entrySet()) {
>       NameStringPair.Builder aBuilder = NameStringPair.newBuilder();
>       aBuilder.setName(e.getKey());
>       aBuilder.setValue(e.getValue());
>       builder.addConfiguration(aBuilder.build());
>     }
> {code}
> NameStringPair.Builder instance can be reused across iterations of the loop.
> This would save creation of short-lived objects.



--
This message was sent by Atlassian JIRA
(v6.2#6252)