当前位置: 代码迷 >> SQL >> 【Spark106】Spark SQL动态代码生成2
  详细解决方案

【Spark106】Spark SQL动态代码生成2

热度:336   发布时间:2016-05-05 09:58:12.0
【Spark106】Spark SQL动态代码生成二

代码

?

public SpecificOrdering generate(org.apache.spark.sql.catalyst.expressions.Expression[] expr) {  return new SpecificOrdering(expr);}class SpecificOrdering extends org.apache.spark.sql.catalyst.expressions.codegen.BaseOrdering {    private org.apache.spark.sql.catalyst.expressions.Expression[] expressions;        public SpecificOrdering(org.apache.spark.sql.catalyst.expressions.Expression[] expr) {    expressions = expr;      }    @Override  public int compare(InternalRow a, InternalRow b) {    InternalRow i = null;  // Holds current row being evaluated.        i = a;    boolean isNullA2;    UTF8String primitiveA3;    {      /* input[2, StringType] */            boolean isNull0 = i.isNullAt(2);      UTF8String primitive1 = isNull0 ? null : (i.getUTF8String(2));            isNullA2 = isNull0;      primitiveA3 = primitive1;    }    i = b;    boolean isNullB4;    UTF8String primitiveB5;    {      /* input[2, StringType] */            boolean isNull0 = i.isNullAt(2);      UTF8String primitive1 = isNull0 ? null : (i.getUTF8String(2));            isNullB4 = isNull0;      primitiveB5 = primitive1;    }    if (isNullA2 && isNullB4) {      // Nothing    } else if (isNullA2) {      return -1;    } else if (isNullB4) {      return 1;    } else {      int comp = primitiveA3.compare(primitiveB5);      if (comp != 0) {        return comp;      }    }        return 0;  }}

?

  相关解决方案