Github user kiszk commented on a diff in the pull request:
https://github.com/apache/spark/pull/21912#discussion_r214145047
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala
---
@@ -385,107 +385,124 @@ case class MapEntries(child: Expression) extends
UnaryExpression with ExpectsInp
override protected def doGenCode(ctx: CodegenContext, ev: ExprCode):
ExprCode = {
nullSafeCodeGen(ctx, ev, c => {
+ val arrayData = ctx.freshName("arrayData")
val numElements = ctx.freshName("numElements")
val keys = ctx.freshName("keys")
val values = ctx.freshName("values")
val isKeyPrimitive =
CodeGenerator.isPrimitiveType(childDataType.keyType)
val isValuePrimitive =
CodeGenerator.isPrimitiveType(childDataType.valueType)
+
+ val wordSize = UnsafeRow.WORD_SIZE
+ val structSize = UnsafeRow.calculateBitSetWidthInBytes(2) + wordSize
* 2
+ val (isPrimitive, elementSize) = if (isKeyPrimitive &&
isValuePrimitive) {
+ (false, structSize + wordSize)
--- End diff --
Good catch, thank you!!
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]