rdd conversion

2015-10-26 Thread Yasemin Kaya
Hi,

I have *JavaRDD>>* and I want to
convert every map to pairrdd, i mean
* JavaPairRDD. *

There is a loop in list to get the indexed map, when I write code below, it
returns me only one rdd.

JavaPairRDD mapToRDD =
 IdMapValues.mapToPair(new
PairFunction>, Integer,
ArrayList>() {

@Override
public Tuple2 call(
List> arg0)
throws Exception {
Tuple2 t = null;
for(int i=0; i entry :arg0.get(i).entrySet()) {
t = new Tuple2  (entry.getKey(),
entry.getValue());
}
}

return t;
}
});

As you can see i am using java. Give me some clue .. Thanks.

Best,
yasemin

-- 
hiç ender hiç


Re: rdd conversion

2015-10-26 Thread Ted Yu
bq.  t = new Tuple2  (entry.getKey(),
entry.getValue());

The return statement is outside the loop.
That was why you got one RDD.

On Mon, Oct 26, 2015 at 9:40 AM, Yasemin Kaya  wrote:

> Hi,
>
> I have *JavaRDD>>* and I want to
> convert every map to pairrdd, i mean
> * JavaPairRDD. *
>
> There is a loop in list to get the indexed map, when I write code below,
> it returns me only one rdd.
>
> JavaPairRDD mapToRDD =
>  IdMapValues.mapToPair(new
> PairFunction>, Integer,
> ArrayList>() {
>
> @Override
> public Tuple2 call(
> List> arg0)
> throws Exception {
> Tuple2 t = null;
> for(int i=0; i for (Map.Entry entry :arg0.get(i).entrySet()) {
> t = new Tuple2  (entry.getKey(),
> entry.getValue());
> }
> }
>
> return t;
> }
> });
>
> As you can see i am using java. Give me some clue .. Thanks.
>
> Best,
> yasemin
>
> --
> hiç ender hiç
>


Re: rdd conversion

2015-10-26 Thread Yasemin Kaya
But if I put the return inside loop, method still wants me a return
statement.

2015-10-26 19:09 GMT+02:00 Ted Yu :

> bq.  t = new Tuple2  (entry.getKey(),
> entry.getValue());
>
> The return statement is outside the loop.
> That was why you got one RDD.
>
> On Mon, Oct 26, 2015 at 9:40 AM, Yasemin Kaya  wrote:
>
>> Hi,
>>
>> I have *JavaRDD>>* and I want to
>> convert every map to pairrdd, i mean
>> * JavaPairRDD. *
>>
>> There is a loop in list to get the indexed map, when I write code below,
>> it returns me only one rdd.
>>
>> JavaPairRDD mapToRDD =
>>  IdMapValues.mapToPair(new
>> PairFunction>, Integer,
>> ArrayList>() {
>>
>> @Override
>> public Tuple2 call(
>> List> arg0)
>> throws Exception {
>> Tuple2 t = null;
>> for(int i=0; i> for (Map.Entry entry :arg0.get(i).entrySet())
>> {
>> t = new Tuple2  (entry.getKey(),
>> entry.getValue());
>> }
>> }
>>
>> return t;
>> }
>> });
>>
>> As you can see i am using java. Give me some clue .. Thanks.
>>
>> Best,
>> yasemin
>>
>> --
>> hiç ender hiç
>>
>
>


-- 
hiç ender hiç