InputBuffer (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
Class InputBuffer

    java.lang.Object
      java.io.InputStream
          java.io.FilterInputStream
              org.apache.hadoop.io.InputBuffer

All Implemented Interfaces:
  Closeable

    public class InputBuffer

extends FilterInputStream

A reusable `InputStream` implementation that reads from an in-memory buffer.

This saves memory over creating a new InputStream and ByteArrayInputStream each time data is read.

Typical usage is something like the following:

     InputBuffer buffer = new InputBuffer();
     while (... loop condition ...) {
       byte[] data = ... get data ...;
       int dataLength = ... get data length ...;
       buffer.reset(data, dataLength);
       ... read buffer using InputStream methods ...
     }

See Also:
  `DataInputBuffer`, `DataOutput`

Field Summary

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

Constructor Summary
`InputBuffer()` Constructs a new empty buffer.

Method Summary
`int` | `getLength()` Returns the length of the input.
`int` | `getPosition()` Returns the current position in the input.
`void` | `reset(byte[] input, int length)` Resets the data that the buffer reads.
`void` | `reset(byte[] input, int start, int length)` Resets the data that the buffer reads.

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

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

Constructor Detail

### InputBuffer

    public InputBuffer()

  Constructs a new empty buffer.

Method Detail

### reset

    public void reset(byte[] input,
                      int length)

  Resets the data that the buffer reads.

### reset

    public void reset(byte[] input,
                      int start,
                      int length)

  Resets the data that the buffer reads.

### getPosition

    public int getPosition()

  Returns the current position in the input.

### getLength

    public int getLength()

  Returns the length of the input.

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