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_2.4_2.12 Show documentation
Show all versions of catboost-spark_2.4_2.12 Show documentation
JVM module to use CatBoost on Apache Spark
The newest version!
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))
}
}
class ExpressionEncoderSerializer(val converter: ExpressionEncoder[Row]) {
def toInternalRow(row : Row) : InternalRow = {
converter.toRow(row)
}
}