Utkarsh Saraf
Utkarsh Saraf

Reputation: 495

Java equivalent for Spark code on Pregel API

I am writing pregel on a graph of format Graph<Row,Row> which is having vertex computation argument in scala as

(_,a,b) => a+b

I am trying to convert it into Java function which is having Signature as

Function3<Object, VD, A, VD> arg4

I understand that VD will be of Row type, A is aggregate message but what will be the return type in Java as should it be of mutable nature due to reccuring computation at particular vertex?

new Function3<Row, Double, Row, Row>() {
        private static final long serialVersionUID = 1L;

        public Row call(Row arg0, Double arg1, Row arg2) throws Exception {
            // TODO Auto-generated method stub

        }

Is it right?

Upvotes: 1

Views: 282

Answers (1)

user6860682
user6860682

Reputation:

Yes, you are right so using Function3, according to this signature - (_,a,b) => a+b, you must ignore the first argument and add the last two, but your signature public Row call(Row arg0, Double arg1, Row arg2) is wrong, arg2 must have Double type, change to:

new Function3<Row, Double, Double, Row>()

Here you ignore first parameter Row, and add second and third and wrap it to return type Row.

Upvotes: 0

Related Questions