apache/spark — pull request #2093 by davies (2014-08-22 04:55:26+00:00)
Title: [SPARK-2871] [PySpark] add RDD.lookup(key)

RDD.lookup(key)

Return the list of values in the RDD for key `key`. This operation
is done efficiently if the RDD has a known partitioner by only
searching the partition that the key maps to.

>>> l = range(1000)
>>> rdd = sc.parallelize(zip(l, l), 10)
>>> rdd.lookup(42) # slow
[42]
>>> sorted = rdd.sortByKey()
>>> sorted.lookup(42) # fast
[42]