Class Encoders

Object
org.apache.spark.sql.Encoders

public class Encoders extends Object
Methods for creating an Encoder.

Since:
1.6.0
  • Constructor Details

    • Encoders

      public Encoders()
  • Method Details

    • BOOLEAN

      public static Encoder<Boolean> BOOLEAN()
      An encoder for nullable boolean type. The Scala primitive encoder is available as scalaBoolean().
      Returns:
      (undocumented)
      Since:
      1.6.0
    • BYTE

      public static Encoder<Byte> BYTE()
      An encoder for nullable byte type. The Scala primitive encoder is available as scalaByte().
      Returns:
      (undocumented)
      Since:
      1.6.0
    • SHORT

      public static Encoder<Short> SHORT()
      An encoder for nullable short type. The Scala primitive encoder is available as scalaShort().
      Returns:
      (undocumented)
      Since:
      1.6.0
    • INT

      public static Encoder<Integer> INT()
      An encoder for nullable int type. The Scala primitive encoder is available as scalaInt().
      Returns:
      (undocumented)
      Since:
      1.6.0
    • LONG

      public static Encoder<Long> LONG()
      An encoder for nullable long type. The Scala primitive encoder is available as scalaLong().
      Returns:
      (undocumented)
      Since:
      1.6.0
    • FLOAT

      public static Encoder<Float> FLOAT()
      An encoder for nullable float type. The Scala primitive encoder is available as scalaFloat().
      Returns:
      (undocumented)
      Since:
      1.6.0
    • DOUBLE

      public static Encoder<Double> DOUBLE()
      An encoder for nullable double type. The Scala primitive encoder is available as scalaDouble().
      Returns:
      (undocumented)
      Since:
      1.6.0
    • STRING

      public static Encoder<String> STRING()
      An encoder for nullable string type.

      Returns:
      (undocumented)
      Since:
      1.6.0
    • DECIMAL

      public static Encoder<BigDecimal> DECIMAL()
      An encoder for nullable decimal type.

      Returns:
      (undocumented)
      Since:
      1.6.0
    • DATE

      public static Encoder<Date> DATE()
      An encoder for nullable date type.

      Returns:
      (undocumented)
      Since:
      1.6.0
    • LOCALDATE

      public static Encoder<LocalDate> LOCALDATE()
      Creates an encoder that serializes instances of the java.time.LocalDate class to the internal representation of nullable Catalyst's DateType.

      Returns:
      (undocumented)
      Since:
      3.0.0
    • LOCALDATETIME

      public static Encoder<LocalDateTime> LOCALDATETIME()
      Creates an encoder that serializes instances of the java.time.LocalDateTime class to the internal representation of nullable Catalyst's TimestampNTZType.

      Returns:
      (undocumented)
      Since:
      3.4.0
    • TIMESTAMP

      public static Encoder<Timestamp> TIMESTAMP()
      An encoder for nullable timestamp type.

      Returns:
      (undocumented)
      Since:
      1.6.0
    • INSTANT

      public static Encoder<Instant> INSTANT()
      Creates an encoder that serializes instances of the java.time.Instant class to the internal representation of nullable Catalyst's TimestampType.

      Returns:
      (undocumented)
      Since:
      3.0.0
    • BINARY

      public static Encoder<byte[]> BINARY()
      An encoder for arrays of bytes.

      Returns:
      (undocumented)
      Since:
      1.6.1
    • DURATION

      public static Encoder<Duration> DURATION()
      Creates an encoder that serializes instances of the java.time.Duration class to the internal representation of nullable Catalyst's DayTimeIntervalType.

      Returns:
      (undocumented)
      Since:
      3.2.0
    • PERIOD

      public static Encoder<Period> PERIOD()
      Creates an encoder that serializes instances of the java.time.Period class to the internal representation of nullable Catalyst's YearMonthIntervalType.

      Returns:
      (undocumented)
      Since:
      3.2.0
    • bean

      public static <T> Encoder<T> bean(Class<T> beanClass)
      Creates an encoder for Java Bean of type T.

      T must be publicly accessible.

      supported types for java bean field: - primitive types: boolean, int, double, etc. - boxed types: Boolean, Integer, Double, etc. - String - java.math.BigDecimal, java.math.BigInteger - time related: java.sql.Date, java.sql.Timestamp, java.time.LocalDate, java.time.Instant - collection types: array, java.util.List, and map - nested java bean.

      Parameters:
      beanClass - (undocumented)
      Returns:
      (undocumented)
      Since:
      1.6.0
    • row

      public static Encoder<Row> row(StructType schema)
      Creates a Row encoder for schema schema.

      Parameters:
      schema - (undocumented)
      Returns:
      (undocumented)
      Since:
      3.5.0
    • kryo

      public static <T> Encoder<T> kryo(scala.reflect.ClassTag<T> evidence$1)
      (Scala-specific) Creates an encoder that serializes objects of type T using Kryo. This encoder maps T into a single byte array (binary) field.

      T must be publicly accessible.

      Parameters:
      evidence$1 - (undocumented)
      Returns:
      (undocumented)
      Since:
      1.6.0
    • kryo

      public static <T> Encoder<T> kryo(Class<T> clazz)
      Creates an encoder that serializes objects of type T using Kryo. This encoder maps T into a single byte array (binary) field.

      T must be publicly accessible.

      Parameters:
      clazz - (undocumented)
      Returns:
      (undocumented)
      Since:
      1.6.0
    • javaSerialization

      public static <T> Encoder<T> javaSerialization(scala.reflect.ClassTag<T> evidence$2)
      (Scala-specific) Creates an encoder that serializes objects of type T using generic Java serialization. This encoder maps T into a single byte array (binary) field.

      T must be publicly accessible.

      Parameters:
      evidence$2 - (undocumented)
      Returns:
      (undocumented)
      Since:
      1.6.0
      Note:
      This is extremely inefficient and should only be used as the last resort.

    • javaSerialization

      public static <T> Encoder<T> javaSerialization(Class<T> clazz)
      Creates an encoder that serializes objects of type T using generic Java serialization. This encoder maps T into a single byte array (binary) field.

      T must be publicly accessible.

      Parameters:
      clazz - (undocumented)
      Returns:
      (undocumented)
      Since:
      1.6.0
      Note:
      This is extremely inefficient and should only be used as the last resort.

    • tuple

      public static <T1, T2> Encoder<scala.Tuple2<T1,T2>> tuple(Encoder<T1> e1, Encoder<T2> e2)
      An encoder for 2-ary tuples.

      Parameters:
      e1 - (undocumented)
      e2 - (undocumented)
      Returns:
      (undocumented)
      Since:
      1.6.0
    • tuple

      public static <T1, T2, T3> Encoder<scala.Tuple3<T1,T2,T3>> tuple(Encoder<T1> e1, Encoder<T2> e2, Encoder<T3> e3)
      An encoder for 3-ary tuples.

      Parameters:
      e1 - (undocumented)
      e2 - (undocumented)
      e3 - (undocumented)
      Returns:
      (undocumented)
      Since:
      1.6.0
    • tuple

      public static <T1, T2, T3, T4> Encoder<scala.Tuple4<T1,T2,T3,T4>> tuple(Encoder<T1> e1, Encoder<T2> e2, Encoder<T3> e3, Encoder<T4> e4)
      An encoder for 4-ary tuples.

      Parameters:
      e1 - (undocumented)
      e2 - (undocumented)
      e3 - (undocumented)
      e4 - (undocumented)
      Returns:
      (undocumented)
      Since:
      1.6.0
    • tuple

      public static <T1, T2, T3, T4, T5> Encoder<scala.Tuple5<T1,T2,T3,T4,T5>> tuple(Encoder<T1> e1, Encoder<T2> e2, Encoder<T3> e3, Encoder<T4> e4, Encoder<T5> e5)
      An encoder for 5-ary tuples.

      Parameters:
      e1 - (undocumented)
      e2 - (undocumented)
      e3 - (undocumented)
      e4 - (undocumented)
      e5 - (undocumented)
      Returns:
      (undocumented)
      Since:
      1.6.0
    • product

      public static <T extends scala.Product> Encoder<T> product(scala.reflect.api.TypeTags.TypeTag<T> evidence$5)
      An encoder for Scala's product type (tuples, case classes, etc).
      Parameters:
      evidence$5 - (undocumented)
      Returns:
      (undocumented)
      Since:
      2.0.0
    • scalaInt

      public static Encoder<Object> scalaInt()
      An encoder for Scala's primitive int type.
      Returns:
      (undocumented)
      Since:
      2.0.0
    • scalaLong

      public static Encoder<Object> scalaLong()
      An encoder for Scala's primitive long type.
      Returns:
      (undocumented)
      Since:
      2.0.0
    • scalaDouble

      public static Encoder<Object> scalaDouble()
      An encoder for Scala's primitive double type.
      Returns:
      (undocumented)
      Since:
      2.0.0
    • scalaFloat

      public static Encoder<Object> scalaFloat()
      An encoder for Scala's primitive float type.
      Returns:
      (undocumented)
      Since:
      2.0.0
    • scalaByte

      public static Encoder<Object> scalaByte()
      An encoder for Scala's primitive byte type.
      Returns:
      (undocumented)
      Since:
      2.0.0
    • scalaShort

      public static Encoder<Object> scalaShort()
      An encoder for Scala's primitive short type.
      Returns:
      (undocumented)
      Since:
      2.0.0
    • scalaBoolean

      public static Encoder<Object> scalaBoolean()
      An encoder for Scala's primitive boolean type.
      Returns:
      (undocumented)
      Since:
      2.0.0