dengzhhu653 commented on code in PR #6499:
URL: https://github.com/apache/hive/pull/6499#discussion_r3331402626


##########
standalone-metastore/metastore-client/src/main/java/org/apache/hadoop/hive/metastore/client/builder/HiveMetaStoreClientBuilder.java:
##########
@@ -81,16 +89,16 @@ public IMetaStoreClient build() {
   }
 
   private static IMetaStoreClient createClient(Configuration conf, boolean 
allowEmbedded) throws MetaException {
-    Class<? extends IMetaStoreClient> mscClass = MetastoreConf.getClass(
-        conf, MetastoreConf.ConfVars.METASTORE_CLIENT_IMPL,
-        ThriftHiveMetaStoreClient.class, IMetaStoreClient.class);
-    LOG.info("Using {} as a base MetaStoreClient", mscClass.getName());
-
-    IMetaStoreClient baseMetaStoreClient = null;
     try {
-      baseMetaStoreClient = JavaUtils.newInstance(mscClass,
-          new Class[]{Configuration.class, boolean.class},
-          new Object[]{conf, allowEmbedded});
+      Class<? extends IMetaStoreClient> mscClass = MetastoreConf.getClass(
+          conf, MetastoreConf.ConfVars.METASTORE_CLIENT_IMPL,
+          ThriftHiveMetaStoreClient.class, IMetaStoreClient.class);
+      LOG.info("Using {} as a base MetaStoreClient", mscClass.getName());
+      MetaStoreClientFactory factory = CLIENT_FACTORIES.get(mscClass);
+      if (factory == null) {
+        CLIENT_FACTORIES.put(mscClass, factory = new 
MetaStoreClientFactory(mscClass));

Review Comment:
   CLIENT_FACTORIES caches the best matching constructor to create the client, 
so we don't need to scan through the class every time upon creating the client



-- 
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