kroushan-nit commented on code in PR #597: URL: https://github.com/apache/incubator-xtable/pull/597#discussion_r1881495076
########## xtable-core/src/main/java/org/apache/xtable/catalog/CatalogConversionFactory.java: ########## @@ -0,0 +1,60 @@ +/* + * 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.xtable.catalog; + +import java.util.List; +import java.util.stream.Collectors; + +import org.apache.hadoop.conf.Configuration; + +import org.apache.xtable.conversion.ExternalCatalog; +import org.apache.xtable.conversion.TargetCatalog; +import org.apache.xtable.reflection.ReflectionUtils; +import org.apache.xtable.spi.extractor.CatalogConversionSource; +import org.apache.xtable.spi.sync.CatalogSyncClient; + +public class CatalogConversionFactory { + private static final CatalogConversionFactory INSTANCE = new CatalogConversionFactory(); + + public static CatalogConversionFactory getInstance() { + return INSTANCE; + } + + public static CatalogConversionSource createSourceForConfig( + ExternalCatalogConfig externalCatalogConfig, Configuration configuration) { + return ReflectionUtils.createInstanceOfClass( + externalCatalogConfig.getCatalogImpl(), externalCatalogConfig, configuration); + } + + public List<CatalogSyncClient> createForCatalog( + TargetCatalog targetCatalog, Configuration configuration) { + return targetCatalog.getTableFormatsToSync().keySet().stream() + .map(tableFormat -> createForTableFormat(targetCatalog, tableFormat, configuration)) + .collect(Collectors.toList()); + } + + private CatalogSyncClient<?> createForTableFormat( + ExternalCatalog externalCatalog, String tableFormat, Configuration configuration) { + return ReflectionUtils.createInstanceOfClass( + externalCatalog.getCatalogConfig().getCatalogImpl(), Review Comment: @vinishjail97 As catalog implementations will be format specific, do we need tableFormat when creating the `CatalogSyncClient` instance? -- 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]
