Package org.apache.spark.sql
Class Encoders
Object
org.apache.spark.sql.Encoders
Methods for creating an
Encoder
.
- Since:
- 1.6.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Encoder<T>
Creates an encoder for Java Bean of type T.static Encoder<byte[]>
BINARY()
An encoder for arrays of bytes.BOOLEAN()
An encoder for nullable boolean type.BYTE()
An encoder for nullable byte type.DATE()
An encoder for nullable date type.static Encoder<BigDecimal>
DECIMAL()
An encoder for nullable decimal type.DOUBLE()
An encoder for nullable double type.DURATION()
Creates an encoder that serializes instances of thejava.time.Duration
class to the internal representation of nullable Catalyst's DayTimeIntervalType.FLOAT()
An encoder for nullable float type.INSTANT()
Creates an encoder that serializes instances of thejava.time.Instant
class to the internal representation of nullable Catalyst's TimestampType.INT()
An encoder for nullable int type.static <T> Encoder<T>
javaSerialization
(Class<T> clazz) Creates an encoder that serializes objects of type T using generic Java serialization.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.static <T> Encoder<T>
Creates an encoder that serializes objects of type T using Kryo.static <T> Encoder<T>
kryo
(scala.reflect.ClassTag<T> evidence$1) (Scala-specific) Creates an encoder that serializes objects of type T using Kryo.Creates an encoder that serializes instances of thejava.time.LocalDate
class to the internal representation of nullable Catalyst's DateType.static Encoder<LocalDateTime>
Creates an encoder that serializes instances of thejava.time.LocalDateTime
class to the internal representation of nullable Catalyst's TimestampNTZType.LONG()
An encoder for nullable long type.PERIOD()
Creates an encoder that serializes instances of thejava.time.Period
class to the internal representation of nullable Catalyst's YearMonthIntervalType.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).row
(StructType schema) Creates aRow
encoder for schemaschema
.An encoder for Scala's primitive boolean type.An encoder for Scala's primitive byte type.An encoder for Scala's primitive double type.An encoder for Scala's primitive float type.scalaInt()
An encoder for Scala's primitive int type.An encoder for Scala's primitive long type.An encoder for Scala's primitive short type.SHORT()
An encoder for nullable short type.STRING()
An encoder for nullable string type.An encoder for nullable timestamp type.static <T1,
T2> Encoder<scala.Tuple2<T1, T2>> An encoder for 2-ary tuples.static <T1,
T2, T3> Encoder<scala.Tuple3<T1, T2, T3>> An encoder for 3-ary tuples.static <T1,
T2, T3, T4>
Encoder<scala.Tuple4<T1,T2, T3, T4>> An encoder for 4-ary tuples.static <T1,
T2, T3, T4, T5>
Encoder<scala.Tuple5<T1,T2, T3, T4, T5>> An encoder for 5-ary tuples.
-
Constructor Details
-
Encoders
public Encoders()
-
-
Method Details
-
BOOLEAN
An encoder for nullable boolean type. The Scala primitive encoder is available asscalaBoolean()
.- Returns:
- (undocumented)
- Since:
- 1.6.0
-
BYTE
An encoder for nullable byte type. The Scala primitive encoder is available asscalaByte()
.- Returns:
- (undocumented)
- Since:
- 1.6.0
-
SHORT
An encoder for nullable short type. The Scala primitive encoder is available asscalaShort()
.- Returns:
- (undocumented)
- Since:
- 1.6.0
-
INT
An encoder for nullable int type. The Scala primitive encoder is available asscalaInt()
.- Returns:
- (undocumented)
- Since:
- 1.6.0
-
LONG
An encoder for nullable long type. The Scala primitive encoder is available asscalaLong()
.- Returns:
- (undocumented)
- Since:
- 1.6.0
-
FLOAT
An encoder for nullable float type. The Scala primitive encoder is available asscalaFloat()
.- Returns:
- (undocumented)
- Since:
- 1.6.0
-
DOUBLE
An encoder for nullable double type. The Scala primitive encoder is available asscalaDouble()
.- Returns:
- (undocumented)
- Since:
- 1.6.0
-
STRING
An encoder for nullable string type.- Returns:
- (undocumented)
- Since:
- 1.6.0
-
DECIMAL
An encoder for nullable decimal type.- Returns:
- (undocumented)
- Since:
- 1.6.0
-
DATE
An encoder for nullable date type.- Returns:
- (undocumented)
- Since:
- 1.6.0
-
LOCALDATE
Creates an encoder that serializes instances of thejava.time.LocalDate
class to the internal representation of nullable Catalyst's DateType.- Returns:
- (undocumented)
- Since:
- 3.0.0
-
LOCALDATETIME
Creates an encoder that serializes instances of thejava.time.LocalDateTime
class to the internal representation of nullable Catalyst's TimestampNTZType.- Returns:
- (undocumented)
- Since:
- 3.4.0
-
TIMESTAMP
An encoder for nullable timestamp type.- Returns:
- (undocumented)
- Since:
- 1.6.0
-
INSTANT
Creates an encoder that serializes instances of thejava.time.Instant
class to the internal representation of nullable Catalyst's TimestampType.- Returns:
- (undocumented)
- Since:
- 3.0.0
-
BINARY
An encoder for arrays of bytes.- Returns:
- (undocumented)
- Since:
- 1.6.1
-
DURATION
Creates an encoder that serializes instances of thejava.time.Duration
class to the internal representation of nullable Catalyst's DayTimeIntervalType.- Returns:
- (undocumented)
- Since:
- 3.2.0
-
PERIOD
Creates an encoder that serializes instances of thejava.time.Period
class to the internal representation of nullable Catalyst's YearMonthIntervalType.- Returns:
- (undocumented)
- Since:
- 3.2.0
-
bean
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
Creates aRow
encoder for schemaschema
.- Parameters:
schema
- (undocumented)- Returns:
- (undocumented)
- Since:
- 3.5.0
-
kryo
(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
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
(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
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
An encoder for 2-ary tuples.- Parameters:
e1
- (undocumented)e2
- (undocumented)- Returns:
- (undocumented)
- Since:
- 1.6.0
-
tuple
public static <T1,T2, Encoder<scala.Tuple3<T1,T3> T2, tupleT3>> (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, Encoder<scala.Tuple4<T1,T3, T4> T2, tupleT3, T4>> (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, Encoder<scala.Tuple5<T1,T3, T4, T5> T2, tupleT3, T4, T5>> (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
An encoder for Scala's primitive int type.- Returns:
- (undocumented)
- Since:
- 2.0.0
-
scalaLong
An encoder for Scala's primitive long type.- Returns:
- (undocumented)
- Since:
- 2.0.0
-
scalaDouble
An encoder for Scala's primitive double type.- Returns:
- (undocumented)
- Since:
- 2.0.0
-
scalaFloat
An encoder for Scala's primitive float type.- Returns:
- (undocumented)
- Since:
- 2.0.0
-
scalaByte
An encoder for Scala's primitive byte type.- Returns:
- (undocumented)
- Since:
- 2.0.0
-
scalaShort
An encoder for Scala's primitive short type.- Returns:
- (undocumented)
- Since:
- 2.0.0
-
scalaBoolean
An encoder for Scala's primitive boolean type.- Returns:
- (undocumented)
- Since:
- 2.0.0
-