Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesign of PySpark DataFrame interface for filtering #120

Closed
lintool opened this issue Nov 23, 2017 · 3 comments
Closed

Redesign of PySpark DataFrame interface for filtering #120

lintool opened this issue Nov 23, 2017 · 3 comments
Assignees

Comments

@lintool
Copy link
Member

lintool commented Nov 23, 2017

Currently, the PySpark DataFrame interface is something like:

	path = "/Users/Prince/Projects/pyaut/aut/example.arc.gz"
	
	spark = SparkSession.builder.appName("filterByDate").getOrCreate()
	sc = spark.sparkContext

	df = RecordLoader.loadArchivesAsDF(path, sc, spark)
	filtered_df = keepDate(df, "2008", DateComponent.YYYY).filter(df['url'].like("%archive%"))
	rdd = filtered_df.rdd
	rdd.map(lambda r: (r.crawlDate, r.domain, r.url, RemoveHTML(r.contentString))) \
	   .saveAsTextFile("out/")

Above snipped from https://github.com/MapleOx/aut/blob/bfb2678e8f88c994f94cc0919f352303f2f1d412/src/main/python/scripts/filterByDateScript.py

We should redesign to use standard NOUN.VERB pattern, something like:

.filter(df['url'].like("%archive%"))
.filter(df['date'].in(DateComponent.YYYY(2008))
.filter(df['date'].in(DateRange.YYYY(2007, 2008)))
.filter(df['date'].in(DateRange.YYYYMM(2007, 1, 2008, 2)))
.filter(df['date'].in(DateRange.YYYYMMDD(2007, 1, 2, 2008, 2, 2)))
@ianmilligan1
Copy link
Member

FYI we are writing the scripts over here on a branch of the website (documentation): https://github.com/archivesunleashed/archivesunleashed.org/blob/pyspark/content/aut/pyspark.md.

@ianmilligan1
Copy link
Member

@dhop is looking into PySpark!

@ruebot
Copy link
Member

ruebot commented May 2, 2018

Resolved with 505c47a

@ruebot ruebot closed this as completed May 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants