paul-rogers commented on a change in pull request #1914: DRILL-7458: Base framework for storage plugins URL: https://github.com/apache/drill/pull/1914#discussion_r369227180
########## File path: exec/java-exec/src/main/java/org/apache/drill/exec/store/base/BaseScanFactory.java ########## @@ -0,0 +1,82 @@ +/* + * 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.drill.exec.store.base; + +import java.util.List; + +import org.apache.drill.common.expression.SchemaPath; +import org.apache.drill.exec.metastore.MetadataProviderManager; +import org.apache.drill.exec.physical.impl.scan.framework.ManagedScanFramework.ScanFrameworkBuilder; +import org.apache.drill.exec.server.options.OptionManager; +import org.apache.drill.exec.server.options.SessionOptionManager; + +/** + * Creates the multiple classes needed to plan and execute a scan. Centralizes + * most implementation-specific object creation in one location to avoid needing + * to implement many methods just for type-specific creation. + * + * @param <PLUGIN> the storage plugin class + * @param <SPEC> the scan specification class + * @param <GROUP> the group scan class + * @param <SUB> the sub scan class + */ + +public abstract class BaseScanFactory< + PLUGIN extends BaseStoragePlugin<?>, + SPEC, + GROUP extends BaseGroupScan, + SUB extends BaseSubScan> { + + @SuppressWarnings("unchecked") Review comment: So here is the thing. The storage plugin mechanism is awkwardly designed. This class is trying to hide that fact. Base classes call into methods we define, passing us generic classes, such as the plugin class. However, the methods for any one plugin want to use plugin-specific classes. In the past, we just cast wherever needed. Here, I'm trying to use parameterized classes to create a "walled garden" in which methods use plugin-specific classes. To do that, we do the casting behind the scenes: from base classes to user-defined classes represented as parameters. We *could* require that the user give us the `Class` objects for their classes so that we can do type-safe casting. But, since all the casting is static (the types don't change often), this old-school casting seems sufficient. If something is wrong, it will blow up on the first test. Does this make sense? Is there a better way to solve these same issues? ---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services
