com.twitter.scalding.typed

Grouped

trait Grouped[K, +V] extends KeyedListLike[K, V, UnsortedGrouped] with HashJoinable[K, V] with Sortable[V, [+x]SortedGrouped[K, x] with Reversable[SortedGrouped[K, x]]] with WithReducers[Grouped[K, V]]

This encodes the rules that 1) sorting is only possible before doing any reduce, 2) reversing is only possible after sorting. 3) unsorted Groups can be CoGrouped or HashJoined

This may appear a complex type, but it makes sure that code won't compile if it breaks the rule

Linear Supertypes
WithReducers[Grouped[K, V]], Sortable[V, [+x]SortedGrouped[K, x] with Reversable[SortedGrouped[K, x]]], HashJoinable[K, V], KeyedPipe[K], CoGroupable[K, V], HasReducers, KeyedListLike[K, V, UnsortedGrouped], Serializable, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Grouped
  2. WithReducers
  3. Sortable
  4. HashJoinable
  5. KeyedPipe
  6. CoGroupable
  7. HasReducers
  8. KeyedListLike
  9. Serializable
  10. AnyRef
  11. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def filterKeys(fn: (K) ⇒ Boolean): UnsortedGrouped[K, V]

    filter keys on a predicate.

    filter keys on a predicate. More efficient than filter if you are only looking at keys

    Definition Classes
    KeyedListLike
  2. abstract def joinFunction: (K, Iterator[Tuple], Seq[Iterable[Tuple]]) ⇒ Iterator[V]

    This function is not type-safe for others to call, but it should never have an error.

    This function is not type-safe for others to call, but it should never have an error. By construction, we never call it with incorrect types. It would be preferable to have stronger type safety here, but unclear how to achieve, and since it is an internal function, not clear it would actually help anyone for it to be type-safe

    Attributes
    protected
    Definition Classes
    CoGroupable
  3. abstract def keyOrdering: Ordering[K]

    Definition Classes
    KeyedPipe
  4. abstract def mapGroup[V](smfn: (K, Iterator[V]) ⇒ Iterator[V]): UnsortedGrouped[K, V]

    Operate on an Iterator[T] of all the values for each key at one time.

    Operate on an Iterator[T] of all the values for each key at one time. Prefer this to toList, when you can avoid accumulating the whole list in memory. Prefer sum, which is partially executed map-side by default. Use mapValueStream when you don't care about the key for the group.

    Definition Classes
    KeyedListLike
  5. abstract def mapped: TypedPipe[(K, Any)]

    Definition Classes
    KeyedPipe
  6. abstract def reducers: Option[Int]

    Definition Classes
    HasReducers
  7. abstract def toTypedPipe: TypedPipe[(K, V)]

    End of the operations on values.

    End of the operations on values. From this point on the keyed structure is lost and another shuffle is generally required to reconstruct it

    Definition Classes
    KeyedListLike
  8. abstract def withReducers(reds: Int): Grouped[K, V]

    never mutates this, instead returns a new item.

    never mutates this, instead returns a new item.

    Definition Classes
    WithReducers
  9. abstract def withSortOrdering[U >: V](so: Ordering[U]): SortedGrouped[K, V] with Reversable[SortedGrouped[K, V]]

    Definition Classes
    Sortable

Concrete Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. def aggregate[B, C](agg: Aggregator[V, B, C]): UnsortedGrouped[K, C]

    Use Algebird Aggregator to do the reduction

    Use Algebird Aggregator to do the reduction

    Definition Classes
    KeyedListLike
  7. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  8. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. def cogroup[R1, R2](smaller: CoGroupable[K, R1])(fn: (K, Iterator[V], Iterable[R1]) ⇒ Iterator[R2]): CoGrouped[K, R2]

    Smaller is about average values/key not total size (that does not matter, but is clearly related).

    Smaller is about average values/key not total size (that does not matter, but is clearly related).

    Note that from the type signature we see that the right side is iterated (or may be) over and over, but the left side is not. That means that you want the side with fewer values per key on the right. If both sides are similar, no need to worry. If one side is a one-to-one mapping, that should be the "smaller" side.

    Definition Classes
    CoGroupable
  10. def count(fn: (V) ⇒ Boolean): UnsortedGrouped[K, Long]

    For each key, count the number of values that satisfy a predicate

    For each key, count the number of values that satisfy a predicate

    Definition Classes
    KeyedListLike
  11. def drop(n: Int): UnsortedGrouped[K, V]

    For each key, selects all elements except first n ones.

    For each key, selects all elements except first n ones.

    Definition Classes
    KeyedListLike
  12. def dropWhile(p: (V) ⇒ Boolean): UnsortedGrouped[K, V]

    For each key, Drops longest prefix of elements that satisfy the given predicate.

    For each key, Drops longest prefix of elements that satisfy the given predicate.

    Definition Classes
    KeyedListLike
  13. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  14. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  15. def filter(fn: ((K, V)) ⇒ Boolean): UnsortedGrouped[K, V]

    .

    .filter(fn).toTypedPipe == .toTypedPipe.filter(fn) It is generally better to avoid going back to a TypedPipe as long as possible: this minimizes the times we go in and out of cascading/hadoop types.

    Definition Classes
    KeyedListLike
  16. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  17. def flattenValues[U](implicit ev: <:<[V, TraversableOnce[U]]): UnsortedGrouped[K, U]

    flatten the values Useful after sortedTake, for instance

    flatten the values Useful after sortedTake, for instance

    Definition Classes
    KeyedListLike
  18. def foldLeft[B](z: B)(fn: (B, V) ⇒ B): UnsortedGrouped[K, B]

    For each key, fold the values.

    For each key, fold the values. see scala.collection.Iterable.foldLeft

    Definition Classes
    KeyedListLike
  19. def forall(fn: (V) ⇒ Boolean): UnsortedGrouped[K, Boolean]

    For each key, check to see if a predicate is true for all Values

    For each key, check to see if a predicate is true for all Values

    Definition Classes
    KeyedListLike
  20. def forceToReducers: UnsortedGrouped[K, V]

    This is just short hand for mapValueStream(identity), it makes sure the planner sees that you want to force a shuffle.

    This is just short hand for mapValueStream(identity), it makes sure the planner sees that you want to force a shuffle. For expert tuning

    Definition Classes
    KeyedListLike
  21. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  22. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  23. def hashCogroupOn[V1, R](mapside: TypedPipe[(K, V1)])(joiner: (K, V1, Iterable[V]) ⇒ Iterator[R]): TypedPipe[(K, R)]

    This fully replicates this entire Grouped to the argument: mapside.

    This fully replicates this entire Grouped to the argument: mapside. This means that we never see the case where the key is absent in the pipe. This means implementing a right-join (from the pipe) is impossible. Note, there is no reduce-phase in this operation. The next issue is that obviously, unlike a cogroup, for a fixed key, each joiner will NOT See all the tuples with those keys. This is because the keys on the left are distributed across many machines See hashjoin: http://docs.cascading.org/cascading/2.0/javadoc/cascading/pipe/HashJoin.html

    Definition Classes
    HashJoinable
  24. def head: UnsortedGrouped[K, V]

    Use this to get the first value encountered.

    Use this to get the first value encountered. prefer this to take(1).

    Definition Classes
    KeyedListLike
  25. def inputs: List[TypedPipe[(K, Any)]]

    A HashJoinable has a single input into to the cogroup

    A HashJoinable has a single input into to the cogroup

    Definition Classes
    HashJoinableCoGroupable
  26. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  27. def join[W](smaller: CoGroupable[K, W]): CoGrouped[K, (V, W)]

    Definition Classes
    CoGroupable
  28. def keys: TypedPipe[K]

    Convert to a TypedPipe and only keep the keys

    Convert to a TypedPipe and only keep the keys

    Definition Classes
    KeyedListLike
  29. def leftJoin[W](smaller: CoGroupable[K, W]): CoGrouped[K, (V, Option[W])]

    Definition Classes
    CoGroupable
  30. def mapValueStream[V](smfn: (Iterator[V]) ⇒ Iterator[V]): UnsortedGrouped[K, V]

    Use this when you don't care about the key for the group, otherwise use mapGroup

    Use this when you don't care about the key for the group, otherwise use mapGroup

    Definition Classes
    KeyedListLike
  31. def mapValues[V](fn: (V) ⇒ V): UnsortedGrouped[K, V]

    This is a special case of mapValueStream, but can be optimized because it doesn't need all the values for a given key at once.

    This is a special case of mapValueStream, but can be optimized because it doesn't need all the values for a given key at once. An unoptimized implementation is: mapValueStream { _.map { fn } } but for Grouped we can avoid resorting to mapValueStream

    Definition Classes
    KeyedListLike
  32. def max[B >: V](implicit cmp: Ordering[B]): UnsortedGrouped[K, V]

    For each key, give the maximum value

    For each key, give the maximum value

    Definition Classes
    KeyedListLike
  33. def maxBy[B](fn: (V) ⇒ B)(implicit cmp: Ordering[B]): UnsortedGrouped[K, V]

    For each key, give the maximum value by some function

    For each key, give the maximum value by some function

    Definition Classes
    KeyedListLike
  34. def min[B >: V](implicit cmp: Ordering[B]): UnsortedGrouped[K, V]

    For each key, give the minimum value

    For each key, give the minimum value

    Definition Classes
    KeyedListLike
  35. def minBy[B](fn: (V) ⇒ B)(implicit cmp: Ordering[B]): UnsortedGrouped[K, V]

    For each key, give the minimum value by some function

    For each key, give the minimum value by some function

    Definition Classes
    KeyedListLike
  36. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  37. final def notify(): Unit

    Definition Classes
    AnyRef
  38. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  39. def outerJoin[W](smaller: CoGroupable[K, W]): CoGrouped[K, (Option[V], Option[W])]

    Definition Classes
    CoGroupable
  40. def product[U >: V](implicit ring: Ring[U]): UnsortedGrouped[K, U]

    For each key, Return the product of all the values

    For each key, Return the product of all the values

    Definition Classes
    KeyedListLike
  41. def reduce[U >: V](fn: (U, U) ⇒ U): UnsortedGrouped[K, U]

    reduce with fn which must be associative and commutative.

    reduce with fn which must be associative and commutative. Like the above this can be optimized in some Grouped cases. If you don't have a commutative operator, use reduceLeft

    Definition Classes
    KeyedListLike
  42. def reduceLeft[U >: V](fn: (U, U) ⇒ U): UnsortedGrouped[K, U]

    Similar to reduce but always on the reduce-side (never optimized to mapside), and named for the scala function.

    Similar to reduce but always on the reduce-side (never optimized to mapside), and named for the scala function. fn need not be associative and/or commutative. Makes sense when you want to reduce, but in a particular sorted order. the old value comes in on the left.

    Definition Classes
    KeyedListLike
  43. def rightJoin[W](smaller: CoGroupable[K, W]): CoGrouped[K, (Option[V], W)]

    Definition Classes
    CoGroupable
  44. def scanLeft[B](z: B)(fn: (B, V) ⇒ B): UnsortedGrouped[K, B]

    For each key, scanLeft the values.

    For each key, scanLeft the values. see scala.collection.Iterable.scanLeft

    Definition Classes
    KeyedListLike
  45. def size: UnsortedGrouped[K, Long]

    For each key, give the number of values

    For each key, give the number of values

    Definition Classes
    KeyedListLike
  46. def sortBy[B](fn: (V) ⇒ B)(implicit arg0: Ordering[B]): SortedGrouped[K, V] with Reversable[SortedGrouped[K, V]]

    Definition Classes
    Sortable
  47. def sortWith(lt: (V, V) ⇒ Boolean): SortedGrouped[K, V] with Reversable[SortedGrouped[K, V]]

    Definition Classes
    Sortable
  48. def sortWithTake[U >: V](k: Int)(lessThan: (U, U) ⇒ Boolean): UnsortedGrouped[K, Seq[V]]

    Like the above, but with a less than operation for the ordering

    Like the above, but with a less than operation for the ordering

    Definition Classes
    KeyedListLike
  49. def sorted[B >: V](implicit ord: Ordering[B]): SortedGrouped[K, V] with Reversable[SortedGrouped[K, V]]

    Definition Classes
    Sortable
  50. def sortedReverseTake(k: Int)(implicit ord: Ordering[_ >: V]): UnsortedGrouped[K, Seq[V]]

    Take the largest k things according to the implicit ordering.

    Take the largest k things according to the implicit ordering. Useful for top-k without having to call ord.reverse

    Definition Classes
    KeyedListLike
  51. def sortedTake(k: Int)(implicit ord: Ordering[_ >: V]): UnsortedGrouped[K, Seq[V]]

    This implements bottom-k (smallest k items) on each mapper for each key, then sends those to reducers to get the result.

    This implements bottom-k (smallest k items) on each mapper for each key, then sends those to reducers to get the result. This is faster than using .take if k * (number of Keys) is small enough to fit in memory.

    Definition Classes
    KeyedListLike
  52. def sum[U >: V](implicit sg: Semigroup[U]): UnsortedGrouped[K, U]

    Add all items according to the implicit Semigroup If there is no sorting, we default to assuming the Semigroup is commutative.

    Add all items according to the implicit Semigroup If there is no sorting, we default to assuming the Semigroup is commutative. If you don't want that, define an ordering on the Values, sort or .forceToReducers.

    Semigroups MAY have a faster implementation of sum for iterators, so prefer using sum/sumLeft to reduce

    Definition Classes
    KeyedListLike
  53. def sumLeft[U >: V](implicit sg: Semigroup[U]): UnsortedGrouped[K, U]

    Semigroups MAY have a faster implementation of sum for iterators, so prefer using sum/sumLeft to reduce/reduceLeft

    Semigroups MAY have a faster implementation of sum for iterators, so prefer using sum/sumLeft to reduce/reduceLeft

    Definition Classes
    KeyedListLike
  54. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  55. def take(n: Int): UnsortedGrouped[K, V]

    For each key, Selects first n elements.

    For each key, Selects first n elements. Don't use this if n == 1, head is faster in that case.

    Definition Classes
    KeyedListLike
  56. def takeWhile(p: (V) ⇒ Boolean): UnsortedGrouped[K, V]

    For each key, Takes longest prefix of elements that satisfy the given predicate.

    For each key, Takes longest prefix of elements that satisfy the given predicate.

    Definition Classes
    KeyedListLike
  57. def toList: UnsortedGrouped[K, List[V]]

    AVOID THIS IF POSSIBLE For each key, accumulate all the values into a List.

    AVOID THIS IF POSSIBLE For each key, accumulate all the values into a List. WARNING: May OOM Only use this method if you are sure all the values will fit in memory. You really should try to ask why you need all the values, and if you want to do some custom reduction, do it in mapGroup or mapValueStream

    Definition Classes
    KeyedListLike
  58. def toSet[U >: V]: UnsortedGrouped[K, Set[U]]

    AVOID THIS IF POSSIBLE Same risks apply here as to toList: you may OOM.

    AVOID THIS IF POSSIBLE Same risks apply here as to toList: you may OOM. See toList. Note that toSet needs to be parameterized even though toList does not. This is because List is covariant in its type parameter in the scala API, but Set is invariant. See: http://stackoverflow.com/questions/676615/why-is-scalas-immutable-set-not-covariant-in-its-type

    Definition Classes
    KeyedListLike
  59. def toString(): String

    Definition Classes
    AnyRef → Any
  60. def values: TypedPipe[V]

    Convert to a TypedPipe and only keep the values

    Convert to a TypedPipe and only keep the values

    Definition Classes
    KeyedListLike
  61. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  62. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  63. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from WithReducers[Grouped[K, V]]

Inherited from Sortable[V, [+x]SortedGrouped[K, x] with Reversable[SortedGrouped[K, x]]]

Inherited from HashJoinable[K, V]

Inherited from KeyedPipe[K]

Inherited from CoGroupable[K, V]

Inherited from HasReducers

Inherited from KeyedListLike[K, V, UnsortedGrouped]

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped