You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by Chris Curtin <cu...@gmail.com> on 2014/07/31 22:00:06 UTC

RDD operation examples with data?

Hi,

I'm learning Spark and I am confused about when to use the many different
operations on RDDs. Does anyone have any examples which show example inputs
and resulting outputs for the various RDD operations and if the operation
takes an Function a simple example of the code?

For example, something like this for flatMap

One row -> "the quick brown fox"

Passed to:

JavaRDD<String> words = lines.flatMap(new FlatMapFunction<String, String>() {
      @Override
      public Iterable<String> call(String s) {
        return Arrays.asList(SPACE.split(s));
      }
    });

When completed: words would contain
"the"
"quick"
"brown"
"fox"

(Yes this one is pretty obvious but some of the others aren't).

If such examples don't exist, is there a shared wiki or someplace we
could start building one?

Thanks,

Chris

Re: RDD operation examples with data?

Posted by Jacob Eisinger <ei...@gmail.com>.
I would check out the source examples on Spark's Github:
https://github.com/apache/spark/tree/master/examples/src/main/scala/org/apache/spark/examples

And, Zhen He put together a great web page with summaries and examples of
each function:
http://apache-spark-user-list.1001560.n3.nabble.com/A-new-resource-for-getting-examples-of-Spark-RDD-API-calls-td5529.html

Hope this helps!

Jacob


On Thu, Jul 31, 2014 at 3:00 PM, Chris Curtin <cu...@gmail.com>
wrote:

> Hi,
>
> I'm learning Spark and I am confused about when to use the many different
> operations on RDDs. Does anyone have any examples which show example inputs
> and resulting outputs for the various RDD operations and if the operation
> takes an Function a simple example of the code?
>
> For example, something like this for flatMap
>
> One row -> "the quick brown fox"
>
> Passed to:
>
> JavaRDD<String> words = lines.flatMap(new FlatMapFunction<String, String>() {
>       @Override
>       public Iterable<String> call(String s) {
>         return Arrays.asList(SPACE.split(s));
>       }
>     });
>
> When completed: words would contain
> "the"
> "quick"
> "brown"
> "fox"
>
> (Yes this one is pretty obvious but some of the others aren't).
>
> If such examples don't exist, is there a shared wiki or someplace we could start building one?
>
> Thanks,
>
> Chris
>
>