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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to