Skip to content

Commit 590ba26

Browse files
committed
Move out of closure those variable evaluations that need to happen only once
1 parent 28f1b70 commit 590ba26

File tree

1 file changed

+5
-4
lines changed
  • sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions

1 file changed

+5
-4
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/SortOrder.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,13 @@ case class SortPrefix(child: SortOrder) extends UnaryExpression {
163163
BinaryPrefixComparator.computePrefix(raw.asInstanceOf[Array[Byte]])
164164
case dt: DecimalType if dt.precision <= Decimal.MAX_LONG_DIGITS =>
165165
_.asInstanceOf[Decimal].toUnscaledLong
166-
case dt: DecimalType if dt.precision - dt.scale <= Decimal.MAX_LONG_DIGITS => (raw) => {
167-
val value = raw.asInstanceOf[Decimal]
166+
case dt: DecimalType if dt.precision - dt.scale <= Decimal.MAX_LONG_DIGITS =>
168167
val p = Decimal.MAX_LONG_DIGITS
169168
val s = p - (dt.precision - dt.scale)
170-
if (value.changePrecision(p, s)) value.toUnscaledLong else Long.MinValue
171-
}
169+
(raw) => {
170+
val value = raw.asInstanceOf[Decimal]
171+
if (value.changePrecision(p, s)) value.toUnscaledLong else Long.MinValue
172+
}
172173
case dt: DecimalType => (raw) =>
173174
DoublePrefixComparator.computePrefix(raw.asInstanceOf[Decimal].toDouble)
174175
case _ => (Any) => 0L

0 commit comments

Comments
 (0)