com.datasalt.pangool.serialization
Class HadoopSerialization

java.lang.Object
  extended by com.datasalt.pangool.serialization.HadoopSerialization

public class HadoopSerialization
extends Object

You can use this utility class to serialize / deserialize anything in the Hadoop context. It is thread safe. Instantiate once, reuse many times. Otherwise it is not efficient.


Constructor Summary
HadoopSerialization(org.apache.hadoop.conf.Configuration conf)
           
 
Method Summary
<T> T
deser(Class clazz, InputStream in)
          Return a new instance of the given class with the deserialized data from the input stream.
<T> T
deser(Object obj, byte[] array, int offset, int length)
          Deserialize an object using Hadoop serialization from a byte array.
<T> T
deser(Object obj, InputStream in)
          Deseerializes into the given object using the Hadoop serialization system.
 void ser(Object datum, OutputStream output)
          Serializes the given object using the Hadoop serialization system.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HadoopSerialization

public HadoopSerialization(org.apache.hadoop.conf.Configuration conf)
                    throws IOException
Throws:
IOException
Method Detail

ser

public void ser(Object datum,
                OutputStream output)
         throws IOException
Serializes the given object using the Hadoop serialization system.

Throws:
IOException

deser

public <T> T deser(Object obj,
                   InputStream in)
        throws IOException
Deseerializes into the given object using the Hadoop serialization system. Object cannot be null.

Throws:
IOException

deser

public <T> T deser(Class clazz,
                   InputStream in)
        throws IOException
Return a new instance of the given class with the deserialized data from the input stream.

Throws:
IOException

deser

public <T> T deser(Object obj,
                   byte[] array,
                   int offset,
                   int length)
        throws IOException
Deserialize an object using Hadoop serialization from a byte array. The object cannot be null.

Throws:
IOException


Copyright © –2014 Datasalt Systems S.L.. All rights reserved.