Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
address review comment
  • Loading branch information
kiszk committed Jul 31, 2018
commit 49b5ab371af9783be8f2d6351cf664a769957a4e
Original file line number Diff line number Diff line change
Expand Up @@ -4081,11 +4081,11 @@ case class ArrayExcept(left: Expression, right: Expression) extends ArraySetLike
val value = ctx.freshName("value")
val hsValue = ctx.freshName("hsValue")
val size = ctx.freshName("size")
val (postFix, openHashElementType, hsJavaTypeName, genHsValue,
getter, setter, javaTypeName, primitiveTypeName, arrayDataBuilder) =
if (elementTypeSupportEquals) {
val ptName = CodeGenerator.primitiveTypeName(elementType)
val unsafeArray = ctx.freshName("unsafeArray")
if (elementTypeSupportEquals) {
val ptName = CodeGenerator.primitiveTypeName(elementType)
val unsafeArray = ctx.freshName("unsafeArray")
val (postFix, openHashElementType, hsJavaTypeName, genHsValue,
getter, setter, javaTypeName, primitiveTypeName, arrayDataBuilder) =
elementType match {
case BooleanType | ByteType | ShortType | IntegerType =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically we can have special handling for boolean type(at most 2 outputs), but I think it's very rare to see boolean type in array_except. Let's leave it unless users require it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree that it is very rare. Let us remove the special handling code for BooleanType.

("$mcI$sp", "Int", "int",
Expand Down Expand Up @@ -4120,13 +4120,8 @@ case class ArrayExcept(left: Expression, right: Expression) extends ArraySetLike
s"get($i, null)", s"update($pos, $value)", "Object", "Ref",
s"${ev.value} = new $genericArrayData(new Object[$size]);")
}
} else {
("", "", "", "", "", "", "", "", "")
}

nullSafeCodeGen(ctx, ev, (array1, array2) => {
if (openHashElementType != "") {
// Here, we ensure elementTypeSupportEquals is true
nullSafeCodeGen(ctx, ev, (array1, array2) => {
val notFoundNullElement = ctx.freshName("notFoundNullElement")
val nullElementIndex = ctx.freshName("nullElementIndex")
val builder = ctx.freshName("builder")
Expand Down Expand Up @@ -4184,7 +4179,7 @@ case class ArrayExcept(left: Expression, right: Expression) extends ArraySetLike
|$hsJavaTypeName $hsValue = $genHsValue;
|if (!$hs.contains($hsValue)) {
| $hs.add$postFix($hsValue);
| $builder.$$plus$$eq($value);
| $builder.$$plus$$eq($value);
| $size++;
|}
""".stripMargin
Expand Down Expand Up @@ -4240,11 +4235,13 @@ case class ArrayExcept(left: Expression, right: Expression) extends ArraySetLike
|}
|${buildResultArrayData(nonNullArrayDataBuild)}
""".stripMargin
} else {
})
} else {
nullSafeCodeGen(ctx, ev, (array1, array2) => {
val expr = ctx.addReferenceObj("arrayExceptExpr", this)
s"${ev.value} = ($arrayData)$expr.nullSafeEval($array1, $array2);"
}
})
})
}
}

override def prettyName: String = "array_except"
Expand Down