AngersZhuuuu commented on a change in pull request #30350:
URL: https://github.com/apache/spark/pull/30350#discussion_r526913458



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/NumberConverter.scala
##########
@@ -21,64 +21,37 @@ import org.apache.spark.unsafe.types.UTF8String
 
 object NumberConverter {
 
-  /**
-   * Divide x by m as if x is an unsigned 64-bit integer. Examples:
-   * unsignedLongDiv(-1, 2) == Long.MAX_VALUE unsignedLongDiv(6, 3) == 2
-   * unsignedLongDiv(0, 5) == 0
-   *
-   * @param x is treated as unsigned
-   * @param m is treated as signed
-   */
-  private def unsignedLongDiv(x: Long, m: Int): Long = {
-    if (x >= 0) {
-      x / m
-    } else {
-      // Let uval be the value of the unsigned long with the same bits as x
-      // Two's complement => x = uval - 2*MAX - 2
-      // => uval = x + 2*MAX + 2
-      // Now, use the fact: (a+b)/c = a/c + b/c + (a%c+b%c)/c
-      x / m + 2 * (Long.MaxValue / m) + 2 / m + (x % m + 2 * (Long.MaxValue % 
m) + 2 % m) / m
-    }
-  }
-
   /**
    * Decode v into value[].
    *
    * @param v is treated as an unsigned 64-bit integer
    * @param radix must be between MIN_RADIX and MAX_RADIX
    */
-  private def decode(v: Long, radix: Int, value: Array[Byte]): Unit = {
+  private def decode(v: BigInt, radix: Int, value: Array[Byte]): Unit = {

Review comment:
       > Have you benchmarked it? In general, long is much faster than `BigInt`.
   
   I will update a benchmark result later




----------------------------------------------------------------
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to