org.apache.hadoop.typedbytes
Class TypedBytesInput

java.lang.Object
  extended by org.apache.hadoop.typedbytes.TypedBytesInput

public class TypedBytesInput
extends Object

Provides functionality for reading typed bytes.


Constructor Summary
TypedBytesInput(DataInput in)
          Creates a new instance of TypedBytesInput.
 
Method Summary
static TypedBytesInput get(DataInput in)
          Get a thread-local typed bytes input for the supplied DataInput.
 Object read()
          Reads a typed bytes sequence and converts it to a Java object.
 boolean readBool()
          Reads the boolean following a Type.BOOL code.
 byte readByte()
          Reads the byte following a Type.BYTE code.
 byte[] readBytes()
          Reads the bytes following a Type.BYTES code.
 double readDouble()
          Reads the double following a Type.DOUBLE code.
 float readFloat()
          Reads the float following a Type.FLOAT code.
 int readInt()
          Reads the integer following a Type.INT code.
 List readList()
          Reads the list following a Type.LIST code.
 long readLong()
          Reads the long following a Type.LONG code.
 TreeMap readMap()
          Reads the map following a Type.MAP code.
 int readMapHeader()
          Reads the header following a Type.MAP code.
 byte[] readRaw()
          Reads a typed bytes sequence.
 byte[] readRawBool()
          Reads the raw bytes following a Type.BOOL code.
 byte[] readRawByte()
          Reads the raw byte following a Type.BYTE code.
 byte[] readRawBytes()
          Reads the raw bytes following a Type.BYTES code.
 byte[] readRawBytes(int code)
          Reads the raw bytes following a custom code.
 byte[] readRawDouble()
          Reads the raw bytes following a Type.DOUBLE code.
 byte[] readRawFloat()
          Reads the raw bytes following a Type.FLOAT code.
 byte[] readRawInt()
          Reads the raw bytes following a Type.INT code.
 byte[] readRawList()
          Reads the raw bytes following a Type.LIST code.
 byte[] readRawLong()
          Reads the raw bytes following a Type.LONG code.
 byte[] readRawMap()
          Reads the raw bytes following a Type.MAP code.
 byte[] readRawString()
          Reads the raw bytes following a Type.STRING code.
 byte[] readRawVector()
          Reads the raw bytes following a Type.VECTOR code.
 String readString()
          Reads the string following a Type.STRING code.
 Type readType()
          Reads a type byte and returns the corresponding Type.
 ArrayList readVector()
          Reads the vector following a Type.VECTOR code.
 int readVectorHeader()
          Reads the header following a Type.VECTOR code.
 boolean skipType()
          Skips a type byte.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypedBytesInput

public TypedBytesInput(DataInput in)
Creates a new instance of TypedBytesInput.

Method Detail

get

public static TypedBytesInput get(DataInput in)
Get a thread-local typed bytes input for the supplied DataInput.

Parameters:
in - data input object
Returns:
typed bytes input corresponding to the supplied DataInput.

read

public Object read()
            throws IOException
Reads a typed bytes sequence and converts it to a Java object. The first byte is interpreted as a type code, and then the right number of subsequent bytes are read depending on the obtained type.

Returns:
the obtained object or null when the end of the file is reached
Throws:
IOException

readRaw

public byte[] readRaw()
               throws IOException
Reads a typed bytes sequence. The first byte is interpreted as a type code, and then the right number of subsequent bytes are read depending on the obtained type.

Returns:
the obtained typed bytes sequence or null when the end of the file is reached
Throws:
IOException

readType

public Type readType()
              throws IOException
Reads a type byte and returns the corresponding Type.

Returns:
the obtained Type or null when the end of the file is reached
Throws:
IOException

skipType

public boolean skipType()
                 throws IOException
Skips a type byte.

Returns:
true iff the end of the file was not reached
Throws:
IOException

readBytes

public byte[] readBytes()
                 throws IOException
Reads the bytes following a Type.BYTES code.

Returns:
the obtained bytes sequence
Throws:
IOException

readRawBytes

public byte[] readRawBytes(int code)
                    throws IOException
Reads the raw bytes following a custom code.

Parameters:
code - the custom type code
Returns:
the obtained bytes sequence
Throws:
IOException

readRawBytes

public byte[] readRawBytes()
                    throws IOException
Reads the raw bytes following a Type.BYTES code.

Returns:
the obtained bytes sequence
Throws:
IOException

readByte

public byte readByte()
              throws IOException
Reads the byte following a Type.BYTE code.

Returns:
the obtained byte
Throws:
IOException

readRawByte

public byte[] readRawByte()
                   throws IOException
Reads the raw byte following a Type.BYTE code.

Returns:
the obtained byte
Throws:
IOException

readBool

public boolean readBool()
                 throws IOException
Reads the boolean following a Type.BOOL code.

Returns:
the obtained boolean
Throws:
IOException

readRawBool

public byte[] readRawBool()
                   throws IOException
Reads the raw bytes following a Type.BOOL code.

Returns:
the obtained bytes sequence
Throws:
IOException

readInt

public int readInt()
            throws IOException
Reads the integer following a Type.INT code.

Returns:
the obtained integer
Throws:
IOException

readRawInt

public byte[] readRawInt()
                  throws IOException
Reads the raw bytes following a Type.INT code.

Returns:
the obtained bytes sequence
Throws:
IOException

readLong

public long readLong()
              throws IOException
Reads the long following a Type.LONG code.

Returns:
the obtained long
Throws:
IOException

readRawLong

public byte[] readRawLong()
                   throws IOException
Reads the raw bytes following a Type.LONG code.

Returns:
the obtained bytes sequence
Throws:
IOException

readFloat

public float readFloat()
                throws IOException
Reads the float following a Type.FLOAT code.

Returns:
the obtained float
Throws:
IOException

readRawFloat

public byte[] readRawFloat()
                    throws IOException
Reads the raw bytes following a Type.FLOAT code.

Returns:
the obtained bytes sequence
Throws:
IOException

readDouble

public double readDouble()
                  throws IOException
Reads the double following a Type.DOUBLE code.

Returns:
the obtained double
Throws:
IOException

readRawDouble

public byte[] readRawDouble()
                     throws IOException
Reads the raw bytes following a Type.DOUBLE code.

Returns:
the obtained bytes sequence
Throws:
IOException

readString

public String readString()
                  throws IOException
Reads the string following a Type.STRING code.

Returns:
the obtained string
Throws:
IOException

readRawString

public byte[] readRawString()
                     throws IOException
Reads the raw bytes following a Type.STRING code.

Returns:
the obtained bytes sequence
Throws:
IOException

readVector

public ArrayList readVector()
                     throws IOException
Reads the vector following a Type.VECTOR code.

Returns:
the obtained vector
Throws:
IOException

readRawVector

public byte[] readRawVector()
                     throws IOException
Reads the raw bytes following a Type.VECTOR code.

Returns:
the obtained bytes sequence
Throws:
IOException

readVectorHeader

public int readVectorHeader()
                     throws IOException
Reads the header following a Type.VECTOR code.

Returns:
the number of elements in the vector
Throws:
IOException

readList

public List readList()
              throws IOException
Reads the list following a Type.LIST code.

Returns:
the obtained list
Throws:
IOException

readRawList

public byte[] readRawList()
                   throws IOException
Reads the raw bytes following a Type.LIST code.

Returns:
the obtained bytes sequence
Throws:
IOException

readMap

public TreeMap readMap()
                throws IOException
Reads the map following a Type.MAP code.

Returns:
the obtained map
Throws:
IOException

readRawMap

public byte[] readRawMap()
                  throws IOException
Reads the raw bytes following a Type.MAP code.

Returns:
the obtained bytes sequence
Throws:
IOException

readMapHeader

public int readMapHeader()
                  throws IOException
Reads the header following a Type.MAP code.

Returns:
the number of key-value pairs in the map
Throws:
IOException


Copyright © 2009 The Apache Software Foundation