org.apache.ignite.internal.processors.igfs

## Class IgfsInputStreamImpl

- java.lang.Object
- - java.io.InputStream
  - - org.apache.ignite.igfs.IgfsInputStream
    - - org.apache.ignite.internal.processors.igfs.IgfsInputStreamAdapter
      - - org.apache.ignite.internal.processors.igfs.IgfsInputStreamImpl

All Implemented Interfaces:
  Closeable, AutoCloseable, IgfsSecondaryFileSystemPositionedReadable

    public class IgfsInputStreamImpl
    extends IgfsInputStreamAdapter

Input stream to read data from grid cache with separate blocks.

### Field Summary

Fields
`protected IgfsPath` `path` Path to file.

### Method Summary

Methods
`int` `available()`
`long` `bytes()` Gets bytes read.
`void` `close()`
`protected IgniteInternalFuture<byte[]>` `dataBlock(IgfsFileInfo fileInfo, long blockIdx)` Get data block for specified block index.
`IgfsFileInfo` `fileInfo()` Gets file info for opened file.
`long` `position()` Get the current position in the input stream.
`int` `read()`
`int` `read(byte[] b, int off, int len)`
`int` `read(long pos, byte[] buf, int off, int len)` Read up to the specified number of bytes, from a given position within a file, and return the number of bytes read.
`byte[][]` `readChunks(long pos, int len)` Reads bytes from given position.
`void` `readFully(long pos, byte[] buf)` Read bytes from the given position in the stream to the given buffer.
`void` `readFully(long pos, byte[] buf, int off, int len)`
`void` `seek(long pos)` Seek to the specified position.
`String` `toString()`

### Methods inherited from class org.apache.ignite.internal.processors.igfs.IgfsInputStreamAdapter

`length`

### Methods inherited from class java.io.InputStream

`mark, markSupported, read, reset, skip`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### path

    protected final IgfsPath path

Path to file.

### Method Detail

#### bytes

    public long bytes()

Gets bytes read.

Returns:
  Bytes read.

#### fileInfo

    public IgfsFileInfo fileInfo()

Gets file info for opened file.

Specified by:
  `fileInfo` in class `IgfsInputStreamAdapter`
Returns:
  File info.

#### read

    public int read()
             throws IOException

Specified by:
  `read` in class `InputStream`
Throws:
  `IOException`

#### read

    public int read(@NotNull
           byte[] b,
           int off,
           int len)
             throws IOException

Overrides:
  `read` in class `InputStream`
Throws:
  `IOException`

#### seek

    public void seek(long pos)
              throws IOException

Seek to the specified position.

Specified by:
  `seek` in class `IgfsInputStream`
Parameters:
  `pos` - Position to seek to.
Throws:
  `IOException` - In case of IO exception.

#### position

    public long position()
                  throws IOException

Get the current position in the input stream.

Specified by:
  `position` in class `IgfsInputStream`
Returns:
  The current position in the input stream.
Throws:
  `IOException` - In case of IO exception.

#### available

    public int available()
                  throws IOException

Overrides:
  `available` in class `InputStream`
Throws:
  `IOException`

#### readFully

    public void readFully(long pos,
                 byte[] buf)
                   throws IOException

Read bytes from the given position in the stream to the given buffer. Continues to read until passed buffer becomes filled.

Specified by:
  `readFully` in class `IgfsInputStream`
Parameters:
  `pos` - Position in the input stream to seek.
  `buf` - Buffer into which data is read.
Throws:
  `IOException` - In case of IO exception.

#### readFully

    public void readFully(long pos,
                 byte[] buf,
                 int off,
                 int len)
                   throws IOException

Specified by:
  `readFully` in class `IgfsInputStream`
Parameters:
  `pos` - Position in the input stream to seek.
  `buf` - Buffer into which data is read.
  `off` - Offset in the buffer from which stream data should be written.
  `len` - The number of bytes to read.
Throws:
  `IOException` - In case of IO exception.

#### read

    public int read(long pos,
           byte[] buf,
           int off,
           int len)
             throws IOException

Read up to the specified number of bytes, from a given position within a file, and return the number of bytes read.

Specified by:
  `read` in interface `IgfsSecondaryFileSystemPositionedReadable`
Specified by:
  `read` in class `IgfsInputStream`
Parameters:
  `pos` - Position in the input stream to seek.
  `buf` - Buffer into which data is read.
  `off` - Offset in the buffer from which stream data should be written.
  `len` - The number of bytes to read.
Returns:
  Total number of bytes read into the buffer, or -1 if there is no more data (EOF).
Throws:
  `IOException` - In case of IO exception.

#### readChunks

    public byte[][] readChunks(long pos,
                      int len)
                        throws IOException

Reads bytes from given position.

Specified by:
  `readChunks` in class `IgfsInputStreamAdapter`
Parameters:
  `pos` - Position to read from.
  `len` - Number of bytes to read.
Returns:
  Array of chunks with respect to chunk file representation.
Throws:
  `IOException` - If read failed.

#### close

    public void close()
               throws IOException

Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `AutoCloseable`
Overrides:
  `close` in class `InputStream`
Throws:
  `IOException`

#### dataBlock

    @Nullable
    protected IgniteInternalFuture<byte[]> dataBlock(IgfsFileInfo fileInfo,
                                                  long blockIdx)
                                              throws IgniteCheckedException

Get data block for specified block index.

Parameters:
  `fileInfo` - File info.
  `blockIdx` - Block index.
Returns:
  Requested data block or `null` if nothing found.
Throws:
  `IgniteCheckedException` - If failed.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0-RC3
Release Date | : March 24 2015