]> code.communitydata.science - cdsc_reddit.git/commitdiff
Cache before sorting so we don't extract twice.
authorNate E TeBlunthuis <nathante@n2347.hyak.local>
Tue, 7 Jul 2020 05:30:04 +0000 (22:30 -0700)
committerNate E TeBlunthuis <nathante@n2347.hyak.local>
Tue, 7 Jul 2020 05:30:04 +0000 (22:30 -0700)
comments_2_parquet.py

index 8716abdccea4fc62d2d3bb01b3a7ce3ba2e8387c..069434e657897ad2434d12bf480a987a7f69654e 100755 (executable)
@@ -128,6 +128,10 @@ df = df.withColumn("Month",f.month(f.col("CreatedAt")))
 df = df.withColumn("Year",f.year(f.col("CreatedAt")))
 df = df.withColumn("Day",f.dayofmonth(f.col("CreatedAt")))
 df = df.withColumn("subreddit_hash",f.sha2(f.col("subreddit"), 256)[0:3])
 df = df.withColumn("Year",f.year(f.col("CreatedAt")))
 df = df.withColumn("Day",f.dayofmonth(f.col("CreatedAt")))
 df = df.withColumn("subreddit_hash",f.sha2(f.col("subreddit"), 256)[0:3])
+
+# cache so we don't have to extract everythin twice
+df = df.cache()
+
 df2 = df.sort(["subreddit","author","link_id","parent_id","Year","Month","Day"],ascending=True)
 df2.write.parquet("/gscratch/comdata/output/reddit_comments_by_subreddit.parquet", partitionBy=["Year",'Month'],mode='overwrite')
 
 df2 = df.sort(["subreddit","author","link_id","parent_id","Year","Month","Day"],ascending=True)
 df2.write.parquet("/gscratch/comdata/output/reddit_comments_by_subreddit.parquet", partitionBy=["Year",'Month'],mode='overwrite')
 

Community Data Science Collective || Want to submit a patch?