org.apache.ignite.igfs.mapreduce

## Class IgfsRangeInputStream

- java.lang.Object
- - java.io.InputStream
  - - org.apache.ignite.igfs.IgfsInputStream
    - - org.apache.ignite.igfs.mapreduce.IgfsRangeInputStream

All Implemented Interfaces:
  Closeable, AutoCloseable

    public final class IgfsRangeInputStream
    extends IgfsInputStream

Decorator for regular `IgfsInputStream` which streams only data within the given range. This stream is used for `IgfsInputStreamJobAdapter` convenience adapter to create jobs which will be working only with the assigned range. You can also use it explicitly when working with `IgfsJob` directly.

### Constructor Summary

Constructors
Constructor and Description
`IgfsRangeInputStream(IgfsInputStream is, IgfsFileRange range)` Constructor.
`IgfsRangeInputStream(IgfsInputStream is, long start, long maxLen)` Constructor.

### Method Summary

Methods
`int` `available()`
`void` `close()`
`long` `length()` Gets file length during file open.
`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)`
`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.
`long` `startOffset()` Since range input stream represents a part of larger file stream, there is an offset at which this range input stream starts in original input stream.
`String` `toString()`

### 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`

### Constructor Detail

#### IgfsRangeInputStream

    public IgfsRangeInputStream(IgfsInputStream is,
                        long start,
                        long maxLen)
                         throws IOException

Constructor.

Parameters:
  `is` - Base input stream.
  `start` - Start position.
  `maxLen` - Maximum stream length.
Throws:
  `IOException` - In case of exception.

#### IgfsRangeInputStream

    public IgfsRangeInputStream(IgfsInputStream is,
                        IgfsFileRange range)
                         throws IOException

Constructor.

Parameters:
  `is` - Base input stream.
  `range` - File range.
Throws:
  `IOException` - In case of exception.

### Method Detail

#### length

    public long length()

Gets file length during file open.

Specified by:
  `length` in class `IgfsInputStream`
Returns:
  File length.

#### 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`

#### read

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

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.

#### 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.

#### 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()

Get the current position in the input stream.

Specified by:
  `position` in class `IgfsInputStream`
Returns:
  The current position in the input stream.

#### startOffset

    public long startOffset()

Since range input stream represents a part of larger file stream, there is an offset at which this range input stream starts in original input stream. This method returns start offset of this input stream relative to original input stream.

Returns:
  Start offset in original input stream.

#### available

    public int available()

Overrides:
  `available` in class `InputStream`

#### 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`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.1.0
Release Date | : July 20 2017