Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More direct map and filter in typed API #1772

Merged
merged 1 commit into from
Jan 29, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,13 @@ object CascadingBackend {
go(fk)
case (f@Filter(_, _), rec) =>
// hand holding for type inference
def go[T1 <: T](f: Filter[T1]): CascadingPipe[T] =
// TODO, maybe it is better to tell cascading we are
// doing a filter here: https://github.com/cwensel/cascading/blob/wip-4.0/cascading-core/src/main/java/cascading/operation/Filter.java
rec(FlatMapped(f.input, FlatMappedFn.fromFilter(f.fn)))
def go[T1 <: T](f: Filter[T1]): CascadingPipe[T] = {
val Filter(input, fn) = f
val CascadingPipe(pipe, initF, fd, conv) = rec(input)
// This does not need a setter, which is nice.
val fpipe = RichPipe(pipe).filter[T1](initF)(fn)(TupleConverter.asSuperConverter(conv))
CascadingPipe[T](fpipe, initF, fd, conv)
}

go(f)
case (f@FlatMapValues(_, _), rec) =>
Expand Down Expand Up @@ -209,9 +212,15 @@ object CascadingBackend {
rec(Mapped[(K, A), (K, B)](fn.input, MapValuesToMap(fn.fn)))

go(f)
case (Mapped(input, fn), rec) =>
// TODO: a native scalding Map operation would be slightly more efficient here
rec(FlatMapped(input, FlatMappedFn.fromMap(fn)))
case (m@Mapped(_, _), rec) =>
def go[A, B <: T](m: Mapped[A, B]): CascadingPipe[T] = {
val Mapped(input, fn) = m
val CascadingPipe(pipe, initF, fd, conv) = rec(input)
val fmpipe = RichPipe(pipe).mapTo[A, T](initF -> f0)(fn)(TupleConverter.asSuperConverter(conv), singleSetter)
CascadingPipe.single[B](fmpipe, fd)
}

go(m)

case (m@MergedTypedPipe(_, _), rec) =>
OptimizationRules.unrollMerge(m) match {
Expand Down