关注 spark技术分享,
撸spark源码 玩spark最佳实践

BoundReference

BoundReference Leaf Expression — Reference to Value in Internal Binary Row

BoundReference is a leaf expression that evaluates to a value in an internal binary row at a specified position and of a given data type.

BoundReference takes the following when created:

  • Ordinal, i.e. the position

  • Data type of the value

  • nullable flag that controls whether the value can be null or not

You can also create a BoundReference using Catalyst DSL’s at method.

Evaluating Expression — eval Method

Note
eval is part of Expression Contract for the interpreted (non-code-generated) expression evaluation, i.e. evaluating a Catalyst expression to a JVM object for a given internal binary row.

eval gives the value at position from the input internal binary row that is of a correct type.

Internally, eval returns null if the value at the position is null.

Otherwise, eval uses the methods of InternalRow per the defined data type to access the value.

Table 1. eval’s DataType to InternalRow’s Methods Mapping (in execution order)
DataType InternalRow’s Method

BooleanType

getBoolean

ByteType

getByte

ShortType

getShort

IntegerType or DateType

getInt

LongType or TimestampType

getLong

FloatType

getFloat

DoubleType

getDouble

StringType

getUTF8String

BinaryType

getBinary

CalendarIntervalType

getInterval

DecimalType

getDecimal

StructType

getStruct

ArrayType

getArray

MapType

getMap

others

get(ordinal, dataType)

Generating Java Source Code (ExprCode) For Code-Generated Expression Evaluation — doGenCode Method

Note
doGenCode is part of Expression Contract to generate a Java source code (ExprCode) for code-generated expression evaluation.

doGenCode…​FIXME

BindReferences.bindReference Method

bindReference…​FIXME

Note
bindReference is used when…​FIXME
赞(0) 打赏
未经允许不得转载:spark技术分享 » BoundReference
分享到: 更多 (0)

关注公众号:spark技术分享

联系我们联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏