|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.hadoop.io.WritableUtils
@InterfaceAudience.Public @InterfaceStability.Stable public final class WritableUtils
Constructor Summary | |
---|---|
WritableUtils()
|
Method Summary | ||
---|---|---|
static
|
clone(T orig,
Configuration conf)
Make a copy of a writable object using serialization to a buffer. |
|
static void |
cloneInto(Writable dst,
Writable src)
Deprecated. use ReflectionUtils.cloneInto instead. |
|
static int |
decodeVIntSize(byte value)
Parse the first byte of a vint/vlong to determine the number of bytes |
|
static void |
displayByteArray(byte[] record)
|
|
static int |
getVIntSize(long i)
Get the encoded length if an integer is stored in a variable-length format |
|
static boolean |
isNegativeVInt(byte value)
Given the first byte of a vint/vlong, determine the sign |
|
static byte[] |
readCompressedByteArray(DataInput in)
|
|
static String |
readCompressedString(DataInput in)
|
|
static String[] |
readCompressedStringArray(DataInput in)
|
|
static
|
readEnum(DataInput in,
Class<T> enumType)
Read an Enum value from DataInput, Enums are read and written using String values. |
|
static String |
readString(DataInput in)
|
|
static String[] |
readStringArray(DataInput in)
|
|
static String |
readStringSafely(DataInput in,
int maxLength)
Read a string, but check it for sanity. |
|
static int |
readVInt(DataInput stream)
Reads a zero-compressed encoded integer from input stream and returns it. |
|
static int |
readVIntInRange(DataInput stream,
int lower,
int upper)
Reads an integer from the input stream and returns it. |
|
static long |
readVLong(DataInput stream)
Reads a zero-compressed encoded long from input stream and returns it. |
|
static void |
skipCompressedByteArray(DataInput in)
|
|
static void |
skipFully(DataInput in,
int len)
Skip len number of bytes in input streamin |
|
static byte[] |
toByteArray(Writable... writables)
Convert writables to a byte array |
|
static int |
writeCompressedByteArray(DataOutput out,
byte[] bytes)
|
|
static int |
writeCompressedString(DataOutput out,
String s)
|
|
static void |
writeCompressedStringArray(DataOutput out,
String[] s)
|
|
static void |
writeEnum(DataOutput out,
Enum<?> enumVal)
writes String value of enum to DataOutput. |
|
static void |
writeString(DataOutput out,
String s)
|
|
static void |
writeStringArray(DataOutput out,
String[] s)
|
|
static void |
writeVInt(DataOutput stream,
int i)
Serializes an integer to a binary stream with zero-compressed encoding. |
|
static void |
writeVLong(DataOutput stream,
long i)
Serializes a long to a binary stream with zero-compressed encoding. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WritableUtils()
Method Detail |
---|
public static byte[] readCompressedByteArray(DataInput in) throws IOException
IOException
public static void skipCompressedByteArray(DataInput in) throws IOException
IOException
public static int writeCompressedByteArray(DataOutput out, byte[] bytes) throws IOException
IOException
public static String readCompressedString(DataInput in) throws IOException
IOException
public static int writeCompressedString(DataOutput out, String s) throws IOException
IOException
public static void writeString(DataOutput out, String s) throws IOException
IOException
public static String readString(DataInput in) throws IOException
IOException
public static void writeStringArray(DataOutput out, String[] s) throws IOException
IOException
public static void writeCompressedStringArray(DataOutput out, String[] s) throws IOException
IOException
public static String[] readStringArray(DataInput in) throws IOException
IOException
public static String[] readCompressedStringArray(DataInput in) throws IOException
IOException
public static void displayByteArray(byte[] record)
public static <T extends Writable> T clone(T orig, Configuration conf)
orig
- The object to copy
@Deprecated public static void cloneInto(Writable dst, Writable src) throws IOException
dst
- the object to copy fromsrc
- the object to copy into, which is destroyed
IOException
public static void writeVInt(DataOutput stream, int i) throws IOException
stream
- Binary output streami
- Integer to be serialized
IOException
public static void writeVLong(DataOutput stream, long i) throws IOException
stream
- Binary output streami
- Long to be serialized
IOException
public static long readVLong(DataInput stream) throws IOException
stream
- Binary input stream
IOException
public static int readVInt(DataInput stream) throws IOException
stream
- Binary input stream
IOException
public static int readVIntInRange(DataInput stream, int lower, int upper) throws IOException
stream
- Binary input stream
IOException
public static boolean isNegativeVInt(byte value)
value
- the first byte
public static int decodeVIntSize(byte value)
value
- the first byte of the vint/vlong
public static int getVIntSize(long i)
public static <T extends Enum<T>> T readEnum(DataInput in, Class<T> enumType) throws IOException
T
- Enum typein
- DataInput to read fromenumType
- Class type of Enum
IOException
public static void writeEnum(DataOutput out, Enum<?> enumVal) throws IOException
out
- Dataoutput streamenumVal
- enum value
IOException
public static void skipFully(DataInput in, int len) throws IOException
in
- input streamlen
- number of bytes to skip
IOException
- when skipped less number of bytespublic static byte[] toByteArray(Writable... writables)
public static String readStringSafely(DataInput in, int maxLength) throws IOException, IllegalArgumentException
in
- the stream to read frommaxLength
- the largest acceptable length of the encoded string
IOException
- if reading from the DataInput fails
IllegalArgumentException
- if the encoded byte size for string
is negative or larger than maxSize. Only the vint is read.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |