flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sunjincheng121 <...@git.apache.org>
Subject [GitHub] flink pull request #5202: [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT ...
Date Mon, 01 Jan 2018 01:55:48 GMT
Github user sunjincheng121 commented on a diff in the pull request:

    https://github.com/apache/flink/pull/5202#discussion_r159148353
  
    --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala
---
    @@ -109,4 +110,75 @@ object ScalarFunctions {
           Math.log(x) / Math.log(base)
         }
       }
    +
    +  /**
    +    * Returns the Int number after the input number left shift n bits
    +    * @param input Int type
    +    * @param n
    +    * @return input << n
    +    */
    +  def shiftLeft(input: Int, n: Int): Int = {
    +    _shiftLeft(input, n).asInstanceOf[Int]
    +  }
    +
    +  /**
    +    * Returns the Long number after the input number left shift n bits
    +    * @param input Long type
    +    * @param n
    +    * @return input << n
    +    */
    +  def shiftLeft(input: Long, n: Int): Long = {
    +    _shiftLeft(input, n).asInstanceOf[Long]
    +  }
    +
    +  /**
    +    * Returns the Int number after the input number right shift n bits
    +    * @param input Int type
    +    * @param n
    +    * @return input >> n
    +    */
    +  def shiftRight(input: Int, n: Int): Int = {
    +    _shiftRight(input, n).asInstanceOf[Int]
    +  }
    +
    +  /**
    +    * Returns the Long number after the input number right shift n bits
    +    * @param input Long type
    +    * @param n
    +    * @return input >> n
    +    */
    +  def shiftRight(input: Long, n: Int): Long = {
    +    _shiftRight(input, n).asInstanceOf[Long]
    +  }
    +
    +  /**
    +    * Returns the number after the input number left shift n bits
    +    * Input must be type 'Long' or type 'Int'
    +    */
    +  private def _shiftLeft(input: Any, n: Int): Any = {
    +    input match {
    +      case l: jl.Long => l << n
    +      case i: jl.Integer => i << n
    +      case _ =>
    +        throw new IllegalArgumentException(
    +          s"type of input in function 'shiftLeft(input, n)' must be Long or Integer"
    +        )
    +    }
    +  }
    +
    +  /**
    +    * Returns the number after the input number right shift n bits
    +    * Input must be type 'Long' or type 'Int'
    +    */
    +  private def _shiftRight(input: Any, n: Int): Any = {
    --- End diff --
    
    remove this method? 


---

Mime
View raw message