Skip to content

Wrong behavior of buffer( timespan, count ) ? #756

@Acardiac

Description

@Acardiac

According to the marble diagram, in case the buffer is full, all subsequent items are ignored till time interval has elapsed.
(green item -> https://github.com/Netflix/RxJava/wiki/Transforming-Observables#buffer )

But according to the description:

This version of buffer( ) emits a new bundle of items for every count items emitted by the source Observable, or, if timespan has elapsed SINCE ITS LAST BUNDLE EMISSION, it emits a bundle of however many items the source Observable has emitted in that span, even if this is less than count.

imho the timespan timer as well as counter should be restarted immediately after buffer emission, so none of the items are dropped.

Compare to Lee Campbell:
http://www.introtorx.com/Content/v1.0.10621.0/13_TimeShiftedSequences.html#Buffer

Some systems may have a sweet spot for the size of a batch they can process, but also have a time constraint to ensure that data is not stale. In this case buffering by both time and count would be suitable.....
We never get a buffer containing more than COUNT elements, and we never wait more than TIMESPAN seconds.....
The variants we have looked at so far do not overlap and have no gaps between buffers, i.e. ALL VALUES FROM THE SOURCE ARE PROPAGATED THROUGH.

see also:
http://msdn.microsoft.com/en-us/library/hh229200.aspx

Indicates EACH element of an observable sequence into a buffer that’s sent out when either it’s full or a given amount of time has elapsed.

Bug or feature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions