[
https://issues.apache.org/jira/browse/HADOOP-19377?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17925123#comment-17925123
]
ASF GitHub Bot commented on HADOOP-19377:
-----------------------------------------
hfutatzhanghb commented on PR #6927:
URL: https://github.com/apache/hadoop/pull/6927#issuecomment-2644432659
> Hello @hfutatzhanghb . I'm a little unclear on the intent of this patch.
It seems a constant is being renamed, but see an actual change in the
initialization logic.
>
> If the intent is to somehow avoid the `new HashMap<>(10)` calls, I imagine
the intent is to pre-allocate space in the structure for a few expected
protocols. This might not actually be useless if it's keeping allocation of the
hash table small, but also pre-allocating enough to avoid dynamic re-allocation
later.
@cnauroth Sir, thanks for your reviewing.
`final static short MAX_SIZE = RPC_PROTOCOL_BUFFER.value`, the value of
MAX_SIZE is 3 and we have three RpcKind in RPC_PROTOCOL_BUFFER.
But we initialize 4 hashmaps and add them to protocolImplMapArray.
The fourth hashmap in protocolImplMapArray will be never used.
```java
Map<ProtoNameVer, ProtoClassProtoImpl> getProtocolImplMap(RPC.RpcKind
rpcKind) {
if (protocolImplMapArray.size() == 0) {// initialize for all rpc kinds
for (int i = 0; i < RpcKind.MAX_SIZE; ++i) {
protocolImplMapArray.add(
new HashMap<ProtoNameVer, ProtoClassProtoImpl>(10));
}
}
return protocolImplMapArray.get(rpcKind.ordinal());
}
```
Hope to receive your response, Sir. thanks again.
> Avoid initializing useless HashMap in protocolImplMapArray.
> -----------------------------------------------------------
>
> Key: HADOOP-19377
> URL: https://issues.apache.org/jira/browse/HADOOP-19377
> Project: Hadoop Common
> Issue Type: Improvement
> Components: common
> Reporter: farmmamba
> Assignee: farmmamba
> Priority: Minor
> Labels: pull-request-available
>
> Avoid initializing useless HashMap in protocolImplMapArray.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]