Skip to content

Instantly share code, notes, and snippets.

@marmbrus
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save marmbrus/9efb31d2b5154aea6652 to your computer and use it in GitHub Desktop.
Save marmbrus/9efb31d2b5154aea6652 to your computer and use it in GitHub Desktop.
Spark SQL Code Generation Example
(() => {
final class $anon extends org.apache.spark.sql.catalyst.expressions.MutableProjection {
def <init>() = {
super.<init>();
()
};
private[this] var mutableRow: org.apache.spark.sql.catalyst.expressions.MutableRow = new org.apache.spark.sql.catalyst.expressions.GenericMutableRow(1);
def target(row: org.apache.spark.sql.catalyst.expressions.MutableRow): org.apache.spark.sql.catalyst.expressions.MutableProjection = {
mutableRow = row;
this
};
def currentValue: org.apache.spark.sql.catalyst.expressions.Row = mutableRow;
def apply(i: org.apache.spark.sql.catalyst.expressions.Row): org.apache.spark.sql.catalyst.expressions.Row = {
val nullTerm$4: Boolean = i.isNullAt(0);
val primitiveTerm$3: org.apache.spark.sql.catalyst.types.IntegerType.JvmType = if (nullTerm$4)
-1
else
i.getInt(0);
();
val nullTerm$7: Boolean = i.isNullAt(1);
val primitiveTerm$6: org.apache.spark.sql.catalyst.types.IntegerType.JvmType = if (nullTerm$7)
-1
else
i.getInt(1);
();
val nullTerm$1 = nullTerm$4.$bar$bar(nullTerm$7);
val primitiveTerm$0: org.apache.spark.sql.catalyst.types.IntegerType.JvmType = if (nullTerm$1)
-1
else
primitiveTerm$3.$plus(primitiveTerm$6).asInstanceOf[org.apache.spark.sql.catalyst.types.IntegerType.JvmType];
();
if (nullTerm$1)
mutableRow.setNullAt(0)
else
mutableRow.setInt(0, primitiveTerm$0);
mutableRow
}
};
new $anon()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment