Github user fhueske commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3913#discussion_r116724361
  
    --- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/catalog/InMemoryExternalCatalog.scala
 ---
    @@ -18,138 +18,97 @@
     
     package org.apache.flink.table.catalog
     
    -import org.apache.flink.table.api.{DatabaseAlreadyExistException, 
DatabaseNotExistException, TableAlreadyExistException, TableNotExistException}
     import java.util.{List => JList}
     
    -import scala.collection.mutable.HashMap
    +import org.apache.flink.table.api.{DatabaseAlreadyExistException, 
DatabaseNotExistException, TableAlreadyExistException, TableNotExistException}
    +
    +import scala.collection.mutable
     import scala.collection.JavaConverters._
     
     /**
       * This class is an in-memory implementation of [[ExternalCatalog]].
       *
       * It could be used for testing or developing instead of used in 
production environment.
       */
    -class InMemoryExternalCatalog extends CrudExternalCatalog {
    +class InMemoryExternalCatalog(name: String) extends CrudExternalCatalog {
     
    -  private val databases = new HashMap[String, Database]
    +  private val databases = new mutable.HashMap[String, ExternalCatalog]
    +  private val tables = new mutable.HashMap[String, ExternalCatalogTable]
     
    -  @throws[DatabaseNotExistException]
       @throws[TableAlreadyExistException]
       override def createTable(
    -      table: ExternalCatalogTable,
    -      ignoreIfExists: Boolean): Unit = synchronized {
    -    val dbName = table.identifier.database
    -    val tables = getTables(dbName)
    -    val tableName = table.identifier.table
    -    if (tables.contains(tableName)) {
    -      if (!ignoreIfExists) {
    -        throw new TableAlreadyExistException(dbName, tableName)
    -      }
    -    } else {
    -      tables.put(tableName, table)
    +    tableName: String,
    +    table: ExternalCatalogTable,
    +    ignoreIfExists: Boolean): Unit = synchronized {
    +    tables.get(tableName) match {
    +      case Some(_) if !ignoreIfExists => throw new 
TableAlreadyExistException(name, tableName)
    +      case _ => tables.put(tableName, table)
         }
       }
     
    -  @throws[DatabaseNotExistException]
       @throws[TableNotExistException]
    -  override def dropTable(
    -      dbName: String,
    -      tableName: String,
    -      ignoreIfNotExists: Boolean): Unit = synchronized {
    -    val tables = getTables(dbName)
    +  override def dropTable(tableName: String, ignoreIfNotExists: Boolean): 
Unit = synchronized {
         if (tables.remove(tableName).isEmpty && !ignoreIfNotExists) {
    -      throw new TableNotExistException(dbName, tableName)
    +      throw new TableNotExistException(name, tableName)
         }
       }
     
    -  @throws[DatabaseNotExistException]
       @throws[TableNotExistException]
    -  override def alterTable(
    -      table: ExternalCatalogTable,
    -      ignoreIfNotExists: Boolean): Unit = synchronized {
    -    val dbName = table.identifier.database
    -    val tables = getTables(dbName)
    -    val tableName = table.identifier.table
    +  override def alterTable(tableName: String, table: ExternalCatalogTable,
    --- End diff --
    
    please put each parameter into a new line


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to