On Thu, Oct 23, 2014 at 3:14 PM, xuhongnever <xuhongne...@gmail.com> wrote:
> my code is here:
>
> from pyspark import SparkConf, SparkContext
>
> def Undirect(edge):
>     vector = edge.strip().split('\t')
>     if(vector[0].isdigit()):
>         return [(vector[0], vector[1])]
>     return []
>
>
> conf = SparkConf()
> conf.setMaster("spark://compute-0-14:7077")
> conf.setAppName("adjacencylist")
> conf.set("spark.executor.memory", "1g")

Use more memory to gain better performance, or spark will keep
spilling the data into disks, that is much slower.
You also could give more memory to Python worker by set
spark.python.worker.memory=1g or 2g

> sc = SparkContext(conf = conf)
>
> file = sc.textFile("file:///home/xzhang/data/soc-LiveJournal1.txt")
> records = file.flatMap(lambda line: Undirect(line)).reduceByKey(lambda a, b:
> a + "\t" + b )

a + "\t" + b will be very slow, if the number of values is large,
groupByKey() will be better than it.

> #print(records.count())
> #records = records.sortByKey()
> records = records.map(lambda line: line[0] + "\t" + line[1])
> records.saveAsTextFile("file:///home/xzhang/data/result")
>
>
>
> --
> View this message in context: 
> http://apache-spark-user-list.1001560.n3.nabble.com/spark-is-running-extremely-slow-with-larger-data-set-like-2G-tp17152p17153.html
> Sent from the Apache Spark User List mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@spark.apache.org
> For additional commands, e-mail: user-h...@spark.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@spark.apache.org
For additional commands, e-mail: user-h...@spark.apache.org

Reply via email to