Zip with a Dense Index

zipWithIndex assigns consecutive labels to the elements, receiving a data set as input and returning a new data set of (unique id, initial value) 2-tuples.
This process requires two passes, first counting then labeling elements, and cannot be pipelined due to the synchronization of counts.
The alternative zipWithUniqueId works in a pipelined fashion and is preferred when a unique labeling is sufficient.
For example, the following code:

Zip with a Unique Identifier

In many cases one may not need to assign consecutive labels.
zipWithUniqueId works in a pipelined fashion, speeding up the label assignment process. This method receives a data set as input and returns a new data set of (unique id, initial value) 2-tuples.
For example, the following code: