How to write a transformation function to transform RDD with reference to a Graphframe object?

Yiliang

I have a Graphframe object: g and a RDD object: candidate:

g = GraphFrame(v,e)
candidates_rdd.collect() 
#  [Row(source=u'a', target=u'b'),
#   Row(source=u'a', target=u'c'),
#   Row(source=u'e', target=u'a')]

I want to compute a path from "source" to "target" in candidates_rdd and generate a result rdd with key, value pairs ((source, target), path_list) using graphframe's breadth first search, where path_list is a list of paths from source to target.

Example outputs:

(('a','b'),['a-c-b','a-d-e-b']), 
(('f','c'),[]),
(('a',d'),['a-b-e-d']

I wrote the below function:

def bfs_(row):    
    arg1 = "id = '" + row.source + "'"
    arg2 = "id = '" + row.target + "'"        
    return ((row.source, row.target), g.bfs(arg1,arg2).rdd)

results = candidates_rdd.map(bfs_)

I got this error:

Py4JError: An error occurred while calling o274.__getnewargs__. Trace:
py4j.Py4JException: Method __getnewargs__([]) does not exist

I have tried to make the graph global or broadcast it, neither works.

Could anyone help me on this?

Thanks very much!!

user6022341

TL;DR It is not possible.

Spark doesn't support nested operations like this. Outer loop has to be not-distributed:

>>> [g.bfs(arg1, arg2) for arg1, arg2 in candidates_rdd.collect()]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to define Spark RDD transformation with non-Lambda Function

From Dev

How to write a function that transform a dataframe to another dataframe?

From Dev

How to write a function that transform a dataframe to another dataframe?

From Dev

How to do a string transformation of an RDD?

From Dev

How to bind function to an object by reference?

From Dev

Spark: How to transform a Seq of RDD into a RDD

From Dev

Is there an RDD transform function that looks at neighboring elements?

From Dev

How to pass an object as reference or pointer to a thread function?

From Dev

How to bind by reference using function that returns object?

From Dev

How should I do to transform a RDD[String] to RDD[(String, String)]?

From Dev

How to write a function that inlines object properties

From Dev

How to write a function that inlines object properties

From Dev

Transform array into an object using an attribute as a reference

From Dev

How to transform Array to Object?

From Dev

Map function to write on global spark rdd

From Dev

How to call a function from another function using the reference of object of a cfc?

From Dev

std::transform() passing reference in the function parameter

From Dev

How to write a function that takes a string and object and interpolates that object in the string?

From Dev

How to write is_reference_const function,make is_reference_const<const int&>::value` is ture

From Dev

RDD lookup inside a transformation

From Dev

RDD transformation map, Python

From Dev

How could I write this Kentico Hierarchical Transformation?

From Dev

How to pass to the AngularJS $resource query callback function the reference to the parent object?

From Dev

c++ How to pass iterator pointer to function that expects the object by reference

From Dev

How to get current object reference inside a jquery callback function?

From Dev

How to transform this lambda code to method reference in Java?

From Dev

how to to transform an object to a string php

From Dev

How to transform an object into an array of objects?

From Dev

How to transform object into sorted array?

Related Related

  1. 1

    How to define Spark RDD transformation with non-Lambda Function

  2. 2

    How to write a function that transform a dataframe to another dataframe?

  3. 3

    How to write a function that transform a dataframe to another dataframe?

  4. 4

    How to do a string transformation of an RDD?

  5. 5

    How to bind function to an object by reference?

  6. 6

    Spark: How to transform a Seq of RDD into a RDD

  7. 7

    Is there an RDD transform function that looks at neighboring elements?

  8. 8

    How to pass an object as reference or pointer to a thread function?

  9. 9

    How to bind by reference using function that returns object?

  10. 10

    How should I do to transform a RDD[String] to RDD[(String, String)]?

  11. 11

    How to write a function that inlines object properties

  12. 12

    How to write a function that inlines object properties

  13. 13

    Transform array into an object using an attribute as a reference

  14. 14

    How to transform Array to Object?

  15. 15

    Map function to write on global spark rdd

  16. 16

    How to call a function from another function using the reference of object of a cfc?

  17. 17

    std::transform() passing reference in the function parameter

  18. 18

    How to write a function that takes a string and object and interpolates that object in the string?

  19. 19

    How to write is_reference_const function,make is_reference_const<const int&>::value` is ture

  20. 20

    RDD lookup inside a transformation

  21. 21

    RDD transformation map, Python

  22. 22

    How could I write this Kentico Hierarchical Transformation?

  23. 23

    How to pass to the AngularJS $resource query callback function the reference to the parent object?

  24. 24

    c++ How to pass iterator pointer to function that expects the object by reference

  25. 25

    How to get current object reference inside a jquery callback function?

  26. 26

    How to transform this lambda code to method reference in Java?

  27. 27

    how to to transform an object to a string php

  28. 28

    How to transform an object into an array of objects?

  29. 29

    How to transform object into sorted array?

HotTag

Archive