public final class CoderHelpers
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
CoderHelpers.FromByteFunction<K,V>
A function for converting a byte array pair to a key-value pair.
|
Modifier and Type | Method and Description |
---|---|
static <T> T |
fromByteArray(byte[] serialized,
Coder<T> coder)
Utility method for deserializing a byte array using the specified coder.
|
static <T> java.lang.Iterable<T> |
fromByteArrays(java.util.Collection<byte[]> serialized,
Coder<T> coder)
Utility method for deserializing a Iterable of byte arrays using the specified coder.
|
static <T> org.apache.spark.api.java.function.Function<byte[],T> |
fromByteFunction(Coder<T> coder)
A function wrapper for converting a byte array to an object.
|
static <K,V> org.apache.spark.api.java.function.PairFunction<scala.Tuple2<ByteArray,java.lang.Iterable<byte[]>>,K,java.lang.Iterable<V>> |
fromByteFunctionIterable(Coder<K> keyCoder,
Coder<V> valueCoder)
A function wrapper for converting a byte array pair to a key-value pair, where values are
Iterable . |
static <T> byte[] |
toByteArray(T value,
Coder<T> coder)
Utility method for serializing an object using the specified coder.
|
static <T> java.util.List<byte[]> |
toByteArrays(java.lang.Iterable<T> values,
Coder<T> coder)
Utility method for serializing a Iterable of values using the specified coder.
|
static <T> byte[] |
toByteArrayWithTs(T value,
Coder<T> coder,
Instant timestamp)
Utility method for serializing an object using the specified coder, appending timestamp
representation.
|
static <K,V> org.apache.spark.api.java.function.PairFunction<scala.Tuple2<K,V>,ByteArray,byte[]> |
toByteFunction(Coder<K> keyCoder,
Coder<V> valueCoder)
A function wrapper for converting a key-value pair to a byte array pair.
|
static <T> org.apache.spark.api.java.function.Function<T,byte[]> |
toByteFunction(Coder<T> coder)
A function wrapper for converting an object to a bytearray.
|
static <K,V> org.apache.spark.api.java.function.PairFunction<scala.Tuple2<K,V>,ByteArray,byte[]> |
toByteFunctionWithTs(Coder<K> keyCoder,
Coder<V> valueCoder,
org.apache.spark.api.java.function.Function<scala.Tuple2<K,V>,Instant> timestamp)
A function wrapper for converting a key-value pair to a byte array pair, where the key in
resulting ByteArray contains (key, timestamp).
|
public static <T> byte[] toByteArray(T value, Coder<T> coder)
T
- type of value that is serializedvalue
- Value to serialize.coder
- Coder to serialize with.public static <T> byte[] toByteArrayWithTs(T value, Coder<T> coder, Instant timestamp)
T
- type of value that is serializedvalue
- Value to serialize.coder
- Coder to serialize with.timestamp
- timestamp to be bundled into key's ByteArray representationpublic static <T> java.util.List<byte[]> toByteArrays(java.lang.Iterable<T> values, Coder<T> coder)
T
- type of value that is serializedvalues
- Values to serialize.coder
- Coder to serialize with.public static <T> T fromByteArray(byte[] serialized, Coder<T> coder)
T
- Type of object to be returned.serialized
- bytearray to be deserialized.coder
- Coder to deserialize with.public static <T> java.lang.Iterable<T> fromByteArrays(java.util.Collection<byte[]> serialized, Coder<T> coder)
T
- Type of object to be returned.serialized
- bytearrays to be deserialized.coder
- Coder to deserialize with.public static <T> org.apache.spark.api.java.function.Function<T,byte[]> toByteFunction(Coder<T> coder)
T
- The type of the object being serialized.coder
- Coder to serialize with.public static <T> org.apache.spark.api.java.function.Function<byte[],T> fromByteFunction(Coder<T> coder)
T
- The type of the object being deserialized.coder
- Coder to deserialize with.public static <K,V> org.apache.spark.api.java.function.PairFunction<scala.Tuple2<K,V>,ByteArray,byte[]> toByteFunction(Coder<K> keyCoder, Coder<V> valueCoder)
K
- The type of the key being serialized.V
- The type of the value being serialized.keyCoder
- Coder to serialize keys.valueCoder
- Coder to serialize values.public static <K,V> org.apache.spark.api.java.function.PairFunction<scala.Tuple2<K,V>,ByteArray,byte[]> toByteFunctionWithTs(Coder<K> keyCoder, Coder<V> valueCoder, org.apache.spark.api.java.function.Function<scala.Tuple2<K,V>,Instant> timestamp)
K
- The type of the key being serialized.V
- The type of the value being serialized.keyCoder
- Coder to serialize keys.valueCoder
- Coder to serialize values.timestamp
- timestamp of the input Tuple2public static <K,V> org.apache.spark.api.java.function.PairFunction<scala.Tuple2<ByteArray,java.lang.Iterable<byte[]>>,K,java.lang.Iterable<V>> fromByteFunctionIterable(Coder<K> keyCoder, Coder<V> valueCoder)
Iterable
.K
- The type of the key being deserialized.V
- The type of the value being deserialized.keyCoder
- Coder to deserialize keys.valueCoder
- Coder to deserialize values.