org.apache.solr.client.solrj.io

## Class ReducerStream

- java.lang.Object
- - org.apache.solr.client.solrj.io.TupleStream
  - - org.apache.solr.client.solrj.io.ReducerStream

All Implemented Interfaces:
  Serializable

    public class ReducerStream
    extends TupleStream

Iterates over a TupleStream and buffers Tuples that are equal based on a comparator. This allows tuples to be grouped by common field(s). The read() method emits one tuple per group. The fields of the emitted Tuple reflect the first tuple encountered in the group. Use the Tuple.getMaps() method to return all the Tuples in the group. This method returns a list of maps (including the group head), which hold the data for each Tuple in the group. Note: The ReducerStream requires that it's underlying stream be sorted and partitioned by the same fields as it's comparator.

See Also:
  Serialized Form

### Constructor Summary

Constructors
Constructor and Description
`ReducerStream(TupleStream tupleStream, Comparator<Tuple> comp)`

### Method Summary

Methods
`List<TupleStream>` `children()`
`void` `close()`
`int` `getCost()`
`void` `open()`
`Tuple` `read()`
`void` `setStreamContext(StreamContext context)`

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

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

### Constructor Detail

#### ReducerStream

    public ReducerStream(TupleStream tupleStream,
                 Comparator<Tuple> comp)

### Method Detail

#### setStreamContext

    public void setStreamContext(StreamContext context)

Specified by:
  `setStreamContext` in class `TupleStream`

#### children

    public List<TupleStream> children()

Specified by:
  `children` in class `TupleStream`

#### open

    public void open()
              throws IOException

Specified by:
  `open` in class `TupleStream`
Throws:
  `IOException`

#### close

    public void close()
               throws IOException

Specified by:
  `close` in class `TupleStream`
Throws:
  `IOException`

#### read

    public Tuple read()
               throws IOException

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

#### getCost

    public int getCost()

Overrides:
  `getCost` in class `TupleStream`