Skip to content

Commit

Permalink
Code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILO-HE committed Jan 4, 2022
1 parent e0be36e commit eb5ef87
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,11 @@ object ColumnarExpressionConverter extends Logging {
case st: StringTranslate =>
logInfo(s"${expr.getClass} ${expr} is supported, no_cal is $check_if_no_calculation.")
ColumnarTernaryOperator.create(
replaceWithColumnarExpression(
st.srcExpr, attributeSeq, convertBoundRefToAttrRef = convertBoundRefToAttrRef),
replaceWithColumnarExpression(st.matchingExpr,
replaceWithColumnarExpression(st.srcExpr, attributeSeq,
convertBoundRefToAttrRef = convertBoundRefToAttrRef),
replaceWithColumnarExpression(st.matchingExpr, attributeSeq,
convertBoundRefToAttrRef = convertBoundRefToAttrRef),
replaceWithColumnarExpression(st.replaceExpr,
replaceWithColumnarExpression(st.replaceExpr, attributeSeq,
convertBoundRefToAttrRef = convertBoundRefToAttrRef),
expr
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,22 @@ class ColumnarStringSplit(child: Expression, regex: Expression,
}
}

class ColumnarStringTranslate(str: Expression, matchingExpr: Expression,
class ColumnarStringTranslate(src: Expression, matchingExpr: Expression,
replaceExpr: Expression, original: Expression)
extends StringTranslate(str, matchingExpr, replaceExpr) with ColumnarExpression{
extends StringTranslate(src, matchingExpr, replaceExpr) with ColumnarExpression{
buildCheck

def buildCheck: Unit = {
val supportedTypes = List(StringType)
if (supportedTypes.indexOf(str.dataType) == -1) {
throw new UnsupportedOperationException(s"${str.dataType}" +
if (supportedTypes.indexOf(src.dataType) == -1) {
throw new UnsupportedOperationException(s"${src.dataType}" +
s" is not supported in ColumnarStringTranslate!")
}
}

override def doColumnarCodeGen(args: java.lang.Object) : (TreeNode, ArrowType) = {
val (str_node, _): (TreeNode, ArrowType) =
str.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)
src.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)
val (matchingExpr_node, _): (TreeNode, ArrowType) =
matchingExpr.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)
val (replaceExpr_node, _): (TreeNode, ArrowType) =
Expand All @@ -138,15 +138,15 @@ class ColumnarStringTranslate(str: Expression, matchingExpr: Expression,

object ColumnarTernaryOperator {

def create(str: Expression, arg1: Expression, arg2: Expression,
def create(src: Expression, arg1: Expression, arg2: Expression,
original: Expression): Expression = original match {
case ss: Substring =>
new ColumnarSubString(str, arg1, arg2, ss)
new ColumnarSubString(src, arg1, arg2, ss)
// Currently not supported.
// case a: StringSplit =>
// new ColumnarStringSplit(str, a.regex, a.limit, a)
case st: StringTranslate =>
new ColumnarStringTranslate(str, arg1, arg2, st)
new ColumnarStringTranslate(src, arg1, arg2, st)
case other =>
throw new UnsupportedOperationException(s"not currently supported: $other.")
}
Expand Down

0 comments on commit eb5ef87

Please sign in to comment.