cloud-fan commented on a change in pull request #31198:
URL: https://github.com/apache/spark/pull/31198#discussion_r559970957



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/bitwiseExpressions.scala
##########
@@ -204,3 +205,60 @@ case class BitwiseCount(child: Expression)
     case LongType => java.lang.Long.bitCount(input.asInstanceOf[Long])
   }
 }
+
+object BitwiseGetUtil {
+  def calculate(target: Any, pos: Int, size: Int): Byte = {

Review comment:
       this is inefficient because of boxing. I'd suggest the following
   ```
   def checkPosition(pos: Int, size: Int) = ...
   ...
   override def nullSafeEval(target: Any, pos: Any): Any = {
     val posInt = pos.asInstanceOf[Int]
     BitwiseGetUtil.checkPosition(posInt, bitSize)
     ((target.asInstanceOf[Number].longValue >> posInt) & 1).toByte
   }
   override def doGenCode... {
     ...
     BitwiseGetUtil.checkPosition($pos, $bitSize)
     (byte)((((long) target) >> $pos) & 1)
   }
   ```




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