UnsafeProjection — Generic Function to Encode InternalRows to UnsafeRows
UnsafeProjection is a Projection function that encodes InternalRows as UnsafeRows.
|
1 2 3 4 5 |
UnsafeProjection: InternalRow =[apply]=> UnsafeRow |
|
Note
|
Spark SQL uses The base |
Creating UnsafeProjection — create Factory Method
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
create(schema: StructType): UnsafeProjection (1) create(fields: Array[DataType]): UnsafeProjection (2) create(expr: Expression): UnsafeProjection (3) create(exprs: Seq[Expression], inputSchema: Seq[Attribute]): UnsafeProjection (4) create(exprs: Seq[Expression]): UnsafeProjection (5) create( exprs: Seq[Expression], inputSchema: Seq[Attribute], subexpressionEliminationEnabled: Boolean): UnsafeProjection |
-
createtakes the DataTypes fromschemaand calls the 2ndcreate -
createcreates a BoundReference per field infieldsand calls the 5thcreate -
createcalls the 5thcreate -
createcalls the 5thcreate -
The main
createthat does the heavy work
create transforms all CreateNamedStruct expressions to CreateNamedStructUnsafe in every BoundReference in the input exprs.
In the end, create requests GenerateUnsafeProjection to generate a UnsafeProjection.
|
Note
|
A variant of create takes subexpressionEliminationEnabled flag (that usually is subexpressionEliminationEnabled flag of SparkPlan).
|
spark技术分享