public final class DataUtil extends Object
Modifier and Type | Class and Description |
---|---|
static class |
DataUtil.InputStreamIterator<T>
An iterator that emits objects from
InputStream using the corresponding Coder . |
Modifier and Type | Method and Description |
---|---|
static String |
blockIdToFilePath(String blockId,
String fileDirectory)
Converts a block id to the corresponding file path.
|
static String |
blockIdToMetaFilePath(String blockId,
String fileDirectory)
Converts a block id to the corresponding metadata file path.
|
static Iterable |
concatNonSerPartitions(Iterable<NonSerializedPartition> partitionsToConcat)
Concatenates an iterable of non-serialized
Partition s into a single iterable of elements. |
static <K extends Serializable> |
convertToNonSerPartitions(Coder coder,
Iterable<SerializedPartition<K>> partitionsToConvert)
|
static <K extends Serializable> |
convertToSerPartitions(Coder coder,
Iterable<NonSerializedPartition<K>> partitionsToConvert)
|
static <K extends Serializable> |
deserializePartition(long elementsInPartition,
Coder coder,
K key,
InputStream inputStream)
Reads the data of a partition from an input stream and deserializes it.
|
static long |
serializePartition(Coder coder,
NonSerializedPartition nonSerializedPartition,
ByteArrayOutputStream bytesOutputStream)
Serializes the elements in a non-serialized partition into an output stream.
|
public static long serializePartition(Coder coder, NonSerializedPartition nonSerializedPartition, ByteArrayOutputStream bytesOutputStream) throws IOException
coder
- the coder to encode the elements.nonSerializedPartition
- the non-serialized partition to serialize.bytesOutputStream
- the output stream to write.IOException
- if fail to serialize.public static <K extends Serializable> NonSerializedPartition deserializePartition(long elementsInPartition, Coder coder, K key, InputStream inputStream) throws IOException
K
- the key type of the partitions.elementsInPartition
- the number of elements in this partition.coder
- the coder to decode the bytes.key
- the key value of the result partition.inputStream
- the input stream which will return the data in the partition as bytes.IOException
- if fail to deserialize.public static <K extends Serializable> Iterable<SerializedPartition<K>> convertToSerPartitions(Coder coder, Iterable<NonSerializedPartition<K>> partitionsToConvert) throws IOException
K
- the key type of the partitions.coder
- the coder for serialization.partitionsToConvert
- the partitions to convert.SerializedPartition
s.IOException
- if fail to convert.public static <K extends Serializable> Iterable<NonSerializedPartition<K>> convertToNonSerPartitions(Coder coder, Iterable<SerializedPartition<K>> partitionsToConvert) throws IOException
K
- the key type of the partitions.coder
- the coder for deserialization.partitionsToConvert
- the partitions to convert.NonSerializedPartition
s.IOException
- if fail to convert.public static String blockIdToFilePath(String blockId, String fileDirectory)
blockId
- the ID of the block.fileDirectory
- the directory of the target block file.public static String blockIdToMetaFilePath(String blockId, String fileDirectory)
blockId
- the ID of the block.fileDirectory
- the directory of the target block file.public static Iterable concatNonSerPartitions(Iterable<NonSerializedPartition> partitionsToConcat) throws IOException
Partition
s into a single iterable of elements.partitionsToConcat
- the partitions to concatenate.IOException
- if fail to concatenate.Copyright © 2018. All rights reserved.