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

【Spark107】Spark SQL动态代码生成3

热度:371   发布时间:2016-05-05 09:58:14.0
【Spark107】Spark SQL动态代码生成三

代码

?

2015-09-02 14:46:27,226-[TS] DEBUG Executor task launch worker-1 org.apache.spark.sql.catalyst.expressions.codegen.GenerateSafeProjection - code for input[0, StringType],input[1, StringType],input[2, StringType],input[3, StringType],input[4, StringType]:public Object generate(org.apache.spark.sql.catalyst.expressions.Expression[] expr) {  return new SpecificSafeProjection(expr);}class SpecificSafeProjection extends org.apache.spark.sql.catalyst.expressions.codegen.BaseProjection {    private org.apache.spark.sql.catalyst.expressions.Expression[] expressions;  private org.apache.spark.sql.catalyst.expressions.MutableRow mutableRow;        public SpecificSafeProjection(org.apache.spark.sql.catalyst.expressions.Expression[] expr) {    expressions = expr;    mutableRow = new org.apache.spark.sql.catalyst.expressions.GenericMutableRow(5);      }    public Object apply(Object _i) {    InternalRow i = (InternalRow) _i;    /* input[0, StringType] */        boolean isNull0 = i.isNullAt(0);    UTF8String primitive1 = isNull0 ? null : (i.getUTF8String(0));        if (isNull0) {      mutableRow.setNullAt(0);    } else {            mutableRow.update(0, primitive1.clone().clone());    }    /* input[1, StringType] */        boolean isNull2 = i.isNullAt(1);    UTF8String primitive3 = isNull2 ? null : (i.getUTF8String(1));        if (isNull2) {      mutableRow.setNullAt(1);    } else {            mutableRow.update(1, primitive3.clone().clone());    }    /* input[2, StringType] */        boolean isNull4 = i.isNullAt(2);    UTF8String primitive5 = isNull4 ? null : (i.getUTF8String(2));        if (isNull4) {      mutableRow.setNullAt(2);    } else {            mutableRow.update(2, primitive5.clone().clone());    }    /* input[3, StringType] */        boolean isNull6 = i.isNullAt(3);    UTF8String primitive7 = isNull6 ? null : (i.getUTF8String(3));        if (isNull6) {      mutableRow.setNullAt(3);    } else {            mutableRow.update(3, primitive7.clone().clone());    }    /* input[4, StringType] */        boolean isNull8 = i.isNullAt(4);    UTF8String primitive9 = isNull8 ? null : (i.getUTF8String(4));        if (isNull8) {      mutableRow.setNullAt(4);    } else {            mutableRow.update(4, primitive9.clone().clone());    }        return mutableRow;  }}

?

  相关解决方案