public class WritableUtils extends Object
Constructor and Description |
---|
WritableUtils() |
Modifier and Type | Method and Description |
---|---|
static <T extends org.apache.hadoop.io.Writable> |
fromByteArray(byte[] array,
Class<T> clazz)
Read a writable from a byte array.
|
static String |
readBytesAsString(DataInput dIn) |
static <T extends org.apache.hadoop.io.Writable> |
readList(DataInput dataInput,
Class<T> clazz)
Read list.
|
static <T extends org.apache.hadoop.io.Writable> |
readMap(DataInput dataInput,
Class<T> clazz)
Read map.
|
static <T extends org.apache.hadoop.io.Writable> |
readMapWithList(DataInput dataInput,
Class<T> clazz)
Read map with list.
|
static String |
readStr(DataInput dataInput)
Read a string from a data input supporting
null values. |
static List<String> |
readStringList(DataInput dataInput) |
static byte[] |
toByteArray(org.apache.hadoop.io.Writable writable)
Write a writable to a byte array.
|
static <T extends org.apache.hadoop.io.Writable> |
writeList(DataOutput dataOutput,
List<T> list)
Write list.
|
static <T extends org.apache.hadoop.io.Writable> |
writeMap(DataOutput dataOutput,
Map<String,T> map)
Write map.
|
static <T extends org.apache.hadoop.io.Writable> |
writeMapWithList(DataOutput dataOutput,
Map<String,List<T>> map)
Write map with list.
|
static void |
writeStr(DataOutput dataOutput,
String str)
Write a string to a data output supporting
null values. |
static void |
writeStringAsBytes(DataOutput dOut,
String value) |
static void |
writeStringList(DataOutput dataOutput,
List<String> list)
Write string list.
|
public WritableUtils()
public static byte[] toByteArray(org.apache.hadoop.io.Writable writable)
writable
- writable to write.public static <T extends org.apache.hadoop.io.Writable> T fromByteArray(byte[] array, Class<T> clazz)
T
- the object typearray
- byte array with the serialized writable.clazz
- writable class.public static void writeStr(DataOutput dataOutput, String str) throws IOException
null
values. It uses the '||' token to represent
null
.
dataOutput
- data output.str
- string to write.IOException
- thrown if the string could not be written.public static String readStr(DataInput dataInput) throws IOException
null
values. It uses the '||' token to represent
null
.
dataInput
- data input.null
if the '||' token was read.IOException
- thrown if the string could not be read.public static <T extends org.apache.hadoop.io.Writable> List<T> readList(DataInput dataInput, Class<T> clazz) throws IOException
T
- the generic typedataInput
- the data inputclazz
- the clazzIOException
- Signals that an I/O exception has occurred.public static List<String> readStringList(DataInput dataInput) throws IOException
IOException
public static <T extends org.apache.hadoop.io.Writable> void writeList(DataOutput dataOutput, List<T> list) throws IOException
T
- the generic typedataOutput
- the data outputlist
- the listIOException
- Signals that an I/O exception has occurred.public static void writeStringList(DataOutput dataOutput, List<String> list) throws IOException
dataOutput
- the data outputlist
- the listIOException
- Signals that an I/O exception has occurred.public static <T extends org.apache.hadoop.io.Writable> void writeMap(DataOutput dataOutput, Map<String,T> map) throws IOException
T
- the generic typedataOutput
- the data outputmap
- the mapIOException
- Signals that an I/O exception has occurred.public static <T extends org.apache.hadoop.io.Writable> void writeMapWithList(DataOutput dataOutput, Map<String,List<T>> map) throws IOException
T
- the generic typedataOutput
- the data outputmap
- the mapIOException
- Signals that an I/O exception has occurred.public static <T extends org.apache.hadoop.io.Writable> Map<String,T> readMap(DataInput dataInput, Class<T> clazz) throws IOException
T
- the generic typedataInput
- the data inputclazz
- the clazzIOException
- Signals that an I/O exception has occurred.public static <T extends org.apache.hadoop.io.Writable> Map<String,List<T>> readMapWithList(DataInput dataInput, Class<T> clazz) throws IOException
T
- the generic typedataInput
- the data inputclazz
- the clazzIOException
- Signals that an I/O exception has occurred.public static void writeStringAsBytes(DataOutput dOut, String value) throws IOException
IOException
public static String readBytesAsString(DataInput dIn) throws IOException
IOException
Copyright © 2018 Apache Software Foundation. All rights reserved.