|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.hadoop.io.DefaultStringifier<T>
T
- the class of the objects to stringify@InterfaceAudience.Public @InterfaceStability.Stable public class DefaultStringifier<T>
DefaultStringifier is the default implementation of the Stringifier
interface which stringifies the objects using base64 encoding of the
serialized version of the objects. The Serializer
and
Deserializer
are obtained from the SerializationFactory
.
DefaultStringifier offers convenience methods to store/load objects to/from
the configuration.
Constructor Summary | |
---|---|
DefaultStringifier(Configuration conf,
Class<T> c)
|
Method Summary | ||
---|---|---|
void |
close()
Closes this object. |
|
T |
fromString(String str)
Restores the object from its string representation. |
|
static
|
load(Configuration conf,
String keyName,
Class<K> itemClass)
Restores the object from the configuration. |
|
static
|
loadArray(Configuration conf,
String keyName,
Class<K> itemClass)
Restores the array of objects from the configuration. |
|
static
|
store(Configuration conf,
K item,
String keyName)
Stores the item in the configuration with the given keyName. |
|
static
|
storeArray(Configuration conf,
K[] items,
String keyName)
Stores the array of items in the configuration with the given keyName. |
|
String |
toString(T obj)
Converts the object to a string representation |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultStringifier(Configuration conf, Class<T> c)
Method Detail |
---|
public T fromString(String str) throws IOException
Stringifier
fromString
in interface Stringifier<T>
str
- the string representation of the object
IOException
- if the object cannot be restoredpublic String toString(T obj) throws IOException
Stringifier
toString
in interface Stringifier<T>
obj
- the object to convert
IOException
- if the object cannot be convertedpublic void close() throws IOException
Stringifier
close
in interface Closeable
close
in interface Stringifier<T>
IOException
- if an I/O error occurspublic static <K> void store(Configuration conf, K item, String keyName) throws IOException
K
- the class of the itemconf
- the configuration to storeitem
- the object to be storedkeyName
- the name of the key to use
IOException
- : forwards Exceptions from the underlying
Serialization
classes.public static <K> K load(Configuration conf, String keyName, Class<K> itemClass) throws IOException
K
- the class of the itemconf
- the configuration to usekeyName
- the name of the key to useitemClass
- the class of the item
IOException
- : forwards Exceptions from the underlying
Serialization
classes.public static <K> void storeArray(Configuration conf, K[] items, String keyName) throws IOException
K
- the class of the itemconf
- the configuration to useitems
- the objects to be storedkeyName
- the name of the key to use
IndexOutOfBoundsException
- if the items array is empty
IOException
- : forwards Exceptions from the underlying
Serialization
classes.public static <K> K[] loadArray(Configuration conf, String keyName, Class<K> itemClass) throws IOException
K
- the class of the itemconf
- the configuration to usekeyName
- the name of the key to useitemClass
- the class of the item
IOException
- : forwards Exceptions from the underlying
Serialization
classes.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |