Utils (Hadoop 0.20.2-cdh3u3 API)
Date: 2012-03-20

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.hadoop.record
Class Utils

    java.lang.Object
      org.apache.hadoop.record.Utils

    public class Utils

extends Object

Various utility functions for Hadooop record I/O runtime.

Field Summary
`static char[]` | `hexchars`

Method Summary
`static int` | `compareBytes(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2)` Lexicographic order of binary data.
`static int` | `getVIntSize(long i)` Get the encoded length if an integer is stored in a variable-length format
`static double` | `readDouble(byte[] bytes, int start)` Parse a double from a byte array.
`static float` | `readFloat(byte[] bytes, int start)` Parse a float from a byte array.
`static int` | `readVInt(byte[] bytes, int start)` Reads a zero-compressed encoded integer from a byte array and returns it.
`static int` | `readVInt(DataInput in)` Reads a zero-compressed encoded integer from a stream and returns it.
`static long` | `readVLong(byte[] bytes, int start)` Reads a zero-compressed encoded long from a byte array and returns it.
`static long` | `readVLong(DataInput in)` Reads a zero-compressed encoded long from a stream and return it.
`static void` | `writeVInt(DataOutput stream, int i)` Serializes an int 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`

Field Detail

### hexchars

    public static final char[] hexchars

Method Detail

### readFloat

    public static float readFloat(byte[] bytes,
                                  int start)

  Parse a float from a byte array.

### readDouble

    public static double readDouble(byte[] bytes,
                                    int start)

  Parse a double from a byte array.

### readVLong

    public static long readVLong(byte[] bytes,
                                 int start)
                          throws IOException

  Reads a zero-compressed encoded long from a byte array and returns it.

  Parameters:
    `bytes` - byte array with decode long
    `start` - starting index
  Returns:
    deserialized long
  Throws:
    `IOException`

### readVInt

    public static int readVInt(byte[] bytes,
                               int start)
                        throws IOException

  Reads a zero-compressed encoded integer from a byte array and returns it.

  Parameters:
    `bytes` - byte array with the encoded integer
    `start` - start index
  Returns:
    deserialized integer
  Throws:
    `IOException`

### readVLong

    public static long readVLong(DataInput in)
                          throws IOException

  Reads a zero-compressed encoded long from a stream and return it.

  Parameters:
    `in` - input stream
  Returns:
    deserialized long
  Throws:
    `IOException`

### readVInt

    public static int readVInt(DataInput in)
                        throws IOException

  Reads a zero-compressed encoded integer from a stream and returns it.

  Parameters:
    `in` - input stream
  Returns:
    deserialized integer
  Throws:
    `IOException`

### getVIntSize

    public static int getVIntSize(long i)

  Get the encoded length if an integer is stored in a variable-length format

  Returns:
    the encoded length

### writeVLong

    public static void writeVLong(DataOutput stream,
                                  long i)
                           throws IOException

  Serializes a long to a binary stream with zero-compressed encoding. For -112 <= i <= 127, only one byte is used with the actual value. For other values of i, the first byte value indicates whether the long is positive or negative, and the number of bytes that follow. If the first byte value v is between -113 and -120, the following long is positive, with number of bytes that follow are -(v+112). If the first byte value v is between -121 and -128, the following long is negative, with number of bytes that follow are -(v+120). Bytes are stored in the high-non-zero-byte-first order.

  Parameters:
    `stream` - Binary output stream
    `i` - Long to be serialized
  Throws:
    `IOException`

### writeVInt

    public static void writeVInt(DataOutput stream,
                                 int i)
                          throws IOException

  Serializes an int to a binary stream with zero-compressed encoding.

  Parameters:
    `stream` - Binary output stream
    `i` - int to be serialized
  Throws:
    `IOException`

### compareBytes

    public static int compareBytes(byte[] b1,
                                   int s1,
                                   int l1,
                                   byte[] b2,
                                   int s2,
                                   int l2)

  Lexicographic order of binary data.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009 The Apache Software Foundation