Trait/Object

com.twitter.scalding.typed

KeyedListLike

Related Docs: object KeyedListLike | package typed

Permalink

trait KeyedListLike[K, +T, +This[K, +T] <: KeyedListLike[K, T, This]] extends Serializable

Represents sharded lists of items of type T There are exactly two fundamental operations: toTypedPipe: marks the end of the grouped-on-key operations. mapValueStream: further transforms all values, in order, one at a time, with a function from Iterator to another Iterator

Source
KeyedList.scala
Linear Supertypes
Serializable, AnyRef, Any
Known Subclasses
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. KeyedListLike
  2. Serializable
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def bufferedTake(n: Int): This[K, T]

    Permalink

    This is like take except that the items are kept in memory and we attempt to partially execute on the mappers if possible For very large values of n, this could create memory pressure.

    This is like take except that the items are kept in memory and we attempt to partially execute on the mappers if possible For very large values of n, this could create memory pressure. (as you may aggregate n items in a memory heap for each key) If you get OOM issues, try to resolve using the method take instead.

  2. abstract def filterKeys(fn: (K) ⇒ Boolean): This[K, T]

    Permalink

    filter keys on a predicate.

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

  3. abstract def mapGroup[V](smfn: (K, Iterator[T]) ⇒ Iterator[V]): This[K, V]

    Permalink

    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.

    Iterator is always Non-empty. Note, any key that has all values removed will not appear in subsequent .mapGroup/mapValueStream

  4. abstract def toTypedPipe: TypedPipe[(K, T)]

    Permalink

    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

Concrete Value Members

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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

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

    Permalink
    Definition Classes
    AnyRef → Any
  4. def aggregate[B, C](agg: Aggregator[T, B, C]): This[K, C]

    Permalink

    Use Algebird Aggregator to do the reduction

  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. def count(fn: (T) ⇒ Boolean): This[K, Long]

    Permalink

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

  8. def distinctSize: This[K, Long]

    Permalink

    For each key, give the number of unique values.

    For each key, give the number of unique values. WARNING: May OOM. This assumes the values for each key can fit in memory.

  9. def distinctValues: This[K, T]

    Permalink

    For each key, remove duplicate values.

    For each key, remove duplicate values. WARNING: May OOM. This assumes the values for each key can fit in memory.

  10. def drop(n: Int): This[K, T]

    Permalink

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

  11. def dropWhile(p: (T) ⇒ Boolean): This[K, T]

    Permalink

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

  12. final def eq(arg0: AnyRef): Boolean

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

    Permalink
    Definition Classes
    AnyRef → Any
  14. def filter(fn: ((K, T)) ⇒ Boolean): This[K, T]

    Permalink

    .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.

  15. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  16. def flatMapValues[V](fn: (T) ⇒ TraversableOnce[V]): This[K, V]

    Permalink

    Similar to mapValues, but works like flatMap, returning a collection of outputs for each value input.

  17. def flattenValues[U](implicit ev: <:<[T, TraversableOnce[U]]): This[K, U]

    Permalink

    flatten the values Useful after sortedTake, for instance

  18. def fold[V](f: Fold[T, V]): This[K, V]

    Permalink

    Folds are composable aggregations that make one pass over the data.

    Folds are composable aggregations that make one pass over the data. If you need to do several custom folds over the same data, use Fold.join and this method

  19. def foldLeft[B](z: B)(fn: (B, T) ⇒ B): This[K, B]

    Permalink

    For each key, fold the values.

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

  20. def foldWithKey[V](fn: (K) ⇒ Fold[T, V]): This[K, V]

    Permalink

    If the fold depends on the key, use this method to construct the fold for each key

  21. def forall(fn: (T) ⇒ Boolean): This[K, Boolean]

    Permalink

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

  22. def forceToReducers: This[K, T]

    Permalink

    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

  23. final def getClass(): Class[_]

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

    Permalink
    Definition Classes
    AnyRef → Any
  25. def head: This[K, T]

    Permalink

    Use this to get the first value encountered.

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

  26. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  27. def keys: TypedPipe[K]

    Permalink

    Convert to a TypedPipe and only keep the keys

  28. def mapValueStream[V](smfn: (Iterator[T]) ⇒ Iterator[V]): This[K, V]

    Permalink

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

  29. def mapValues[V](fn: (T) ⇒ V): This[K, V]

    Permalink

    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

  30. def max[B >: T](implicit cmp: Ordering[B]): This[K, T]

    Permalink

    For each key, give the maximum value

  31. def maxBy[B](fn: (T) ⇒ B)(implicit cmp: Ordering[B]): This[K, T]

    Permalink

    For each key, give the maximum value by some function

  32. def min[B >: T](implicit cmp: Ordering[B]): This[K, T]

    Permalink

    For each key, give the minimum value

  33. def minBy[B](fn: (T) ⇒ B)(implicit cmp: Ordering[B]): This[K, T]

    Permalink

    For each key, give the minimum value by some function

  34. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  35. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  36. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  37. def product[U >: T](implicit ring: Ring[U]): This[K, U]

    Permalink

    For each key, Return the product of all the values

  38. def reduce[U >: T](fn: (U, U) ⇒ U): This[K, U]

    Permalink

    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

  39. def reduceLeft[U >: T](fn: (U, U) ⇒ U): This[K, U]

    Permalink

    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.

  40. def scanLeft[B](z: B)(fn: (B, T) ⇒ B): This[K, B]

    Permalink

    For each key, scanLeft the values.

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

  41. def size: This[K, Long]

    Permalink

    For each key, give the number of values

  42. def sortWithTake[U >: T](k: Int)(lessThan: (U, U) ⇒ Boolean): This[K, Seq[T]]

    Permalink

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

  43. def sortedReverseTake(k: Int)(implicit ord: Ordering[_ >: T]): This[K, Seq[T]]

    Permalink

    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

  44. def sortedTake(k: Int)(implicit ord: Ordering[_ >: T]): This[K, Seq[T]]

    Permalink

    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.

  45. def sum[U >: T](implicit sg: Semigroup[U]): This[K, U]

    Permalink

    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

  46. def sumLeft[U >: T](implicit sg: Semigroup[U]): This[K, U]

    Permalink

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

  47. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  48. def take(n: Int): This[K, T]

    Permalink

    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.

  49. def takeWhile(p: (T) ⇒ Boolean): This[K, T]

    Permalink

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

  50. def toList: This[K, List[T]]

    Permalink

    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

  51. def toSet[U >: T]: This[K, Set[U]]

    Permalink

    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

  52. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  53. def values: TypedPipe[T]

    Permalink

    Convert to a TypedPipe and only keep the values

  54. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped