src/main/java/io/reactivex/Observable.java
@SuppressWarnings({ "unchecked", "rawtypes" })
    @CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public final <K> Observable<GroupedObservable<K, T>> groupBy(Function<? super T, ? extends K> keySelector) {
        return groupBy(keySelector, (Function)Functions.identity(), false, bufferSize());
    }
@SuppressWarnings({ "unchecked", "rawtypes" })
    @CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public final <K> Observable<GroupedObservable<K, T>> groupBy(Function<? super T, ? extends K> keySelector) {
        return groupBy(keySelector, (Function)Functions.identity(), false, bufferSize());
    }
@ SuppressWarnings ( { "unchecked" , "rawtypes" } ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < K > Observable < GroupedObservable < K , T > > groupBy ( Function < ? super T , ? extends K > keySelector ) { return groupBy ( keySelector , ( Function ) Functions . identity ( ) , false , bufferSize ( ) ) ; }
Groups the items emitted by an {@code ObservableSource} according to a specified criterion, and emits these
grouped items as {@link GroupedObservable}s. The emitted {@code GroupedObservableSource} allows only a single
{@link Observer} during its lifetime and if this {@code Observer} calls dispose() before the
source terminates, the next emission by the source having the same key will trigger a new
{@code GroupedObservableSource} emission.
<p>
<img width="640" height="360" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/groupBy.png" alt="">
<p>
<em>Note:</em> A {@link GroupedObservable} will cache the items it is to emit until such time as it
is subscribed to. For this reason, in order to avoid memory leaks, you should not simply ignore those
{@code GroupedObservableSource}s that do not concern you. Instead, you can signal to them that they may
discard their buffers by applying an operator like {@link #ignoreElements} to them.
<dl>
<dt><b>Scheduler:</b></dt>
<dd>{@code groupBy} does not operate by default on a particular {@link Scheduler}.</dd>
</dl>

@param keySelector
a function that extracts the key for each item
@param <K>
the key type
@return an {@code ObservableSource} that emits {@link GroupedObservable}s, each of which corresponds to a
unique key value and each of which emits those items from the source ObservableSource that share that
key value
@see <a href="http://reactivex.io/documentation/operators/groupby.html">ReactiveX operators documentation: GroupBy</a>
Groups the items emitted by an { @code ObservableSource } according to a specified criterion and emits these grouped items as { @link GroupedObservable } s . The emitted { @code GroupedObservableSource } allows only a single { @link Observer } during its lifetime and if this { @code Observer } calls dispose () before the source terminates the next emission by the source having the same key will trigger a new { @code GroupedObservableSource } emission . <p > <img width = 640 height = 360 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / groupBy . png alt = > <p > <em > Note : < / em > A { @link GroupedObservable } will cache the items it is to emit until such time as it is subscribed to . For this reason in order to avoid memory leaks you should not simply ignore those { @code GroupedObservableSource } s that do not concern you . Instead you can signal to them that they may discard their buffers by applying an operator like { @link #ignoreElements } to them . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code groupBy } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl >