1
/*
2
 * Copyright 2017 Spotify AB.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing,
11
 * software distributed under the License is distributed on an
12
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13
 * KIND, either express or implied.  See the License for the
14
 * specific language governing permissions and limitations
15
 * under the License.
16
 */
17

18
package com.spotify.featran
19

20
import com.twitter.algebird.Semigroup
21
import com.twitter.scalding.typed.TypedPipe
22

23
import scala.reflect.ClassTag
24

25
package object scalding {
26

27
  /** [[CollectionType]] for extraction from Scalding `TypedPipe` type. */
28
  implicit object ScaldingCollectionType extends CollectionType[TypedPipe] {
29 1
    override def map[A, B: ClassTag](ma: TypedPipe[A])(f: A => B): TypedPipe[B] = ma.map(f)
30

31
    override def reduce[A](ma: TypedPipe[A])(f: (A, A) => A): TypedPipe[A] =
32 1
      ma.sum(Semigroup.from(f))
33

34
    override def cross[A, B: ClassTag](ma: TypedPipe[A])(mb: TypedPipe[B]): TypedPipe[(A, B)] =
35 1
      ma.cross(mb)
36

37
    override def pure[A, B: ClassTag](ma: TypedPipe[A])(b: B): TypedPipe[B] =
38 1
      TypedPipe.from(Iterable(b))
39
  }
40
}

Read our documentation on viewing source code .

Loading