use of org.apache.spark.sql.types.ObjectType in project beam by apache.
the class EncoderFactory method fromBeamCoder.
public static <T> Encoder<T> fromBeamCoder(Coder<T> coder) {
Class<? super T> clazz = coder.getEncodedTypeDescriptor().getRawType();
ClassTag<T> classTag = ClassTag$.MODULE$.apply(clazz);
Expression serializer = new EncoderHelpers.EncodeUsingBeamCoder<>(new BoundReference(0, new ObjectType(clazz), true), coder);
Expression deserializer = new EncoderHelpers.DecodeUsingBeamCoder<>(new Cast(new GetColumnByOrdinal(0, BinaryType), BinaryType, scala.Option.<String>empty()), classTag, coder);
return new ExpressionEncoder<>(serializer, deserializer, classTag);
}
Aggregations