Skip to content

Commit

Permalink
Cherry-pick "Fix stack overflow in typedPipeMonoid.zero" (#1688)
Browse files Browse the repository at this point in the history
* Fix stack overflow in typedPipeMonoid.zero

* Timur's comments.
  • Loading branch information
ttim authored May 22, 2017
1 parent 9da38a1 commit 6bcb169
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ scalding-hadoop-test/NOTICE
NOTICE

# Auto-copied by sbt-microsites
docs/src/main/tut/contributing.md
docs/src/main/tut/contributing.md
.DS_Store
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ object TypedPipe extends Serializable {
* TypedPipe instances are monoids. They are isomorphic to multisets.
*/
implicit def typedPipeMonoid[T]: Monoid[TypedPipe[T]] = new Monoid[TypedPipe[T]] {
def zero = empty
def zero = TypedPipe.empty
def plus(left: TypedPipe[T], right: TypedPipe[T]): TypedPipe[T] =
left ++ right
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package com.twitter.scalding

import org.scalatest.{ FunSuite, Matchers, WordSpec }

import com.twitter.algebird.Monoid
import com.twitter.scalding.source.TypedText
// Use the scalacheck generators
import org.scalacheck.Gen
Expand Down Expand Up @@ -121,6 +122,15 @@ class TypedSumByKeyTest extends WordSpec with Matchers {
}
}

class TypedPipeMonoidTest extends WordSpec with Matchers {
"typedPipeMonoid.zero" should {
"be equal to TypePipe.empty" in {
val mon = implicitly[Monoid[TypedPipe[Int]]]
assert(mon.zero == TypedPipe.empty)
}
}
}

class TypedPipeSortByJob(args: Args) extends Job(args) {
TypedPipe.from(TypedText.tsv[(Int, Float, String)]("input"))
.groupBy(_._1)
Expand Down

0 comments on commit 6bcb169

Please sign in to comment.