Skip to content

Add Iterant.bufferSliding + bufferTumbling + batched#413

Merged
alexandru merged 1 commit into
monix:masterfrom
alexandru:sliding
Aug 14, 2017
Merged

Add Iterant.bufferSliding + bufferTumbling + batched#413
alexandru merged 1 commit into
monix:masterfrom
alexandru:sliding

Conversation

@alexandru
Copy link
Copy Markdown
Member

New Iterant operators:

sealed abstract class Iterant[F[_], A] {

  def batched(count: Int)(implicit F: Sync[F]): Iterant[F, A]

  def bufferTumbling(count: Int)(implicit F: Sync[F]): Iterant[F, Seq[A]]
 
  def bufferSliding(count: Int, skip: Int)(implicit F: Sync[F]): Iterant[F, Seq[A]] =
}

These all share the same implementation, more or less:

  1. bufferSliding is the exact equivalent of the sliding operation on Scala's collection or of Observable.bufferSliding
  2. bufferTumbling(count) is a handy alias for bufferSliding(count, count)
  3. batched(count) is equivalent with bufferTumbling(count), however what it does is to emit NextBatch nodes, thus hiding the actual batches being emitted in the underlying implementation - this operator is useful for optimizing the representation of the source

Example for bufferSliding given in the docs:

val source = Iterant[Coeval].of(1, 2, 3, 4, 5, 6, 7)

// Yields Seq(1, 2, 3), Seq(4, 5, 6), Seq(7)
source.bufferSliding(3, 3)

// Yields Seq(1, 2, 3), Seq(5, 6, 7)
source.bufferSliding(3, 4)

// Yields Seq(1, 2, 3), Seq(3, 4, 5), Seq(5, 6, 7)
source.bufferSliding(3, 2)

@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 14, 2017

Codecov Report

Merging #413 into master will increase coverage by 0.05%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master     #413      +/-   ##
==========================================
+ Coverage   88.46%   88.52%   +0.05%     
==========================================
  Files         338      339       +1     
  Lines        9236     9297      +61     
  Branches     1254     1245       -9     
==========================================
+ Hits         8171     8230      +59     
- Misses       1065     1067       +2

@alexandru alexandru merged commit d922573 into monix:master Aug 14, 2017
@alexandru alexandru added this to the 3.0.0 milestone Jan 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant