ai.catboost.spark.impl.ExpressionEncoderSerializer.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of catboost-spark_3.0_2.12 Show documentation
Show all versions of catboost-spark_3.0_2.12 Show documentation
JVM module to use CatBoost on Apache Spark
package ai.catboost.spark.impl
import org.apache.spark.sql.Row
import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.encoders.{ExpressionEncoder,RowEncoder}
import org.apache.spark.sql.types.StructType
object ExpressionEncoderSerializer {
def apply(schema: StructType) : ExpressionEncoderSerializer = {
new ExpressionEncoderSerializer(RowEncoder(schema).createSerializer())
}
}
class ExpressionEncoderSerializer(val serializer: ExpressionEncoder.Serializer[Row]) {
def toInternalRow(row : Row) : InternalRow = {
serializer(row)
}
}