flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnowojski <...@git.apache.org>
Subject [GitHub] flink pull request #6323: [FLINK-8558] [FLINK-8866] [table] Finalize unified...
Date Sat, 14 Jul 2018 17:52:07 GMT
Github user pnowojski commented on a diff in the pull request:

    https://github.com/apache/flink/pull/6323#discussion_r202521122
  
    --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/factories/TableFactoryService.scala
---
    @@ -18,143 +18,358 @@
     
     package org.apache.flink.table.factories
     
    -import java.util.{ServiceConfigurationError, ServiceLoader}
    +import java.util.{ServiceConfigurationError, ServiceLoader, Map => JMap}
     
     import org.apache.flink.table.api._
     import org.apache.flink.table.descriptors.ConnectorDescriptorValidator._
     import org.apache.flink.table.descriptors.FormatDescriptorValidator._
     import org.apache.flink.table.descriptors.MetadataValidator._
     import org.apache.flink.table.descriptors.StatisticsValidator._
    -import org.apache.flink.table.descriptors.{DescriptorProperties, TableDescriptor, TableDescriptorValidator}
    +import org.apache.flink.table.descriptors._
     import org.apache.flink.table.util.Logging
    +import org.apache.flink.util.Preconditions
     
     import _root_.scala.collection.JavaConverters._
     import _root_.scala.collection.mutable
     
     /**
    -  * Unified interface to search for TableFactoryDiscoverable of provided type and properties.
    +  * Unified interface to search for a [[TableFactory]] of provided type and properties.
       */
     object TableFactoryService extends Logging {
     
       private lazy val defaultLoader = ServiceLoader.load(classOf[TableFactory])
     
    -  def find(clz: Class[_], descriptor: TableDescriptor): TableFactory = {
    -    find(clz, descriptor, null)
    +  /**
    +    * Finds a table factory of the given class and descriptor.
    +    *
    +    * @param factoryClass desired factory class
    +    * @param descriptor descriptor describing the factory configuration
    +    * @tparam T factory class type
    +    * @return the matching factory
    +    */
    +  def find[T](factoryClass: Class[T], descriptor: Descriptor): T = {
    +    Preconditions.checkNotNull(factoryClass)
    --- End diff --
    
    But this leads to quite some unnecessary code duplication. `checkNotNull(factoryClass)`
appears 5 times here and same applies to other params. Doing the check only in the place where
you are touching value would either solve or at least limit this issue.


---

Mime
View raw message