Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/22216#discussion_r212663909
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala
---
@@ -35,28 +35,38 @@ case class NamedLambdaVariable(
name: String,
dataType: DataType,
nullable: Boolean,
- exprId: ExprId = NamedExpression.newExprId,
- value: AtomicReference[Any] = new AtomicReference())
+ exprId: ExprId = NamedExpression.newExprId)
extends LeafExpression
with NamedExpression
with CodegenFallback {
override def qualifier: Seq[String] = Seq.empty
- override def newInstance(): NamedExpression =
- copy(exprId = NamedExpression.newExprId, value = new AtomicReference())
+ override def newInstance(): NamedExpression = copy(exprId =
NamedExpression.newExprId)
override def toAttribute: Attribute = {
AttributeReference(name, dataType, nullable, Metadata.empty)(exprId,
Seq.empty)
}
- override def eval(input: InternalRow): Any = value.get
+ override def eval(input: InternalRow): Any =
NamedLambdaVariable.values(this)
override def toString: String = s"lambda $name#${exprId.id}$typeSuffix"
override def simpleString: String = s"lambda $name#${exprId.id}:
${dataType.simpleString}"
}
+object NamedLambdaVariable {
+
+ private[this] val _values =
+ new ThreadLocal[mutable.Map[NamedLambdaVariable, Any]] {
--- End diff --
shall we use `ExprId` as the key?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]