BufferedFSInputStream (Hadoop 0.20.2-cdh3u4 API)
Date: 2012-05-07

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.fs
Class BufferedFSInputStream

    java.lang.Object
      java.io.InputStream
          java.io.FilterInputStream
              java.io.BufferedInputStream
                  org.apache.hadoop.fs.BufferedFSInputStream

All Implemented Interfaces:
  Closeable, PositionedReadable, Seekable

    public class BufferedFSInputStream

extends BufferedInputStream
implements Seekable, PositionedReadable

A class optimizes reading from FSInputStream by bufferring

Field Summary

Fields inherited from class java.io.BufferedInputStream
`buf, count, marklimit, markpos, pos`

Fields inherited from class java.io.FilterInputStream
`in`

Constructor Summary
`BufferedFSInputStream(FSInputStream in, int size)` Creates a `BufferedFSInputStream` with the specified buffer size, and saves its argument, the input stream `in`, for later use.

Method Summary
`long` | `getPos()` Return the current offset from the start of the file
`int` | `read(long position, byte[] buffer, int offset, int length)` Read upto the specified number of bytes, from a given position within a file, and return the number of bytes read.
`void` | `readFully(long position, byte[] buffer)` Read number of bytes equalt to the length of the buffer, from a given position within a file.
`void` | `readFully(long position, byte[] buffer, int offset, int length)` Read the specified number of bytes, from a given position within a file.
`void` | `seek(long pos)` Seek to the given offset from the start of the file.
`boolean` | `seekToNewSource(long targetPos)` Seeks a different copy of the data.
`long` | `skip(long n)`

Methods inherited from class java.io.BufferedInputStream
`available, close, mark, markSupported, read, read, reset`

Methods inherited from class java.io.FilterInputStream
`read`

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

Constructor Detail

### BufferedFSInputStream

    public BufferedFSInputStream(FSInputStream in,
                                 int size)

  Creates a `BufferedFSInputStream` with the specified buffer size, and saves its argument, the input stream `in`, for later use. An internal buffer array of length `size` is created and stored in `buf`.

  Parameters:
    `in` - the underlying input stream.
    `size` - the buffer size.
  Throws:
    `IllegalArgumentException` - if size <= 0.

Method Detail

### getPos

    public long getPos()
                throws IOException

  Description copied from interface: `Seekable`
  Return the current offset from the start of the file

  Specified by:
    `getPos` in interface `Seekable`
  Throws:
    `IOException`

### skip

    public long skip(long n)
              throws IOException

  Overrides:
    `skip` in class `BufferedInputStream`
  Throws:
    `IOException`

### seek

    public void seek(long pos)
              throws IOException

  Description copied from interface: `Seekable`
  Seek to the given offset from the start of the file. The next read() will be from that location. Can't seek past the end of the file.

  Specified by:
    `seek` in interface `Seekable`
  Throws:
    `IOException`

### seekToNewSource

    public boolean seekToNewSource(long targetPos)
                            throws IOException

  Description copied from interface: `Seekable`
  Seeks a different copy of the data. Returns true if found a new source, false otherwise.

  Specified by:
    `seekToNewSource` in interface `Seekable`
  Throws:
    `IOException`

### read

    public int read(long position,
                    byte[] buffer,
                    int offset,
                    int length)
             throws IOException

  Description copied from interface: `PositionedReadable`
  Read upto the specified number of bytes, from a given position within a file, and return the number of bytes read. This does not change the current offset of a file, and is thread-safe.

  Specified by:
    `read` in interface `PositionedReadable`
  Throws:
    `IOException`

### readFully

    public void readFully(long position,
                          byte[] buffer,
                          int offset,
                          int length)
                   throws IOException

  Description copied from interface: `PositionedReadable`
  Read the specified number of bytes, from a given position within a file. This does not change the current offset of a file, and is thread-safe.

  Specified by:
    `readFully` in interface `PositionedReadable`
  Throws:
    `IOException`

### readFully

    public void readFully(long position,
                          byte[] buffer)
                   throws IOException

  Description copied from interface: `PositionedReadable`
  Read number of bytes equalt to the length of the buffer, from a given position within a file. This does not change the current offset of a file, and is thread-safe.

  Specified by:
    `readFully` in interface `PositionedReadable`
  Throws:
    `IOException`

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