bowenli86 commented on a change in pull request #8564: [FLINK-12649][hive] Add 
a shim layer to support multiple versions of HMS
URL: https://github.com/apache/flink/pull/8564#discussion_r288692112
 
 

 ##########
 File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveShimLoader.java
 ##########
 @@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog.hive;
+
+import org.apache.hive.common.util.HiveVersionInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * A loader to load HiveShim.
+ */
+public class HiveShimLoader {
+
+       private static final String HIVE_V1_VERSION_NAME = "1.x";
+       private static final String HIVE_V2_VERSION_NAME = "2.x";
+       private static final String DEFAULT_HIVE_VERSION_NAME = 
HIVE_V2_VERSION_NAME;
+
+       private static final Map<String, HiveShim> hiveShims = new 
ConcurrentHashMap<>(2);
+
+       private static final Logger LOG = 
LoggerFactory.getLogger(HiveShimLoader.class);
+
+       private HiveShimLoader() {
+       }
+
+       public static HiveShim loadHiveShim() {
+               String version = getVersion();
+               return hiveShims.computeIfAbsent(version, (v) -> {
+                       switch (v) {
+                               case HIVE_V1_VERSION_NAME:
+                                       return new HiveShimV1();
+                               case HIVE_V2_VERSION_NAME:
+                                       return new HiveShimV2();
+                               default:
+                                       throw new 
IllegalArgumentException("Unsupported Hive version " + v);
+                       }
+               });
+       }
+
+       private static String getVersion() {
+               String version = HiveVersionInfo.getVersion();
 
 Review comment:
   does this mean the the hive version is determined by the jars users provide?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to