TFile.Reader.Scanner.Entry (Hadoop 1.2.1 API)
Date: 2013-07-22

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.io.file.tfile
Class TFile.Reader.Scanner.Entry

    java.lang.Object
      org.apache.hadoop.io.file.tfile.TFile.Reader.Scanner.Entry

All Implemented Interfaces:
  Comparable<RawComparable>

Enclosing class:
  TFile.Reader.Scanner

    public class TFile.Reader.Scanner.Entry

extends Object
implements Comparable<RawComparable>

Entry to a <Key, Value> pair.

Constructor Summary
`TFile.Reader.Scanner.Entry()`

Method Summary
`int` | `compareTo(byte[] buf)` Compare the entry key to another key.
`int` | `compareTo(byte[] buf, int offset, int length)` Compare the entry key to another key.
`int` | `compareTo(RawComparable key)` Compare an entry with a RawComparable object.
`boolean` | `equals(Object other)` Compare whether this and other points to the same key value.
`void` | `get(BytesWritable key, BytesWritable value)` Copy the key and value in one shot into BytesWritables.
`int` | `getKey(byte[] buf)` Copy the key into user supplied buffer.
`int` | `getKey(byte[] buf, int offset)` Copy the key into user supplied buffer.
`int` | `getKey(BytesWritable key)` Copy the key into BytesWritable.
`int` | `getKeyLength()` Get the length of the key.
`DataInputStream` | `getKeyStream()` Streaming access to the key.
`int` | `getValue(byte[] buf)` Copy value into user-supplied buffer.
`int` | `getValue(byte[] buf, int offset)` Copy value into user-supplied buffer.
`long` | `getValue(BytesWritable value)` Copy the value into BytesWritable.
`int` | `getValueLength()` Get the length of the value.
`DataInputStream` | `getValueStream()` Stream access to value.
`int` | `hashCode()`
`boolean` | `isValueLengthKnown()` Check whether it is safe to call getValueLength().
`int` | `writeKey(OutputStream out)` Writing the key to the output stream.
`long` | `writeValue(OutputStream out)` Writing the value to the output stream.

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### TFile.Reader.Scanner.Entry

    public TFile.Reader.Scanner.Entry()

Method Detail

### getKeyLength

    public int getKeyLength()

  Get the length of the key.

  Returns:
    the length of the key.

### get

    public void get(BytesWritable key,
                    BytesWritable value)
             throws IOException

  Copy the key and value in one shot into BytesWritables. This is equivalent to getKey(key); getValue(value);

  Parameters:
    `key` - BytesWritable to hold key.
    `value` - BytesWritable to hold value
  Throws:
    `IOException`

### getKey

    public int getKey(BytesWritable key)
               throws IOException

  Copy the key into BytesWritable. The input BytesWritable will be automatically resized to the actual key size.

  Parameters:
    `key` - BytesWritable to hold the key.
  Throws:
    `IOException`

### getValue

    public long getValue(BytesWritable value)
                  throws IOException

  Copy the value into BytesWritable. The input BytesWritable will be automatically resized to the actual value size. The implementation directly uses the buffer inside BytesWritable for storing the value. The call does not require the value length to be known.

  Parameters:
    `value` -
  Throws:
    `IOException`

### writeKey

    public int writeKey(OutputStream out)
                 throws IOException

  Writing the key to the output stream. This method avoids copying key buffer from Scanner into user buffer, then writing to the output stream.

  Parameters:
    `out` - The output stream
  Returns:
    the length of the key.
  Throws:
    `IOException`

### writeValue

    public long writeValue(OutputStream out)
                    throws IOException

  Writing the value to the output stream. This method avoids copying value data from Scanner into user buffer, then writing to the output stream. It does not require the value length to be known.

  Parameters:
    `out` - The output stream
  Returns:
    the length of the value
  Throws:
    `IOException`

### getKey

    public int getKey(byte[] buf)
               throws IOException

  Copy the key into user supplied buffer.

  Parameters:
    `buf` - The buffer supplied by user. The length of the buffer must not be shorter than the key length.
  Returns:
    The length of the key.
  Throws:
    `IOException`

### getKey

    public int getKey(byte[] buf,
                      int offset)
               throws IOException

  Copy the key into user supplied buffer.

  Parameters:
    `buf` - The buffer supplied by user.
    `offset` - The starting offset of the user buffer where we should copy the key into. Requiring the key-length + offset no greater than the buffer length.
  Returns:
    The length of the key.
  Throws:
    `IOException`

### getKeyStream

    public DataInputStream getKeyStream()

  Streaming access to the key. Useful for desrializing the key into user objects.

  Returns:
    The input stream.

### getValueLength

    public int getValueLength()

  Get the length of the value. isValueLengthKnown() must be tested true.

  Returns:
    the length of the value.

### getValue

    public int getValue(byte[] buf)
                 throws IOException

  Copy value into user-supplied buffer. User supplied buffer must be large enough to hold the whole value. The value part of the key-value pair pointed by the current cursor is not cached and can only be examined once. Calling any of the following functions more than once without moving the cursor will result in exception: `getValue(byte[])`, `getValue(byte[], int)`, `getValueStream()`.

  Returns:
    the length of the value. Does not require isValueLengthKnown() to be true.
  Throws:
    `IOException`

### getValue

    public int getValue(byte[] buf,
                        int offset)
                 throws IOException

  Copy value into user-supplied buffer. User supplied buffer must be large enough to hold the whole value (starting from the offset). The value part of the key-value pair pointed by the current cursor is not cached and can only be examined once. Calling any of the following functions more than once without moving the cursor will result in exception: `getValue(byte[])`, `getValue(byte[], int)`, `getValueStream()`.

  Returns:
    the length of the value. Does not require isValueLengthKnown() to be true.
  Throws:
    `IOException`

### getValueStream

    public DataInputStream getValueStream()
                                   throws IOException

  Stream access to value. The value part of the key-value pair pointed by the current cursor is not cached and can only be examined once. Calling any of the following functions more than once without moving the cursor will result in exception: `getValue(byte[])`, `getValue(byte[], int)`, `getValueStream()`.

  Returns:
    The input stream for reading the value.
  Throws:
    `IOException`

### isValueLengthKnown

    public boolean isValueLengthKnown()

  Check whether it is safe to call getValueLength().

  Returns:
    true if value length is known before hand. Values less than the chunk size will always have their lengths known before hand. Values that are written out as a whole (with advertised length up-front) will always have their lengths known in read.

### compareTo

    public int compareTo(byte[] buf)

  Compare the entry key to another key. Synonymous to compareTo(key, 0, key.length).

  Parameters:
    `buf` - The key buffer.
  Returns:
    comparison result between the entry key with the input key.

### compareTo

    public int compareTo(byte[] buf,
                         int offset,
                         int length)

  Compare the entry key to another key. Synonymous to compareTo(new ByteArray(buf, offset, length)

  Parameters:
    `buf` - The key buffer
    `offset` - offset into the key buffer.
    `length` - the length of the key.
  Returns:
    comparison result between the entry key with the input key.

### compareTo

    public int compareTo(RawComparable key)

  Compare an entry with a RawComparable object. This is useful when Entries are stored in a collection, and we want to compare a user supplied key.

  Specified by:
    `compareTo` in interface `Comparable<RawComparable>`

### equals

    public boolean equals(Object other)

  Compare whether this and other points to the same key value.

  Overrides:
    `equals` in class `Object`

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Object`

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