flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From twalthr <...@git.apache.org>
Subject [GitHub] flink pull request #5564: [FLINK-8538] [table] Add a Kafka table source fact...
Date Mon, 26 Feb 2018 11:23:57 GMT
Github user twalthr commented on a diff in the pull request:

    https://github.com/apache/flink/pull/5564#discussion_r170561781
  
    --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/descriptors/DescriptorProperties.scala
---
    @@ -178,46 +244,128 @@ class DescriptorProperties(normalizeKeys: Boolean = true) {
         }
       }
     
    +  /**
    +    * Adds an indexed mapping of properties under a common key.
    +    *
    +    * For example:
    +    *
    +    * schema.fields.0.type = INT, schema.fields.0.name = test
    +    *                             schema.fields.1.name = test2
    +    *
    +    * The arity of the propertySets can differ.
    +    *
    +    * This method is intended for Java code.
    +    */
    +  def putIndexedVariableProperties(
    +      key: String,
    +      propertySets: JList[JMap[String, String]])
    +    : Unit = {
    +    checkNotNull(key)
    +    checkNotNull(propertySets)
    +    putIndexedVariableProperties(key, propertySets.asScala.map(_.asScala.toMap))
    +  }
    +
       // ----------------------------------------------------------------------------------------------
     
    +  /**
    +    * Returns a string value under the given key if it exists.
    +    */
       def getString(key: String): Option[String] = {
         properties.get(key)
       }
     
    -  def getCharacter(key: String): Option[Character] = getString(key) match {
    -    case Some(c) =>
    -      if (c.length != 1) {
    -        throw new ValidationException(s"The value of $key must only contain one character.")
    -      }
    -      Some(c.charAt(0))
    +  /**
    +    * Returns a string value under the given key if it exists.
    +    * This method is intended for Java code.
    +    */
    +  def getOptionalString(key: String): Optional[String] = toJava(getString(key))
     
    -    case None => None
    +  /**
    +    * Returns a character value under the given key if it exists.
    +    */
    +  def getCharacter(key: String): Option[Character] = getString(key).map { c =>
    +    if (c.length != 1) {
    +      throw new ValidationException(s"The value of $key must only contain one character.")
    +    }
    +    c.charAt(0)
       }
     
    -  def getBoolean(key: String): Option[Boolean] = getString(key) match {
    -    case Some(b) => Some(JBoolean.parseBoolean(b))
    -
    -    case None => None
    +  /**
    +    * Returns a class value under the given key if it exists.
    +    */
    +  def getClass[T](key: String, superClass: Class[T]): Option[Class[T]] = {
    --- End diff --
    
    We need to provide the superclass to validate what we just deserialized otherwise it would
lead to class cast exception.


---

Mime
View raw message