src/main/java/io/reactivex/Observable.java
@CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public final <K, V> Observable<GroupedObservable<K, V>> groupBy(Function<? super T, ? extends K> keySelector,
            Function<? super T, ? extends V> valueSelector,
            boolean delayError, int bufferSize) {
        ObjectHelper.requireNonNull(keySelector, "keySelector is null");
        ObjectHelper.requireNonNull(valueSelector, "valueSelector is null");
        ObjectHelper.verifyPositive(bufferSize, "bufferSize");

        return RxJavaPlugins.onAssembly(new ObservableGroupBy<T, K, V>(this, keySelector, valueSelector, bufferSize, delayError));
    }
@CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public final <K, V> Observable<GroupedObservable<K, V>> groupBy(Function<? super T, ? extends K> keySelector,
            Function<? super T, ? extends V> valueSelector,
            boolean delayError, int bufferSize) {
        ObjectHelper.requireNonNull(keySelector, "keySelector is null");
        ObjectHelper.requireNonNull(valueSelector, "valueSelector is null");
        ObjectHelper.verifyPositive(bufferSize, "bufferSize");

        return RxJavaPlugins.onAssembly(new ObservableGroupBy<T, K, V>(this, keySelector, valueSelector, bufferSize, delayError));
    }
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 valueSelector
a function that extracts the return element for each item
@param delayError
if true, the exception from the current Observable is delayed in each group until that specific group emitted
the normal values; if false, the exception bypasses values in the groups and is reported immediately.
@param bufferSize
the hint for how many {@link GroupedObservable}s and element in each {@link GroupedObservable} should be buffered
@param <K>
the key type
@param <V>
the element 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>